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 RecoveryPointsClient struct {
19 BaseClient
20 }
21
22
23 func NewRecoveryPointsClient(subscriptionID string) RecoveryPointsClient {
24 return NewRecoveryPointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29 func NewRecoveryPointsClientWithBaseURI(baseURI string, subscriptionID string) RecoveryPointsClient {
30 return RecoveryPointsClient{NewWithBaseURI(baseURI, subscriptionID)}
31 }
32
33
34
35
36
37
38
39
40
41
42 func (client RecoveryPointsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string) (result RecoveryPointResource, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/RecoveryPointsClient.Get")
45 defer func() {
46 sc := -1
47 if result.Response.Response != nil {
48 sc = result.Response.Response.StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, recoveryPointID)
54 if err != nil {
55 err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "Get", nil, "Failure preparing request")
56 return
57 }
58
59 resp, err := client.GetSender(req)
60 if err != nil {
61 result.Response = autorest.Response{Response: resp}
62 err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "Get", resp, "Failure sending request")
63 return
64 }
65
66 result, err = client.GetResponder(resp)
67 if err != nil {
68 err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "Get", resp, "Failure responding to request")
69 return
70 }
71
72 return
73 }
74
75
76 func (client RecoveryPointsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string) (*http.Request, error) {
77 pathParameters := map[string]interface{}{
78 "containerName": autorest.Encode("path", containerName),
79 "fabricName": autorest.Encode("path", fabricName),
80 "protectedItemName": autorest.Encode("path", protectedItemName),
81 "recoveryPointId": autorest.Encode("path", recoveryPointID),
82 "resourceGroupName": autorest.Encode("path", resourceGroupName),
83 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
84 "vaultName": autorest.Encode("path", vaultName),
85 }
86
87 const APIVersion = "2016-06-01"
88 queryParameters := map[string]interface{}{
89 "api-version": APIVersion,
90 }
91
92 preparer := autorest.CreatePreparer(
93 autorest.AsGet(),
94 autorest.WithBaseURL(client.BaseURI),
95 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}", pathParameters),
96 autorest.WithQueryParameters(queryParameters))
97 return preparer.Prepare((&http.Request{}).WithContext(ctx))
98 }
99
100
101
102 func (client RecoveryPointsClient) GetSender(req *http.Request) (*http.Response, error) {
103 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
104 }
105
106
107
108 func (client RecoveryPointsClient) GetResponder(resp *http.Response) (result RecoveryPointResource, err error) {
109 err = autorest.Respond(
110 resp,
111 azure.WithErrorUnlessStatusCode(http.StatusOK),
112 autorest.ByUnmarshallingJSON(&result),
113 autorest.ByClosing())
114 result.Response = autorest.Response{Response: resp}
115 return
116 }
117
118
119
120
121
122
123
124
125
126 func (client RecoveryPointsClient) List(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, filter string) (result RecoveryPointResourceList, err error) {
127 if tracing.IsEnabled() {
128 ctx = tracing.StartSpan(ctx, fqdn+"/RecoveryPointsClient.List")
129 defer func() {
130 sc := -1
131 if result.Response.Response != nil {
132 sc = result.Response.Response.StatusCode
133 }
134 tracing.EndSpan(ctx, sc, err)
135 }()
136 }
137 req, err := client.ListPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, filter)
138 if err != nil {
139 err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "List", nil, "Failure preparing request")
140 return
141 }
142
143 resp, err := client.ListSender(req)
144 if err != nil {
145 result.Response = autorest.Response{Response: resp}
146 err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "List", resp, "Failure sending request")
147 return
148 }
149
150 result, err = client.ListResponder(resp)
151 if err != nil {
152 err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "List", resp, "Failure responding to request")
153 return
154 }
155
156 return
157 }
158
159
160 func (client RecoveryPointsClient) ListPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, filter string) (*http.Request, error) {
161 pathParameters := map[string]interface{}{
162 "containerName": autorest.Encode("path", containerName),
163 "fabricName": autorest.Encode("path", fabricName),
164 "protectedItemName": autorest.Encode("path", protectedItemName),
165 "resourceGroupName": autorest.Encode("path", resourceGroupName),
166 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
167 "vaultName": autorest.Encode("path", vaultName),
168 }
169
170 const APIVersion = "2016-06-01"
171 queryParameters := map[string]interface{}{
172 "api-version": APIVersion,
173 }
174 if len(filter) > 0 {
175 queryParameters["$filter"] = autorest.Encode("query", filter)
176 }
177
178 preparer := autorest.CreatePreparer(
179 autorest.AsGet(),
180 autorest.WithBaseURL(client.BaseURI),
181 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints", pathParameters),
182 autorest.WithQueryParameters(queryParameters))
183 return preparer.Prepare((&http.Request{}).WithContext(ctx))
184 }
185
186
187
188 func (client RecoveryPointsClient) ListSender(req *http.Request) (*http.Response, error) {
189 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
190 }
191
192
193
194 func (client RecoveryPointsClient) ListResponder(resp *http.Response) (result RecoveryPointResourceList, err error) {
195 err = autorest.Respond(
196 resp,
197 azure.WithErrorUnlessStatusCode(http.StatusOK),
198 autorest.ByUnmarshallingJSON(&result),
199 autorest.ByClosing())
200 result.Response = autorest.Response{Response: resp}
201 return
202 }
203
View as plain text