1 package storsimple
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 BandwidthSettingsClient struct {
20 BaseClient
21 }
22
23
24 func NewBandwidthSettingsClient(subscriptionID string) BandwidthSettingsClient {
25 return NewBandwidthSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewBandwidthSettingsClientWithBaseURI(baseURI string, subscriptionID string) BandwidthSettingsClient {
32 return BandwidthSettingsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client BandwidthSettingsClient) CreateOrUpdate(ctx context.Context, bandwidthSettingName string, parameters BandwidthSetting, resourceGroupName string, managerName string) (result BandwidthSettingsCreateOrUpdateFuture, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/BandwidthSettingsClient.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: parameters,
54 Constraints: []validation.Constraint{{Target: "parameters.BandwidthRateSettingProperties", Name: validation.Null, Rule: true,
55 Chain: []validation.Constraint{{Target: "parameters.BandwidthRateSettingProperties.Schedules", Name: validation.Null, Rule: true, Chain: nil}}}}},
56 {TargetValue: managerName,
57 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
58 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
59 return result, validation.NewError("storsimple.BandwidthSettingsClient", "CreateOrUpdate", err.Error())
60 }
61
62 req, err := client.CreateOrUpdatePreparer(ctx, bandwidthSettingName, parameters, resourceGroupName, managerName)
63 if err != nil {
64 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "CreateOrUpdate", nil, "Failure preparing request")
65 return
66 }
67
68 result, err = client.CreateOrUpdateSender(req)
69 if err != nil {
70 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
71 return
72 }
73
74 return
75 }
76
77
78 func (client BandwidthSettingsClient) CreateOrUpdatePreparer(ctx context.Context, bandwidthSettingName string, parameters BandwidthSetting, resourceGroupName string, managerName string) (*http.Request, error) {
79 pathParameters := map[string]interface{}{
80 "bandwidthSettingName": bandwidthSettingName,
81 "managerName": managerName,
82 "resourceGroupName": resourceGroupName,
83 "subscriptionId": client.SubscriptionID,
84 }
85
86 const APIVersion = "2017-06-01"
87 queryParameters := map[string]interface{}{
88 "api-version": APIVersion,
89 }
90
91 preparer := autorest.CreatePreparer(
92 autorest.AsContentType("application/json; charset=utf-8"),
93 autorest.AsPut(),
94 autorest.WithBaseURL(client.BaseURI),
95 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings/{bandwidthSettingName}", pathParameters),
96 autorest.WithJSON(parameters),
97 autorest.WithQueryParameters(queryParameters))
98 return preparer.Prepare((&http.Request{}).WithContext(ctx))
99 }
100
101
102
103 func (client BandwidthSettingsClient) CreateOrUpdateSender(req *http.Request) (future BandwidthSettingsCreateOrUpdateFuture, err error) {
104 var resp *http.Response
105 future.FutureAPI = &azure.Future{}
106 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
107 if err != nil {
108 return
109 }
110 var azf azure.Future
111 azf, err = azure.NewFutureFromResponse(resp)
112 future.FutureAPI = &azf
113 future.Result = future.result
114 return
115 }
116
117
118
119 func (client BandwidthSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result BandwidthSetting, err error) {
120 err = autorest.Respond(
121 resp,
122 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
123 autorest.ByUnmarshallingJSON(&result),
124 autorest.ByClosing())
125 result.Response = autorest.Response{Response: resp}
126 return
127 }
128
129
130
131
132
133
134 func (client BandwidthSettingsClient) Delete(ctx context.Context, bandwidthSettingName string, resourceGroupName string, managerName string) (result BandwidthSettingsDeleteFuture, err error) {
135 if tracing.IsEnabled() {
136 ctx = tracing.StartSpan(ctx, fqdn+"/BandwidthSettingsClient.Delete")
137 defer func() {
138 sc := -1
139 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
140 sc = result.FutureAPI.Response().StatusCode
141 }
142 tracing.EndSpan(ctx, sc, err)
143 }()
144 }
145 if err := validation.Validate([]validation.Validation{
146 {TargetValue: managerName,
147 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
148 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
149 return result, validation.NewError("storsimple.BandwidthSettingsClient", "Delete", err.Error())
150 }
151
152 req, err := client.DeletePreparer(ctx, bandwidthSettingName, resourceGroupName, managerName)
153 if err != nil {
154 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "Delete", nil, "Failure preparing request")
155 return
156 }
157
158 result, err = client.DeleteSender(req)
159 if err != nil {
160 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "Delete", result.Response(), "Failure sending request")
161 return
162 }
163
164 return
165 }
166
167
168 func (client BandwidthSettingsClient) DeletePreparer(ctx context.Context, bandwidthSettingName string, resourceGroupName string, managerName string) (*http.Request, error) {
169 pathParameters := map[string]interface{}{
170 "bandwidthSettingName": bandwidthSettingName,
171 "managerName": managerName,
172 "resourceGroupName": resourceGroupName,
173 "subscriptionId": client.SubscriptionID,
174 }
175
176 const APIVersion = "2017-06-01"
177 queryParameters := map[string]interface{}{
178 "api-version": APIVersion,
179 }
180
181 preparer := autorest.CreatePreparer(
182 autorest.AsDelete(),
183 autorest.WithBaseURL(client.BaseURI),
184 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings/{bandwidthSettingName}", pathParameters),
185 autorest.WithQueryParameters(queryParameters))
186 return preparer.Prepare((&http.Request{}).WithContext(ctx))
187 }
188
189
190
191 func (client BandwidthSettingsClient) DeleteSender(req *http.Request) (future BandwidthSettingsDeleteFuture, err error) {
192 var resp *http.Response
193 future.FutureAPI = &azure.Future{}
194 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
195 if err != nil {
196 return
197 }
198 var azf azure.Future
199 azf, err = azure.NewFutureFromResponse(resp)
200 future.FutureAPI = &azf
201 future.Result = future.result
202 return
203 }
204
205
206
207 func (client BandwidthSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
208 err = autorest.Respond(
209 resp,
210 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
211 autorest.ByClosing())
212 result.Response = resp
213 return
214 }
215
216
217
218
219
220
221 func (client BandwidthSettingsClient) Get(ctx context.Context, bandwidthSettingName string, resourceGroupName string, managerName string) (result BandwidthSetting, err error) {
222 if tracing.IsEnabled() {
223 ctx = tracing.StartSpan(ctx, fqdn+"/BandwidthSettingsClient.Get")
224 defer func() {
225 sc := -1
226 if result.Response.Response != nil {
227 sc = result.Response.Response.StatusCode
228 }
229 tracing.EndSpan(ctx, sc, err)
230 }()
231 }
232 if err := validation.Validate([]validation.Validation{
233 {TargetValue: managerName,
234 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
235 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
236 return result, validation.NewError("storsimple.BandwidthSettingsClient", "Get", err.Error())
237 }
238
239 req, err := client.GetPreparer(ctx, bandwidthSettingName, resourceGroupName, managerName)
240 if err != nil {
241 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "Get", nil, "Failure preparing request")
242 return
243 }
244
245 resp, err := client.GetSender(req)
246 if err != nil {
247 result.Response = autorest.Response{Response: resp}
248 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "Get", resp, "Failure sending request")
249 return
250 }
251
252 result, err = client.GetResponder(resp)
253 if err != nil {
254 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "Get", resp, "Failure responding to request")
255 return
256 }
257
258 return
259 }
260
261
262 func (client BandwidthSettingsClient) GetPreparer(ctx context.Context, bandwidthSettingName string, resourceGroupName string, managerName string) (*http.Request, error) {
263 pathParameters := map[string]interface{}{
264 "bandwidthSettingName": bandwidthSettingName,
265 "managerName": managerName,
266 "resourceGroupName": resourceGroupName,
267 "subscriptionId": client.SubscriptionID,
268 }
269
270 const APIVersion = "2017-06-01"
271 queryParameters := map[string]interface{}{
272 "api-version": APIVersion,
273 }
274
275 preparer := autorest.CreatePreparer(
276 autorest.AsGet(),
277 autorest.WithBaseURL(client.BaseURI),
278 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings/{bandwidthSettingName}", pathParameters),
279 autorest.WithQueryParameters(queryParameters))
280 return preparer.Prepare((&http.Request{}).WithContext(ctx))
281 }
282
283
284
285 func (client BandwidthSettingsClient) GetSender(req *http.Request) (*http.Response, error) {
286 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
287 }
288
289
290
291 func (client BandwidthSettingsClient) GetResponder(resp *http.Response) (result BandwidthSetting, err error) {
292 err = autorest.Respond(
293 resp,
294 azure.WithErrorUnlessStatusCode(http.StatusOK),
295 autorest.ByUnmarshallingJSON(&result),
296 autorest.ByClosing())
297 result.Response = autorest.Response{Response: resp}
298 return
299 }
300
301
302
303
304
305 func (client BandwidthSettingsClient) ListByManager(ctx context.Context, resourceGroupName string, managerName string) (result BandwidthSettingList, err error) {
306 if tracing.IsEnabled() {
307 ctx = tracing.StartSpan(ctx, fqdn+"/BandwidthSettingsClient.ListByManager")
308 defer func() {
309 sc := -1
310 if result.Response.Response != nil {
311 sc = result.Response.Response.StatusCode
312 }
313 tracing.EndSpan(ctx, sc, err)
314 }()
315 }
316 if err := validation.Validate([]validation.Validation{
317 {TargetValue: managerName,
318 Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
319 {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
320 return result, validation.NewError("storsimple.BandwidthSettingsClient", "ListByManager", err.Error())
321 }
322
323 req, err := client.ListByManagerPreparer(ctx, resourceGroupName, managerName)
324 if err != nil {
325 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "ListByManager", nil, "Failure preparing request")
326 return
327 }
328
329 resp, err := client.ListByManagerSender(req)
330 if err != nil {
331 result.Response = autorest.Response{Response: resp}
332 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "ListByManager", resp, "Failure sending request")
333 return
334 }
335
336 result, err = client.ListByManagerResponder(resp)
337 if err != nil {
338 err = autorest.NewErrorWithError(err, "storsimple.BandwidthSettingsClient", "ListByManager", resp, "Failure responding to request")
339 return
340 }
341
342 return
343 }
344
345
346 func (client BandwidthSettingsClient) ListByManagerPreparer(ctx context.Context, resourceGroupName string, managerName string) (*http.Request, error) {
347 pathParameters := map[string]interface{}{
348 "managerName": managerName,
349 "resourceGroupName": resourceGroupName,
350 "subscriptionId": client.SubscriptionID,
351 }
352
353 const APIVersion = "2017-06-01"
354 queryParameters := map[string]interface{}{
355 "api-version": APIVersion,
356 }
357
358 preparer := autorest.CreatePreparer(
359 autorest.AsGet(),
360 autorest.WithBaseURL(client.BaseURI),
361 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings", pathParameters),
362 autorest.WithQueryParameters(queryParameters))
363 return preparer.Prepare((&http.Request{}).WithContext(ctx))
364 }
365
366
367
368 func (client BandwidthSettingsClient) ListByManagerSender(req *http.Request) (*http.Response, error) {
369 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
370 }
371
372
373
374 func (client BandwidthSettingsClient) ListByManagerResponder(resp *http.Response) (result BandwidthSettingList, err error) {
375 err = autorest.Respond(
376 resp,
377 azure.WithErrorUnlessStatusCode(http.StatusOK),
378 autorest.ByUnmarshallingJSON(&result),
379 autorest.ByClosing())
380 result.Response = autorest.Response{Response: resp}
381 return
382 }
383
View as plain text