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