1 package apimanagement
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 APIIssueAttachmentClient struct {
20 BaseClient
21 }
22
23
24 func NewAPIIssueAttachmentClient(subscriptionID string) APIIssueAttachmentClient {
25 return NewAPIIssueAttachmentClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewAPIIssueAttachmentClientWithBaseURI(baseURI string, subscriptionID string) APIIssueAttachmentClient {
32 return APIIssueAttachmentClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42
43
44
45 func (client APIIssueAttachmentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, parameters IssueAttachmentContract, ifMatch string) (result IssueAttachmentContract, err error) {
46 if tracing.IsEnabled() {
47 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.CreateOrUpdate")
48 defer func() {
49 sc := -1
50 if result.Response.Response != nil {
51 sc = result.Response.Response.StatusCode
52 }
53 tracing.EndSpan(ctx, sc, err)
54 }()
55 }
56 if err := validation.Validate([]validation.Validation{
57 {TargetValue: serviceName,
58 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
59 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
60 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
61 {TargetValue: apiid,
62 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
63 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
64 {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}},
65 {TargetValue: issueID,
66 Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
67 {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
68 {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
69 {TargetValue: attachmentID,
70 Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
71 {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil},
72 {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
73 {TargetValue: parameters,
74 Constraints: []validation.Constraint{{Target: "parameters.IssueAttachmentContractProperties", Name: validation.Null, Rule: false,
75 Chain: []validation.Constraint{{Target: "parameters.IssueAttachmentContractProperties.Title", Name: validation.Null, Rule: true, Chain: nil},
76 {Target: "parameters.IssueAttachmentContractProperties.ContentFormat", Name: validation.Null, Rule: true, Chain: nil},
77 {Target: "parameters.IssueAttachmentContractProperties.Content", Name: validation.Null, Rule: true, Chain: nil},
78 }}}}}); err != nil {
79 return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", err.Error())
80 }
81
82 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID, parameters, ifMatch)
83 if err != nil {
84 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", nil, "Failure preparing request")
85 return
86 }
87
88 resp, err := client.CreateOrUpdateSender(req)
89 if err != nil {
90 result.Response = autorest.Response{Response: resp}
91 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", resp, "Failure sending request")
92 return
93 }
94
95 result, err = client.CreateOrUpdateResponder(resp)
96 if err != nil {
97 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", resp, "Failure responding to request")
98 return
99 }
100
101 return
102 }
103
104
105 func (client APIIssueAttachmentClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, parameters IssueAttachmentContract, ifMatch string) (*http.Request, error) {
106 pathParameters := map[string]interface{}{
107 "apiId": autorest.Encode("path", apiid),
108 "attachmentId": autorest.Encode("path", attachmentID),
109 "issueId": autorest.Encode("path", issueID),
110 "resourceGroupName": autorest.Encode("path", resourceGroupName),
111 "serviceName": autorest.Encode("path", serviceName),
112 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
113 }
114
115 const APIVersion = "2018-01-01"
116 queryParameters := map[string]interface{}{
117 "api-version": APIVersion,
118 }
119
120 preparer := autorest.CreatePreparer(
121 autorest.AsContentType("application/json; charset=utf-8"),
122 autorest.AsPut(),
123 autorest.WithBaseURL(client.BaseURI),
124 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters),
125 autorest.WithJSON(parameters),
126 autorest.WithQueryParameters(queryParameters))
127 if len(ifMatch) > 0 {
128 preparer = autorest.DecoratePreparer(preparer,
129 autorest.WithHeader("If-Match", autorest.String(ifMatch)))
130 }
131 return preparer.Prepare((&http.Request{}).WithContext(ctx))
132 }
133
134
135
136 func (client APIIssueAttachmentClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
137 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
138 }
139
140
141
142 func (client APIIssueAttachmentClient) CreateOrUpdateResponder(resp *http.Response) (result IssueAttachmentContract, err error) {
143 err = autorest.Respond(
144 resp,
145 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
146 autorest.ByUnmarshallingJSON(&result),
147 autorest.ByClosing())
148 result.Response = autorest.Response{Response: resp}
149 return
150 }
151
152
153
154
155
156
157
158
159
160
161 func (client APIIssueAttachmentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, ifMatch string) (result autorest.Response, err error) {
162 if tracing.IsEnabled() {
163 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.Delete")
164 defer func() {
165 sc := -1
166 if result.Response != nil {
167 sc = result.Response.StatusCode
168 }
169 tracing.EndSpan(ctx, sc, err)
170 }()
171 }
172 if err := validation.Validate([]validation.Validation{
173 {TargetValue: serviceName,
174 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
175 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
176 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
177 {TargetValue: apiid,
178 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
179 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
180 {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}},
181 {TargetValue: issueID,
182 Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
183 {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
184 {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
185 {TargetValue: attachmentID,
186 Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
187 {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil},
188 {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
189 return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "Delete", err.Error())
190 }
191
192 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID, ifMatch)
193 if err != nil {
194 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Delete", nil, "Failure preparing request")
195 return
196 }
197
198 resp, err := client.DeleteSender(req)
199 if err != nil {
200 result.Response = resp
201 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Delete", resp, "Failure sending request")
202 return
203 }
204
205 result, err = client.DeleteResponder(resp)
206 if err != nil {
207 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Delete", resp, "Failure responding to request")
208 return
209 }
210
211 return
212 }
213
214
215 func (client APIIssueAttachmentClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, ifMatch string) (*http.Request, error) {
216 pathParameters := map[string]interface{}{
217 "apiId": autorest.Encode("path", apiid),
218 "attachmentId": autorest.Encode("path", attachmentID),
219 "issueId": autorest.Encode("path", issueID),
220 "resourceGroupName": autorest.Encode("path", resourceGroupName),
221 "serviceName": autorest.Encode("path", serviceName),
222 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
223 }
224
225 const APIVersion = "2018-01-01"
226 queryParameters := map[string]interface{}{
227 "api-version": APIVersion,
228 }
229
230 preparer := autorest.CreatePreparer(
231 autorest.AsDelete(),
232 autorest.WithBaseURL(client.BaseURI),
233 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters),
234 autorest.WithQueryParameters(queryParameters),
235 autorest.WithHeader("If-Match", autorest.String(ifMatch)))
236 return preparer.Prepare((&http.Request{}).WithContext(ctx))
237 }
238
239
240
241 func (client APIIssueAttachmentClient) DeleteSender(req *http.Request) (*http.Response, error) {
242 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
243 }
244
245
246
247 func (client APIIssueAttachmentClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
248 err = autorest.Respond(
249 resp,
250 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
251 autorest.ByClosing())
252 result.Response = resp
253 return
254 }
255
256
257
258
259
260
261
262
263 func (client APIIssueAttachmentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (result IssueAttachmentContract, err error) {
264 if tracing.IsEnabled() {
265 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.Get")
266 defer func() {
267 sc := -1
268 if result.Response.Response != nil {
269 sc = result.Response.Response.StatusCode
270 }
271 tracing.EndSpan(ctx, sc, err)
272 }()
273 }
274 if err := validation.Validate([]validation.Validation{
275 {TargetValue: serviceName,
276 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
277 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
278 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
279 {TargetValue: apiid,
280 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
281 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
282 {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}},
283 {TargetValue: issueID,
284 Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
285 {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
286 {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
287 {TargetValue: attachmentID,
288 Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
289 {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil},
290 {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
291 return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "Get", err.Error())
292 }
293
294 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID)
295 if err != nil {
296 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Get", nil, "Failure preparing request")
297 return
298 }
299
300 resp, err := client.GetSender(req)
301 if err != nil {
302 result.Response = autorest.Response{Response: resp}
303 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Get", resp, "Failure sending request")
304 return
305 }
306
307 result, err = client.GetResponder(resp)
308 if err != nil {
309 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Get", resp, "Failure responding to request")
310 return
311 }
312
313 return
314 }
315
316
317 func (client APIIssueAttachmentClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (*http.Request, error) {
318 pathParameters := map[string]interface{}{
319 "apiId": autorest.Encode("path", apiid),
320 "attachmentId": autorest.Encode("path", attachmentID),
321 "issueId": autorest.Encode("path", issueID),
322 "resourceGroupName": autorest.Encode("path", resourceGroupName),
323 "serviceName": autorest.Encode("path", serviceName),
324 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
325 }
326
327 const APIVersion = "2018-01-01"
328 queryParameters := map[string]interface{}{
329 "api-version": APIVersion,
330 }
331
332 preparer := autorest.CreatePreparer(
333 autorest.AsGet(),
334 autorest.WithBaseURL(client.BaseURI),
335 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters),
336 autorest.WithQueryParameters(queryParameters))
337 return preparer.Prepare((&http.Request{}).WithContext(ctx))
338 }
339
340
341
342 func (client APIIssueAttachmentClient) GetSender(req *http.Request) (*http.Response, error) {
343 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
344 }
345
346
347
348 func (client APIIssueAttachmentClient) GetResponder(resp *http.Response) (result IssueAttachmentContract, err error) {
349 err = autorest.Respond(
350 resp,
351 azure.WithErrorUnlessStatusCode(http.StatusOK),
352 autorest.ByUnmarshallingJSON(&result),
353 autorest.ByClosing())
354 result.Response = autorest.Response{Response: resp}
355 return
356 }
357
358
359
360
361
362
363
364
365 func (client APIIssueAttachmentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (result autorest.Response, err error) {
366 if tracing.IsEnabled() {
367 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.GetEntityTag")
368 defer func() {
369 sc := -1
370 if result.Response != nil {
371 sc = result.Response.StatusCode
372 }
373 tracing.EndSpan(ctx, sc, err)
374 }()
375 }
376 if err := validation.Validate([]validation.Validation{
377 {TargetValue: serviceName,
378 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
379 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
380 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
381 {TargetValue: apiid,
382 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
383 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
384 {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}},
385 {TargetValue: issueID,
386 Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
387 {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
388 {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
389 {TargetValue: attachmentID,
390 Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
391 {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil},
392 {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
393 return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "GetEntityTag", err.Error())
394 }
395
396 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID)
397 if err != nil {
398 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "GetEntityTag", nil, "Failure preparing request")
399 return
400 }
401
402 resp, err := client.GetEntityTagSender(req)
403 if err != nil {
404 result.Response = resp
405 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "GetEntityTag", resp, "Failure sending request")
406 return
407 }
408
409 result, err = client.GetEntityTagResponder(resp)
410 if err != nil {
411 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "GetEntityTag", resp, "Failure responding to request")
412 return
413 }
414
415 return
416 }
417
418
419 func (client APIIssueAttachmentClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (*http.Request, error) {
420 pathParameters := map[string]interface{}{
421 "apiId": autorest.Encode("path", apiid),
422 "attachmentId": autorest.Encode("path", attachmentID),
423 "issueId": autorest.Encode("path", issueID),
424 "resourceGroupName": autorest.Encode("path", resourceGroupName),
425 "serviceName": autorest.Encode("path", serviceName),
426 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
427 }
428
429 const APIVersion = "2018-01-01"
430 queryParameters := map[string]interface{}{
431 "api-version": APIVersion,
432 }
433
434 preparer := autorest.CreatePreparer(
435 autorest.AsHead(),
436 autorest.WithBaseURL(client.BaseURI),
437 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters),
438 autorest.WithQueryParameters(queryParameters))
439 return preparer.Prepare((&http.Request{}).WithContext(ctx))
440 }
441
442
443
444 func (client APIIssueAttachmentClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
445 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
446 }
447
448
449
450 func (client APIIssueAttachmentClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
451 err = autorest.Respond(
452 resp,
453 azure.WithErrorUnlessStatusCode(http.StatusOK),
454 autorest.ByClosing())
455 result.Response = resp
456 return
457 }
458
459
460
461
462
463
464
465
466
467
468
469
470
471 func (client APIIssueAttachmentClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueAttachmentCollectionPage, err error) {
472 if tracing.IsEnabled() {
473 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.ListByService")
474 defer func() {
475 sc := -1
476 if result.iac.Response.Response != nil {
477 sc = result.iac.Response.Response.StatusCode
478 }
479 tracing.EndSpan(ctx, sc, err)
480 }()
481 }
482 if err := validation.Validate([]validation.Validation{
483 {TargetValue: serviceName,
484 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
485 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
486 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
487 {TargetValue: apiid,
488 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
489 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
490 {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}},
491 {TargetValue: issueID,
492 Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
493 {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
494 {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
495 {TargetValue: top,
496 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
497 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
498 {TargetValue: skip,
499 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
500 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
501 return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "ListByService", err.Error())
502 }
503
504 result.fn = client.listByServiceNextResults
505 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip)
506 if err != nil {
507 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "ListByService", nil, "Failure preparing request")
508 return
509 }
510
511 resp, err := client.ListByServiceSender(req)
512 if err != nil {
513 result.iac.Response = autorest.Response{Response: resp}
514 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "ListByService", resp, "Failure sending request")
515 return
516 }
517
518 result.iac, err = client.ListByServiceResponder(resp)
519 if err != nil {
520 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "ListByService", resp, "Failure responding to request")
521 return
522 }
523 if result.iac.hasNextLink() && result.iac.IsEmpty() {
524 err = result.NextWithContext(ctx)
525 return
526 }
527
528 return
529 }
530
531
532 func (client APIIssueAttachmentClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (*http.Request, error) {
533 pathParameters := map[string]interface{}{
534 "apiId": autorest.Encode("path", apiid),
535 "issueId": autorest.Encode("path", issueID),
536 "resourceGroupName": autorest.Encode("path", resourceGroupName),
537 "serviceName": autorest.Encode("path", serviceName),
538 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
539 }
540
541 const APIVersion = "2018-01-01"
542 queryParameters := map[string]interface{}{
543 "api-version": APIVersion,
544 }
545 if len(filter) > 0 {
546 queryParameters["$filter"] = autorest.Encode("query", filter)
547 }
548 if top != nil {
549 queryParameters["$top"] = autorest.Encode("query", *top)
550 }
551 if skip != nil {
552 queryParameters["$skip"] = autorest.Encode("query", *skip)
553 }
554
555 preparer := autorest.CreatePreparer(
556 autorest.AsGet(),
557 autorest.WithBaseURL(client.BaseURI),
558 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments", pathParameters),
559 autorest.WithQueryParameters(queryParameters))
560 return preparer.Prepare((&http.Request{}).WithContext(ctx))
561 }
562
563
564
565 func (client APIIssueAttachmentClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
566 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
567 }
568
569
570
571 func (client APIIssueAttachmentClient) ListByServiceResponder(resp *http.Response) (result IssueAttachmentCollection, err error) {
572 err = autorest.Respond(
573 resp,
574 azure.WithErrorUnlessStatusCode(http.StatusOK),
575 autorest.ByUnmarshallingJSON(&result),
576 autorest.ByClosing())
577 result.Response = autorest.Response{Response: resp}
578 return
579 }
580
581
582 func (client APIIssueAttachmentClient) listByServiceNextResults(ctx context.Context, lastResults IssueAttachmentCollection) (result IssueAttachmentCollection, err error) {
583 req, err := lastResults.issueAttachmentCollectionPreparer(ctx)
584 if err != nil {
585 return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "listByServiceNextResults", nil, "Failure preparing next results request")
586 }
587 if req == nil {
588 return
589 }
590 resp, err := client.ListByServiceSender(req)
591 if err != nil {
592 result.Response = autorest.Response{Response: resp}
593 return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "listByServiceNextResults", resp, "Failure sending next results request")
594 }
595 result, err = client.ListByServiceResponder(resp)
596 if err != nil {
597 err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "listByServiceNextResults", resp, "Failure responding to next results request")
598 }
599 return
600 }
601
602
603 func (client APIIssueAttachmentClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueAttachmentCollectionIterator, err error) {
604 if tracing.IsEnabled() {
605 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.ListByService")
606 defer func() {
607 sc := -1
608 if result.Response().Response.Response != nil {
609 sc = result.page.Response().Response.Response.StatusCode
610 }
611 tracing.EndSpan(ctx, sc, err)
612 }()
613 }
614 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip)
615 return
616 }
617
View as plain text