1 package compute
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 SnapshotsClient struct {
20 BaseClient
21 }
22
23
24 func NewSnapshotsClient(subscriptionID string) SnapshotsClient {
25 return NewSnapshotsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) SnapshotsClient {
31 return SnapshotsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40
41 func (client SnapshotsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (result SnapshotsCreateOrUpdateFuture, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.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: snapshot,
54 Constraints: []validation.Constraint{{Target: "snapshot.SnapshotProperties", Name: validation.Null, Rule: false,
55 Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.PurchasePlan", Name: validation.Null, Rule: false,
56 Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.PurchasePlan.Publisher", Name: validation.Null, Rule: true, Chain: nil},
57 {Target: "snapshot.SnapshotProperties.PurchasePlan.Name", Name: validation.Null, Rule: true, Chain: nil},
58 {Target: "snapshot.SnapshotProperties.PurchasePlan.Product", Name: validation.Null, Rule: true, Chain: nil},
59 }},
60 {Target: "snapshot.SnapshotProperties.CreationData", Name: validation.Null, Rule: true,
61 Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
62 Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
63 {Target: "snapshot.SnapshotProperties.CreationData.GalleryImageReference", Name: validation.Null, Rule: false,
64 Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.GalleryImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
65 }},
66 {Target: "snapshot.SnapshotProperties.EncryptionSettingsCollection", Name: validation.Null, Rule: false,
67 Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettingsCollection.Enabled", Name: validation.Null, Rule: true, Chain: nil}}},
68 }}}}}); err != nil {
69 return result, validation.NewError("compute.SnapshotsClient", "CreateOrUpdate", err.Error())
70 }
71
72 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
73 if err != nil {
74 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request")
75 return
76 }
77
78 result, err = client.CreateOrUpdateSender(req)
79 if err != nil {
80 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
81 return
82 }
83
84 return
85 }
86
87
88 func (client SnapshotsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (*http.Request, error) {
89 pathParameters := map[string]interface{}{
90 "resourceGroupName": autorest.Encode("path", resourceGroupName),
91 "snapshotName": autorest.Encode("path", snapshotName),
92 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
93 }
94
95 const APIVersion = "2021-04-01"
96 queryParameters := map[string]interface{}{
97 "api-version": APIVersion,
98 }
99
100 snapshot.ManagedBy = nil
101 preparer := autorest.CreatePreparer(
102 autorest.AsContentType("application/json; charset=utf-8"),
103 autorest.AsPut(),
104 autorest.WithBaseURL(client.BaseURI),
105 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
106 autorest.WithJSON(snapshot),
107 autorest.WithQueryParameters(queryParameters))
108 return preparer.Prepare((&http.Request{}).WithContext(ctx))
109 }
110
111
112
113 func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (future SnapshotsCreateOrUpdateFuture, err error) {
114 var resp *http.Response
115 future.FutureAPI = &azure.Future{}
116 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
117 if err != nil {
118 return
119 }
120 var azf azure.Future
121 azf, err = azure.NewFutureFromResponse(resp)
122 future.FutureAPI = &azf
123 future.Result = future.result
124 return
125 }
126
127
128
129 func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result Snapshot, err error) {
130 err = autorest.Respond(
131 resp,
132 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
133 autorest.ByUnmarshallingJSON(&result),
134 autorest.ByClosing())
135 result.Response = autorest.Response{Response: resp}
136 return
137 }
138
139
140
141
142
143
144
145 func (client SnapshotsClient) Delete(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsDeleteFuture, err error) {
146 if tracing.IsEnabled() {
147 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.Delete")
148 defer func() {
149 sc := -1
150 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
151 sc = result.FutureAPI.Response().StatusCode
152 }
153 tracing.EndSpan(ctx, sc, err)
154 }()
155 }
156 req, err := client.DeletePreparer(ctx, resourceGroupName, snapshotName)
157 if err != nil {
158 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", nil, "Failure preparing request")
159 return
160 }
161
162 result, err = client.DeleteSender(req)
163 if err != nil {
164 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", result.Response(), "Failure sending request")
165 return
166 }
167
168 return
169 }
170
171
172 func (client SnapshotsClient) DeletePreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
173 pathParameters := map[string]interface{}{
174 "resourceGroupName": autorest.Encode("path", resourceGroupName),
175 "snapshotName": autorest.Encode("path", snapshotName),
176 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
177 }
178
179 const APIVersion = "2021-04-01"
180 queryParameters := map[string]interface{}{
181 "api-version": APIVersion,
182 }
183
184 preparer := autorest.CreatePreparer(
185 autorest.AsDelete(),
186 autorest.WithBaseURL(client.BaseURI),
187 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
188 autorest.WithQueryParameters(queryParameters))
189 return preparer.Prepare((&http.Request{}).WithContext(ctx))
190 }
191
192
193
194 func (client SnapshotsClient) DeleteSender(req *http.Request) (future SnapshotsDeleteFuture, err error) {
195 var resp *http.Response
196 future.FutureAPI = &azure.Future{}
197 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
198 if err != nil {
199 return
200 }
201 var azf azure.Future
202 azf, err = azure.NewFutureFromResponse(resp)
203 future.FutureAPI = &azf
204 future.Result = future.result
205 return
206 }
207
208
209
210 func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
211 err = autorest.Respond(
212 resp,
213 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
214 autorest.ByClosing())
215 result.Response = resp
216 return
217 }
218
219
220
221
222
223
224
225 func (client SnapshotsClient) Get(ctx context.Context, resourceGroupName string, snapshotName string) (result Snapshot, err error) {
226 if tracing.IsEnabled() {
227 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.Get")
228 defer func() {
229 sc := -1
230 if result.Response.Response != nil {
231 sc = result.Response.Response.StatusCode
232 }
233 tracing.EndSpan(ctx, sc, err)
234 }()
235 }
236 req, err := client.GetPreparer(ctx, resourceGroupName, snapshotName)
237 if err != nil {
238 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", nil, "Failure preparing request")
239 return
240 }
241
242 resp, err := client.GetSender(req)
243 if err != nil {
244 result.Response = autorest.Response{Response: resp}
245 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure sending request")
246 return
247 }
248
249 result, err = client.GetResponder(resp)
250 if err != nil {
251 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure responding to request")
252 return
253 }
254
255 return
256 }
257
258
259 func (client SnapshotsClient) GetPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
260 pathParameters := map[string]interface{}{
261 "resourceGroupName": autorest.Encode("path", resourceGroupName),
262 "snapshotName": autorest.Encode("path", snapshotName),
263 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
264 }
265
266 const APIVersion = "2021-04-01"
267 queryParameters := map[string]interface{}{
268 "api-version": APIVersion,
269 }
270
271 preparer := autorest.CreatePreparer(
272 autorest.AsGet(),
273 autorest.WithBaseURL(client.BaseURI),
274 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
275 autorest.WithQueryParameters(queryParameters))
276 return preparer.Prepare((&http.Request{}).WithContext(ctx))
277 }
278
279
280
281 func (client SnapshotsClient) GetSender(req *http.Request) (*http.Response, error) {
282 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
283 }
284
285
286
287 func (client SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot, err error) {
288 err = autorest.Respond(
289 resp,
290 azure.WithErrorUnlessStatusCode(http.StatusOK),
291 autorest.ByUnmarshallingJSON(&result),
292 autorest.ByClosing())
293 result.Response = autorest.Response{Response: resp}
294 return
295 }
296
297
298
299
300
301
302
303
304 func (client SnapshotsClient) GrantAccess(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (result SnapshotsGrantAccessFuture, err error) {
305 if tracing.IsEnabled() {
306 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.GrantAccess")
307 defer func() {
308 sc := -1
309 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
310 sc = result.FutureAPI.Response().StatusCode
311 }
312 tracing.EndSpan(ctx, sc, err)
313 }()
314 }
315 if err := validation.Validate([]validation.Validation{
316 {TargetValue: grantAccessData,
317 Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
318 return result, validation.NewError("compute.SnapshotsClient", "GrantAccess", err.Error())
319 }
320
321 req, err := client.GrantAccessPreparer(ctx, resourceGroupName, snapshotName, grantAccessData)
322 if err != nil {
323 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", nil, "Failure preparing request")
324 return
325 }
326
327 result, err = client.GrantAccessSender(req)
328 if err != nil {
329 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", result.Response(), "Failure sending request")
330 return
331 }
332
333 return
334 }
335
336
337 func (client SnapshotsClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (*http.Request, error) {
338 pathParameters := map[string]interface{}{
339 "resourceGroupName": autorest.Encode("path", resourceGroupName),
340 "snapshotName": autorest.Encode("path", snapshotName),
341 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
342 }
343
344 const APIVersion = "2021-04-01"
345 queryParameters := map[string]interface{}{
346 "api-version": APIVersion,
347 }
348
349 preparer := autorest.CreatePreparer(
350 autorest.AsContentType("application/json; charset=utf-8"),
351 autorest.AsPost(),
352 autorest.WithBaseURL(client.BaseURI),
353 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", pathParameters),
354 autorest.WithJSON(grantAccessData),
355 autorest.WithQueryParameters(queryParameters))
356 return preparer.Prepare((&http.Request{}).WithContext(ctx))
357 }
358
359
360
361 func (client SnapshotsClient) GrantAccessSender(req *http.Request) (future SnapshotsGrantAccessFuture, err error) {
362 var resp *http.Response
363 future.FutureAPI = &azure.Future{}
364 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
365 if err != nil {
366 return
367 }
368 var azf azure.Future
369 azf, err = azure.NewFutureFromResponse(resp)
370 future.FutureAPI = &azf
371 future.Result = future.result
372 return
373 }
374
375
376
377 func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
378 err = autorest.Respond(
379 resp,
380 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
381 autorest.ByUnmarshallingJSON(&result),
382 autorest.ByClosing())
383 result.Response = autorest.Response{Response: resp}
384 return
385 }
386
387
388 func (client SnapshotsClient) List(ctx context.Context) (result SnapshotListPage, err error) {
389 if tracing.IsEnabled() {
390 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.List")
391 defer func() {
392 sc := -1
393 if result.sl.Response.Response != nil {
394 sc = result.sl.Response.Response.StatusCode
395 }
396 tracing.EndSpan(ctx, sc, err)
397 }()
398 }
399 result.fn = client.listNextResults
400 req, err := client.ListPreparer(ctx)
401 if err != nil {
402 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", nil, "Failure preparing request")
403 return
404 }
405
406 resp, err := client.ListSender(req)
407 if err != nil {
408 result.sl.Response = autorest.Response{Response: resp}
409 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure sending request")
410 return
411 }
412
413 result.sl, err = client.ListResponder(resp)
414 if err != nil {
415 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure responding to request")
416 return
417 }
418 if result.sl.hasNextLink() && result.sl.IsEmpty() {
419 err = result.NextWithContext(ctx)
420 return
421 }
422
423 return
424 }
425
426
427 func (client SnapshotsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
428 pathParameters := map[string]interface{}{
429 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
430 }
431
432 const APIVersion = "2021-04-01"
433 queryParameters := map[string]interface{}{
434 "api-version": APIVersion,
435 }
436
437 preparer := autorest.CreatePreparer(
438 autorest.AsGet(),
439 autorest.WithBaseURL(client.BaseURI),
440 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", pathParameters),
441 autorest.WithQueryParameters(queryParameters))
442 return preparer.Prepare((&http.Request{}).WithContext(ctx))
443 }
444
445
446
447 func (client SnapshotsClient) ListSender(req *http.Request) (*http.Response, error) {
448 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
449 }
450
451
452
453 func (client SnapshotsClient) ListResponder(resp *http.Response) (result SnapshotList, err error) {
454 err = autorest.Respond(
455 resp,
456 azure.WithErrorUnlessStatusCode(http.StatusOK),
457 autorest.ByUnmarshallingJSON(&result),
458 autorest.ByClosing())
459 result.Response = autorest.Response{Response: resp}
460 return
461 }
462
463
464 func (client SnapshotsClient) listNextResults(ctx context.Context, lastResults SnapshotList) (result SnapshotList, err error) {
465 req, err := lastResults.snapshotListPreparer(ctx)
466 if err != nil {
467 return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", nil, "Failure preparing next results request")
468 }
469 if req == nil {
470 return
471 }
472 resp, err := client.ListSender(req)
473 if err != nil {
474 result.Response = autorest.Response{Response: resp}
475 return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure sending next results request")
476 }
477 result, err = client.ListResponder(resp)
478 if err != nil {
479 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure responding to next results request")
480 }
481 return
482 }
483
484
485 func (client SnapshotsClient) ListComplete(ctx context.Context) (result SnapshotListIterator, err error) {
486 if tracing.IsEnabled() {
487 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.List")
488 defer func() {
489 sc := -1
490 if result.Response().Response.Response != nil {
491 sc = result.page.Response().Response.Response.StatusCode
492 }
493 tracing.EndSpan(ctx, sc, err)
494 }()
495 }
496 result.page, err = client.List(ctx)
497 return
498 }
499
500
501
502
503 func (client SnapshotsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result SnapshotListPage, err error) {
504 if tracing.IsEnabled() {
505 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.ListByResourceGroup")
506 defer func() {
507 sc := -1
508 if result.sl.Response.Response != nil {
509 sc = result.sl.Response.Response.StatusCode
510 }
511 tracing.EndSpan(ctx, sc, err)
512 }()
513 }
514 result.fn = client.listByResourceGroupNextResults
515 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
516 if err != nil {
517 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request")
518 return
519 }
520
521 resp, err := client.ListByResourceGroupSender(req)
522 if err != nil {
523 result.sl.Response = autorest.Response{Response: resp}
524 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request")
525 return
526 }
527
528 result.sl, err = client.ListByResourceGroupResponder(resp)
529 if err != nil {
530 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to request")
531 return
532 }
533 if result.sl.hasNextLink() && result.sl.IsEmpty() {
534 err = result.NextWithContext(ctx)
535 return
536 }
537
538 return
539 }
540
541
542 func (client SnapshotsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
543 pathParameters := map[string]interface{}{
544 "resourceGroupName": autorest.Encode("path", resourceGroupName),
545 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
546 }
547
548 const APIVersion = "2021-04-01"
549 queryParameters := map[string]interface{}{
550 "api-version": APIVersion,
551 }
552
553 preparer := autorest.CreatePreparer(
554 autorest.AsGet(),
555 autorest.WithBaseURL(client.BaseURI),
556 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", pathParameters),
557 autorest.WithQueryParameters(queryParameters))
558 return preparer.Prepare((&http.Request{}).WithContext(ctx))
559 }
560
561
562
563 func (client SnapshotsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
564 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
565 }
566
567
568
569 func (client SnapshotsClient) ListByResourceGroupResponder(resp *http.Response) (result SnapshotList, err error) {
570 err = autorest.Respond(
571 resp,
572 azure.WithErrorUnlessStatusCode(http.StatusOK),
573 autorest.ByUnmarshallingJSON(&result),
574 autorest.ByClosing())
575 result.Response = autorest.Response{Response: resp}
576 return
577 }
578
579
580 func (client SnapshotsClient) listByResourceGroupNextResults(ctx context.Context, lastResults SnapshotList) (result SnapshotList, err error) {
581 req, err := lastResults.snapshotListPreparer(ctx)
582 if err != nil {
583 return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
584 }
585 if req == nil {
586 return
587 }
588 resp, err := client.ListByResourceGroupSender(req)
589 if err != nil {
590 result.Response = autorest.Response{Response: resp}
591 return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
592 }
593 result, err = client.ListByResourceGroupResponder(resp)
594 if err != nil {
595 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
596 }
597 return
598 }
599
600
601 func (client SnapshotsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result SnapshotListIterator, err error) {
602 if tracing.IsEnabled() {
603 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.ListByResourceGroup")
604 defer func() {
605 sc := -1
606 if result.Response().Response.Response != nil {
607 sc = result.page.Response().Response.Response.StatusCode
608 }
609 tracing.EndSpan(ctx, sc, err)
610 }()
611 }
612 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
613 return
614 }
615
616
617
618
619
620
621
622 func (client SnapshotsClient) RevokeAccess(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsRevokeAccessFuture, err error) {
623 if tracing.IsEnabled() {
624 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.RevokeAccess")
625 defer func() {
626 sc := -1
627 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
628 sc = result.FutureAPI.Response().StatusCode
629 }
630 tracing.EndSpan(ctx, sc, err)
631 }()
632 }
633 req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, snapshotName)
634 if err != nil {
635 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request")
636 return
637 }
638
639 result, err = client.RevokeAccessSender(req)
640 if err != nil {
641 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", result.Response(), "Failure sending request")
642 return
643 }
644
645 return
646 }
647
648
649 func (client SnapshotsClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
650 pathParameters := map[string]interface{}{
651 "resourceGroupName": autorest.Encode("path", resourceGroupName),
652 "snapshotName": autorest.Encode("path", snapshotName),
653 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
654 }
655
656 const APIVersion = "2021-04-01"
657 queryParameters := map[string]interface{}{
658 "api-version": APIVersion,
659 }
660
661 preparer := autorest.CreatePreparer(
662 autorest.AsPost(),
663 autorest.WithBaseURL(client.BaseURI),
664 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", pathParameters),
665 autorest.WithQueryParameters(queryParameters))
666 return preparer.Prepare((&http.Request{}).WithContext(ctx))
667 }
668
669
670
671 func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (future SnapshotsRevokeAccessFuture, err error) {
672 var resp *http.Response
673 future.FutureAPI = &azure.Future{}
674 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
675 if err != nil {
676 return
677 }
678 var azf azure.Future
679 azf, err = azure.NewFutureFromResponse(resp)
680 future.FutureAPI = &azf
681 future.Result = future.result
682 return
683 }
684
685
686
687 func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
688 err = autorest.Respond(
689 resp,
690 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
691 autorest.ByClosing())
692 result.Response = resp
693 return
694 }
695
696
697
698
699
700
701
702
703 func (client SnapshotsClient) Update(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (result SnapshotsUpdateFuture, err error) {
704 if tracing.IsEnabled() {
705 ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.Update")
706 defer func() {
707 sc := -1
708 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
709 sc = result.FutureAPI.Response().StatusCode
710 }
711 tracing.EndSpan(ctx, sc, err)
712 }()
713 }
714 req, err := client.UpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
715 if err != nil {
716 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", nil, "Failure preparing request")
717 return
718 }
719
720 result, err = client.UpdateSender(req)
721 if err != nil {
722 err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", result.Response(), "Failure sending request")
723 return
724 }
725
726 return
727 }
728
729
730 func (client SnapshotsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (*http.Request, error) {
731 pathParameters := map[string]interface{}{
732 "resourceGroupName": autorest.Encode("path", resourceGroupName),
733 "snapshotName": autorest.Encode("path", snapshotName),
734 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
735 }
736
737 const APIVersion = "2021-04-01"
738 queryParameters := map[string]interface{}{
739 "api-version": APIVersion,
740 }
741
742 preparer := autorest.CreatePreparer(
743 autorest.AsContentType("application/json; charset=utf-8"),
744 autorest.AsPatch(),
745 autorest.WithBaseURL(client.BaseURI),
746 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
747 autorest.WithJSON(snapshot),
748 autorest.WithQueryParameters(queryParameters))
749 return preparer.Prepare((&http.Request{}).WithContext(ctx))
750 }
751
752
753
754 func (client SnapshotsClient) UpdateSender(req *http.Request) (future SnapshotsUpdateFuture, err error) {
755 var resp *http.Response
756 future.FutureAPI = &azure.Future{}
757 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
758 if err != nil {
759 return
760 }
761 var azf azure.Future
762 azf, err = azure.NewFutureFromResponse(resp)
763 future.FutureAPI = &azf
764 future.Result = future.result
765 return
766 }
767
768
769
770 func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result Snapshot, err error) {
771 err = autorest.Respond(
772 resp,
773 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
774 autorest.ByUnmarshallingJSON(&result),
775 autorest.ByClosing())
776 result.Response = autorest.Response{Response: resp}
777 return
778 }
779
View as plain text