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