1 package storagecache
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
20 type CachesClient struct {
21 BaseClient
22 }
23
24
25 func NewCachesClient(subscriptionID string) CachesClient {
26 return NewCachesClientWithBaseURI(DefaultBaseURI, subscriptionID)
27 }
28
29
30
31 func NewCachesClientWithBaseURI(baseURI string, subscriptionID string) CachesClient {
32 return CachesClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42 func (client CachesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result CachesCreateOrUpdateFuture, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName,
55 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}},
56 {TargetValue: cache,
57 Constraints: []validation.Constraint{{Target: "cache", Name: validation.Null, Rule: false,
58 Chain: []validation.Constraint{{Target: "cache.CacheProperties", Name: validation.Null, Rule: false,
59 Chain: []validation.Constraint{{Target: "cache.CacheProperties.NetworkSettings", Name: validation.Null, Rule: false,
60 Chain: []validation.Constraint{{Target: "cache.CacheProperties.NetworkSettings.Mtu", Name: validation.Null, Rule: false,
61 Chain: []validation.Constraint{{Target: "cache.CacheProperties.NetworkSettings.Mtu", Name: validation.InclusiveMaximum, Rule: int64(1500), Chain: nil},
62 {Target: "cache.CacheProperties.NetworkSettings.Mtu", Name: validation.InclusiveMinimum, Rule: int64(576), Chain: nil},
63 }},
64 }},
65 {Target: "cache.CacheProperties.EncryptionSettings", Name: validation.Null, Rule: false,
66 Chain: []validation.Constraint{{Target: "cache.CacheProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
67 Chain: []validation.Constraint{{Target: "cache.CacheProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
68 {Target: "cache.CacheProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
69 }},
70 }},
71 {Target: "cache.CacheProperties.DirectoryServicesSettings", Name: validation.Null, Rule: false,
72 Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory", Name: validation.Null, Rule: false,
73 Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.PrimaryDNSIPAddress", Name: validation.Null, Rule: true, Chain: nil},
74 {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.DomainName", Name: validation.Null, Rule: true, Chain: nil},
75 {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.DomainNetBiosName", Name: validation.Null, Rule: true, Chain: nil},
76 {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.CacheNetBiosName", Name: validation.Null, Rule: true,
77 Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.CacheNetBiosName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z]{1,15}$`, Chain: nil}}},
78 {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.Credentials", Name: validation.Null, Rule: false,
79 Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.Credentials.Username", Name: validation.Null, Rule: true, Chain: nil},
80 {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.Credentials.Password", Name: validation.Null, Rule: true, Chain: nil},
81 }},
82 }},
83 }},
84 }},
85 }}}}}); err != nil {
86 return result, validation.NewError("storagecache.CachesClient", "CreateOrUpdate", err.Error())
87 }
88
89 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, cacheName, cache)
90 if err != nil {
91 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "CreateOrUpdate", nil, "Failure preparing request")
92 return
93 }
94
95 result, err = client.CreateOrUpdateSender(req)
96 if err != nil {
97 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
98 return
99 }
100
101 return
102 }
103
104
105 func (client CachesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (*http.Request, error) {
106 pathParameters := map[string]interface{}{
107 "cacheName": autorest.Encode("path", cacheName),
108 "resourceGroupName": autorest.Encode("path", resourceGroupName),
109 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
110 }
111
112 const APIVersion = "2021-09-01"
113 queryParameters := map[string]interface{}{
114 "api-version": APIVersion,
115 }
116
117 cache.ID = nil
118 cache.Name = nil
119 cache.Type = nil
120 cache.SystemData = nil
121 preparer := autorest.CreatePreparer(
122 autorest.AsContentType("application/json; charset=utf-8"),
123 autorest.AsPut(),
124 autorest.WithBaseURL(client.BaseURI),
125 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters),
126 autorest.WithQueryParameters(queryParameters))
127 if cache != nil {
128 preparer = autorest.DecoratePreparer(preparer,
129 autorest.WithJSON(cache))
130 }
131 return preparer.Prepare((&http.Request{}).WithContext(ctx))
132 }
133
134
135
136 func (client CachesClient) CreateOrUpdateSender(req *http.Request) (future CachesCreateOrUpdateFuture, err error) {
137 var resp *http.Response
138 future.FutureAPI = &azure.Future{}
139 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
140 if err != nil {
141 return
142 }
143 var azf azure.Future
144 azf, err = azure.NewFutureFromResponse(resp)
145 future.FutureAPI = &azf
146 future.Result = future.result
147 return
148 }
149
150
151
152 func (client CachesClient) CreateOrUpdateResponder(resp *http.Response) (result Cache, err error) {
153 err = autorest.Respond(
154 resp,
155 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
156 autorest.ByUnmarshallingJSON(&result),
157 autorest.ByClosing())
158 result.Response = autorest.Response{Response: resp}
159 return
160 }
161
162
163
164
165
166
167 func (client CachesClient) DebugInfo(ctx context.Context, resourceGroupName string, cacheName string) (result CachesDebugInfoFuture, err error) {
168 if tracing.IsEnabled() {
169 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.DebugInfo")
170 defer func() {
171 sc := -1
172 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
173 sc = result.FutureAPI.Response().StatusCode
174 }
175 tracing.EndSpan(ctx, sc, err)
176 }()
177 }
178 if err := validation.Validate([]validation.Validation{
179 {TargetValue: cacheName,
180 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
181 return result, validation.NewError("storagecache.CachesClient", "DebugInfo", err.Error())
182 }
183
184 req, err := client.DebugInfoPreparer(ctx, resourceGroupName, cacheName)
185 if err != nil {
186 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "DebugInfo", nil, "Failure preparing request")
187 return
188 }
189
190 result, err = client.DebugInfoSender(req)
191 if err != nil {
192 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "DebugInfo", result.Response(), "Failure sending request")
193 return
194 }
195
196 return
197 }
198
199
200 func (client CachesClient) DebugInfoPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
201 pathParameters := map[string]interface{}{
202 "cacheName": autorest.Encode("path", cacheName),
203 "resourceGroupName": autorest.Encode("path", resourceGroupName),
204 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
205 }
206
207 const APIVersion = "2021-09-01"
208 queryParameters := map[string]interface{}{
209 "api-version": APIVersion,
210 }
211
212 preparer := autorest.CreatePreparer(
213 autorest.AsPost(),
214 autorest.WithBaseURL(client.BaseURI),
215 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo", pathParameters),
216 autorest.WithQueryParameters(queryParameters))
217 return preparer.Prepare((&http.Request{}).WithContext(ctx))
218 }
219
220
221
222 func (client CachesClient) DebugInfoSender(req *http.Request) (future CachesDebugInfoFuture, err error) {
223 var resp *http.Response
224 future.FutureAPI = &azure.Future{}
225 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
226 if err != nil {
227 return
228 }
229 var azf azure.Future
230 azf, err = azure.NewFutureFromResponse(resp)
231 future.FutureAPI = &azf
232 future.Result = future.result
233 return
234 }
235
236
237
238 func (client CachesClient) DebugInfoResponder(resp *http.Response) (result autorest.Response, err error) {
239 err = autorest.Respond(
240 resp,
241 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
242 autorest.ByClosing())
243 result.Response = resp
244 return
245 }
246
247
248
249
250
251
252 func (client CachesClient) Delete(ctx context.Context, resourceGroupName string, cacheName string) (result CachesDeleteFuture, err error) {
253 if tracing.IsEnabled() {
254 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Delete")
255 defer func() {
256 sc := -1
257 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
258 sc = result.FutureAPI.Response().StatusCode
259 }
260 tracing.EndSpan(ctx, sc, err)
261 }()
262 }
263 if err := validation.Validate([]validation.Validation{
264 {TargetValue: cacheName,
265 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
266 return result, validation.NewError("storagecache.CachesClient", "Delete", err.Error())
267 }
268
269 req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName)
270 if err != nil {
271 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Delete", nil, "Failure preparing request")
272 return
273 }
274
275 result, err = client.DeleteSender(req)
276 if err != nil {
277 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Delete", result.Response(), "Failure sending request")
278 return
279 }
280
281 return
282 }
283
284
285 func (client CachesClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
286 pathParameters := map[string]interface{}{
287 "cacheName": autorest.Encode("path", cacheName),
288 "resourceGroupName": autorest.Encode("path", resourceGroupName),
289 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
290 }
291
292 const APIVersion = "2021-09-01"
293 queryParameters := map[string]interface{}{
294 "api-version": APIVersion,
295 }
296
297 preparer := autorest.CreatePreparer(
298 autorest.AsDelete(),
299 autorest.WithBaseURL(client.BaseURI),
300 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters),
301 autorest.WithQueryParameters(queryParameters))
302 return preparer.Prepare((&http.Request{}).WithContext(ctx))
303 }
304
305
306
307 func (client CachesClient) DeleteSender(req *http.Request) (future CachesDeleteFuture, err error) {
308 var resp *http.Response
309 future.FutureAPI = &azure.Future{}
310 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
311 if err != nil {
312 return
313 }
314 var azf azure.Future
315 azf, err = azure.NewFutureFromResponse(resp)
316 future.FutureAPI = &azf
317 future.Result = future.result
318 return
319 }
320
321
322
323 func (client CachesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
324 err = autorest.Respond(
325 resp,
326 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
327 autorest.ByClosing())
328 result.Response = resp
329 return
330 }
331
332
333
334
335
336
337
338 func (client CachesClient) Flush(ctx context.Context, resourceGroupName string, cacheName string) (result CachesFlushFuture, err error) {
339 if tracing.IsEnabled() {
340 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Flush")
341 defer func() {
342 sc := -1
343 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
344 sc = result.FutureAPI.Response().StatusCode
345 }
346 tracing.EndSpan(ctx, sc, err)
347 }()
348 }
349 if err := validation.Validate([]validation.Validation{
350 {TargetValue: cacheName,
351 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
352 return result, validation.NewError("storagecache.CachesClient", "Flush", err.Error())
353 }
354
355 req, err := client.FlushPreparer(ctx, resourceGroupName, cacheName)
356 if err != nil {
357 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Flush", nil, "Failure preparing request")
358 return
359 }
360
361 result, err = client.FlushSender(req)
362 if err != nil {
363 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Flush", result.Response(), "Failure sending request")
364 return
365 }
366
367 return
368 }
369
370
371 func (client CachesClient) FlushPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
372 pathParameters := map[string]interface{}{
373 "cacheName": autorest.Encode("path", cacheName),
374 "resourceGroupName": autorest.Encode("path", resourceGroupName),
375 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
376 }
377
378 const APIVersion = "2021-09-01"
379 queryParameters := map[string]interface{}{
380 "api-version": APIVersion,
381 }
382
383 preparer := autorest.CreatePreparer(
384 autorest.AsPost(),
385 autorest.WithBaseURL(client.BaseURI),
386 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush", pathParameters),
387 autorest.WithQueryParameters(queryParameters))
388 return preparer.Prepare((&http.Request{}).WithContext(ctx))
389 }
390
391
392
393 func (client CachesClient) FlushSender(req *http.Request) (future CachesFlushFuture, err error) {
394 var resp *http.Response
395 future.FutureAPI = &azure.Future{}
396 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
397 if err != nil {
398 return
399 }
400 var azf azure.Future
401 azf, err = azure.NewFutureFromResponse(resp)
402 future.FutureAPI = &azf
403 future.Result = future.result
404 return
405 }
406
407
408
409 func (client CachesClient) FlushResponder(resp *http.Response) (result autorest.Response, err error) {
410 err = autorest.Respond(
411 resp,
412 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
413 autorest.ByClosing())
414 result.Response = resp
415 return
416 }
417
418
419
420
421
422
423 func (client CachesClient) Get(ctx context.Context, resourceGroupName string, cacheName string) (result Cache, err error) {
424 if tracing.IsEnabled() {
425 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Get")
426 defer func() {
427 sc := -1
428 if result.Response.Response != nil {
429 sc = result.Response.Response.StatusCode
430 }
431 tracing.EndSpan(ctx, sc, err)
432 }()
433 }
434 if err := validation.Validate([]validation.Validation{
435 {TargetValue: cacheName,
436 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
437 return result, validation.NewError("storagecache.CachesClient", "Get", err.Error())
438 }
439
440 req, err := client.GetPreparer(ctx, resourceGroupName, cacheName)
441 if err != nil {
442 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", nil, "Failure preparing request")
443 return
444 }
445
446 resp, err := client.GetSender(req)
447 if err != nil {
448 result.Response = autorest.Response{Response: resp}
449 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", resp, "Failure sending request")
450 return
451 }
452
453 result, err = client.GetResponder(resp)
454 if err != nil {
455 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", resp, "Failure responding to request")
456 return
457 }
458
459 return
460 }
461
462
463 func (client CachesClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
464 pathParameters := map[string]interface{}{
465 "cacheName": autorest.Encode("path", cacheName),
466 "resourceGroupName": autorest.Encode("path", resourceGroupName),
467 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
468 }
469
470 const APIVersion = "2021-09-01"
471 queryParameters := map[string]interface{}{
472 "api-version": APIVersion,
473 }
474
475 preparer := autorest.CreatePreparer(
476 autorest.AsGet(),
477 autorest.WithBaseURL(client.BaseURI),
478 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters),
479 autorest.WithQueryParameters(queryParameters))
480 return preparer.Prepare((&http.Request{}).WithContext(ctx))
481 }
482
483
484
485 func (client CachesClient) GetSender(req *http.Request) (*http.Response, error) {
486 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
487 }
488
489
490
491 func (client CachesClient) GetResponder(resp *http.Response) (result Cache, err error) {
492 err = autorest.Respond(
493 resp,
494 azure.WithErrorUnlessStatusCode(http.StatusOK),
495 autorest.ByUnmarshallingJSON(&result),
496 autorest.ByClosing())
497 result.Response = autorest.Response{Response: resp}
498 return
499 }
500
501
502 func (client CachesClient) List(ctx context.Context) (result CachesListResultPage, err error) {
503 if tracing.IsEnabled() {
504 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.List")
505 defer func() {
506 sc := -1
507 if result.clr.Response.Response != nil {
508 sc = result.clr.Response.Response.StatusCode
509 }
510 tracing.EndSpan(ctx, sc, err)
511 }()
512 }
513 result.fn = client.listNextResults
514 req, err := client.ListPreparer(ctx)
515 if err != nil {
516 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", nil, "Failure preparing request")
517 return
518 }
519
520 resp, err := client.ListSender(req)
521 if err != nil {
522 result.clr.Response = autorest.Response{Response: resp}
523 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", resp, "Failure sending request")
524 return
525 }
526
527 result.clr, err = client.ListResponder(resp)
528 if err != nil {
529 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", resp, "Failure responding to request")
530 return
531 }
532 if result.clr.hasNextLink() && result.clr.IsEmpty() {
533 err = result.NextWithContext(ctx)
534 return
535 }
536
537 return
538 }
539
540
541 func (client CachesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
542 pathParameters := map[string]interface{}{
543 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
544 }
545
546 const APIVersion = "2021-09-01"
547 queryParameters := map[string]interface{}{
548 "api-version": APIVersion,
549 }
550
551 preparer := autorest.CreatePreparer(
552 autorest.AsGet(),
553 autorest.WithBaseURL(client.BaseURI),
554 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches", pathParameters),
555 autorest.WithQueryParameters(queryParameters))
556 return preparer.Prepare((&http.Request{}).WithContext(ctx))
557 }
558
559
560
561 func (client CachesClient) ListSender(req *http.Request) (*http.Response, error) {
562 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
563 }
564
565
566
567 func (client CachesClient) ListResponder(resp *http.Response) (result CachesListResult, err error) {
568 err = autorest.Respond(
569 resp,
570 azure.WithErrorUnlessStatusCode(http.StatusOK),
571 autorest.ByUnmarshallingJSON(&result),
572 autorest.ByClosing())
573 result.Response = autorest.Response{Response: resp}
574 return
575 }
576
577
578 func (client CachesClient) listNextResults(ctx context.Context, lastResults CachesListResult) (result CachesListResult, err error) {
579 req, err := lastResults.cachesListResultPreparer(ctx)
580 if err != nil {
581 return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "listNextResults", nil, "Failure preparing next results request")
582 }
583 if req == nil {
584 return
585 }
586 resp, err := client.ListSender(req)
587 if err != nil {
588 result.Response = autorest.Response{Response: resp}
589 return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "listNextResults", resp, "Failure sending next results request")
590 }
591 result, err = client.ListResponder(resp)
592 if err != nil {
593 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "listNextResults", resp, "Failure responding to next results request")
594 }
595 return
596 }
597
598
599 func (client CachesClient) ListComplete(ctx context.Context) (result CachesListResultIterator, err error) {
600 if tracing.IsEnabled() {
601 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.List")
602 defer func() {
603 sc := -1
604 if result.Response().Response.Response != nil {
605 sc = result.page.Response().Response.Response.StatusCode
606 }
607 tracing.EndSpan(ctx, sc, err)
608 }()
609 }
610 result.page, err = client.List(ctx)
611 return
612 }
613
614
615
616
617 func (client CachesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result CachesListResultPage, err error) {
618 if tracing.IsEnabled() {
619 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.ListByResourceGroup")
620 defer func() {
621 sc := -1
622 if result.clr.Response.Response != nil {
623 sc = result.clr.Response.Response.StatusCode
624 }
625 tracing.EndSpan(ctx, sc, err)
626 }()
627 }
628 result.fn = client.listByResourceGroupNextResults
629 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
630 if err != nil {
631 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", nil, "Failure preparing request")
632 return
633 }
634
635 resp, err := client.ListByResourceGroupSender(req)
636 if err != nil {
637 result.clr.Response = autorest.Response{Response: resp}
638 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", resp, "Failure sending request")
639 return
640 }
641
642 result.clr, err = client.ListByResourceGroupResponder(resp)
643 if err != nil {
644 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", resp, "Failure responding to request")
645 return
646 }
647 if result.clr.hasNextLink() && result.clr.IsEmpty() {
648 err = result.NextWithContext(ctx)
649 return
650 }
651
652 return
653 }
654
655
656 func (client CachesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
657 pathParameters := map[string]interface{}{
658 "resourceGroupName": autorest.Encode("path", resourceGroupName),
659 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
660 }
661
662 const APIVersion = "2021-09-01"
663 queryParameters := map[string]interface{}{
664 "api-version": APIVersion,
665 }
666
667 preparer := autorest.CreatePreparer(
668 autorest.AsGet(),
669 autorest.WithBaseURL(client.BaseURI),
670 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches", pathParameters),
671 autorest.WithQueryParameters(queryParameters))
672 return preparer.Prepare((&http.Request{}).WithContext(ctx))
673 }
674
675
676
677 func (client CachesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
678 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
679 }
680
681
682
683 func (client CachesClient) ListByResourceGroupResponder(resp *http.Response) (result CachesListResult, err error) {
684 err = autorest.Respond(
685 resp,
686 azure.WithErrorUnlessStatusCode(http.StatusOK),
687 autorest.ByUnmarshallingJSON(&result),
688 autorest.ByClosing())
689 result.Response = autorest.Response{Response: resp}
690 return
691 }
692
693
694 func (client CachesClient) listByResourceGroupNextResults(ctx context.Context, lastResults CachesListResult) (result CachesListResult, err error) {
695 req, err := lastResults.cachesListResultPreparer(ctx)
696 if err != nil {
697 return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
698 }
699 if req == nil {
700 return
701 }
702 resp, err := client.ListByResourceGroupSender(req)
703 if err != nil {
704 result.Response = autorest.Response{Response: resp}
705 return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
706 }
707 result, err = client.ListByResourceGroupResponder(resp)
708 if err != nil {
709 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
710 }
711 return
712 }
713
714
715 func (client CachesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result CachesListResultIterator, err error) {
716 if tracing.IsEnabled() {
717 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.ListByResourceGroup")
718 defer func() {
719 sc := -1
720 if result.Response().Response.Response != nil {
721 sc = result.page.Response().Response.Response.StatusCode
722 }
723 tracing.EndSpan(ctx, sc, err)
724 }()
725 }
726 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
727 return
728 }
729
730
731
732
733
734
735 func (client CachesClient) Start(ctx context.Context, resourceGroupName string, cacheName string) (result CachesStartFuture, err error) {
736 if tracing.IsEnabled() {
737 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Start")
738 defer func() {
739 sc := -1
740 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
741 sc = result.FutureAPI.Response().StatusCode
742 }
743 tracing.EndSpan(ctx, sc, err)
744 }()
745 }
746 if err := validation.Validate([]validation.Validation{
747 {TargetValue: cacheName,
748 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
749 return result, validation.NewError("storagecache.CachesClient", "Start", err.Error())
750 }
751
752 req, err := client.StartPreparer(ctx, resourceGroupName, cacheName)
753 if err != nil {
754 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Start", nil, "Failure preparing request")
755 return
756 }
757
758 result, err = client.StartSender(req)
759 if err != nil {
760 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Start", result.Response(), "Failure sending request")
761 return
762 }
763
764 return
765 }
766
767
768 func (client CachesClient) StartPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
769 pathParameters := map[string]interface{}{
770 "cacheName": autorest.Encode("path", cacheName),
771 "resourceGroupName": autorest.Encode("path", resourceGroupName),
772 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
773 }
774
775 const APIVersion = "2021-09-01"
776 queryParameters := map[string]interface{}{
777 "api-version": APIVersion,
778 }
779
780 preparer := autorest.CreatePreparer(
781 autorest.AsPost(),
782 autorest.WithBaseURL(client.BaseURI),
783 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start", pathParameters),
784 autorest.WithQueryParameters(queryParameters))
785 return preparer.Prepare((&http.Request{}).WithContext(ctx))
786 }
787
788
789
790 func (client CachesClient) StartSender(req *http.Request) (future CachesStartFuture, err error) {
791 var resp *http.Response
792 future.FutureAPI = &azure.Future{}
793 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
794 if err != nil {
795 return
796 }
797 var azf azure.Future
798 azf, err = azure.NewFutureFromResponse(resp)
799 future.FutureAPI = &azf
800 future.Result = future.result
801 return
802 }
803
804
805
806 func (client CachesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
807 err = autorest.Respond(
808 resp,
809 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
810 autorest.ByClosing())
811 result.Response = resp
812 return
813 }
814
815
816
817
818
819
820 func (client CachesClient) Stop(ctx context.Context, resourceGroupName string, cacheName string) (result CachesStopFuture, err error) {
821 if tracing.IsEnabled() {
822 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Stop")
823 defer func() {
824 sc := -1
825 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
826 sc = result.FutureAPI.Response().StatusCode
827 }
828 tracing.EndSpan(ctx, sc, err)
829 }()
830 }
831 if err := validation.Validate([]validation.Validation{
832 {TargetValue: cacheName,
833 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
834 return result, validation.NewError("storagecache.CachesClient", "Stop", err.Error())
835 }
836
837 req, err := client.StopPreparer(ctx, resourceGroupName, cacheName)
838 if err != nil {
839 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Stop", nil, "Failure preparing request")
840 return
841 }
842
843 result, err = client.StopSender(req)
844 if err != nil {
845 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Stop", result.Response(), "Failure sending request")
846 return
847 }
848
849 return
850 }
851
852
853 func (client CachesClient) StopPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
854 pathParameters := map[string]interface{}{
855 "cacheName": autorest.Encode("path", cacheName),
856 "resourceGroupName": autorest.Encode("path", resourceGroupName),
857 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
858 }
859
860 const APIVersion = "2021-09-01"
861 queryParameters := map[string]interface{}{
862 "api-version": APIVersion,
863 }
864
865 preparer := autorest.CreatePreparer(
866 autorest.AsPost(),
867 autorest.WithBaseURL(client.BaseURI),
868 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop", pathParameters),
869 autorest.WithQueryParameters(queryParameters))
870 return preparer.Prepare((&http.Request{}).WithContext(ctx))
871 }
872
873
874
875 func (client CachesClient) StopSender(req *http.Request) (future CachesStopFuture, err error) {
876 var resp *http.Response
877 future.FutureAPI = &azure.Future{}
878 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
879 if err != nil {
880 return
881 }
882 var azf azure.Future
883 azf, err = azure.NewFutureFromResponse(resp)
884 future.FutureAPI = &azf
885 future.Result = future.result
886 return
887 }
888
889
890
891 func (client CachesClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
892 err = autorest.Respond(
893 resp,
894 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
895 autorest.ByClosing())
896 result.Response = resp
897 return
898 }
899
900
901
902
903
904
905
906
907 func (client CachesClient) Update(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result Cache, err error) {
908 if tracing.IsEnabled() {
909 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Update")
910 defer func() {
911 sc := -1
912 if result.Response.Response != nil {
913 sc = result.Response.Response.StatusCode
914 }
915 tracing.EndSpan(ctx, sc, err)
916 }()
917 }
918 if err := validation.Validate([]validation.Validation{
919 {TargetValue: cacheName,
920 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
921 return result, validation.NewError("storagecache.CachesClient", "Update", err.Error())
922 }
923
924 req, err := client.UpdatePreparer(ctx, resourceGroupName, cacheName, cache)
925 if err != nil {
926 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", nil, "Failure preparing request")
927 return
928 }
929
930 resp, err := client.UpdateSender(req)
931 if err != nil {
932 result.Response = autorest.Response{Response: resp}
933 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", resp, "Failure sending request")
934 return
935 }
936
937 result, err = client.UpdateResponder(resp)
938 if err != nil {
939 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", resp, "Failure responding to request")
940 return
941 }
942
943 return
944 }
945
946
947 func (client CachesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (*http.Request, error) {
948 pathParameters := map[string]interface{}{
949 "cacheName": autorest.Encode("path", cacheName),
950 "resourceGroupName": autorest.Encode("path", resourceGroupName),
951 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
952 }
953
954 const APIVersion = "2021-09-01"
955 queryParameters := map[string]interface{}{
956 "api-version": APIVersion,
957 }
958
959 cache.ID = nil
960 cache.Name = nil
961 cache.Type = nil
962 cache.SystemData = nil
963 preparer := autorest.CreatePreparer(
964 autorest.AsContentType("application/json; charset=utf-8"),
965 autorest.AsPatch(),
966 autorest.WithBaseURL(client.BaseURI),
967 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters),
968 autorest.WithQueryParameters(queryParameters))
969 if cache != nil {
970 preparer = autorest.DecoratePreparer(preparer,
971 autorest.WithJSON(cache))
972 }
973 return preparer.Prepare((&http.Request{}).WithContext(ctx))
974 }
975
976
977
978 func (client CachesClient) UpdateSender(req *http.Request) (*http.Response, error) {
979 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
980 }
981
982
983
984 func (client CachesClient) UpdateResponder(resp *http.Response) (result Cache, err error) {
985 err = autorest.Respond(
986 resp,
987 azure.WithErrorUnlessStatusCode(http.StatusOK),
988 autorest.ByUnmarshallingJSON(&result),
989 autorest.ByClosing())
990 result.Response = autorest.Response{Response: resp}
991 return
992 }
993
994
995
996
997
998
999 func (client CachesClient) UpgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string) (result CachesUpgradeFirmwareFuture, err error) {
1000 if tracing.IsEnabled() {
1001 ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.UpgradeFirmware")
1002 defer func() {
1003 sc := -1
1004 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1005 sc = result.FutureAPI.Response().StatusCode
1006 }
1007 tracing.EndSpan(ctx, sc, err)
1008 }()
1009 }
1010 if err := validation.Validate([]validation.Validation{
1011 {TargetValue: cacheName,
1012 Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil {
1013 return result, validation.NewError("storagecache.CachesClient", "UpgradeFirmware", err.Error())
1014 }
1015
1016 req, err := client.UpgradeFirmwarePreparer(ctx, resourceGroupName, cacheName)
1017 if err != nil {
1018 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "UpgradeFirmware", nil, "Failure preparing request")
1019 return
1020 }
1021
1022 result, err = client.UpgradeFirmwareSender(req)
1023 if err != nil {
1024 err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "UpgradeFirmware", result.Response(), "Failure sending request")
1025 return
1026 }
1027
1028 return
1029 }
1030
1031
1032 func (client CachesClient) UpgradeFirmwarePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) {
1033 pathParameters := map[string]interface{}{
1034 "cacheName": autorest.Encode("path", cacheName),
1035 "resourceGroupName": autorest.Encode("path", resourceGroupName),
1036 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
1037 }
1038
1039 const APIVersion = "2021-09-01"
1040 queryParameters := map[string]interface{}{
1041 "api-version": APIVersion,
1042 }
1043
1044 preparer := autorest.CreatePreparer(
1045 autorest.AsPost(),
1046 autorest.WithBaseURL(client.BaseURI),
1047 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade", pathParameters),
1048 autorest.WithQueryParameters(queryParameters))
1049 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1050 }
1051
1052
1053
1054 func (client CachesClient) UpgradeFirmwareSender(req *http.Request) (future CachesUpgradeFirmwareFuture, err error) {
1055 var resp *http.Response
1056 future.FutureAPI = &azure.Future{}
1057 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1058 if err != nil {
1059 return
1060 }
1061 var azf azure.Future
1062 azf, err = azure.NewFutureFromResponse(resp)
1063 future.FutureAPI = &azf
1064 future.Result = future.result
1065 return
1066 }
1067
1068
1069
1070 func (client CachesClient) UpgradeFirmwareResponder(resp *http.Response) (result autorest.Response, err error) {
1071 err = autorest.Respond(
1072 resp,
1073 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNoContent),
1074 autorest.ByClosing())
1075 result.Response = resp
1076 return
1077 }
1078
View as plain text