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