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// APITagDescriptionClient is the apiManagement Client
30type APITagDescriptionClient struct {
31	BaseClient
32}
33
34// NewAPITagDescriptionClient creates an instance of the APITagDescriptionClient client.
35func NewAPITagDescriptionClient(subscriptionID string) APITagDescriptionClient {
36	return NewAPITagDescriptionClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewAPITagDescriptionClientWithBaseURI creates an instance of the APITagDescriptionClient client.
40func NewAPITagDescriptionClientWithBaseURI(baseURI string, subscriptionID string) APITagDescriptionClient {
41	return APITagDescriptionClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CreateOrUpdate create/Update tag description in scope of the Api.
45// Parameters:
46// resourceGroupName - the name of the resource group.
47// serviceName - the name of the API Management service.
48// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
49// revision has ;rev=n as a suffix where n is the revision number.
50// tagID - tag identifier. Must be unique in the current API Management service instance.
51// parameters - create parameters.
52// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity.
53func (client APITagDescriptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string, parameters TagDescriptionCreateParameters, ifMatch string) (result TagDescriptionContract, err error) {
54	if tracing.IsEnabled() {
55		ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.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: 256, Chain: nil},
71				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
72				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
73		{TargetValue: tagID,
74			Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil},
75				{Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil},
76				{Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
77		{TargetValue: parameters,
78			Constraints: []validation.Constraint{{Target: "parameters.TagDescriptionBaseProperties", Name: validation.Null, Rule: false,
79				Chain: []validation.Constraint{{Target: "parameters.TagDescriptionBaseProperties.ExternalDocsURL", Name: validation.Null, Rule: false,
80					Chain: []validation.Constraint{{Target: "parameters.TagDescriptionBaseProperties.ExternalDocsURL", Name: validation.MaxLength, Rule: 2000, Chain: nil}}},
81				}}}}}); err != nil {
82		return result, validation.NewError("apimanagement.APITagDescriptionClient", "CreateOrUpdate", err.Error())
83	}
84
85	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, tagID, parameters, ifMatch)
86	if err != nil {
87		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "CreateOrUpdate", nil, "Failure preparing request")
88		return
89	}
90
91	resp, err := client.CreateOrUpdateSender(req)
92	if err != nil {
93		result.Response = autorest.Response{Response: resp}
94		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "CreateOrUpdate", resp, "Failure sending request")
95		return
96	}
97
98	result, err = client.CreateOrUpdateResponder(resp)
99	if err != nil {
100		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "CreateOrUpdate", resp, "Failure responding to request")
101	}
102
103	return
104}
105
106// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
107func (client APITagDescriptionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string, parameters TagDescriptionCreateParameters, ifMatch string) (*http.Request, error) {
108	pathParameters := map[string]interface{}{
109		"apiId":             autorest.Encode("path", apiid),
110		"resourceGroupName": autorest.Encode("path", resourceGroupName),
111		"serviceName":       autorest.Encode("path", serviceName),
112		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
113		"tagId":             autorest.Encode("path", tagID),
114	}
115
116	const APIVersion = "2019-01-01"
117	queryParameters := map[string]interface{}{
118		"api-version": APIVersion,
119	}
120
121	preparer := autorest.CreatePreparer(
122		autorest.AsContentType("application/json; charset=utf-8"),
123		autorest.AsPut(),
124		autorest.WithBaseURL(client.BaseURI),
125		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagId}", pathParameters),
126		autorest.WithJSON(parameters),
127		autorest.WithQueryParameters(queryParameters))
128	if len(ifMatch) > 0 {
129		preparer = autorest.DecoratePreparer(preparer,
130			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
131	}
132	return preparer.Prepare((&http.Request{}).WithContext(ctx))
133}
134
135// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
136// http.Response Body if it receives an error.
137func (client APITagDescriptionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
138	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
139	return autorest.SendWithSender(client, req, sd...)
140}
141
142// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
143// closes the http.Response Body.
144func (client APITagDescriptionClient) CreateOrUpdateResponder(resp *http.Response) (result TagDescriptionContract, err error) {
145	err = autorest.Respond(
146		resp,
147		client.ByInspecting(),
148		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
149		autorest.ByUnmarshallingJSON(&result),
150		autorest.ByClosing())
151	result.Response = autorest.Response{Response: resp}
152	return
153}
154
155// Delete delete tag description for the Api.
156// Parameters:
157// resourceGroupName - the name of the resource group.
158// serviceName - the name of the API Management service.
159// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
160// revision has ;rev=n as a suffix where n is the revision number.
161// tagID - tag identifier. Must be unique in the current API Management service instance.
162// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
163// request or it should be * for unconditional update.
164func (client APITagDescriptionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string, ifMatch string) (result autorest.Response, err error) {
165	if tracing.IsEnabled() {
166		ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.Delete")
167		defer func() {
168			sc := -1
169			if result.Response != nil {
170				sc = result.Response.StatusCode
171			}
172			tracing.EndSpan(ctx, sc, err)
173		}()
174	}
175	if err := validation.Validate([]validation.Validation{
176		{TargetValue: serviceName,
177			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
178				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
179				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
180		{TargetValue: apiid,
181			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
182				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
183				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
184		{TargetValue: tagID,
185			Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil},
186				{Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil},
187				{Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
188		return result, validation.NewError("apimanagement.APITagDescriptionClient", "Delete", err.Error())
189	}
190
191	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, tagID, ifMatch)
192	if err != nil {
193		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Delete", nil, "Failure preparing request")
194		return
195	}
196
197	resp, err := client.DeleteSender(req)
198	if err != nil {
199		result.Response = resp
200		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Delete", resp, "Failure sending request")
201		return
202	}
203
204	result, err = client.DeleteResponder(resp)
205	if err != nil {
206		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Delete", resp, "Failure responding to request")
207	}
208
209	return
210}
211
212// DeletePreparer prepares the Delete request.
213func (client APITagDescriptionClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string, ifMatch string) (*http.Request, error) {
214	pathParameters := map[string]interface{}{
215		"apiId":             autorest.Encode("path", apiid),
216		"resourceGroupName": autorest.Encode("path", resourceGroupName),
217		"serviceName":       autorest.Encode("path", serviceName),
218		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
219		"tagId":             autorest.Encode("path", tagID),
220	}
221
222	const APIVersion = "2019-01-01"
223	queryParameters := map[string]interface{}{
224		"api-version": APIVersion,
225	}
226
227	preparer := autorest.CreatePreparer(
228		autorest.AsDelete(),
229		autorest.WithBaseURL(client.BaseURI),
230		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagId}", pathParameters),
231		autorest.WithQueryParameters(queryParameters),
232		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
233	return preparer.Prepare((&http.Request{}).WithContext(ctx))
234}
235
236// DeleteSender sends the Delete request. The method will close the
237// http.Response Body if it receives an error.
238func (client APITagDescriptionClient) DeleteSender(req *http.Request) (*http.Response, error) {
239	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
240	return autorest.SendWithSender(client, req, sd...)
241}
242
243// DeleteResponder handles the response to the Delete request. The method always
244// closes the http.Response Body.
245func (client APITagDescriptionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
246	err = autorest.Respond(
247		resp,
248		client.ByInspecting(),
249		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
250		autorest.ByClosing())
251	result.Response = resp
252	return
253}
254
255// Get get Tag description in scope of API
256// Parameters:
257// resourceGroupName - the name of the resource group.
258// serviceName - the name of the API Management service.
259// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
260// revision has ;rev=n as a suffix where n is the revision number.
261// tagID - tag identifier. Must be unique in the current API Management service instance.
262func (client APITagDescriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result TagDescriptionContract, err error) {
263	if tracing.IsEnabled() {
264		ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.Get")
265		defer func() {
266			sc := -1
267			if result.Response.Response != nil {
268				sc = result.Response.Response.StatusCode
269			}
270			tracing.EndSpan(ctx, sc, err)
271		}()
272	}
273	if err := validation.Validate([]validation.Validation{
274		{TargetValue: serviceName,
275			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
276				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
277				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
278		{TargetValue: apiid,
279			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
280				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
281				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
282		{TargetValue: tagID,
283			Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil},
284				{Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil},
285				{Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
286		return result, validation.NewError("apimanagement.APITagDescriptionClient", "Get", err.Error())
287	}
288
289	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, tagID)
290	if err != nil {
291		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Get", nil, "Failure preparing request")
292		return
293	}
294
295	resp, err := client.GetSender(req)
296	if err != nil {
297		result.Response = autorest.Response{Response: resp}
298		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Get", resp, "Failure sending request")
299		return
300	}
301
302	result, err = client.GetResponder(resp)
303	if err != nil {
304		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Get", resp, "Failure responding to request")
305	}
306
307	return
308}
309
310// GetPreparer prepares the Get request.
311func (client APITagDescriptionClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) {
312	pathParameters := map[string]interface{}{
313		"apiId":             autorest.Encode("path", apiid),
314		"resourceGroupName": autorest.Encode("path", resourceGroupName),
315		"serviceName":       autorest.Encode("path", serviceName),
316		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
317		"tagId":             autorest.Encode("path", tagID),
318	}
319
320	const APIVersion = "2019-01-01"
321	queryParameters := map[string]interface{}{
322		"api-version": APIVersion,
323	}
324
325	preparer := autorest.CreatePreparer(
326		autorest.AsGet(),
327		autorest.WithBaseURL(client.BaseURI),
328		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagId}", pathParameters),
329		autorest.WithQueryParameters(queryParameters))
330	return preparer.Prepare((&http.Request{}).WithContext(ctx))
331}
332
333// GetSender sends the Get request. The method will close the
334// http.Response Body if it receives an error.
335func (client APITagDescriptionClient) GetSender(req *http.Request) (*http.Response, error) {
336	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
337	return autorest.SendWithSender(client, req, sd...)
338}
339
340// GetResponder handles the response to the Get request. The method always
341// closes the http.Response Body.
342func (client APITagDescriptionClient) GetResponder(resp *http.Response) (result TagDescriptionContract, err error) {
343	err = autorest.Respond(
344		resp,
345		client.ByInspecting(),
346		azure.WithErrorUnlessStatusCode(http.StatusOK),
347		autorest.ByUnmarshallingJSON(&result),
348		autorest.ByClosing())
349	result.Response = autorest.Response{Response: resp}
350	return
351}
352
353// GetEntityTag gets the entity state version of the tag specified by its identifier.
354// Parameters:
355// resourceGroupName - the name of the resource group.
356// serviceName - the name of the API Management service.
357// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
358// revision has ;rev=n as a suffix where n is the revision number.
359// tagID - tag identifier. Must be unique in the current API Management service instance.
360func (client APITagDescriptionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) {
361	if tracing.IsEnabled() {
362		ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.GetEntityTag")
363		defer func() {
364			sc := -1
365			if result.Response != nil {
366				sc = result.Response.StatusCode
367			}
368			tracing.EndSpan(ctx, sc, err)
369		}()
370	}
371	if err := validation.Validate([]validation.Validation{
372		{TargetValue: serviceName,
373			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
374				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
375				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
376		{TargetValue: apiid,
377			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
378				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
379				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
380		{TargetValue: tagID,
381			Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil},
382				{Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil},
383				{Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
384		return result, validation.NewError("apimanagement.APITagDescriptionClient", "GetEntityTag", err.Error())
385	}
386
387	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, tagID)
388	if err != nil {
389		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "GetEntityTag", nil, "Failure preparing request")
390		return
391	}
392
393	resp, err := client.GetEntityTagSender(req)
394	if err != nil {
395		result.Response = resp
396		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "GetEntityTag", resp, "Failure sending request")
397		return
398	}
399
400	result, err = client.GetEntityTagResponder(resp)
401	if err != nil {
402		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "GetEntityTag", resp, "Failure responding to request")
403	}
404
405	return
406}
407
408// GetEntityTagPreparer prepares the GetEntityTag request.
409func (client APITagDescriptionClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) {
410	pathParameters := map[string]interface{}{
411		"apiId":             autorest.Encode("path", apiid),
412		"resourceGroupName": autorest.Encode("path", resourceGroupName),
413		"serviceName":       autorest.Encode("path", serviceName),
414		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
415		"tagId":             autorest.Encode("path", tagID),
416	}
417
418	const APIVersion = "2019-01-01"
419	queryParameters := map[string]interface{}{
420		"api-version": APIVersion,
421	}
422
423	preparer := autorest.CreatePreparer(
424		autorest.AsHead(),
425		autorest.WithBaseURL(client.BaseURI),
426		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagId}", pathParameters),
427		autorest.WithQueryParameters(queryParameters))
428	return preparer.Prepare((&http.Request{}).WithContext(ctx))
429}
430
431// GetEntityTagSender sends the GetEntityTag request. The method will close the
432// http.Response Body if it receives an error.
433func (client APITagDescriptionClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
434	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
435	return autorest.SendWithSender(client, req, sd...)
436}
437
438// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
439// closes the http.Response Body.
440func (client APITagDescriptionClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
441	err = autorest.Respond(
442		resp,
443		client.ByInspecting(),
444		azure.WithErrorUnlessStatusCode(http.StatusOK),
445		autorest.ByClosing())
446	result.Response = resp
447	return
448}
449
450// ListByService lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is defined on
451// API level but tag may be assigned to the Operations
452// Parameters:
453// resourceGroupName - the name of the resource group.
454// serviceName - the name of the API Management service.
455// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
456// revision has ;rev=n as a suffix where n is the revision number.
457// filter - |   Field     |     Usage     |     Supported operators     |     Supported functions
458// |</br>|-------------|-------------|-------------|-------------|</br>| displayName | filter | ge, le, eq, ne,
459// gt, lt | substringof, contains, startswith, endswith | </br>| name | filter | ge, le, eq, ne, gt, lt |
460// substringof, contains, startswith, endswith | </br>
461// top - number of records to return.
462// skip - number of records to skip.
463func (client APITagDescriptionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagDescriptionCollectionPage, err error) {
464	if tracing.IsEnabled() {
465		ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.ListByService")
466		defer func() {
467			sc := -1
468			if result.tdc.Response.Response != nil {
469				sc = result.tdc.Response.Response.StatusCode
470			}
471			tracing.EndSpan(ctx, sc, err)
472		}()
473	}
474	if err := validation.Validate([]validation.Validation{
475		{TargetValue: serviceName,
476			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
477				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
478				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
479		{TargetValue: apiid,
480			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
481				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
482				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
483		{TargetValue: top,
484			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
485				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
486		{TargetValue: skip,
487			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
488				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
489		return result, validation.NewError("apimanagement.APITagDescriptionClient", "ListByService", err.Error())
490	}
491
492	result.fn = client.listByServiceNextResults
493	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip)
494	if err != nil {
495		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "ListByService", nil, "Failure preparing request")
496		return
497	}
498
499	resp, err := client.ListByServiceSender(req)
500	if err != nil {
501		result.tdc.Response = autorest.Response{Response: resp}
502		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "ListByService", resp, "Failure sending request")
503		return
504	}
505
506	result.tdc, err = client.ListByServiceResponder(resp)
507	if err != nil {
508		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "ListByService", resp, "Failure responding to request")
509	}
510
511	return
512}
513
514// ListByServicePreparer prepares the ListByService request.
515func (client APITagDescriptionClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) {
516	pathParameters := map[string]interface{}{
517		"apiId":             autorest.Encode("path", apiid),
518		"resourceGroupName": autorest.Encode("path", resourceGroupName),
519		"serviceName":       autorest.Encode("path", serviceName),
520		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
521	}
522
523	const APIVersion = "2019-01-01"
524	queryParameters := map[string]interface{}{
525		"api-version": APIVersion,
526	}
527	if len(filter) > 0 {
528		queryParameters["$filter"] = autorest.Encode("query", filter)
529	}
530	if top != nil {
531		queryParameters["$top"] = autorest.Encode("query", *top)
532	}
533	if skip != nil {
534		queryParameters["$skip"] = autorest.Encode("query", *skip)
535	}
536
537	preparer := autorest.CreatePreparer(
538		autorest.AsGet(),
539		autorest.WithBaseURL(client.BaseURI),
540		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions", pathParameters),
541		autorest.WithQueryParameters(queryParameters))
542	return preparer.Prepare((&http.Request{}).WithContext(ctx))
543}
544
545// ListByServiceSender sends the ListByService request. The method will close the
546// http.Response Body if it receives an error.
547func (client APITagDescriptionClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
548	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
549	return autorest.SendWithSender(client, req, sd...)
550}
551
552// ListByServiceResponder handles the response to the ListByService request. The method always
553// closes the http.Response Body.
554func (client APITagDescriptionClient) ListByServiceResponder(resp *http.Response) (result TagDescriptionCollection, err error) {
555	err = autorest.Respond(
556		resp,
557		client.ByInspecting(),
558		azure.WithErrorUnlessStatusCode(http.StatusOK),
559		autorest.ByUnmarshallingJSON(&result),
560		autorest.ByClosing())
561	result.Response = autorest.Response{Response: resp}
562	return
563}
564
565// listByServiceNextResults retrieves the next set of results, if any.
566func (client APITagDescriptionClient) listByServiceNextResults(ctx context.Context, lastResults TagDescriptionCollection) (result TagDescriptionCollection, err error) {
567	req, err := lastResults.tagDescriptionCollectionPreparer(ctx)
568	if err != nil {
569		return result, autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "listByServiceNextResults", nil, "Failure preparing next results request")
570	}
571	if req == nil {
572		return
573	}
574	resp, err := client.ListByServiceSender(req)
575	if err != nil {
576		result.Response = autorest.Response{Response: resp}
577		return result, autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "listByServiceNextResults", resp, "Failure sending next results request")
578	}
579	result, err = client.ListByServiceResponder(resp)
580	if err != nil {
581		err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "listByServiceNextResults", resp, "Failure responding to next results request")
582	}
583	return
584}
585
586// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required.
587func (client APITagDescriptionClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagDescriptionCollectionIterator, err error) {
588	if tracing.IsEnabled() {
589		ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.ListByService")
590		defer func() {
591			sc := -1
592			if result.Response().Response.Response != nil {
593				sc = result.page.Response().Response.Response.StatusCode
594			}
595			tracing.EndSpan(ctx, sc, err)
596		}()
597	}
598	result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip)
599	return
600}
601