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.
40func NewAPIIssueCommentClientWithBaseURI(baseURI string, subscriptionID string) APIIssueCommentClient {
41	return APIIssueCommentClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CreateOrUpdate creates a new Comment for the Issue in an API or updates an existing one.
45// Parameters:
46// resourceGroupName - the name of the resource group.
47// serviceName - the name of the API Management service.
48// apiid - API identifier. Must be unique in the current API Management service instance.
49// issueID - issue identifier. Must be unique in the current API Management service instance.
50// commentID - comment identifier within an Issue. Must be unique in the current Issue.
51// parameters - create parameters.
52// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity.
53func (client APIIssueCommentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, parameters IssueCommentContract, ifMatch string) (result IssueCommentContract, err error) {
54	if tracing.IsEnabled() {
55		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.CreateOrUpdate")
56		defer func() {
57			sc := -1
58			if result.Response.Response != nil {
59				sc = result.Response.Response.StatusCode
60			}
61			tracing.EndSpan(ctx, sc, err)
62		}()
63	}
64	if err := validation.Validate([]validation.Validation{
65		{TargetValue: serviceName,
66			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
67				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
68				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
69		{TargetValue: apiid,
70			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
71				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
72				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, 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 = "2018-06-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	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
144	return autorest.SendWithSender(client, req, sd...)
145}
146
147// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
148// closes the http.Response Body.
149func (client APIIssueCommentClient) CreateOrUpdateResponder(resp *http.Response) (result IssueCommentContract, err error) {
150	err = autorest.Respond(
151		resp,
152		client.ByInspecting(),
153		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
154		autorest.ByUnmarshallingJSON(&result),
155		autorest.ByClosing())
156	result.Response = autorest.Response{Response: resp}
157	return
158}
159
160// Delete deletes the specified comment from an Issue.
161// Parameters:
162// resourceGroupName - the name of the resource group.
163// serviceName - the name of the API Management service.
164// apiid - API identifier. Must be unique in the current API Management service instance.
165// issueID - issue identifier. Must be unique in the current API Management service instance.
166// commentID - comment identifier within an Issue. Must be unique in the current Issue.
167// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
168// request or it should be * for unconditional update.
169func (client APIIssueCommentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, ifMatch string) (result autorest.Response, err error) {
170	if tracing.IsEnabled() {
171		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.Delete")
172		defer func() {
173			sc := -1
174			if result.Response != nil {
175				sc = result.Response.StatusCode
176			}
177			tracing.EndSpan(ctx, sc, err)
178		}()
179	}
180	if err := validation.Validate([]validation.Validation{
181		{TargetValue: serviceName,
182			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
183				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
184				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
185		{TargetValue: apiid,
186			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
187				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
188				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
189		{TargetValue: issueID,
190			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
191				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
192				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
193		{TargetValue: commentID,
194			Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
195				{Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil},
196				{Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
197		return result, validation.NewError("apimanagement.APIIssueCommentClient", "Delete", err.Error())
198	}
199
200	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID, ifMatch)
201	if err != nil {
202		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Delete", nil, "Failure preparing request")
203		return
204	}
205
206	resp, err := client.DeleteSender(req)
207	if err != nil {
208		result.Response = resp
209		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Delete", resp, "Failure sending request")
210		return
211	}
212
213	result, err = client.DeleteResponder(resp)
214	if err != nil {
215		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Delete", resp, "Failure responding to request")
216	}
217
218	return
219}
220
221// DeletePreparer prepares the Delete request.
222func (client APIIssueCommentClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, ifMatch string) (*http.Request, error) {
223	pathParameters := map[string]interface{}{
224		"apiId":             autorest.Encode("path", apiid),
225		"commentId":         autorest.Encode("path", commentID),
226		"issueId":           autorest.Encode("path", issueID),
227		"resourceGroupName": autorest.Encode("path", resourceGroupName),
228		"serviceName":       autorest.Encode("path", serviceName),
229		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
230	}
231
232	const APIVersion = "2018-06-01-preview"
233	queryParameters := map[string]interface{}{
234		"api-version": APIVersion,
235	}
236
237	preparer := autorest.CreatePreparer(
238		autorest.AsDelete(),
239		autorest.WithBaseURL(client.BaseURI),
240		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters),
241		autorest.WithQueryParameters(queryParameters),
242		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
243	return preparer.Prepare((&http.Request{}).WithContext(ctx))
244}
245
246// DeleteSender sends the Delete request. The method will close the
247// http.Response Body if it receives an error.
248func (client APIIssueCommentClient) DeleteSender(req *http.Request) (*http.Response, error) {
249	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
250	return autorest.SendWithSender(client, req, sd...)
251}
252
253// DeleteResponder handles the response to the Delete request. The method always
254// closes the http.Response Body.
255func (client APIIssueCommentClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
256	err = autorest.Respond(
257		resp,
258		client.ByInspecting(),
259		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
260		autorest.ByClosing())
261	result.Response = resp
262	return
263}
264
265// Get gets the details of the issue Comment for an API specified by its identifier.
266// Parameters:
267// resourceGroupName - the name of the resource group.
268// serviceName - the name of the API Management service.
269// apiid - API identifier. Must be unique in the current API Management service instance.
270// issueID - issue identifier. Must be unique in the current API Management service instance.
271// commentID - comment identifier within an Issue. Must be unique in the current Issue.
272func (client APIIssueCommentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result IssueCommentContract, err error) {
273	if tracing.IsEnabled() {
274		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.Get")
275		defer func() {
276			sc := -1
277			if result.Response.Response != nil {
278				sc = result.Response.Response.StatusCode
279			}
280			tracing.EndSpan(ctx, sc, err)
281		}()
282	}
283	if err := validation.Validate([]validation.Validation{
284		{TargetValue: serviceName,
285			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
286				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
287				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
288		{TargetValue: apiid,
289			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
290				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
291				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
292		{TargetValue: issueID,
293			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
294				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
295				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
296		{TargetValue: commentID,
297			Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
298				{Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil},
299				{Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
300		return result, validation.NewError("apimanagement.APIIssueCommentClient", "Get", err.Error())
301	}
302
303	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID)
304	if err != nil {
305		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Get", nil, "Failure preparing request")
306		return
307	}
308
309	resp, err := client.GetSender(req)
310	if err != nil {
311		result.Response = autorest.Response{Response: resp}
312		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Get", resp, "Failure sending request")
313		return
314	}
315
316	result, err = client.GetResponder(resp)
317	if err != nil {
318		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Get", resp, "Failure responding to request")
319	}
320
321	return
322}
323
324// GetPreparer prepares the Get request.
325func (client APIIssueCommentClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (*http.Request, error) {
326	pathParameters := map[string]interface{}{
327		"apiId":             autorest.Encode("path", apiid),
328		"commentId":         autorest.Encode("path", commentID),
329		"issueId":           autorest.Encode("path", issueID),
330		"resourceGroupName": autorest.Encode("path", resourceGroupName),
331		"serviceName":       autorest.Encode("path", serviceName),
332		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
333	}
334
335	const APIVersion = "2018-06-01-preview"
336	queryParameters := map[string]interface{}{
337		"api-version": APIVersion,
338	}
339
340	preparer := autorest.CreatePreparer(
341		autorest.AsGet(),
342		autorest.WithBaseURL(client.BaseURI),
343		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters),
344		autorest.WithQueryParameters(queryParameters))
345	return preparer.Prepare((&http.Request{}).WithContext(ctx))
346}
347
348// GetSender sends the Get request. The method will close the
349// http.Response Body if it receives an error.
350func (client APIIssueCommentClient) GetSender(req *http.Request) (*http.Response, error) {
351	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
352	return autorest.SendWithSender(client, req, sd...)
353}
354
355// GetResponder handles the response to the Get request. The method always
356// closes the http.Response Body.
357func (client APIIssueCommentClient) GetResponder(resp *http.Response) (result IssueCommentContract, err error) {
358	err = autorest.Respond(
359		resp,
360		client.ByInspecting(),
361		azure.WithErrorUnlessStatusCode(http.StatusOK),
362		autorest.ByUnmarshallingJSON(&result),
363		autorest.ByClosing())
364	result.Response = autorest.Response{Response: resp}
365	return
366}
367
368// GetEntityTag gets the entity state (Etag) version of the issue Comment for an API specified by its identifier.
369// Parameters:
370// resourceGroupName - the name of the resource group.
371// serviceName - the name of the API Management service.
372// apiid - API identifier. Must be unique in the current API Management service instance.
373// issueID - issue identifier. Must be unique in the current API Management service instance.
374// commentID - comment identifier within an Issue. Must be unique in the current Issue.
375func (client APIIssueCommentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result autorest.Response, err error) {
376	if tracing.IsEnabled() {
377		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.GetEntityTag")
378		defer func() {
379			sc := -1
380			if result.Response != nil {
381				sc = result.Response.StatusCode
382			}
383			tracing.EndSpan(ctx, sc, err)
384		}()
385	}
386	if err := validation.Validate([]validation.Validation{
387		{TargetValue: serviceName,
388			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
389				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
390				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
391		{TargetValue: apiid,
392			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
393				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
394				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
395		{TargetValue: issueID,
396			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
397				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
398				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
399		{TargetValue: commentID,
400			Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil},
401				{Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil},
402				{Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
403		return result, validation.NewError("apimanagement.APIIssueCommentClient", "GetEntityTag", err.Error())
404	}
405
406	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID)
407	if err != nil {
408		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "GetEntityTag", nil, "Failure preparing request")
409		return
410	}
411
412	resp, err := client.GetEntityTagSender(req)
413	if err != nil {
414		result.Response = resp
415		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "GetEntityTag", resp, "Failure sending request")
416		return
417	}
418
419	result, err = client.GetEntityTagResponder(resp)
420	if err != nil {
421		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "GetEntityTag", resp, "Failure responding to request")
422	}
423
424	return
425}
426
427// GetEntityTagPreparer prepares the GetEntityTag request.
428func (client APIIssueCommentClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (*http.Request, error) {
429	pathParameters := map[string]interface{}{
430		"apiId":             autorest.Encode("path", apiid),
431		"commentId":         autorest.Encode("path", commentID),
432		"issueId":           autorest.Encode("path", issueID),
433		"resourceGroupName": autorest.Encode("path", resourceGroupName),
434		"serviceName":       autorest.Encode("path", serviceName),
435		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
436	}
437
438	const APIVersion = "2018-06-01-preview"
439	queryParameters := map[string]interface{}{
440		"api-version": APIVersion,
441	}
442
443	preparer := autorest.CreatePreparer(
444		autorest.AsHead(),
445		autorest.WithBaseURL(client.BaseURI),
446		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters),
447		autorest.WithQueryParameters(queryParameters))
448	return preparer.Prepare((&http.Request{}).WithContext(ctx))
449}
450
451// GetEntityTagSender sends the GetEntityTag request. The method will close the
452// http.Response Body if it receives an error.
453func (client APIIssueCommentClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
454	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
455	return autorest.SendWithSender(client, req, sd...)
456}
457
458// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
459// closes the http.Response Body.
460func (client APIIssueCommentClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
461	err = autorest.Respond(
462		resp,
463		client.ByInspecting(),
464		azure.WithErrorUnlessStatusCode(http.StatusOK),
465		autorest.ByClosing())
466	result.Response = resp
467	return
468}
469
470// ListByService lists all comments for the Issue associated with the specified API.
471// Parameters:
472// resourceGroupName - the name of the resource group.
473// serviceName - the name of the API Management service.
474// apiid - API identifier. Must be unique in the current API Management service instance.
475// issueID - issue identifier. Must be unique in the current API Management service instance.
476// filter - | Field       | Supported operators    | Supported functions               |
477// |-------------|------------------------|-----------------------------------|
478//
479// |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith|
480// |userId | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith|
481// top - number of records to return.
482// skip - number of records to skip.
483func (client APIIssueCommentClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueCommentCollectionPage, err error) {
484	if tracing.IsEnabled() {
485		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.ListByService")
486		defer func() {
487			sc := -1
488			if result.icc.Response.Response != nil {
489				sc = result.icc.Response.Response.StatusCode
490			}
491			tracing.EndSpan(ctx, sc, err)
492		}()
493	}
494	if err := validation.Validate([]validation.Validation{
495		{TargetValue: serviceName,
496			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
497				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
498				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
499		{TargetValue: apiid,
500			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil},
501				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
502				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
503		{TargetValue: issueID,
504			Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil},
505				{Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil},
506				{Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
507		{TargetValue: top,
508			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
509				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
510		{TargetValue: skip,
511			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
512				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
513		return result, validation.NewError("apimanagement.APIIssueCommentClient", "ListByService", err.Error())
514	}
515
516	result.fn = client.listByServiceNextResults
517	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip)
518	if err != nil {
519		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "ListByService", nil, "Failure preparing request")
520		return
521	}
522
523	resp, err := client.ListByServiceSender(req)
524	if err != nil {
525		result.icc.Response = autorest.Response{Response: resp}
526		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "ListByService", resp, "Failure sending request")
527		return
528	}
529
530	result.icc, err = client.ListByServiceResponder(resp)
531	if err != nil {
532		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "ListByService", resp, "Failure responding to request")
533	}
534
535	return
536}
537
538// ListByServicePreparer prepares the ListByService request.
539func (client APIIssueCommentClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (*http.Request, error) {
540	pathParameters := map[string]interface{}{
541		"apiId":             autorest.Encode("path", apiid),
542		"issueId":           autorest.Encode("path", issueID),
543		"resourceGroupName": autorest.Encode("path", resourceGroupName),
544		"serviceName":       autorest.Encode("path", serviceName),
545		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
546	}
547
548	const APIVersion = "2018-06-01-preview"
549	queryParameters := map[string]interface{}{
550		"api-version": APIVersion,
551	}
552	if len(filter) > 0 {
553		queryParameters["$filter"] = autorest.Encode("query", filter)
554	}
555	if top != nil {
556		queryParameters["$top"] = autorest.Encode("query", *top)
557	}
558	if skip != nil {
559		queryParameters["$skip"] = autorest.Encode("query", *skip)
560	}
561
562	preparer := autorest.CreatePreparer(
563		autorest.AsGet(),
564		autorest.WithBaseURL(client.BaseURI),
565		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments", pathParameters),
566		autorest.WithQueryParameters(queryParameters))
567	return preparer.Prepare((&http.Request{}).WithContext(ctx))
568}
569
570// ListByServiceSender sends the ListByService request. The method will close the
571// http.Response Body if it receives an error.
572func (client APIIssueCommentClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
573	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
574	return autorest.SendWithSender(client, req, sd...)
575}
576
577// ListByServiceResponder handles the response to the ListByService request. The method always
578// closes the http.Response Body.
579func (client APIIssueCommentClient) ListByServiceResponder(resp *http.Response) (result IssueCommentCollection, err error) {
580	err = autorest.Respond(
581		resp,
582		client.ByInspecting(),
583		azure.WithErrorUnlessStatusCode(http.StatusOK),
584		autorest.ByUnmarshallingJSON(&result),
585		autorest.ByClosing())
586	result.Response = autorest.Response{Response: resp}
587	return
588}
589
590// listByServiceNextResults retrieves the next set of results, if any.
591func (client APIIssueCommentClient) listByServiceNextResults(ctx context.Context, lastResults IssueCommentCollection) (result IssueCommentCollection, err error) {
592	req, err := lastResults.issueCommentCollectionPreparer(ctx)
593	if err != nil {
594		return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "listByServiceNextResults", nil, "Failure preparing next results request")
595	}
596	if req == nil {
597		return
598	}
599	resp, err := client.ListByServiceSender(req)
600	if err != nil {
601		result.Response = autorest.Response{Response: resp}
602		return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "listByServiceNextResults", resp, "Failure sending next results request")
603	}
604	result, err = client.ListByServiceResponder(resp)
605	if err != nil {
606		err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "listByServiceNextResults", resp, "Failure responding to next results request")
607	}
608	return
609}
610
611// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required.
612func (client APIIssueCommentClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueCommentCollectionIterator, err error) {
613	if tracing.IsEnabled() {
614		ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.ListByService")
615		defer func() {
616			sc := -1
617			if result.Response().Response.Response != nil {
618				sc = result.page.Response().Response.Response.StatusCode
619			}
620			tracing.EndSpan(ctx, sc, err)
621		}()
622	}
623	result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip)
624	return
625}
626