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