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 VolumeContainersClient struct {
20 BaseClient
21 }
22
23
24 func NewVolumeContainersClient(subscriptionID string) VolumeContainersClient {
25 return NewVolumeContainersClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewVolumeContainersClientWithBaseURI(baseURI string, subscriptionID string) VolumeContainersClient {
32 return VolumeContainersClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42 func (client VolumeContainersClient) CreateOrUpdate(ctx context.Context, deviceName string, volumeContainerName string, parameters VolumeContainer, resourceGroupName string, managerName string) (result VolumeContainersCreateOrUpdateFuture, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/VolumeContainersClient.CreateOrUpdate")
45 defer func() {
46 sc := -1
47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
48 sc = result.FutureAPI.Response().StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: parameters,
55 Constraints: []validation.Constraint{{Target: "parameters.VolumeContainerProperties", Name: validation.Null, Rule: true,
56 Chain: []validation.Constraint{{Target: "parameters.VolumeContainerProperties.EncryptionKey", Name: validation.Null, Rule: false,
57 Chain: []validation.Constraint{{Target: "parameters.VolumeContainerProperties.EncryptionKey.Value", Name: validation.Null, Rule: true, Chain: nil}}},
58 {Target: "parameters.VolumeContainerProperties.StorageAccountCredentialID", Name: validation.Null, Rule: true, Chain: nil},
59 }}}},
60 {TargetValue: managerName,
61 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
62 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
63 return result, validation.NewError("storsimple.VolumeContainersClient", "CreateOrUpdate", err.Error())
64 }
65
66 req, err := client.CreateOrUpdatePreparer(ctx, deviceName, volumeContainerName, parameters, resourceGroupName, managerName)
67 if err != nil {
68 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "CreateOrUpdate", nil, "Failure preparing request")
69 return
70 }
71
72 result, err = client.CreateOrUpdateSender(req)
73 if err != nil {
74 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "CreateOrUpdate", result.Response(), "Failure sending request")
75 return
76 }
77
78 return
79 }
80
81
82 func (client VolumeContainersClient) CreateOrUpdatePreparer(ctx context.Context, deviceName string, volumeContainerName string, parameters VolumeContainer, resourceGroupName string, managerName string) (*http.Request, error) {
83 pathParameters := map[string]interface{}{
84 "deviceName": deviceName,
85 "managerName": managerName,
86 "resourceGroupName": resourceGroupName,
87 "subscriptionId": client.SubscriptionID,
88 "volumeContainerName": volumeContainerName,
89 }
90
91 const APIVersion = "2017-06-01"
92 queryParameters := map[string]interface{}{
93 "api-version": APIVersion,
94 }
95
96 preparer := autorest.CreatePreparer(
97 autorest.AsContentType("application/json; charset=utf-8"),
98 autorest.AsPut(),
99 autorest.WithBaseURL(client.BaseURI),
100 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}", pathParameters),
101 autorest.WithJSON(parameters),
102 autorest.WithQueryParameters(queryParameters))
103 return preparer.Prepare((&http.Request{}).WithContext(ctx))
104 }
105
106
107
108 func (client VolumeContainersClient) CreateOrUpdateSender(req *http.Request) (future VolumeContainersCreateOrUpdateFuture, err error) {
109 var resp *http.Response
110 future.FutureAPI = &azure.Future{}
111 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
112 if err != nil {
113 return
114 }
115 var azf azure.Future
116 azf, err = azure.NewFutureFromResponse(resp)
117 future.FutureAPI = &azf
118 future.Result = future.result
119 return
120 }
121
122
123
124 func (client VolumeContainersClient) CreateOrUpdateResponder(resp *http.Response) (result VolumeContainer, err error) {
125 err = autorest.Respond(
126 resp,
127 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
128 autorest.ByUnmarshallingJSON(&result),
129 autorest.ByClosing())
130 result.Response = autorest.Response{Response: resp}
131 return
132 }
133
134
135
136
137
138
139
140 func (client VolumeContainersClient) Delete(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result VolumeContainersDeleteFuture, err error) {
141 if tracing.IsEnabled() {
142 ctx = tracing.StartSpan(ctx, fqdn+"/VolumeContainersClient.Delete")
143 defer func() {
144 sc := -1
145 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
146 sc = result.FutureAPI.Response().StatusCode
147 }
148 tracing.EndSpan(ctx, sc, err)
149 }()
150 }
151 if err := validation.Validate([]validation.Validation{
152 {TargetValue: managerName,
153 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
154 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
155 return result, validation.NewError("storsimple.VolumeContainersClient", "Delete", err.Error())
156 }
157
158 req, err := client.DeletePreparer(ctx, deviceName, volumeContainerName, resourceGroupName, managerName)
159 if err != nil {
160 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "Delete", nil, "Failure preparing request")
161 return
162 }
163
164 result, err = client.DeleteSender(req)
165 if err != nil {
166 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "Delete", result.Response(), "Failure sending request")
167 return
168 }
169
170 return
171 }
172
173
174 func (client VolumeContainersClient) DeletePreparer(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) {
175 pathParameters := map[string]interface{}{
176 "deviceName": deviceName,
177 "managerName": managerName,
178 "resourceGroupName": resourceGroupName,
179 "subscriptionId": client.SubscriptionID,
180 "volumeContainerName": volumeContainerName,
181 }
182
183 const APIVersion = "2017-06-01"
184 queryParameters := map[string]interface{}{
185 "api-version": APIVersion,
186 }
187
188 preparer := autorest.CreatePreparer(
189 autorest.AsDelete(),
190 autorest.WithBaseURL(client.BaseURI),
191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}", pathParameters),
192 autorest.WithQueryParameters(queryParameters))
193 return preparer.Prepare((&http.Request{}).WithContext(ctx))
194 }
195
196
197
198 func (client VolumeContainersClient) DeleteSender(req *http.Request) (future VolumeContainersDeleteFuture, err error) {
199 var resp *http.Response
200 future.FutureAPI = &azure.Future{}
201 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
202 if err != nil {
203 return
204 }
205 var azf azure.Future
206 azf, err = azure.NewFutureFromResponse(resp)
207 future.FutureAPI = &azf
208 future.Result = future.result
209 return
210 }
211
212
213
214 func (client VolumeContainersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
215 err = autorest.Respond(
216 resp,
217 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
218 autorest.ByClosing())
219 result.Response = resp
220 return
221 }
222
223
224
225
226
227
228
229 func (client VolumeContainersClient) Get(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result VolumeContainer, err error) {
230 if tracing.IsEnabled() {
231 ctx = tracing.StartSpan(ctx, fqdn+"/VolumeContainersClient.Get")
232 defer func() {
233 sc := -1
234 if result.Response.Response != nil {
235 sc = result.Response.Response.StatusCode
236 }
237 tracing.EndSpan(ctx, sc, err)
238 }()
239 }
240 if err := validation.Validate([]validation.Validation{
241 {TargetValue: managerName,
242 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
243 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
244 return result, validation.NewError("storsimple.VolumeContainersClient", "Get", err.Error())
245 }
246
247 req, err := client.GetPreparer(ctx, deviceName, volumeContainerName, resourceGroupName, managerName)
248 if err != nil {
249 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "Get", nil, "Failure preparing request")
250 return
251 }
252
253 resp, err := client.GetSender(req)
254 if err != nil {
255 result.Response = autorest.Response{Response: resp}
256 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "Get", resp, "Failure sending request")
257 return
258 }
259
260 result, err = client.GetResponder(resp)
261 if err != nil {
262 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "Get", resp, "Failure responding to request")
263 return
264 }
265
266 return
267 }
268
269
270 func (client VolumeContainersClient) GetPreparer(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) {
271 pathParameters := map[string]interface{}{
272 "deviceName": deviceName,
273 "managerName": managerName,
274 "resourceGroupName": resourceGroupName,
275 "subscriptionId": client.SubscriptionID,
276 "volumeContainerName": volumeContainerName,
277 }
278
279 const APIVersion = "2017-06-01"
280 queryParameters := map[string]interface{}{
281 "api-version": APIVersion,
282 }
283
284 preparer := autorest.CreatePreparer(
285 autorest.AsGet(),
286 autorest.WithBaseURL(client.BaseURI),
287 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}", pathParameters),
288 autorest.WithQueryParameters(queryParameters))
289 return preparer.Prepare((&http.Request{}).WithContext(ctx))
290 }
291
292
293
294 func (client VolumeContainersClient) GetSender(req *http.Request) (*http.Response, error) {
295 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
296 }
297
298
299
300 func (client VolumeContainersClient) GetResponder(resp *http.Response) (result VolumeContainer, err error) {
301 err = autorest.Respond(
302 resp,
303 azure.WithErrorUnlessStatusCode(http.StatusOK),
304 autorest.ByUnmarshallingJSON(&result),
305 autorest.ByClosing())
306 result.Response = autorest.Response{Response: resp}
307 return
308 }
309
310
311
312
313
314
315 func (client VolumeContainersClient) ListByDevice(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result VolumeContainerList, err error) {
316 if tracing.IsEnabled() {
317 ctx = tracing.StartSpan(ctx, fqdn+"/VolumeContainersClient.ListByDevice")
318 defer func() {
319 sc := -1
320 if result.Response.Response != nil {
321 sc = result.Response.Response.StatusCode
322 }
323 tracing.EndSpan(ctx, sc, err)
324 }()
325 }
326 if err := validation.Validate([]validation.Validation{
327 {TargetValue: managerName,
328 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
329 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
330 return result, validation.NewError("storsimple.VolumeContainersClient", "ListByDevice", err.Error())
331 }
332
333 req, err := client.ListByDevicePreparer(ctx, deviceName, resourceGroupName, managerName)
334 if err != nil {
335 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListByDevice", nil, "Failure preparing request")
336 return
337 }
338
339 resp, err := client.ListByDeviceSender(req)
340 if err != nil {
341 result.Response = autorest.Response{Response: resp}
342 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListByDevice", resp, "Failure sending request")
343 return
344 }
345
346 result, err = client.ListByDeviceResponder(resp)
347 if err != nil {
348 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListByDevice", resp, "Failure responding to request")
349 return
350 }
351
352 return
353 }
354
355
356 func (client VolumeContainersClient) ListByDevicePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
357 pathParameters := map[string]interface{}{
358 "deviceName": deviceName,
359 "managerName": managerName,
360 "resourceGroupName": resourceGroupName,
361 "subscriptionId": client.SubscriptionID,
362 }
363
364 const APIVersion = "2017-06-01"
365 queryParameters := map[string]interface{}{
366 "api-version": APIVersion,
367 }
368
369 preparer := autorest.CreatePreparer(
370 autorest.AsGet(),
371 autorest.WithBaseURL(client.BaseURI),
372 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers", pathParameters),
373 autorest.WithQueryParameters(queryParameters))
374 return preparer.Prepare((&http.Request{}).WithContext(ctx))
375 }
376
377
378
379 func (client VolumeContainersClient) ListByDeviceSender(req *http.Request) (*http.Response, error) {
380 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
381 }
382
383
384
385 func (client VolumeContainersClient) ListByDeviceResponder(resp *http.Response) (result VolumeContainerList, err error) {
386 err = autorest.Respond(
387 resp,
388 azure.WithErrorUnlessStatusCode(http.StatusOK),
389 autorest.ByUnmarshallingJSON(&result),
390 autorest.ByClosing())
391 result.Response = autorest.Response{Response: resp}
392 return
393 }
394
395
396
397
398
399
400
401 func (client VolumeContainersClient) ListMetricDefinition(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) {
402 if tracing.IsEnabled() {
403 ctx = tracing.StartSpan(ctx, fqdn+"/VolumeContainersClient.ListMetricDefinition")
404 defer func() {
405 sc := -1
406 if result.Response.Response != nil {
407 sc = result.Response.Response.StatusCode
408 }
409 tracing.EndSpan(ctx, sc, err)
410 }()
411 }
412 if err := validation.Validate([]validation.Validation{
413 {TargetValue: managerName,
414 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
415 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
416 return result, validation.NewError("storsimple.VolumeContainersClient", "ListMetricDefinition", err.Error())
417 }
418
419 req, err := client.ListMetricDefinitionPreparer(ctx, deviceName, volumeContainerName, resourceGroupName, managerName)
420 if err != nil {
421 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListMetricDefinition", nil, "Failure preparing request")
422 return
423 }
424
425 resp, err := client.ListMetricDefinitionSender(req)
426 if err != nil {
427 result.Response = autorest.Response{Response: resp}
428 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListMetricDefinition", resp, "Failure sending request")
429 return
430 }
431
432 result, err = client.ListMetricDefinitionResponder(resp)
433 if err != nil {
434 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListMetricDefinition", resp, "Failure responding to request")
435 return
436 }
437
438 return
439 }
440
441
442 func (client VolumeContainersClient) ListMetricDefinitionPreparer(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) {
443 pathParameters := map[string]interface{}{
444 "deviceName": deviceName,
445 "managerName": managerName,
446 "resourceGroupName": resourceGroupName,
447 "subscriptionId": client.SubscriptionID,
448 "volumeContainerName": volumeContainerName,
449 }
450
451 const APIVersion = "2017-06-01"
452 queryParameters := map[string]interface{}{
453 "api-version": APIVersion,
454 }
455
456 preparer := autorest.CreatePreparer(
457 autorest.AsGet(),
458 autorest.WithBaseURL(client.BaseURI),
459 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/metricsDefinitions", pathParameters),
460 autorest.WithQueryParameters(queryParameters))
461 return preparer.Prepare((&http.Request{}).WithContext(ctx))
462 }
463
464
465
466 func (client VolumeContainersClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) {
467 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
468 }
469
470
471
472 func (client VolumeContainersClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) {
473 err = autorest.Respond(
474 resp,
475 azure.WithErrorUnlessStatusCode(http.StatusOK),
476 autorest.ByUnmarshallingJSON(&result),
477 autorest.ByClosing())
478 result.Response = autorest.Response{Response: resp}
479 return
480 }
481
482
483
484
485
486
487
488
489 func (client VolumeContainersClient) ListMetrics(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) {
490 if tracing.IsEnabled() {
491 ctx = tracing.StartSpan(ctx, fqdn+"/VolumeContainersClient.ListMetrics")
492 defer func() {
493 sc := -1
494 if result.Response.Response != nil {
495 sc = result.Response.Response.StatusCode
496 }
497 tracing.EndSpan(ctx, sc, err)
498 }()
499 }
500 if err := validation.Validate([]validation.Validation{
501 {TargetValue: managerName,
502 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
503 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
504 return result, validation.NewError("storsimple.VolumeContainersClient", "ListMetrics", err.Error())
505 }
506
507 req, err := client.ListMetricsPreparer(ctx, deviceName, volumeContainerName, resourceGroupName, managerName, filter)
508 if err != nil {
509 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListMetrics", nil, "Failure preparing request")
510 return
511 }
512
513 resp, err := client.ListMetricsSender(req)
514 if err != nil {
515 result.Response = autorest.Response{Response: resp}
516 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListMetrics", resp, "Failure sending request")
517 return
518 }
519
520 result, err = client.ListMetricsResponder(resp)
521 if err != nil {
522 err = autorest.NewErrorWithError(err, "storsimple.VolumeContainersClient", "ListMetrics", resp, "Failure responding to request")
523 return
524 }
525
526 return
527 }
528
529
530 func (client VolumeContainersClient) ListMetricsPreparer(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) {
531 pathParameters := map[string]interface{}{
532 "deviceName": deviceName,
533 "managerName": managerName,
534 "resourceGroupName": resourceGroupName,
535 "subscriptionId": client.SubscriptionID,
536 "volumeContainerName": volumeContainerName,
537 }
538
539 const APIVersion = "2017-06-01"
540 queryParameters := map[string]interface{}{
541 "$filter": autorest.Encode("query", filter),
542 "api-version": APIVersion,
543 }
544
545 preparer := autorest.CreatePreparer(
546 autorest.AsGet(),
547 autorest.WithBaseURL(client.BaseURI),
548 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/metrics", pathParameters),
549 autorest.WithQueryParameters(queryParameters))
550 return preparer.Prepare((&http.Request{}).WithContext(ctx))
551 }
552
553
554
555 func (client VolumeContainersClient) ListMetricsSender(req *http.Request) (*http.Response, error) {
556 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
557 }
558
559
560
561 func (client VolumeContainersClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) {
562 err = autorest.Respond(
563 resp,
564 azure.WithErrorUnlessStatusCode(http.StatusOK),
565 autorest.ByUnmarshallingJSON(&result),
566 autorest.ByClosing())
567 result.Response = autorest.Response{Response: resp}
568 return
569 }
570
View as plain text