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