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