1 package storsimple
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type StorageDomainsClient struct {
20 BaseClient
21 }
22
23
24 func NewStorageDomainsClient(subscriptionID string) StorageDomainsClient {
25 return NewStorageDomainsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewStorageDomainsClientWithBaseURI(baseURI string, subscriptionID string) StorageDomainsClient {
31 return StorageDomainsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40 func (client StorageDomainsClient) CreateOrUpdate(ctx context.Context, storageDomainName string, storageDomain StorageDomain, resourceGroupName string, managerName string) (result StorageDomainsCreateOrUpdateFuture, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/StorageDomainsClient.CreateOrUpdate")
43 defer func() {
44 sc := -1
45 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46 sc = result.FutureAPI.Response().StatusCode
47 }
48 tracing.EndSpan(ctx, sc, err)
49 }()
50 }
51 if err := validation.Validate([]validation.Validation{
52 {TargetValue: storageDomain,
53 Constraints: []validation.Constraint{{Target: "storageDomain.StorageDomainProperties", Name: validation.Null, Rule: true,
54 Chain: []validation.Constraint{{Target: "storageDomain.StorageDomainProperties.StorageAccountCredentialIds", Name: validation.Null, Rule: true, Chain: nil},
55 {Target: "storageDomain.StorageDomainProperties.EncryptionKey", Name: validation.Null, Rule: false,
56 Chain: []validation.Constraint{{Target: "storageDomain.StorageDomainProperties.EncryptionKey.Value", Name: validation.Null, Rule: true, Chain: nil}}},
57 }}}},
58 {TargetValue: managerName,
59 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
60 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
61 return result, validation.NewError("storsimple.StorageDomainsClient", "CreateOrUpdate", err.Error())
62 }
63
64 req, err := client.CreateOrUpdatePreparer(ctx, storageDomainName, storageDomain, resourceGroupName, managerName)
65 if err != nil {
66 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "CreateOrUpdate", nil, "Failure preparing request")
67 return
68 }
69
70 result, err = client.CreateOrUpdateSender(req)
71 if err != nil {
72 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
73 return
74 }
75
76 return
77 }
78
79
80 func (client StorageDomainsClient) CreateOrUpdatePreparer(ctx context.Context, storageDomainName string, storageDomain StorageDomain, resourceGroupName string, managerName string) (*http.Request, error) {
81 pathParameters := map[string]interface{}{
82 "managerName": autorest.Encode("path", managerName),
83 "resourceGroupName": autorest.Encode("path", resourceGroupName),
84 "storageDomainName": autorest.Encode("path", storageDomainName),
85 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
86 }
87
88 const APIVersion = "2016-10-01"
89 queryParameters := map[string]interface{}{
90 "api-version": APIVersion,
91 }
92
93 preparer := autorest.CreatePreparer(
94 autorest.AsContentType("application/json; charset=utf-8"),
95 autorest.AsPut(),
96 autorest.WithBaseURL(client.BaseURI),
97 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageDomains/{storageDomainName}", pathParameters),
98 autorest.WithJSON(storageDomain),
99 autorest.WithQueryParameters(queryParameters))
100 return preparer.Prepare((&http.Request{}).WithContext(ctx))
101 }
102
103
104
105 func (client StorageDomainsClient) CreateOrUpdateSender(req *http.Request) (future StorageDomainsCreateOrUpdateFuture, err error) {
106 var resp *http.Response
107 future.FutureAPI = &azure.Future{}
108 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
109 if err != nil {
110 return
111 }
112 var azf azure.Future
113 azf, err = azure.NewFutureFromResponse(resp)
114 future.FutureAPI = &azf
115 future.Result = future.result
116 return
117 }
118
119
120
121 func (client StorageDomainsClient) CreateOrUpdateResponder(resp *http.Response) (result StorageDomain, err error) {
122 err = autorest.Respond(
123 resp,
124 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
125 autorest.ByUnmarshallingJSON(&result),
126 autorest.ByClosing())
127 result.Response = autorest.Response{Response: resp}
128 return
129 }
130
131
132
133
134
135
136 func (client StorageDomainsClient) Delete(ctx context.Context, storageDomainName string, resourceGroupName string, managerName string) (result StorageDomainsDeleteFuture, err error) {
137 if tracing.IsEnabled() {
138 ctx = tracing.StartSpan(ctx, fqdn+"/StorageDomainsClient.Delete")
139 defer func() {
140 sc := -1
141 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
142 sc = result.FutureAPI.Response().StatusCode
143 }
144 tracing.EndSpan(ctx, sc, err)
145 }()
146 }
147 if err := validation.Validate([]validation.Validation{
148 {TargetValue: managerName,
149 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
150 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
151 return result, validation.NewError("storsimple.StorageDomainsClient", "Delete", err.Error())
152 }
153
154 req, err := client.DeletePreparer(ctx, storageDomainName, resourceGroupName, managerName)
155 if err != nil {
156 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "Delete", nil, "Failure preparing request")
157 return
158 }
159
160 result, err = client.DeleteSender(req)
161 if err != nil {
162 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "Delete", result.Response(), "Failure sending request")
163 return
164 }
165
166 return
167 }
168
169
170 func (client StorageDomainsClient) DeletePreparer(ctx context.Context, storageDomainName string, resourceGroupName string, managerName string) (*http.Request, error) {
171 pathParameters := map[string]interface{}{
172 "managerName": autorest.Encode("path", managerName),
173 "resourceGroupName": autorest.Encode("path", resourceGroupName),
174 "storageDomainName": autorest.Encode("path", storageDomainName),
175 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
176 }
177
178 const APIVersion = "2016-10-01"
179 queryParameters := map[string]interface{}{
180 "api-version": APIVersion,
181 }
182
183 preparer := autorest.CreatePreparer(
184 autorest.AsDelete(),
185 autorest.WithBaseURL(client.BaseURI),
186 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageDomains/{storageDomainName}", pathParameters),
187 autorest.WithQueryParameters(queryParameters))
188 return preparer.Prepare((&http.Request{}).WithContext(ctx))
189 }
190
191
192
193 func (client StorageDomainsClient) DeleteSender(req *http.Request) (future StorageDomainsDeleteFuture, err error) {
194 var resp *http.Response
195 future.FutureAPI = &azure.Future{}
196 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
197 if err != nil {
198 return
199 }
200 var azf azure.Future
201 azf, err = azure.NewFutureFromResponse(resp)
202 future.FutureAPI = &azf
203 future.Result = future.result
204 return
205 }
206
207
208
209 func (client StorageDomainsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
210 err = autorest.Respond(
211 resp,
212 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
213 autorest.ByClosing())
214 result.Response = resp
215 return
216 }
217
218
219
220
221
222
223 func (client StorageDomainsClient) Get(ctx context.Context, storageDomainName string, resourceGroupName string, managerName string) (result StorageDomain, err error) {
224 if tracing.IsEnabled() {
225 ctx = tracing.StartSpan(ctx, fqdn+"/StorageDomainsClient.Get")
226 defer func() {
227 sc := -1
228 if result.Response.Response != nil {
229 sc = result.Response.Response.StatusCode
230 }
231 tracing.EndSpan(ctx, sc, err)
232 }()
233 }
234 if err := validation.Validate([]validation.Validation{
235 {TargetValue: managerName,
236 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
237 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
238 return result, validation.NewError("storsimple.StorageDomainsClient", "Get", err.Error())
239 }
240
241 req, err := client.GetPreparer(ctx, storageDomainName, resourceGroupName, managerName)
242 if err != nil {
243 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "Get", nil, "Failure preparing request")
244 return
245 }
246
247 resp, err := client.GetSender(req)
248 if err != nil {
249 result.Response = autorest.Response{Response: resp}
250 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "Get", resp, "Failure sending request")
251 return
252 }
253
254 result, err = client.GetResponder(resp)
255 if err != nil {
256 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "Get", resp, "Failure responding to request")
257 return
258 }
259
260 return
261 }
262
263
264 func (client StorageDomainsClient) GetPreparer(ctx context.Context, storageDomainName string, resourceGroupName string, managerName string) (*http.Request, error) {
265 pathParameters := map[string]interface{}{
266 "managerName": autorest.Encode("path", managerName),
267 "resourceGroupName": autorest.Encode("path", resourceGroupName),
268 "storageDomainName": autorest.Encode("path", storageDomainName),
269 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
270 }
271
272 const APIVersion = "2016-10-01"
273 queryParameters := map[string]interface{}{
274 "api-version": APIVersion,
275 }
276
277 preparer := autorest.CreatePreparer(
278 autorest.AsGet(),
279 autorest.WithBaseURL(client.BaseURI),
280 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageDomains/{storageDomainName}", pathParameters),
281 autorest.WithQueryParameters(queryParameters))
282 return preparer.Prepare((&http.Request{}).WithContext(ctx))
283 }
284
285
286
287 func (client StorageDomainsClient) GetSender(req *http.Request) (*http.Response, error) {
288 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
289 }
290
291
292
293 func (client StorageDomainsClient) GetResponder(resp *http.Response) (result StorageDomain, err error) {
294 err = autorest.Respond(
295 resp,
296 azure.WithErrorUnlessStatusCode(http.StatusOK),
297 autorest.ByUnmarshallingJSON(&result),
298 autorest.ByClosing())
299 result.Response = autorest.Response{Response: resp}
300 return
301 }
302
303
304
305
306
307 func (client StorageDomainsClient) ListByManager(ctx context.Context, resourceGroupName string, managerName string) (result StorageDomainList, err error) {
308 if tracing.IsEnabled() {
309 ctx = tracing.StartSpan(ctx, fqdn+"/StorageDomainsClient.ListByManager")
310 defer func() {
311 sc := -1
312 if result.Response.Response != nil {
313 sc = result.Response.Response.StatusCode
314 }
315 tracing.EndSpan(ctx, sc, err)
316 }()
317 }
318 if err := validation.Validate([]validation.Validation{
319 {TargetValue: managerName,
320 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
321 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
322 return result, validation.NewError("storsimple.StorageDomainsClient", "ListByManager", err.Error())
323 }
324
325 req, err := client.ListByManagerPreparer(ctx, resourceGroupName, managerName)
326 if err != nil {
327 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "ListByManager", nil, "Failure preparing request")
328 return
329 }
330
331 resp, err := client.ListByManagerSender(req)
332 if err != nil {
333 result.Response = autorest.Response{Response: resp}
334 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "ListByManager", resp, "Failure sending request")
335 return
336 }
337
338 result, err = client.ListByManagerResponder(resp)
339 if err != nil {
340 err = autorest.NewErrorWithError(err, "storsimple.StorageDomainsClient", "ListByManager", resp, "Failure responding to request")
341 return
342 }
343
344 return
345 }
346
347
348 func (client StorageDomainsClient) ListByManagerPreparer(ctx context.Context, resourceGroupName string, managerName string) (*http.Request, error) {
349 pathParameters := map[string]interface{}{
350 "managerName": autorest.Encode("path", managerName),
351 "resourceGroupName": autorest.Encode("path", resourceGroupName),
352 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
353 }
354
355 const APIVersion = "2016-10-01"
356 queryParameters := map[string]interface{}{
357 "api-version": APIVersion,
358 }
359
360 preparer := autorest.CreatePreparer(
361 autorest.AsGet(),
362 autorest.WithBaseURL(client.BaseURI),
363 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageDomains", pathParameters),
364 autorest.WithQueryParameters(queryParameters))
365 return preparer.Prepare((&http.Request{}).WithContext(ctx))
366 }
367
368
369
370 func (client StorageDomainsClient) ListByManagerSender(req *http.Request) (*http.Response, error) {
371 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
372 }
373
374
375
376 func (client StorageDomainsClient) ListByManagerResponder(resp *http.Response) (result StorageDomainList, err error) {
377 err = autorest.Respond(
378 resp,
379 azure.WithErrorUnlessStatusCode(http.StatusOK),
380 autorest.ByUnmarshallingJSON(&result),
381 autorest.ByClosing())
382 result.Response = autorest.Response{Response: resp}
383 return
384 }
385
View as plain text