-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathVolumeState.cs
More file actions
181 lines (166 loc) · 5.9 KB
/
Copy pathVolumeState.cs
File metadata and controls
181 lines (166 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
namespace net.openstack.Core.Domain
{
using System;
using System.Collections.Concurrent;
using Newtonsoft.Json;
/// <summary>
/// Represents the state of a block storage volume.
/// </summary>
/// <remarks>
/// This class functions as a strongly-typed enumeration of known volume states,
/// with added support for unknown states returned by a server extension.
/// </remarks>
/// <threadsafety static="true" instance="false"/>
[JsonConverter(typeof(VolumeState.Converter))]
public sealed class VolumeState : ExtensibleEnum<VolumeState>
{
private static readonly ConcurrentDictionary<string, VolumeState> _states =
new ConcurrentDictionary<string, VolumeState>(StringComparer.OrdinalIgnoreCase);
private static readonly VolumeState _creating = FromName("creating");
private static readonly VolumeState _available = FromName("available");
private static readonly VolumeState _attaching = FromName("attaching");
private static readonly VolumeState _inUse = FromName("in-use");
private static readonly VolumeState _deleting = FromName("deleting");
private static readonly VolumeState _error = FromName("error");
private static readonly VolumeState _errorDeleting = FromName("error_deleting");
private static readonly VolumeState _backingUp = FromName("backing-up");
private static readonly VolumeState _restoringBackup = FromName("restoring-backup");
private static readonly VolumeState _errorRestoring = FromName("error_restoring");
/// <summary>
/// Initializes a new instance of the <see cref="VolumeState"/> class with the specified name.
/// </summary>
/// <inheritdoc/>
private VolumeState(string name)
: base(name)
{
}
/// <summary>
/// Gets the <see cref="VolumeState"/> instance with the specified name.
/// </summary>
/// <param name="name">The name.</param>
/// <returns>The unique <see cref="VolumeState"/> instance with the specified name.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If <paramref name="name"/> is empty.</exception>
public static VolumeState FromName(string name)
{
if (name == null)
throw new ArgumentNullException("name");
if (string.IsNullOrEmpty(name))
throw new ArgumentException("name cannot be empty");
return _states.GetOrAdd(name, i => new VolumeState(i));
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating the volume is being created.
/// </summary>
public static VolumeState Creating
{
get
{
return _creating;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating the volume is ready to be attached to an instance.
/// </summary>
public static VolumeState Available
{
get
{
return _available;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating the volume is attaching to an instance.
/// </summary>
public static VolumeState Attaching
{
get
{
return _attaching;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating the volume is attached to an instance.
/// </summary>
public static VolumeState InUse
{
get
{
return _inUse;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating the volume is being deleted.
/// </summary>
public static VolumeState Deleting
{
get
{
return _deleting;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating an error occurred during volume creation.
/// </summary>
public static VolumeState Error
{
get
{
return _error;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating an error occurred during volume deletion.
/// </summary>
public static VolumeState ErrorDeleting
{
get
{
return _errorDeleting;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating the volume is being backed-up.
/// </summary>
public static VolumeState BackingUp
{
get
{
return _backingUp;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating a backup is being restored to the volume.
/// </summary>
public static VolumeState RestoringBackup
{
get
{
return _restoringBackup;
}
}
/// <summary>
/// Gets a <see cref="VolumeState"/> indicating an error occurred during backup restoration to a volume.
/// </summary>
public static VolumeState ErrorRestoring
{
get
{
return _errorRestoring;
}
}
/// <summary>
/// Provides support for serializing and deserializing <see cref="VolumeState"/>
/// objects to JSON string values.
/// </summary>
/// <threadsafety static="true" instance="false"/>
private sealed class Converter : ConverterBase
{
/// <inheritdoc/>
protected override VolumeState FromName(string name)
{
return VolumeState.FromName(name);
}
}
}
}