1package apimanagement
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
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// APIIssueClient is the apiManagement Client
19type APIIssueClient struct {
20	BaseClient
21}
22
23// NewAPIIssueClient creates an instance of the APIIssueClient client.
24func NewAPIIssueClient(subscriptionID string) APIIssueClient {
25	return NewAPIIssueClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewAPIIssueClientWithBaseURI creates an instance of the APIIssueClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewAPIIssueClientWithBaseURI(baseURI string, subscriptionID string) APIIssueClient {
31	return APIIssueClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate creates a new Issue for an API or updates an existing one.
35// Parameters:
36// resourceGroupName - the name of the resource group.
37// serviceName - the name of the API Management service.
38// apiid - API identifier. Must be unique in the current API Management service instance.
39// issueID - issue identifier. Must be unique in the current API Management service instance.
40// parameters - create parameters.
41// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity.
42func (client APIIssueClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueContract, ifMatch string) (result IssueContract, err error) {
43	if tracing.IsEnabled() {
44		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.CreateOrUpdate")
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	if err := validation.Validate([]validation.Validation{
54		{TargetValue: serviceName,
55			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
56				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
57				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
58		{TargetValue: apiid,
59			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
60				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}},
61		{TargetValue: issueID,
62			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
63				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
64				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
65		{TargetValue: parameters,
66			Constraints: []validation.Constraint{{Target: "parameters.IssueContractProperties", Name: validation.Null, Rule: false,
67				Chain: []validation.Constraint{{Target: "parameters.IssueContractProperties.Title", Name: validation.Null, Rule: true, Chain: nil},
68					{Target: "parameters.IssueContractProperties.Description", Name: validation.Null, Rule: true, Chain: nil},
69					{Target: "parameters.IssueContractProperties.UserID", Name: validation.Null, Rule: true, Chain: nil},
70				}}}}}); err != nil {
71		return result, validation.NewError("apimanagement.APIIssueClient", "CreateOrUpdate", err.Error())
72	}
73
74	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, parameters, ifMatch)
75	if err != nil {
76		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "CreateOrUpdate", nil, "Failure preparing request")
77		return
78	}
79
80	resp, err := client.CreateOrUpdateSender(req)
81	if err != nil {
82		result.Response = autorest.Response{Response: resp}
83		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "CreateOrUpdate", resp, "Failure sending request")
84		return
85	}
86
87	result, err = client.CreateOrUpdateResponder(resp)
88	if err != nil {
89		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "CreateOrUpdate", resp, "Failure responding to request")
90		return
91	}
92
93	return
94}
95
96// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
97func (client APIIssueClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueContract, ifMatch string) (*http.Request, error) {
98	pathParameters := map[string]interface{}{
99		"apiId":             autorest.Encode("path", apiid),
100		"issueId":           autorest.Encode("path", issueID),
101		"resourceGroupName": autorest.Encode("path", resourceGroupName),
102		"serviceName":       autorest.Encode("path", serviceName),
103		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
104	}
105
106	const APIVersion = "2021-01-01-preview"
107	queryParameters := map[string]interface{}{
108		"api-version": APIVersion,
109	}
110
111	preparer := autorest.CreatePreparer(
112		autorest.AsContentType("application/json; charset=utf-8"),
113		autorest.AsPut(),
114		autorest.WithBaseURL(client.BaseURI),
115		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters),
116		autorest.WithJSON(parameters),
117		autorest.WithQueryParameters(queryParameters))
118	if len(ifMatch) > 0 {
119		preparer = autorest.DecoratePreparer(preparer,
120			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
121	}
122	return preparer.Prepare((&http.Request{}).WithContext(ctx))
123}
124
125// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
126// http.Response Body if it receives an error.
127func (client APIIssueClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
128	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
129}
130
131// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
132// closes the http.Response Body.
133func (client APIIssueClient) CreateOrUpdateResponder(resp *http.Response) (result IssueContract, err error) {
134	err = autorest.Respond(
135		resp,
136		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
137		autorest.ByUnmarshallingJSON(&result),
138		autorest.ByClosing())
139	result.Response = autorest.Response{Response: resp}
140	return
141}
142
143// Delete deletes the specified Issue from an API.
144// Parameters:
145// resourceGroupName - the name of the resource group.
146// serviceName - the name of the API Management service.
147// apiid - API identifier. Must be unique in the current API Management service instance.
148// issueID - issue identifier. Must be unique in the current API Management service instance.
149// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
150// request or it should be * for unconditional update.
151func (client APIIssueClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, ifMatch string) (result autorest.Response, err error) {
152	if tracing.IsEnabled() {
153		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Delete")
154		defer func() {
155			sc := -1
156			if result.Response != nil {
157				sc = result.Response.StatusCode
158			}
159			tracing.EndSpan(ctx, sc, err)
160		}()
161	}
162	if err := validation.Validate([]validation.Validation{
163		{TargetValue: serviceName,
164			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
165				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
166				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
167		{TargetValue: apiid,
168			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
169				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}},
170		{TargetValue: issueID,
171			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
172				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
173				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
174		return result, validation.NewError("apimanagement.APIIssueClient", "Delete", err.Error())
175	}
176
177	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, ifMatch)
178	if err != nil {
179		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Delete", nil, "Failure preparing request")
180		return
181	}
182
183	resp, err := client.DeleteSender(req)
184	if err != nil {
185		result.Response = resp
186		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Delete", resp, "Failure sending request")
187		return
188	}
189
190	result, err = client.DeleteResponder(resp)
191	if err != nil {
192		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Delete", resp, "Failure responding to request")
193		return
194	}
195
196	return
197}
198
199// DeletePreparer prepares the Delete request.
200func (client APIIssueClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, ifMatch string) (*http.Request, error) {
201	pathParameters := map[string]interface{}{
202		"apiId":             autorest.Encode("path", apiid),
203		"issueId":           autorest.Encode("path", issueID),
204		"resourceGroupName": autorest.Encode("path", resourceGroupName),
205		"serviceName":       autorest.Encode("path", serviceName),
206		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
207	}
208
209	const APIVersion = "2021-01-01-preview"
210	queryParameters := map[string]interface{}{
211		"api-version": APIVersion,
212	}
213
214	preparer := autorest.CreatePreparer(
215		autorest.AsDelete(),
216		autorest.WithBaseURL(client.BaseURI),
217		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters),
218		autorest.WithQueryParameters(queryParameters),
219		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
220	return preparer.Prepare((&http.Request{}).WithContext(ctx))
221}
222
223// DeleteSender sends the Delete request. The method will close the
224// http.Response Body if it receives an error.
225func (client APIIssueClient) DeleteSender(req *http.Request) (*http.Response, error) {
226	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
227}
228
229// DeleteResponder handles the response to the Delete request. The method always
230// closes the http.Response Body.
231func (client APIIssueClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
232	err = autorest.Respond(
233		resp,
234		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
235		autorest.ByClosing())
236	result.Response = resp
237	return
238}
239
240// Get gets the details of the Issue for an API specified by its identifier.
241// Parameters:
242// resourceGroupName - the name of the resource group.
243// serviceName - the name of the API Management service.
244// apiid - API identifier. Must be unique in the current API Management service instance.
245// issueID - issue identifier. Must be unique in the current API Management service instance.
246// expandCommentsAttachments - expand the comment attachments.
247func (client APIIssueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, expandCommentsAttachments *bool) (result IssueContract, err error) {
248	if tracing.IsEnabled() {
249		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Get")
250		defer func() {
251			sc := -1
252			if result.Response.Response != nil {
253				sc = result.Response.Response.StatusCode
254			}
255			tracing.EndSpan(ctx, sc, err)
256		}()
257	}
258	if err := validation.Validate([]validation.Validation{
259		{TargetValue: serviceName,
260			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
261				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
262				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
263		{TargetValue: apiid,
264			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
265				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}},
266		{TargetValue: issueID,
267			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
268				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
269				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
270		return result, validation.NewError("apimanagement.APIIssueClient", "Get", err.Error())
271	}
272
273	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, expandCommentsAttachments)
274	if err != nil {
275		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Get", nil, "Failure preparing request")
276		return
277	}
278
279	resp, err := client.GetSender(req)
280	if err != nil {
281		result.Response = autorest.Response{Response: resp}
282		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Get", resp, "Failure sending request")
283		return
284	}
285
286	result, err = client.GetResponder(resp)
287	if err != nil {
288		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Get", resp, "Failure responding to request")
289		return
290	}
291
292	return
293}
294
295// GetPreparer prepares the Get request.
296func (client APIIssueClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, expandCommentsAttachments *bool) (*http.Request, error) {
297	pathParameters := map[string]interface{}{
298		"apiId":             autorest.Encode("path", apiid),
299		"issueId":           autorest.Encode("path", issueID),
300		"resourceGroupName": autorest.Encode("path", resourceGroupName),
301		"serviceName":       autorest.Encode("path", serviceName),
302		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
303	}
304
305	const APIVersion = "2021-01-01-preview"
306	queryParameters := map[string]interface{}{
307		"api-version": APIVersion,
308	}
309	if expandCommentsAttachments != nil {
310		queryParameters["expandCommentsAttachments"] = autorest.Encode("query", *expandCommentsAttachments)
311	}
312
313	preparer := autorest.CreatePreparer(
314		autorest.AsGet(),
315		autorest.WithBaseURL(client.BaseURI),
316		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters),
317		autorest.WithQueryParameters(queryParameters))
318	return preparer.Prepare((&http.Request{}).WithContext(ctx))
319}
320
321// GetSender sends the Get request. The method will close the
322// http.Response Body if it receives an error.
323func (client APIIssueClient) GetSender(req *http.Request) (*http.Response, error) {
324	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
325}
326
327// GetResponder handles the response to the Get request. The method always
328// closes the http.Response Body.
329func (client APIIssueClient) GetResponder(resp *http.Response) (result IssueContract, err error) {
330	err = autorest.Respond(
331		resp,
332		azure.WithErrorUnlessStatusCode(http.StatusOK),
333		autorest.ByUnmarshallingJSON(&result),
334		autorest.ByClosing())
335	result.Response = autorest.Response{Response: resp}
336	return
337}
338
339// GetEntityTag gets the entity state (Etag) version of the Issue for an API specified by its identifier.
340// Parameters:
341// resourceGroupName - the name of the resource group.
342// serviceName - the name of the API Management service.
343// apiid - API identifier. Must be unique in the current API Management service instance.
344// issueID - issue identifier. Must be unique in the current API Management service instance.
345func (client APIIssueClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result autorest.Response, err error) {
346	if tracing.IsEnabled() {
347		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.GetEntityTag")
348		defer func() {
349			sc := -1
350			if result.Response != nil {
351				sc = result.Response.StatusCode
352			}
353			tracing.EndSpan(ctx, sc, err)
354		}()
355	}
356	if err := validation.Validate([]validation.Validation{
357		{TargetValue: serviceName,
358			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
359				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
360				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
361		{TargetValue: apiid,
362			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
363				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}},
364		{TargetValue: issueID,
365			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
366				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
367				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
368		return result, validation.NewError("apimanagement.APIIssueClient", "GetEntityTag", err.Error())
369	}
370
371	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, issueID)
372	if err != nil {
373		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "GetEntityTag", nil, "Failure preparing request")
374		return
375	}
376
377	resp, err := client.GetEntityTagSender(req)
378	if err != nil {
379		result.Response = resp
380		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "GetEntityTag", resp, "Failure sending request")
381		return
382	}
383
384	result, err = client.GetEntityTagResponder(resp)
385	if err != nil {
386		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "GetEntityTag", resp, "Failure responding to request")
387		return
388	}
389
390	return
391}
392
393// GetEntityTagPreparer prepares the GetEntityTag request.
394func (client APIIssueClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (*http.Request, error) {
395	pathParameters := map[string]interface{}{
396		"apiId":             autorest.Encode("path", apiid),
397		"issueId":           autorest.Encode("path", issueID),
398		"resourceGroupName": autorest.Encode("path", resourceGroupName),
399		"serviceName":       autorest.Encode("path", serviceName),
400		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
401	}
402
403	const APIVersion = "2021-01-01-preview"
404	queryParameters := map[string]interface{}{
405		"api-version": APIVersion,
406	}
407
408	preparer := autorest.CreatePreparer(
409		autorest.AsHead(),
410		autorest.WithBaseURL(client.BaseURI),
411		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters),
412		autorest.WithQueryParameters(queryParameters))
413	return preparer.Prepare((&http.Request{}).WithContext(ctx))
414}
415
416// GetEntityTagSender sends the GetEntityTag request. The method will close the
417// http.Response Body if it receives an error.
418func (client APIIssueClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
419	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
420}
421
422// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
423// closes the http.Response Body.
424func (client APIIssueClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
425	err = autorest.Respond(
426		resp,
427		azure.WithErrorUnlessStatusCode(http.StatusOK),
428		autorest.ByClosing())
429	result.Response = resp
430	return
431}
432
433// ListByService lists all issues associated with the specified API.
434// Parameters:
435// resourceGroupName - the name of the resource group.
436// serviceName - the name of the API Management service.
437// apiid - API identifier. Must be unique in the current API Management service instance.
438// filter - |     Field     |     Usage     |     Supported operators     |     Supported functions
439// |</br>|-------------|-------------|-------------|-------------|</br>| name | filter | ge, le, eq, ne, gt, lt
440// | substringof, contains, startswith, endswith |</br>| userId | filter | ge, le, eq, ne, gt, lt |
441// substringof, contains, startswith, endswith |</br>| state | filter | eq |     |</br>
442// expandCommentsAttachments - expand the comment attachments.
443// top - number of records to return.
444// skip - number of records to skip.
445func (client APIIssueClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (result IssueCollectionPage, err error) {
446	if tracing.IsEnabled() {
447		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.ListByService")
448		defer func() {
449			sc := -1
450			if result.ic.Response.Response != nil {
451				sc = result.ic.Response.Response.StatusCode
452			}
453			tracing.EndSpan(ctx, sc, err)
454		}()
455	}
456	if err := validation.Validate([]validation.Validation{
457		{TargetValue: serviceName,
458			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
459				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
460				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
461		{TargetValue: apiid,
462			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
463				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}},
464		{TargetValue: top,
465			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
466				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
467		{TargetValue: skip,
468			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
469				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
470		return result, validation.NewError("apimanagement.APIIssueClient", "ListByService", err.Error())
471	}
472
473	result.fn = client.listByServiceNextResults
474	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, expandCommentsAttachments, top, skip)
475	if err != nil {
476		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "ListByService", nil, "Failure preparing request")
477		return
478	}
479
480	resp, err := client.ListByServiceSender(req)
481	if err != nil {
482		result.ic.Response = autorest.Response{Response: resp}
483		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "ListByService", resp, "Failure sending request")
484		return
485	}
486
487	result.ic, err = client.ListByServiceResponder(resp)
488	if err != nil {
489		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "ListByService", resp, "Failure responding to request")
490		return
491	}
492	if result.ic.hasNextLink() && result.ic.IsEmpty() {
493		err = result.NextWithContext(ctx)
494		return
495	}
496
497	return
498}
499
500// ListByServicePreparer prepares the ListByService request.
501func (client APIIssueClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (*http.Request, error) {
502	pathParameters := map[string]interface{}{
503		"apiId":             autorest.Encode("path", apiid),
504		"resourceGroupName": autorest.Encode("path", resourceGroupName),
505		"serviceName":       autorest.Encode("path", serviceName),
506		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
507	}
508
509	const APIVersion = "2021-01-01-preview"
510	queryParameters := map[string]interface{}{
511		"api-version": APIVersion,
512	}
513	if len(filter) > 0 {
514		queryParameters["$filter"] = autorest.Encode("query", filter)
515	}
516	if expandCommentsAttachments != nil {
517		queryParameters["expandCommentsAttachments"] = autorest.Encode("query", *expandCommentsAttachments)
518	}
519	if top != nil {
520		queryParameters["$top"] = autorest.Encode("query", *top)
521	}
522	if skip != nil {
523		queryParameters["$skip"] = autorest.Encode("query", *skip)
524	}
525
526	preparer := autorest.CreatePreparer(
527		autorest.AsGet(),
528		autorest.WithBaseURL(client.BaseURI),
529		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues", pathParameters),
530		autorest.WithQueryParameters(queryParameters))
531	return preparer.Prepare((&http.Request{}).WithContext(ctx))
532}
533
534// ListByServiceSender sends the ListByService request. The method will close the
535// http.Response Body if it receives an error.
536func (client APIIssueClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
537	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
538}
539
540// ListByServiceResponder handles the response to the ListByService request. The method always
541// closes the http.Response Body.
542func (client APIIssueClient) ListByServiceResponder(resp *http.Response) (result IssueCollection, err error) {
543	err = autorest.Respond(
544		resp,
545		azure.WithErrorUnlessStatusCode(http.StatusOK),
546		autorest.ByUnmarshallingJSON(&result),
547		autorest.ByClosing())
548	result.Response = autorest.Response{Response: resp}
549	return
550}
551
552// listByServiceNextResults retrieves the next set of results, if any.
553func (client APIIssueClient) listByServiceNextResults(ctx context.Context, lastResults IssueCollection) (result IssueCollection, err error) {
554	req, err := lastResults.issueCollectionPreparer(ctx)
555	if err != nil {
556		return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "listByServiceNextResults", nil, "Failure preparing next results request")
557	}
558	if req == nil {
559		return
560	}
561	resp, err := client.ListByServiceSender(req)
562	if err != nil {
563		result.Response = autorest.Response{Response: resp}
564		return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "listByServiceNextResults", resp, "Failure sending next results request")
565	}
566	result, err = client.ListByServiceResponder(resp)
567	if err != nil {
568		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "listByServiceNextResults", resp, "Failure responding to next results request")
569	}
570	return
571}
572
573// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required.
574func (client APIIssueClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (result IssueCollectionIterator, err error) {
575	if tracing.IsEnabled() {
576		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.ListByService")
577		defer func() {
578			sc := -1
579			if result.Response().Response.Response != nil {
580				sc = result.page.Response().Response.Response.StatusCode
581			}
582			tracing.EndSpan(ctx, sc, err)
583		}()
584	}
585	result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, expandCommentsAttachments, top, skip)
586	return
587}
588
589// Update updates an existing issue for an API.
590// Parameters:
591// resourceGroupName - the name of the resource group.
592// serviceName - the name of the API Management service.
593// apiid - API identifier. Must be unique in the current API Management service instance.
594// issueID - issue identifier. Must be unique in the current API Management service instance.
595// parameters - update parameters.
596// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
597// request or it should be * for unconditional update.
598func (client APIIssueClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (result IssueContract, err error) {
599	if tracing.IsEnabled() {
600		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Update")
601		defer func() {
602			sc := -1
603			if result.Response.Response != nil {
604				sc = result.Response.Response.StatusCode
605			}
606			tracing.EndSpan(ctx, sc, err)
607		}()
608	}
609	if err := validation.Validate([]validation.Validation{
610		{TargetValue: serviceName,
611			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
612				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
613				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
614		{TargetValue: apiid,
615			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
616				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}},
617		{TargetValue: issueID,
618			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
619				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
620				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
621		return result, validation.NewError("apimanagement.APIIssueClient", "Update", err.Error())
622	}
623
624	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, parameters, ifMatch)
625	if err != nil {
626		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", nil, "Failure preparing request")
627		return
628	}
629
630	resp, err := client.UpdateSender(req)
631	if err != nil {
632		result.Response = autorest.Response{Response: resp}
633		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure sending request")
634		return
635	}
636
637	result, err = client.UpdateResponder(resp)
638	if err != nil {
639		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure responding to request")
640		return
641	}
642
643	return
644}
645
646// UpdatePreparer prepares the Update request.
647func (client APIIssueClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (*http.Request, error) {
648	pathParameters := map[string]interface{}{
649		"apiId":             autorest.Encode("path", apiid),
650		"issueId":           autorest.Encode("path", issueID),
651		"resourceGroupName": autorest.Encode("path", resourceGroupName),
652		"serviceName":       autorest.Encode("path", serviceName),
653		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
654	}
655
656	const APIVersion = "2021-01-01-preview"
657	queryParameters := map[string]interface{}{
658		"api-version": APIVersion,
659	}
660
661	preparer := autorest.CreatePreparer(
662		autorest.AsContentType("application/json; charset=utf-8"),
663		autorest.AsPatch(),
664		autorest.WithBaseURL(client.BaseURI),
665		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters),
666		autorest.WithJSON(parameters),
667		autorest.WithQueryParameters(queryParameters),
668		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
669	return preparer.Prepare((&http.Request{}).WithContext(ctx))
670}
671
672// UpdateSender sends the Update request. The method will close the
673// http.Response Body if it receives an error.
674func (client APIIssueClient) UpdateSender(req *http.Request) (*http.Response, error) {
675	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
676}
677
678// UpdateResponder handles the response to the Update request. The method always
679// closes the http.Response Body.
680func (client APIIssueClient) UpdateResponder(resp *http.Response) (result IssueContract, err error) {
681	err = autorest.Respond(
682		resp,
683		azure.WithErrorUnlessStatusCode(http.StatusOK),
684		autorest.ByUnmarshallingJSON(&result),
685		autorest.ByClosing())
686	result.Response = autorest.Response{Response: resp}
687	return
688}
689