1 package backup
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/tracing"
14 "net/http"
15 )
16
17
18 type CrrOperationResultsClient struct {
19 BaseClient
20 }
21
22
23 func NewCrrOperationResultsClient(subscriptionID string) CrrOperationResultsClient {
24 return NewCrrOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29
30 func NewCrrOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) CrrOperationResultsClient {
31 return CrrOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37 func (client CrrOperationResultsClient) Get(ctx context.Context, azureRegion string, operationID string) (result autorest.Response, err error) {
38 if tracing.IsEnabled() {
39 ctx = tracing.StartSpan(ctx, fqdn+"/CrrOperationResultsClient.Get")
40 defer func() {
41 sc := -1
42 if result.Response != nil {
43 sc = result.Response.StatusCode
44 }
45 tracing.EndSpan(ctx, sc, err)
46 }()
47 }
48 req, err := client.GetPreparer(ctx, azureRegion, operationID)
49 if err != nil {
50 err = autorest.NewErrorWithError(err, "backup.CrrOperationResultsClient", "Get", nil, "Failure preparing request")
51 return
52 }
53
54 resp, err := client.GetSender(req)
55 if err != nil {
56 result.Response = resp
57 err = autorest.NewErrorWithError(err, "backup.CrrOperationResultsClient", "Get", resp, "Failure sending request")
58 return
59 }
60
61 result, err = client.GetResponder(resp)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "backup.CrrOperationResultsClient", "Get", resp, "Failure responding to request")
64 return
65 }
66
67 return
68 }
69
70
71 func (client CrrOperationResultsClient) GetPreparer(ctx context.Context, azureRegion string, operationID string) (*http.Request, error) {
72 pathParameters := map[string]interface{}{
73 "azureRegion": autorest.Encode("path", azureRegion),
74 "operationId": autorest.Encode("path", operationID),
75 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
76 }
77
78 const APIVersion = "2018-12-20"
79 queryParameters := map[string]interface{}{
80 "api-version": APIVersion,
81 }
82
83 preparer := autorest.CreatePreparer(
84 autorest.AsGet(),
85 autorest.WithBaseURL(client.BaseURI),
86 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RecoveryServices/locations/{azureRegion}/backupCrrOperationResults/{operationId}", pathParameters),
87 autorest.WithQueryParameters(queryParameters))
88 return preparer.Prepare((&http.Request{}).WithContext(ctx))
89 }
90
91
92
93 func (client CrrOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) {
94 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
95 }
96
97
98
99 func (client CrrOperationResultsClient) GetResponder(resp *http.Response) (result autorest.Response, err error) {
100 err = autorest.Respond(
101 resp,
102 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
103 autorest.ByClosing())
104 result.Response = resp
105 return
106 }
107
View as plain text