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