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// TagClient is the apiManagement Client 30type TagClient struct { 31 BaseClient 32} 33 34// NewTagClient creates an instance of the TagClient client. 35func NewTagClient(subscriptionID string) TagClient { 36 return NewTagClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewTagClientWithBaseURI creates an instance of the TagClient client using a custom endpoint. Use this when 40// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 41func NewTagClientWithBaseURI(baseURI string, subscriptionID string) TagClient { 42 return TagClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// AssignToAPI assign tag to the Api. 46// Parameters: 47// resourceGroupName - the name of the resource group. 48// serviceName - the name of the API Management service. 49// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 50// revision has ;rev=n as a suffix where n is the revision number. 51// tagID - tag identifier. Must be unique in the current API Management service instance. 52func (client TagClient) AssignToAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result TagContract, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.AssignToAPI") 55 defer func() { 56 sc := -1 57 if result.Response.Response != nil { 58 sc = result.Response.Response.StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 if err := validation.Validate([]validation.Validation{ 64 {TargetValue: serviceName, 65 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 66 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 67 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 68 {TargetValue: apiid, 69 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 70 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 71 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 72 {TargetValue: tagID, 73 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 74 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 75 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 76 return result, validation.NewError("apimanagement.TagClient", "AssignToAPI", err.Error()) 77 } 78 79 req, err := client.AssignToAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToAPI", nil, "Failure preparing request") 82 return 83 } 84 85 resp, err := client.AssignToAPISender(req) 86 if err != nil { 87 result.Response = autorest.Response{Response: resp} 88 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToAPI", resp, "Failure sending request") 89 return 90 } 91 92 result, err = client.AssignToAPIResponder(resp) 93 if err != nil { 94 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToAPI", resp, "Failure responding to request") 95 return 96 } 97 98 return 99} 100 101// AssignToAPIPreparer prepares the AssignToAPI request. 102func (client TagClient) AssignToAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { 103 pathParameters := map[string]interface{}{ 104 "apiId": autorest.Encode("path", apiid), 105 "resourceGroupName": autorest.Encode("path", resourceGroupName), 106 "serviceName": autorest.Encode("path", serviceName), 107 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 108 "tagId": autorest.Encode("path", tagID), 109 } 110 111 const APIVersion = "2020-12-01" 112 queryParameters := map[string]interface{}{ 113 "api-version": APIVersion, 114 } 115 116 preparer := autorest.CreatePreparer( 117 autorest.AsPut(), 118 autorest.WithBaseURL(client.BaseURI), 119 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), 120 autorest.WithQueryParameters(queryParameters)) 121 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 122} 123 124// AssignToAPISender sends the AssignToAPI request. The method will close the 125// http.Response Body if it receives an error. 126func (client TagClient) AssignToAPISender(req *http.Request) (*http.Response, error) { 127 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 128} 129 130// AssignToAPIResponder handles the response to the AssignToAPI request. The method always 131// closes the http.Response Body. 132func (client TagClient) AssignToAPIResponder(resp *http.Response) (result TagContract, err error) { 133 err = autorest.Respond( 134 resp, 135 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 136 autorest.ByUnmarshallingJSON(&result), 137 autorest.ByClosing()) 138 result.Response = autorest.Response{Response: resp} 139 return 140} 141 142// AssignToOperation assign tag to the Operation. 143// Parameters: 144// resourceGroupName - the name of the resource group. 145// serviceName - the name of the API Management service. 146// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 147// revision has ;rev=n as a suffix where n is the revision number. 148// operationID - operation identifier within an API. Must be unique in the current API Management service 149// instance. 150// tagID - tag identifier. Must be unique in the current API Management service instance. 151func (client TagClient) AssignToOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result TagContract, err error) { 152 if tracing.IsEnabled() { 153 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.AssignToOperation") 154 defer func() { 155 sc := -1 156 if result.Response.Response != nil { 157 sc = result.Response.Response.StatusCode 158 } 159 tracing.EndSpan(ctx, sc, err) 160 }() 161 } 162 if err := validation.Validate([]validation.Validation{ 163 {TargetValue: serviceName, 164 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 165 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 166 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 167 {TargetValue: apiid, 168 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 169 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 170 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 171 {TargetValue: operationID, 172 Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 173 {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 174 {TargetValue: tagID, 175 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 176 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 177 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 178 return result, validation.NewError("apimanagement.TagClient", "AssignToOperation", err.Error()) 179 } 180 181 req, err := client.AssignToOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) 182 if err != nil { 183 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToOperation", nil, "Failure preparing request") 184 return 185 } 186 187 resp, err := client.AssignToOperationSender(req) 188 if err != nil { 189 result.Response = autorest.Response{Response: resp} 190 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToOperation", resp, "Failure sending request") 191 return 192 } 193 194 result, err = client.AssignToOperationResponder(resp) 195 if err != nil { 196 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToOperation", resp, "Failure responding to request") 197 return 198 } 199 200 return 201} 202 203// AssignToOperationPreparer prepares the AssignToOperation request. 204func (client TagClient) AssignToOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { 205 pathParameters := map[string]interface{}{ 206 "apiId": autorest.Encode("path", apiid), 207 "operationId": autorest.Encode("path", operationID), 208 "resourceGroupName": autorest.Encode("path", resourceGroupName), 209 "serviceName": autorest.Encode("path", serviceName), 210 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 211 "tagId": autorest.Encode("path", tagID), 212 } 213 214 const APIVersion = "2020-12-01" 215 queryParameters := map[string]interface{}{ 216 "api-version": APIVersion, 217 } 218 219 preparer := autorest.CreatePreparer( 220 autorest.AsPut(), 221 autorest.WithBaseURL(client.BaseURI), 222 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), 223 autorest.WithQueryParameters(queryParameters)) 224 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 225} 226 227// AssignToOperationSender sends the AssignToOperation request. The method will close the 228// http.Response Body if it receives an error. 229func (client TagClient) AssignToOperationSender(req *http.Request) (*http.Response, error) { 230 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 231} 232 233// AssignToOperationResponder handles the response to the AssignToOperation request. The method always 234// closes the http.Response Body. 235func (client TagClient) AssignToOperationResponder(resp *http.Response) (result TagContract, err error) { 236 err = autorest.Respond( 237 resp, 238 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 239 autorest.ByUnmarshallingJSON(&result), 240 autorest.ByClosing()) 241 result.Response = autorest.Response{Response: resp} 242 return 243} 244 245// AssignToProduct assign tag to the Product. 246// Parameters: 247// resourceGroupName - the name of the resource group. 248// serviceName - the name of the API Management service. 249// productID - product identifier. Must be unique in the current API Management service instance. 250// tagID - tag identifier. Must be unique in the current API Management service instance. 251func (client TagClient) AssignToProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result TagContract, err error) { 252 if tracing.IsEnabled() { 253 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.AssignToProduct") 254 defer func() { 255 sc := -1 256 if result.Response.Response != nil { 257 sc = result.Response.Response.StatusCode 258 } 259 tracing.EndSpan(ctx, sc, err) 260 }() 261 } 262 if err := validation.Validate([]validation.Validation{ 263 {TargetValue: serviceName, 264 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 265 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 266 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 267 {TargetValue: productID, 268 Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 269 {Target: "productID", Name: validation.MinLength, Rule: 1, 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: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 274 return result, validation.NewError("apimanagement.TagClient", "AssignToProduct", err.Error()) 275 } 276 277 req, err := client.AssignToProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) 278 if err != nil { 279 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToProduct", nil, "Failure preparing request") 280 return 281 } 282 283 resp, err := client.AssignToProductSender(req) 284 if err != nil { 285 result.Response = autorest.Response{Response: resp} 286 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToProduct", resp, "Failure sending request") 287 return 288 } 289 290 result, err = client.AssignToProductResponder(resp) 291 if err != nil { 292 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToProduct", resp, "Failure responding to request") 293 return 294 } 295 296 return 297} 298 299// AssignToProductPreparer prepares the AssignToProduct request. 300func (client TagClient) AssignToProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { 301 pathParameters := map[string]interface{}{ 302 "productId": autorest.Encode("path", productID), 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 = "2020-12-01" 310 queryParameters := map[string]interface{}{ 311 "api-version": APIVersion, 312 } 313 314 preparer := autorest.CreatePreparer( 315 autorest.AsPut(), 316 autorest.WithBaseURL(client.BaseURI), 317 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), 318 autorest.WithQueryParameters(queryParameters)) 319 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 320} 321 322// AssignToProductSender sends the AssignToProduct request. The method will close the 323// http.Response Body if it receives an error. 324func (client TagClient) AssignToProductSender(req *http.Request) (*http.Response, error) { 325 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 326} 327 328// AssignToProductResponder handles the response to the AssignToProduct request. The method always 329// closes the http.Response Body. 330func (client TagClient) AssignToProductResponder(resp *http.Response) (result TagContract, err error) { 331 err = autorest.Respond( 332 resp, 333 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 334 autorest.ByUnmarshallingJSON(&result), 335 autorest.ByClosing()) 336 result.Response = autorest.Response{Response: resp} 337 return 338} 339 340// CreateOrUpdate creates a tag. 341// Parameters: 342// resourceGroupName - the name of the resource group. 343// serviceName - the name of the API Management service. 344// tagID - tag identifier. Must be unique in the current API Management service instance. 345// parameters - create parameters. 346// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. 347func (client TagClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (result TagContract, err error) { 348 if tracing.IsEnabled() { 349 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.CreateOrUpdate") 350 defer func() { 351 sc := -1 352 if result.Response.Response != nil { 353 sc = result.Response.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: tagID, 364 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 365 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 366 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 367 {TargetValue: parameters, 368 Constraints: []validation.Constraint{{Target: "parameters.TagContractProperties", Name: validation.Null, Rule: false, 369 Chain: []validation.Constraint{{Target: "parameters.TagContractProperties.DisplayName", Name: validation.Null, Rule: true, 370 Chain: []validation.Constraint{{Target: "parameters.TagContractProperties.DisplayName", Name: validation.MaxLength, Rule: 160, Chain: nil}, 371 {Target: "parameters.TagContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, 372 }}, 373 }}}}}); err != nil { 374 return result, validation.NewError("apimanagement.TagClient", "CreateOrUpdate", err.Error()) 375 } 376 377 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, tagID, parameters, ifMatch) 378 if err != nil { 379 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "CreateOrUpdate", nil, "Failure preparing request") 380 return 381 } 382 383 resp, err := client.CreateOrUpdateSender(req) 384 if err != nil { 385 result.Response = autorest.Response{Response: resp} 386 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "CreateOrUpdate", resp, "Failure sending request") 387 return 388 } 389 390 result, err = client.CreateOrUpdateResponder(resp) 391 if err != nil { 392 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "CreateOrUpdate", resp, "Failure responding to request") 393 return 394 } 395 396 return 397} 398 399// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 400func (client TagClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (*http.Request, error) { 401 pathParameters := map[string]interface{}{ 402 "resourceGroupName": autorest.Encode("path", resourceGroupName), 403 "serviceName": autorest.Encode("path", serviceName), 404 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 405 "tagId": autorest.Encode("path", tagID), 406 } 407 408 const APIVersion = "2020-12-01" 409 queryParameters := map[string]interface{}{ 410 "api-version": APIVersion, 411 } 412 413 preparer := autorest.CreatePreparer( 414 autorest.AsContentType("application/json; charset=utf-8"), 415 autorest.AsPut(), 416 autorest.WithBaseURL(client.BaseURI), 417 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), 418 autorest.WithJSON(parameters), 419 autorest.WithQueryParameters(queryParameters)) 420 if len(ifMatch) > 0 { 421 preparer = autorest.DecoratePreparer(preparer, 422 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 423 } 424 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 425} 426 427// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 428// http.Response Body if it receives an error. 429func (client TagClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 430 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 431} 432 433// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 434// closes the http.Response Body. 435func (client TagClient) CreateOrUpdateResponder(resp *http.Response) (result TagContract, err error) { 436 err = autorest.Respond( 437 resp, 438 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 439 autorest.ByUnmarshallingJSON(&result), 440 autorest.ByClosing()) 441 result.Response = autorest.Response{Response: resp} 442 return 443} 444 445// Delete deletes specific tag of the API Management service instance. 446// Parameters: 447// resourceGroupName - the name of the resource group. 448// serviceName - the name of the API Management service. 449// tagID - tag identifier. Must be unique in the current API Management service instance. 450// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 451// request or it should be * for unconditional update. 452func (client TagClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string) (result autorest.Response, err error) { 453 if tracing.IsEnabled() { 454 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.Delete") 455 defer func() { 456 sc := -1 457 if result.Response != nil { 458 sc = result.Response.StatusCode 459 } 460 tracing.EndSpan(ctx, sc, err) 461 }() 462 } 463 if err := validation.Validate([]validation.Validation{ 464 {TargetValue: serviceName, 465 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 466 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 467 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 468 {TargetValue: tagID, 469 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 470 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 471 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 472 return result, validation.NewError("apimanagement.TagClient", "Delete", err.Error()) 473 } 474 475 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, tagID, ifMatch) 476 if err != nil { 477 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Delete", nil, "Failure preparing request") 478 return 479 } 480 481 resp, err := client.DeleteSender(req) 482 if err != nil { 483 result.Response = resp 484 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Delete", resp, "Failure sending request") 485 return 486 } 487 488 result, err = client.DeleteResponder(resp) 489 if err != nil { 490 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Delete", resp, "Failure responding to request") 491 return 492 } 493 494 return 495} 496 497// DeletePreparer prepares the Delete request. 498func (client TagClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string) (*http.Request, error) { 499 pathParameters := map[string]interface{}{ 500 "resourceGroupName": autorest.Encode("path", resourceGroupName), 501 "serviceName": autorest.Encode("path", serviceName), 502 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 503 "tagId": autorest.Encode("path", tagID), 504 } 505 506 const APIVersion = "2020-12-01" 507 queryParameters := map[string]interface{}{ 508 "api-version": APIVersion, 509 } 510 511 preparer := autorest.CreatePreparer( 512 autorest.AsDelete(), 513 autorest.WithBaseURL(client.BaseURI), 514 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), 515 autorest.WithQueryParameters(queryParameters), 516 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 517 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 518} 519 520// DeleteSender sends the Delete request. The method will close the 521// http.Response Body if it receives an error. 522func (client TagClient) DeleteSender(req *http.Request) (*http.Response, error) { 523 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 524} 525 526// DeleteResponder handles the response to the Delete request. The method always 527// closes the http.Response Body. 528func (client TagClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 529 err = autorest.Respond( 530 resp, 531 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 532 autorest.ByClosing()) 533 result.Response = resp 534 return 535} 536 537// DetachFromAPI detach the tag from the Api. 538// Parameters: 539// resourceGroupName - the name of the resource group. 540// serviceName - the name of the API Management service. 541// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 542// revision has ;rev=n as a suffix where n is the revision number. 543// tagID - tag identifier. Must be unique in the current API Management service instance. 544func (client TagClient) DetachFromAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) { 545 if tracing.IsEnabled() { 546 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.DetachFromAPI") 547 defer func() { 548 sc := -1 549 if result.Response != nil { 550 sc = result.Response.StatusCode 551 } 552 tracing.EndSpan(ctx, sc, err) 553 }() 554 } 555 if err := validation.Validate([]validation.Validation{ 556 {TargetValue: serviceName, 557 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 558 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 559 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 560 {TargetValue: apiid, 561 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 562 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 563 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 564 {TargetValue: tagID, 565 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 566 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 567 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 568 return result, validation.NewError("apimanagement.TagClient", "DetachFromAPI", err.Error()) 569 } 570 571 req, err := client.DetachFromAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) 572 if err != nil { 573 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromAPI", nil, "Failure preparing request") 574 return 575 } 576 577 resp, err := client.DetachFromAPISender(req) 578 if err != nil { 579 result.Response = resp 580 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromAPI", resp, "Failure sending request") 581 return 582 } 583 584 result, err = client.DetachFromAPIResponder(resp) 585 if err != nil { 586 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromAPI", resp, "Failure responding to request") 587 return 588 } 589 590 return 591} 592 593// DetachFromAPIPreparer prepares the DetachFromAPI request. 594func (client TagClient) DetachFromAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { 595 pathParameters := map[string]interface{}{ 596 "apiId": autorest.Encode("path", apiid), 597 "resourceGroupName": autorest.Encode("path", resourceGroupName), 598 "serviceName": autorest.Encode("path", serviceName), 599 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 600 "tagId": autorest.Encode("path", tagID), 601 } 602 603 const APIVersion = "2020-12-01" 604 queryParameters := map[string]interface{}{ 605 "api-version": APIVersion, 606 } 607 608 preparer := autorest.CreatePreparer( 609 autorest.AsDelete(), 610 autorest.WithBaseURL(client.BaseURI), 611 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), 612 autorest.WithQueryParameters(queryParameters)) 613 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 614} 615 616// DetachFromAPISender sends the DetachFromAPI request. The method will close the 617// http.Response Body if it receives an error. 618func (client TagClient) DetachFromAPISender(req *http.Request) (*http.Response, error) { 619 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 620} 621 622// DetachFromAPIResponder handles the response to the DetachFromAPI request. The method always 623// closes the http.Response Body. 624func (client TagClient) DetachFromAPIResponder(resp *http.Response) (result autorest.Response, err error) { 625 err = autorest.Respond( 626 resp, 627 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 628 autorest.ByClosing()) 629 result.Response = resp 630 return 631} 632 633// DetachFromOperation detach the tag from the Operation. 634// Parameters: 635// resourceGroupName - the name of the resource group. 636// serviceName - the name of the API Management service. 637// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 638// revision has ;rev=n as a suffix where n is the revision number. 639// operationID - operation identifier within an API. Must be unique in the current API Management service 640// instance. 641// tagID - tag identifier. Must be unique in the current API Management service instance. 642func (client TagClient) DetachFromOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result autorest.Response, err error) { 643 if tracing.IsEnabled() { 644 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.DetachFromOperation") 645 defer func() { 646 sc := -1 647 if result.Response != nil { 648 sc = result.Response.StatusCode 649 } 650 tracing.EndSpan(ctx, sc, err) 651 }() 652 } 653 if err := validation.Validate([]validation.Validation{ 654 {TargetValue: serviceName, 655 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 656 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 657 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 658 {TargetValue: apiid, 659 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 660 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 661 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 662 {TargetValue: operationID, 663 Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 664 {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 665 {TargetValue: tagID, 666 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 667 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 668 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 669 return result, validation.NewError("apimanagement.TagClient", "DetachFromOperation", err.Error()) 670 } 671 672 req, err := client.DetachFromOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) 673 if err != nil { 674 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromOperation", nil, "Failure preparing request") 675 return 676 } 677 678 resp, err := client.DetachFromOperationSender(req) 679 if err != nil { 680 result.Response = resp 681 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromOperation", resp, "Failure sending request") 682 return 683 } 684 685 result, err = client.DetachFromOperationResponder(resp) 686 if err != nil { 687 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromOperation", resp, "Failure responding to request") 688 return 689 } 690 691 return 692} 693 694// DetachFromOperationPreparer prepares the DetachFromOperation request. 695func (client TagClient) DetachFromOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { 696 pathParameters := map[string]interface{}{ 697 "apiId": autorest.Encode("path", apiid), 698 "operationId": autorest.Encode("path", operationID), 699 "resourceGroupName": autorest.Encode("path", resourceGroupName), 700 "serviceName": autorest.Encode("path", serviceName), 701 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 702 "tagId": autorest.Encode("path", tagID), 703 } 704 705 const APIVersion = "2020-12-01" 706 queryParameters := map[string]interface{}{ 707 "api-version": APIVersion, 708 } 709 710 preparer := autorest.CreatePreparer( 711 autorest.AsDelete(), 712 autorest.WithBaseURL(client.BaseURI), 713 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), 714 autorest.WithQueryParameters(queryParameters)) 715 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 716} 717 718// DetachFromOperationSender sends the DetachFromOperation request. The method will close the 719// http.Response Body if it receives an error. 720func (client TagClient) DetachFromOperationSender(req *http.Request) (*http.Response, error) { 721 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 722} 723 724// DetachFromOperationResponder handles the response to the DetachFromOperation request. The method always 725// closes the http.Response Body. 726func (client TagClient) DetachFromOperationResponder(resp *http.Response) (result autorest.Response, err error) { 727 err = autorest.Respond( 728 resp, 729 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 730 autorest.ByClosing()) 731 result.Response = resp 732 return 733} 734 735// DetachFromProduct detach the tag from the Product. 736// Parameters: 737// resourceGroupName - the name of the resource group. 738// serviceName - the name of the API Management service. 739// productID - product identifier. Must be unique in the current API Management service instance. 740// tagID - tag identifier. Must be unique in the current API Management service instance. 741func (client TagClient) DetachFromProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result autorest.Response, err error) { 742 if tracing.IsEnabled() { 743 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.DetachFromProduct") 744 defer func() { 745 sc := -1 746 if result.Response != nil { 747 sc = result.Response.StatusCode 748 } 749 tracing.EndSpan(ctx, sc, err) 750 }() 751 } 752 if err := validation.Validate([]validation.Validation{ 753 {TargetValue: serviceName, 754 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 755 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 756 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 757 {TargetValue: productID, 758 Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 759 {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 760 {TargetValue: tagID, 761 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 762 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 763 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 764 return result, validation.NewError("apimanagement.TagClient", "DetachFromProduct", err.Error()) 765 } 766 767 req, err := client.DetachFromProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) 768 if err != nil { 769 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromProduct", nil, "Failure preparing request") 770 return 771 } 772 773 resp, err := client.DetachFromProductSender(req) 774 if err != nil { 775 result.Response = resp 776 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromProduct", resp, "Failure sending request") 777 return 778 } 779 780 result, err = client.DetachFromProductResponder(resp) 781 if err != nil { 782 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromProduct", resp, "Failure responding to request") 783 return 784 } 785 786 return 787} 788 789// DetachFromProductPreparer prepares the DetachFromProduct request. 790func (client TagClient) DetachFromProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { 791 pathParameters := map[string]interface{}{ 792 "productId": autorest.Encode("path", productID), 793 "resourceGroupName": autorest.Encode("path", resourceGroupName), 794 "serviceName": autorest.Encode("path", serviceName), 795 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 796 "tagId": autorest.Encode("path", tagID), 797 } 798 799 const APIVersion = "2020-12-01" 800 queryParameters := map[string]interface{}{ 801 "api-version": APIVersion, 802 } 803 804 preparer := autorest.CreatePreparer( 805 autorest.AsDelete(), 806 autorest.WithBaseURL(client.BaseURI), 807 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), 808 autorest.WithQueryParameters(queryParameters)) 809 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 810} 811 812// DetachFromProductSender sends the DetachFromProduct request. The method will close the 813// http.Response Body if it receives an error. 814func (client TagClient) DetachFromProductSender(req *http.Request) (*http.Response, error) { 815 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 816} 817 818// DetachFromProductResponder handles the response to the DetachFromProduct request. The method always 819// closes the http.Response Body. 820func (client TagClient) DetachFromProductResponder(resp *http.Response) (result autorest.Response, err error) { 821 err = autorest.Respond( 822 resp, 823 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 824 autorest.ByClosing()) 825 result.Response = resp 826 return 827} 828 829// Get gets the details of the tag specified by its identifier. 830// Parameters: 831// resourceGroupName - the name of the resource group. 832// serviceName - the name of the API Management service. 833// tagID - tag identifier. Must be unique in the current API Management service instance. 834func (client TagClient) Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (result TagContract, err error) { 835 if tracing.IsEnabled() { 836 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.Get") 837 defer func() { 838 sc := -1 839 if result.Response.Response != nil { 840 sc = result.Response.Response.StatusCode 841 } 842 tracing.EndSpan(ctx, sc, err) 843 }() 844 } 845 if err := validation.Validate([]validation.Validation{ 846 {TargetValue: serviceName, 847 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 848 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 849 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 850 {TargetValue: tagID, 851 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 852 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 853 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 854 return result, validation.NewError("apimanagement.TagClient", "Get", err.Error()) 855 } 856 857 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, tagID) 858 if err != nil { 859 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Get", nil, "Failure preparing request") 860 return 861 } 862 863 resp, err := client.GetSender(req) 864 if err != nil { 865 result.Response = autorest.Response{Response: resp} 866 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Get", resp, "Failure sending request") 867 return 868 } 869 870 result, err = client.GetResponder(resp) 871 if err != nil { 872 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Get", resp, "Failure responding to request") 873 return 874 } 875 876 return 877} 878 879// GetPreparer prepares the Get request. 880func (client TagClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (*http.Request, error) { 881 pathParameters := map[string]interface{}{ 882 "resourceGroupName": autorest.Encode("path", resourceGroupName), 883 "serviceName": autorest.Encode("path", serviceName), 884 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 885 "tagId": autorest.Encode("path", tagID), 886 } 887 888 const APIVersion = "2020-12-01" 889 queryParameters := map[string]interface{}{ 890 "api-version": APIVersion, 891 } 892 893 preparer := autorest.CreatePreparer( 894 autorest.AsGet(), 895 autorest.WithBaseURL(client.BaseURI), 896 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), 897 autorest.WithQueryParameters(queryParameters)) 898 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 899} 900 901// GetSender sends the Get request. The method will close the 902// http.Response Body if it receives an error. 903func (client TagClient) GetSender(req *http.Request) (*http.Response, error) { 904 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 905} 906 907// GetResponder handles the response to the Get request. The method always 908// closes the http.Response Body. 909func (client TagClient) GetResponder(resp *http.Response) (result TagContract, err error) { 910 err = autorest.Respond( 911 resp, 912 azure.WithErrorUnlessStatusCode(http.StatusOK), 913 autorest.ByUnmarshallingJSON(&result), 914 autorest.ByClosing()) 915 result.Response = autorest.Response{Response: resp} 916 return 917} 918 919// GetByAPI get tag associated with the API. 920// Parameters: 921// resourceGroupName - the name of the resource group. 922// serviceName - the name of the API Management service. 923// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 924// revision has ;rev=n as a suffix where n is the revision number. 925// tagID - tag identifier. Must be unique in the current API Management service instance. 926func (client TagClient) GetByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result TagContract, err error) { 927 if tracing.IsEnabled() { 928 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetByAPI") 929 defer func() { 930 sc := -1 931 if result.Response.Response != nil { 932 sc = result.Response.Response.StatusCode 933 } 934 tracing.EndSpan(ctx, sc, err) 935 }() 936 } 937 if err := validation.Validate([]validation.Validation{ 938 {TargetValue: serviceName, 939 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 940 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 941 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 942 {TargetValue: apiid, 943 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 944 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 945 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 946 {TargetValue: tagID, 947 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 948 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 949 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 950 return result, validation.NewError("apimanagement.TagClient", "GetByAPI", err.Error()) 951 } 952 953 req, err := client.GetByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) 954 if err != nil { 955 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByAPI", nil, "Failure preparing request") 956 return 957 } 958 959 resp, err := client.GetByAPISender(req) 960 if err != nil { 961 result.Response = autorest.Response{Response: resp} 962 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByAPI", resp, "Failure sending request") 963 return 964 } 965 966 result, err = client.GetByAPIResponder(resp) 967 if err != nil { 968 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByAPI", resp, "Failure responding to request") 969 return 970 } 971 972 return 973} 974 975// GetByAPIPreparer prepares the GetByAPI request. 976func (client TagClient) GetByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { 977 pathParameters := map[string]interface{}{ 978 "apiId": autorest.Encode("path", apiid), 979 "resourceGroupName": autorest.Encode("path", resourceGroupName), 980 "serviceName": autorest.Encode("path", serviceName), 981 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 982 "tagId": autorest.Encode("path", tagID), 983 } 984 985 const APIVersion = "2020-12-01" 986 queryParameters := map[string]interface{}{ 987 "api-version": APIVersion, 988 } 989 990 preparer := autorest.CreatePreparer( 991 autorest.AsGet(), 992 autorest.WithBaseURL(client.BaseURI), 993 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), 994 autorest.WithQueryParameters(queryParameters)) 995 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 996} 997 998// GetByAPISender sends the GetByAPI request. The method will close the 999// http.Response Body if it receives an error. 1000func (client TagClient) GetByAPISender(req *http.Request) (*http.Response, error) { 1001 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1002} 1003 1004// GetByAPIResponder handles the response to the GetByAPI request. The method always 1005// closes the http.Response Body. 1006func (client TagClient) GetByAPIResponder(resp *http.Response) (result TagContract, err error) { 1007 err = autorest.Respond( 1008 resp, 1009 azure.WithErrorUnlessStatusCode(http.StatusOK), 1010 autorest.ByUnmarshallingJSON(&result), 1011 autorest.ByClosing()) 1012 result.Response = autorest.Response{Response: resp} 1013 return 1014} 1015 1016// GetByOperation get tag associated with the Operation. 1017// Parameters: 1018// resourceGroupName - the name of the resource group. 1019// serviceName - the name of the API Management service. 1020// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 1021// revision has ;rev=n as a suffix where n is the revision number. 1022// operationID - operation identifier within an API. Must be unique in the current API Management service 1023// instance. 1024// tagID - tag identifier. Must be unique in the current API Management service instance. 1025func (client TagClient) GetByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result TagContract, err error) { 1026 if tracing.IsEnabled() { 1027 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetByOperation") 1028 defer func() { 1029 sc := -1 1030 if result.Response.Response != nil { 1031 sc = result.Response.Response.StatusCode 1032 } 1033 tracing.EndSpan(ctx, sc, err) 1034 }() 1035 } 1036 if err := validation.Validate([]validation.Validation{ 1037 {TargetValue: serviceName, 1038 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1039 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1040 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1041 {TargetValue: apiid, 1042 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1043 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 1044 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 1045 {TargetValue: operationID, 1046 Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1047 {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1048 {TargetValue: tagID, 1049 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1050 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 1051 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 1052 return result, validation.NewError("apimanagement.TagClient", "GetByOperation", err.Error()) 1053 } 1054 1055 req, err := client.GetByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) 1056 if err != nil { 1057 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByOperation", nil, "Failure preparing request") 1058 return 1059 } 1060 1061 resp, err := client.GetByOperationSender(req) 1062 if err != nil { 1063 result.Response = autorest.Response{Response: resp} 1064 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByOperation", resp, "Failure sending request") 1065 return 1066 } 1067 1068 result, err = client.GetByOperationResponder(resp) 1069 if err != nil { 1070 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByOperation", resp, "Failure responding to request") 1071 return 1072 } 1073 1074 return 1075} 1076 1077// GetByOperationPreparer prepares the GetByOperation request. 1078func (client TagClient) GetByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { 1079 pathParameters := map[string]interface{}{ 1080 "apiId": autorest.Encode("path", apiid), 1081 "operationId": autorest.Encode("path", operationID), 1082 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1083 "serviceName": autorest.Encode("path", serviceName), 1084 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1085 "tagId": autorest.Encode("path", tagID), 1086 } 1087 1088 const APIVersion = "2020-12-01" 1089 queryParameters := map[string]interface{}{ 1090 "api-version": APIVersion, 1091 } 1092 1093 preparer := autorest.CreatePreparer( 1094 autorest.AsGet(), 1095 autorest.WithBaseURL(client.BaseURI), 1096 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), 1097 autorest.WithQueryParameters(queryParameters)) 1098 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1099} 1100 1101// GetByOperationSender sends the GetByOperation request. The method will close the 1102// http.Response Body if it receives an error. 1103func (client TagClient) GetByOperationSender(req *http.Request) (*http.Response, error) { 1104 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1105} 1106 1107// GetByOperationResponder handles the response to the GetByOperation request. The method always 1108// closes the http.Response Body. 1109func (client TagClient) GetByOperationResponder(resp *http.Response) (result TagContract, err error) { 1110 err = autorest.Respond( 1111 resp, 1112 azure.WithErrorUnlessStatusCode(http.StatusOK), 1113 autorest.ByUnmarshallingJSON(&result), 1114 autorest.ByClosing()) 1115 result.Response = autorest.Response{Response: resp} 1116 return 1117} 1118 1119// GetByProduct get tag associated with the Product. 1120// Parameters: 1121// resourceGroupName - the name of the resource group. 1122// serviceName - the name of the API Management service. 1123// productID - product identifier. Must be unique in the current API Management service instance. 1124// tagID - tag identifier. Must be unique in the current API Management service instance. 1125func (client TagClient) GetByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result TagContract, err error) { 1126 if tracing.IsEnabled() { 1127 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetByProduct") 1128 defer func() { 1129 sc := -1 1130 if result.Response.Response != nil { 1131 sc = result.Response.Response.StatusCode 1132 } 1133 tracing.EndSpan(ctx, sc, err) 1134 }() 1135 } 1136 if err := validation.Validate([]validation.Validation{ 1137 {TargetValue: serviceName, 1138 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1139 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1140 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1141 {TargetValue: productID, 1142 Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1143 {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1144 {TargetValue: tagID, 1145 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1146 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 1147 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 1148 return result, validation.NewError("apimanagement.TagClient", "GetByProduct", err.Error()) 1149 } 1150 1151 req, err := client.GetByProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) 1152 if err != nil { 1153 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByProduct", nil, "Failure preparing request") 1154 return 1155 } 1156 1157 resp, err := client.GetByProductSender(req) 1158 if err != nil { 1159 result.Response = autorest.Response{Response: resp} 1160 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByProduct", resp, "Failure sending request") 1161 return 1162 } 1163 1164 result, err = client.GetByProductResponder(resp) 1165 if err != nil { 1166 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByProduct", resp, "Failure responding to request") 1167 return 1168 } 1169 1170 return 1171} 1172 1173// GetByProductPreparer prepares the GetByProduct request. 1174func (client TagClient) GetByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { 1175 pathParameters := map[string]interface{}{ 1176 "productId": autorest.Encode("path", productID), 1177 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1178 "serviceName": autorest.Encode("path", serviceName), 1179 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1180 "tagId": autorest.Encode("path", tagID), 1181 } 1182 1183 const APIVersion = "2020-12-01" 1184 queryParameters := map[string]interface{}{ 1185 "api-version": APIVersion, 1186 } 1187 1188 preparer := autorest.CreatePreparer( 1189 autorest.AsGet(), 1190 autorest.WithBaseURL(client.BaseURI), 1191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), 1192 autorest.WithQueryParameters(queryParameters)) 1193 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1194} 1195 1196// GetByProductSender sends the GetByProduct request. The method will close the 1197// http.Response Body if it receives an error. 1198func (client TagClient) GetByProductSender(req *http.Request) (*http.Response, error) { 1199 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1200} 1201 1202// GetByProductResponder handles the response to the GetByProduct request. The method always 1203// closes the http.Response Body. 1204func (client TagClient) GetByProductResponder(resp *http.Response) (result TagContract, err error) { 1205 err = autorest.Respond( 1206 resp, 1207 azure.WithErrorUnlessStatusCode(http.StatusOK), 1208 autorest.ByUnmarshallingJSON(&result), 1209 autorest.ByClosing()) 1210 result.Response = autorest.Response{Response: resp} 1211 return 1212} 1213 1214// GetEntityState gets the entity state version of the tag specified by its identifier. 1215// Parameters: 1216// resourceGroupName - the name of the resource group. 1217// serviceName - the name of the API Management service. 1218// tagID - tag identifier. Must be unique in the current API Management service instance. 1219func (client TagClient) GetEntityState(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (result autorest.Response, err error) { 1220 if tracing.IsEnabled() { 1221 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityState") 1222 defer func() { 1223 sc := -1 1224 if result.Response != nil { 1225 sc = result.Response.StatusCode 1226 } 1227 tracing.EndSpan(ctx, sc, err) 1228 }() 1229 } 1230 if err := validation.Validate([]validation.Validation{ 1231 {TargetValue: serviceName, 1232 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1233 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1234 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1235 {TargetValue: tagID, 1236 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1237 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 1238 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 1239 return result, validation.NewError("apimanagement.TagClient", "GetEntityState", err.Error()) 1240 } 1241 1242 req, err := client.GetEntityStatePreparer(ctx, resourceGroupName, serviceName, tagID) 1243 if err != nil { 1244 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityState", nil, "Failure preparing request") 1245 return 1246 } 1247 1248 resp, err := client.GetEntityStateSender(req) 1249 if err != nil { 1250 result.Response = resp 1251 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityState", resp, "Failure sending request") 1252 return 1253 } 1254 1255 result, err = client.GetEntityStateResponder(resp) 1256 if err != nil { 1257 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityState", resp, "Failure responding to request") 1258 return 1259 } 1260 1261 return 1262} 1263 1264// GetEntityStatePreparer prepares the GetEntityState request. 1265func (client TagClient) GetEntityStatePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (*http.Request, error) { 1266 pathParameters := map[string]interface{}{ 1267 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1268 "serviceName": autorest.Encode("path", serviceName), 1269 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1270 "tagId": autorest.Encode("path", tagID), 1271 } 1272 1273 const APIVersion = "2020-12-01" 1274 queryParameters := map[string]interface{}{ 1275 "api-version": APIVersion, 1276 } 1277 1278 preparer := autorest.CreatePreparer( 1279 autorest.AsHead(), 1280 autorest.WithBaseURL(client.BaseURI), 1281 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), 1282 autorest.WithQueryParameters(queryParameters)) 1283 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1284} 1285 1286// GetEntityStateSender sends the GetEntityState request. The method will close the 1287// http.Response Body if it receives an error. 1288func (client TagClient) GetEntityStateSender(req *http.Request) (*http.Response, error) { 1289 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1290} 1291 1292// GetEntityStateResponder handles the response to the GetEntityState request. The method always 1293// closes the http.Response Body. 1294func (client TagClient) GetEntityStateResponder(resp *http.Response) (result autorest.Response, err error) { 1295 err = autorest.Respond( 1296 resp, 1297 azure.WithErrorUnlessStatusCode(http.StatusOK), 1298 autorest.ByClosing()) 1299 result.Response = resp 1300 return 1301} 1302 1303// GetEntityStateByAPI gets the entity state version of the tag specified by its identifier. 1304// Parameters: 1305// resourceGroupName - the name of the resource group. 1306// serviceName - the name of the API Management service. 1307// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 1308// revision has ;rev=n as a suffix where n is the revision number. 1309// tagID - tag identifier. Must be unique in the current API Management service instance. 1310func (client TagClient) GetEntityStateByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) { 1311 if tracing.IsEnabled() { 1312 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityStateByAPI") 1313 defer func() { 1314 sc := -1 1315 if result.Response != nil { 1316 sc = result.Response.StatusCode 1317 } 1318 tracing.EndSpan(ctx, sc, err) 1319 }() 1320 } 1321 if err := validation.Validate([]validation.Validation{ 1322 {TargetValue: serviceName, 1323 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1324 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1325 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1326 {TargetValue: apiid, 1327 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1328 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 1329 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 1330 {TargetValue: tagID, 1331 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1332 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 1333 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 1334 return result, validation.NewError("apimanagement.TagClient", "GetEntityStateByAPI", err.Error()) 1335 } 1336 1337 req, err := client.GetEntityStateByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) 1338 if err != nil { 1339 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByAPI", nil, "Failure preparing request") 1340 return 1341 } 1342 1343 resp, err := client.GetEntityStateByAPISender(req) 1344 if err != nil { 1345 result.Response = resp 1346 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByAPI", resp, "Failure sending request") 1347 return 1348 } 1349 1350 result, err = client.GetEntityStateByAPIResponder(resp) 1351 if err != nil { 1352 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByAPI", resp, "Failure responding to request") 1353 return 1354 } 1355 1356 return 1357} 1358 1359// GetEntityStateByAPIPreparer prepares the GetEntityStateByAPI request. 1360func (client TagClient) GetEntityStateByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { 1361 pathParameters := map[string]interface{}{ 1362 "apiId": autorest.Encode("path", apiid), 1363 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1364 "serviceName": autorest.Encode("path", serviceName), 1365 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1366 "tagId": autorest.Encode("path", tagID), 1367 } 1368 1369 const APIVersion = "2020-12-01" 1370 queryParameters := map[string]interface{}{ 1371 "api-version": APIVersion, 1372 } 1373 1374 preparer := autorest.CreatePreparer( 1375 autorest.AsHead(), 1376 autorest.WithBaseURL(client.BaseURI), 1377 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), 1378 autorest.WithQueryParameters(queryParameters)) 1379 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1380} 1381 1382// GetEntityStateByAPISender sends the GetEntityStateByAPI request. The method will close the 1383// http.Response Body if it receives an error. 1384func (client TagClient) GetEntityStateByAPISender(req *http.Request) (*http.Response, error) { 1385 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1386} 1387 1388// GetEntityStateByAPIResponder handles the response to the GetEntityStateByAPI request. The method always 1389// closes the http.Response Body. 1390func (client TagClient) GetEntityStateByAPIResponder(resp *http.Response) (result autorest.Response, err error) { 1391 err = autorest.Respond( 1392 resp, 1393 azure.WithErrorUnlessStatusCode(http.StatusOK), 1394 autorest.ByClosing()) 1395 result.Response = resp 1396 return 1397} 1398 1399// GetEntityStateByOperation gets the entity state version of the tag specified by its identifier. 1400// Parameters: 1401// resourceGroupName - the name of the resource group. 1402// serviceName - the name of the API Management service. 1403// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 1404// revision has ;rev=n as a suffix where n is the revision number. 1405// operationID - operation identifier within an API. Must be unique in the current API Management service 1406// instance. 1407// tagID - tag identifier. Must be unique in the current API Management service instance. 1408func (client TagClient) GetEntityStateByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result autorest.Response, err error) { 1409 if tracing.IsEnabled() { 1410 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityStateByOperation") 1411 defer func() { 1412 sc := -1 1413 if result.Response != nil { 1414 sc = result.Response.StatusCode 1415 } 1416 tracing.EndSpan(ctx, sc, err) 1417 }() 1418 } 1419 if err := validation.Validate([]validation.Validation{ 1420 {TargetValue: serviceName, 1421 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1422 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1423 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1424 {TargetValue: apiid, 1425 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1426 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 1427 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 1428 {TargetValue: operationID, 1429 Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1430 {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1431 {TargetValue: tagID, 1432 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1433 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 1434 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 1435 return result, validation.NewError("apimanagement.TagClient", "GetEntityStateByOperation", err.Error()) 1436 } 1437 1438 req, err := client.GetEntityStateByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) 1439 if err != nil { 1440 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByOperation", nil, "Failure preparing request") 1441 return 1442 } 1443 1444 resp, err := client.GetEntityStateByOperationSender(req) 1445 if err != nil { 1446 result.Response = resp 1447 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByOperation", resp, "Failure sending request") 1448 return 1449 } 1450 1451 result, err = client.GetEntityStateByOperationResponder(resp) 1452 if err != nil { 1453 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByOperation", resp, "Failure responding to request") 1454 return 1455 } 1456 1457 return 1458} 1459 1460// GetEntityStateByOperationPreparer prepares the GetEntityStateByOperation request. 1461func (client TagClient) GetEntityStateByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { 1462 pathParameters := map[string]interface{}{ 1463 "apiId": autorest.Encode("path", apiid), 1464 "operationId": autorest.Encode("path", operationID), 1465 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1466 "serviceName": autorest.Encode("path", serviceName), 1467 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1468 "tagId": autorest.Encode("path", tagID), 1469 } 1470 1471 const APIVersion = "2020-12-01" 1472 queryParameters := map[string]interface{}{ 1473 "api-version": APIVersion, 1474 } 1475 1476 preparer := autorest.CreatePreparer( 1477 autorest.AsHead(), 1478 autorest.WithBaseURL(client.BaseURI), 1479 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), 1480 autorest.WithQueryParameters(queryParameters)) 1481 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1482} 1483 1484// GetEntityStateByOperationSender sends the GetEntityStateByOperation request. The method will close the 1485// http.Response Body if it receives an error. 1486func (client TagClient) GetEntityStateByOperationSender(req *http.Request) (*http.Response, error) { 1487 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1488} 1489 1490// GetEntityStateByOperationResponder handles the response to the GetEntityStateByOperation request. The method always 1491// closes the http.Response Body. 1492func (client TagClient) GetEntityStateByOperationResponder(resp *http.Response) (result autorest.Response, err error) { 1493 err = autorest.Respond( 1494 resp, 1495 azure.WithErrorUnlessStatusCode(http.StatusOK), 1496 autorest.ByClosing()) 1497 result.Response = resp 1498 return 1499} 1500 1501// GetEntityStateByProduct gets the entity state version of the tag specified by its identifier. 1502// Parameters: 1503// resourceGroupName - the name of the resource group. 1504// serviceName - the name of the API Management service. 1505// productID - product identifier. Must be unique in the current API Management service instance. 1506// tagID - tag identifier. Must be unique in the current API Management service instance. 1507func (client TagClient) GetEntityStateByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result autorest.Response, err error) { 1508 if tracing.IsEnabled() { 1509 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityStateByProduct") 1510 defer func() { 1511 sc := -1 1512 if result.Response != nil { 1513 sc = result.Response.StatusCode 1514 } 1515 tracing.EndSpan(ctx, sc, err) 1516 }() 1517 } 1518 if err := validation.Validate([]validation.Validation{ 1519 {TargetValue: serviceName, 1520 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1521 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1522 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1523 {TargetValue: productID, 1524 Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1525 {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1526 {TargetValue: tagID, 1527 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1528 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 1529 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 1530 return result, validation.NewError("apimanagement.TagClient", "GetEntityStateByProduct", err.Error()) 1531 } 1532 1533 req, err := client.GetEntityStateByProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) 1534 if err != nil { 1535 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByProduct", nil, "Failure preparing request") 1536 return 1537 } 1538 1539 resp, err := client.GetEntityStateByProductSender(req) 1540 if err != nil { 1541 result.Response = resp 1542 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByProduct", resp, "Failure sending request") 1543 return 1544 } 1545 1546 result, err = client.GetEntityStateByProductResponder(resp) 1547 if err != nil { 1548 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByProduct", resp, "Failure responding to request") 1549 return 1550 } 1551 1552 return 1553} 1554 1555// GetEntityStateByProductPreparer prepares the GetEntityStateByProduct request. 1556func (client TagClient) GetEntityStateByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { 1557 pathParameters := map[string]interface{}{ 1558 "productId": autorest.Encode("path", productID), 1559 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1560 "serviceName": autorest.Encode("path", serviceName), 1561 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1562 "tagId": autorest.Encode("path", tagID), 1563 } 1564 1565 const APIVersion = "2020-12-01" 1566 queryParameters := map[string]interface{}{ 1567 "api-version": APIVersion, 1568 } 1569 1570 preparer := autorest.CreatePreparer( 1571 autorest.AsHead(), 1572 autorest.WithBaseURL(client.BaseURI), 1573 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), 1574 autorest.WithQueryParameters(queryParameters)) 1575 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1576} 1577 1578// GetEntityStateByProductSender sends the GetEntityStateByProduct request. The method will close the 1579// http.Response Body if it receives an error. 1580func (client TagClient) GetEntityStateByProductSender(req *http.Request) (*http.Response, error) { 1581 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1582} 1583 1584// GetEntityStateByProductResponder handles the response to the GetEntityStateByProduct request. The method always 1585// closes the http.Response Body. 1586func (client TagClient) GetEntityStateByProductResponder(resp *http.Response) (result autorest.Response, err error) { 1587 err = autorest.Respond( 1588 resp, 1589 azure.WithErrorUnlessStatusCode(http.StatusOK), 1590 autorest.ByClosing()) 1591 result.Response = resp 1592 return 1593} 1594 1595// ListByAPI lists all Tags associated with the API. 1596// Parameters: 1597// resourceGroupName - the name of the resource group. 1598// serviceName - the name of the API Management service. 1599// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 1600// revision has ;rev=n as a suffix where n is the revision number. 1601// filter - | Field | Usage | Supported operators | Supported functions 1602// |</br>|-------------|-------------|-------------|-------------|</br>| displayName | filter | ge, le, eq, ne, 1603// gt, lt | substringof, contains, startswith, endswith |</br>| name | filter | ge, le, eq, ne, gt, lt | 1604// substringof, contains, startswith, endswith |</br> 1605// top - number of records to return. 1606// skip - number of records to skip. 1607func (client TagClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagCollectionPage, err error) { 1608 if tracing.IsEnabled() { 1609 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByAPI") 1610 defer func() { 1611 sc := -1 1612 if result.tc.Response.Response != nil { 1613 sc = result.tc.Response.Response.StatusCode 1614 } 1615 tracing.EndSpan(ctx, sc, err) 1616 }() 1617 } 1618 if err := validation.Validate([]validation.Validation{ 1619 {TargetValue: serviceName, 1620 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1621 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1622 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1623 {TargetValue: apiid, 1624 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1625 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 1626 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 1627 {TargetValue: top, 1628 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1629 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 1630 {TargetValue: skip, 1631 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 1632 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1633 return result, validation.NewError("apimanagement.TagClient", "ListByAPI", err.Error()) 1634 } 1635 1636 result.fn = client.listByAPINextResults 1637 req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) 1638 if err != nil { 1639 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByAPI", nil, "Failure preparing request") 1640 return 1641 } 1642 1643 resp, err := client.ListByAPISender(req) 1644 if err != nil { 1645 result.tc.Response = autorest.Response{Response: resp} 1646 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByAPI", resp, "Failure sending request") 1647 return 1648 } 1649 1650 result.tc, err = client.ListByAPIResponder(resp) 1651 if err != nil { 1652 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByAPI", resp, "Failure responding to request") 1653 return 1654 } 1655 if result.tc.hasNextLink() && result.tc.IsEmpty() { 1656 err = result.NextWithContext(ctx) 1657 return 1658 } 1659 1660 return 1661} 1662 1663// ListByAPIPreparer prepares the ListByAPI request. 1664func (client TagClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { 1665 pathParameters := map[string]interface{}{ 1666 "apiId": autorest.Encode("path", apiid), 1667 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1668 "serviceName": autorest.Encode("path", serviceName), 1669 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1670 } 1671 1672 const APIVersion = "2020-12-01" 1673 queryParameters := map[string]interface{}{ 1674 "api-version": APIVersion, 1675 } 1676 if len(filter) > 0 { 1677 queryParameters["$filter"] = autorest.Encode("query", filter) 1678 } 1679 if top != nil { 1680 queryParameters["$top"] = autorest.Encode("query", *top) 1681 } 1682 if skip != nil { 1683 queryParameters["$skip"] = autorest.Encode("query", *skip) 1684 } 1685 1686 preparer := autorest.CreatePreparer( 1687 autorest.AsGet(), 1688 autorest.WithBaseURL(client.BaseURI), 1689 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags", pathParameters), 1690 autorest.WithQueryParameters(queryParameters)) 1691 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1692} 1693 1694// ListByAPISender sends the ListByAPI request. The method will close the 1695// http.Response Body if it receives an error. 1696func (client TagClient) ListByAPISender(req *http.Request) (*http.Response, error) { 1697 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1698} 1699 1700// ListByAPIResponder handles the response to the ListByAPI request. The method always 1701// closes the http.Response Body. 1702func (client TagClient) ListByAPIResponder(resp *http.Response) (result TagCollection, err error) { 1703 err = autorest.Respond( 1704 resp, 1705 azure.WithErrorUnlessStatusCode(http.StatusOK), 1706 autorest.ByUnmarshallingJSON(&result), 1707 autorest.ByClosing()) 1708 result.Response = autorest.Response{Response: resp} 1709 return 1710} 1711 1712// listByAPINextResults retrieves the next set of results, if any. 1713func (client TagClient) listByAPINextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { 1714 req, err := lastResults.tagCollectionPreparer(ctx) 1715 if err != nil { 1716 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByAPINextResults", nil, "Failure preparing next results request") 1717 } 1718 if req == nil { 1719 return 1720 } 1721 resp, err := client.ListByAPISender(req) 1722 if err != nil { 1723 result.Response = autorest.Response{Response: resp} 1724 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByAPINextResults", resp, "Failure sending next results request") 1725 } 1726 result, err = client.ListByAPIResponder(resp) 1727 if err != nil { 1728 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByAPINextResults", resp, "Failure responding to next results request") 1729 } 1730 return 1731} 1732 1733// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required. 1734func (client TagClient) ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagCollectionIterator, err error) { 1735 if tracing.IsEnabled() { 1736 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByAPI") 1737 defer func() { 1738 sc := -1 1739 if result.Response().Response.Response != nil { 1740 sc = result.page.Response().Response.Response.StatusCode 1741 } 1742 tracing.EndSpan(ctx, sc, err) 1743 }() 1744 } 1745 result.page, err = client.ListByAPI(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) 1746 return 1747} 1748 1749// ListByOperation lists all Tags associated with the Operation. 1750// Parameters: 1751// resourceGroupName - the name of the resource group. 1752// serviceName - the name of the API Management service. 1753// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 1754// revision has ;rev=n as a suffix where n is the revision number. 1755// operationID - operation identifier within an API. Must be unique in the current API Management service 1756// instance. 1757// filter - | Field | Usage | Supported operators | Supported functions 1758// |</br>|-------------|-------------|-------------|-------------|</br>| displayName | filter | ge, le, eq, ne, 1759// gt, lt | substringof, contains, startswith, endswith |</br>| name | filter | ge, le, eq, ne, gt, lt | 1760// substringof, contains, startswith, endswith |</br> 1761// top - number of records to return. 1762// skip - number of records to skip. 1763func (client TagClient) ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (result TagCollectionPage, err error) { 1764 if tracing.IsEnabled() { 1765 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByOperation") 1766 defer func() { 1767 sc := -1 1768 if result.tc.Response.Response != nil { 1769 sc = result.tc.Response.Response.StatusCode 1770 } 1771 tracing.EndSpan(ctx, sc, err) 1772 }() 1773 } 1774 if err := validation.Validate([]validation.Validation{ 1775 {TargetValue: serviceName, 1776 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1777 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1778 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1779 {TargetValue: apiid, 1780 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1781 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 1782 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 1783 {TargetValue: operationID, 1784 Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 1785 {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1786 {TargetValue: top, 1787 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1788 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 1789 {TargetValue: skip, 1790 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 1791 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1792 return result, validation.NewError("apimanagement.TagClient", "ListByOperation", err.Error()) 1793 } 1794 1795 result.fn = client.listByOperationNextResults 1796 req, err := client.ListByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, filter, top, skip) 1797 if err != nil { 1798 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByOperation", nil, "Failure preparing request") 1799 return 1800 } 1801 1802 resp, err := client.ListByOperationSender(req) 1803 if err != nil { 1804 result.tc.Response = autorest.Response{Response: resp} 1805 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByOperation", resp, "Failure sending request") 1806 return 1807 } 1808 1809 result.tc, err = client.ListByOperationResponder(resp) 1810 if err != nil { 1811 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByOperation", resp, "Failure responding to request") 1812 return 1813 } 1814 if result.tc.hasNextLink() && result.tc.IsEmpty() { 1815 err = result.NextWithContext(ctx) 1816 return 1817 } 1818 1819 return 1820} 1821 1822// ListByOperationPreparer prepares the ListByOperation request. 1823func (client TagClient) ListByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (*http.Request, error) { 1824 pathParameters := map[string]interface{}{ 1825 "apiId": autorest.Encode("path", apiid), 1826 "operationId": autorest.Encode("path", operationID), 1827 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1828 "serviceName": autorest.Encode("path", serviceName), 1829 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1830 } 1831 1832 const APIVersion = "2020-12-01" 1833 queryParameters := map[string]interface{}{ 1834 "api-version": APIVersion, 1835 } 1836 if len(filter) > 0 { 1837 queryParameters["$filter"] = autorest.Encode("query", filter) 1838 } 1839 if top != nil { 1840 queryParameters["$top"] = autorest.Encode("query", *top) 1841 } 1842 if skip != nil { 1843 queryParameters["$skip"] = autorest.Encode("query", *skip) 1844 } 1845 1846 preparer := autorest.CreatePreparer( 1847 autorest.AsGet(), 1848 autorest.WithBaseURL(client.BaseURI), 1849 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags", pathParameters), 1850 autorest.WithQueryParameters(queryParameters)) 1851 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1852} 1853 1854// ListByOperationSender sends the ListByOperation request. The method will close the 1855// http.Response Body if it receives an error. 1856func (client TagClient) ListByOperationSender(req *http.Request) (*http.Response, error) { 1857 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1858} 1859 1860// ListByOperationResponder handles the response to the ListByOperation request. The method always 1861// closes the http.Response Body. 1862func (client TagClient) ListByOperationResponder(resp *http.Response) (result TagCollection, err error) { 1863 err = autorest.Respond( 1864 resp, 1865 azure.WithErrorUnlessStatusCode(http.StatusOK), 1866 autorest.ByUnmarshallingJSON(&result), 1867 autorest.ByClosing()) 1868 result.Response = autorest.Response{Response: resp} 1869 return 1870} 1871 1872// listByOperationNextResults retrieves the next set of results, if any. 1873func (client TagClient) listByOperationNextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { 1874 req, err := lastResults.tagCollectionPreparer(ctx) 1875 if err != nil { 1876 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByOperationNextResults", nil, "Failure preparing next results request") 1877 } 1878 if req == nil { 1879 return 1880 } 1881 resp, err := client.ListByOperationSender(req) 1882 if err != nil { 1883 result.Response = autorest.Response{Response: resp} 1884 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByOperationNextResults", resp, "Failure sending next results request") 1885 } 1886 result, err = client.ListByOperationResponder(resp) 1887 if err != nil { 1888 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByOperationNextResults", resp, "Failure responding to next results request") 1889 } 1890 return 1891} 1892 1893// ListByOperationComplete enumerates all values, automatically crossing page boundaries as required. 1894func (client TagClient) ListByOperationComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (result TagCollectionIterator, err error) { 1895 if tracing.IsEnabled() { 1896 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByOperation") 1897 defer func() { 1898 sc := -1 1899 if result.Response().Response.Response != nil { 1900 sc = result.page.Response().Response.Response.StatusCode 1901 } 1902 tracing.EndSpan(ctx, sc, err) 1903 }() 1904 } 1905 result.page, err = client.ListByOperation(ctx, resourceGroupName, serviceName, apiid, operationID, filter, top, skip) 1906 return 1907} 1908 1909// ListByProduct lists all Tags associated with the Product. 1910// Parameters: 1911// resourceGroupName - the name of the resource group. 1912// serviceName - the name of the API Management service. 1913// productID - product identifier. Must be unique in the current API Management service instance. 1914// filter - | Field | Usage | Supported operators | Supported functions 1915// |</br>|-------------|-------------|-------------|-------------|</br>| displayName | filter | ge, le, eq, ne, 1916// gt, lt | substringof, contains, startswith, endswith |</br>| name | filter | ge, le, eq, ne, gt, lt | 1917// substringof, contains, startswith, endswith |</br> 1918// top - number of records to return. 1919// skip - number of records to skip. 1920func (client TagClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result TagCollectionPage, err error) { 1921 if tracing.IsEnabled() { 1922 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByProduct") 1923 defer func() { 1924 sc := -1 1925 if result.tc.Response.Response != nil { 1926 sc = result.tc.Response.Response.StatusCode 1927 } 1928 tracing.EndSpan(ctx, sc, err) 1929 }() 1930 } 1931 if err := validation.Validate([]validation.Validation{ 1932 {TargetValue: serviceName, 1933 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1934 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1935 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1936 {TargetValue: productID, 1937 Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 1938 {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1939 {TargetValue: top, 1940 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1941 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 1942 {TargetValue: skip, 1943 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 1944 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1945 return result, validation.NewError("apimanagement.TagClient", "ListByProduct", err.Error()) 1946 } 1947 1948 result.fn = client.listByProductNextResults 1949 req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, productID, filter, top, skip) 1950 if err != nil { 1951 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByProduct", nil, "Failure preparing request") 1952 return 1953 } 1954 1955 resp, err := client.ListByProductSender(req) 1956 if err != nil { 1957 result.tc.Response = autorest.Response{Response: resp} 1958 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByProduct", resp, "Failure sending request") 1959 return 1960 } 1961 1962 result.tc, err = client.ListByProductResponder(resp) 1963 if err != nil { 1964 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByProduct", resp, "Failure responding to request") 1965 return 1966 } 1967 if result.tc.hasNextLink() && result.tc.IsEmpty() { 1968 err = result.NextWithContext(ctx) 1969 return 1970 } 1971 1972 return 1973} 1974 1975// ListByProductPreparer prepares the ListByProduct request. 1976func (client TagClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { 1977 pathParameters := map[string]interface{}{ 1978 "productId": autorest.Encode("path", productID), 1979 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1980 "serviceName": autorest.Encode("path", serviceName), 1981 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1982 } 1983 1984 const APIVersion = "2020-12-01" 1985 queryParameters := map[string]interface{}{ 1986 "api-version": APIVersion, 1987 } 1988 if len(filter) > 0 { 1989 queryParameters["$filter"] = autorest.Encode("query", filter) 1990 } 1991 if top != nil { 1992 queryParameters["$top"] = autorest.Encode("query", *top) 1993 } 1994 if skip != nil { 1995 queryParameters["$skip"] = autorest.Encode("query", *skip) 1996 } 1997 1998 preparer := autorest.CreatePreparer( 1999 autorest.AsGet(), 2000 autorest.WithBaseURL(client.BaseURI), 2001 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags", pathParameters), 2002 autorest.WithQueryParameters(queryParameters)) 2003 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 2004} 2005 2006// ListByProductSender sends the ListByProduct request. The method will close the 2007// http.Response Body if it receives an error. 2008func (client TagClient) ListByProductSender(req *http.Request) (*http.Response, error) { 2009 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 2010} 2011 2012// ListByProductResponder handles the response to the ListByProduct request. The method always 2013// closes the http.Response Body. 2014func (client TagClient) ListByProductResponder(resp *http.Response) (result TagCollection, err error) { 2015 err = autorest.Respond( 2016 resp, 2017 azure.WithErrorUnlessStatusCode(http.StatusOK), 2018 autorest.ByUnmarshallingJSON(&result), 2019 autorest.ByClosing()) 2020 result.Response = autorest.Response{Response: resp} 2021 return 2022} 2023 2024// listByProductNextResults retrieves the next set of results, if any. 2025func (client TagClient) listByProductNextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { 2026 req, err := lastResults.tagCollectionPreparer(ctx) 2027 if err != nil { 2028 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByProductNextResults", nil, "Failure preparing next results request") 2029 } 2030 if req == nil { 2031 return 2032 } 2033 resp, err := client.ListByProductSender(req) 2034 if err != nil { 2035 result.Response = autorest.Response{Response: resp} 2036 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByProductNextResults", resp, "Failure sending next results request") 2037 } 2038 result, err = client.ListByProductResponder(resp) 2039 if err != nil { 2040 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByProductNextResults", resp, "Failure responding to next results request") 2041 } 2042 return 2043} 2044 2045// ListByProductComplete enumerates all values, automatically crossing page boundaries as required. 2046func (client TagClient) ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result TagCollectionIterator, err error) { 2047 if tracing.IsEnabled() { 2048 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByProduct") 2049 defer func() { 2050 sc := -1 2051 if result.Response().Response.Response != nil { 2052 sc = result.page.Response().Response.Response.StatusCode 2053 } 2054 tracing.EndSpan(ctx, sc, err) 2055 }() 2056 } 2057 result.page, err = client.ListByProduct(ctx, resourceGroupName, serviceName, productID, filter, top, skip) 2058 return 2059} 2060 2061// ListByService lists a collection of tags defined within a service instance. 2062// Parameters: 2063// resourceGroupName - the name of the resource group. 2064// serviceName - the name of the API Management service. 2065// filter - | Field | Usage | Supported operators | Supported functions 2066// |</br>|-------------|-------------|-------------|-------------|</br>| name | filter | ge, le, eq, ne, gt, lt 2067// | substringof, contains, startswith, endswith |</br>| displayName | filter | ge, le, eq, ne, gt, lt | 2068// substringof, contains, startswith, endswith |</br> 2069// top - number of records to return. 2070// skip - number of records to skip. 2071// scope - scope like 'apis', 'products' or 'apis/{apiId} 2072func (client TagClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (result TagCollectionPage, err error) { 2073 if tracing.IsEnabled() { 2074 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByService") 2075 defer func() { 2076 sc := -1 2077 if result.tc.Response.Response != nil { 2078 sc = result.tc.Response.Response.StatusCode 2079 } 2080 tracing.EndSpan(ctx, sc, err) 2081 }() 2082 } 2083 if err := validation.Validate([]validation.Validation{ 2084 {TargetValue: serviceName, 2085 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 2086 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 2087 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 2088 {TargetValue: top, 2089 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 2090 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 2091 {TargetValue: skip, 2092 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 2093 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 2094 return result, validation.NewError("apimanagement.TagClient", "ListByService", err.Error()) 2095 } 2096 2097 result.fn = client.listByServiceNextResults 2098 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, scope) 2099 if err != nil { 2100 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByService", nil, "Failure preparing request") 2101 return 2102 } 2103 2104 resp, err := client.ListByServiceSender(req) 2105 if err != nil { 2106 result.tc.Response = autorest.Response{Response: resp} 2107 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByService", resp, "Failure sending request") 2108 return 2109 } 2110 2111 result.tc, err = client.ListByServiceResponder(resp) 2112 if err != nil { 2113 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByService", resp, "Failure responding to request") 2114 return 2115 } 2116 if result.tc.hasNextLink() && result.tc.IsEmpty() { 2117 err = result.NextWithContext(ctx) 2118 return 2119 } 2120 2121 return 2122} 2123 2124// ListByServicePreparer prepares the ListByService request. 2125func (client TagClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (*http.Request, error) { 2126 pathParameters := map[string]interface{}{ 2127 "resourceGroupName": autorest.Encode("path", resourceGroupName), 2128 "serviceName": autorest.Encode("path", serviceName), 2129 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 2130 } 2131 2132 const APIVersion = "2020-12-01" 2133 queryParameters := map[string]interface{}{ 2134 "api-version": APIVersion, 2135 } 2136 if len(filter) > 0 { 2137 queryParameters["$filter"] = autorest.Encode("query", filter) 2138 } 2139 if top != nil { 2140 queryParameters["$top"] = autorest.Encode("query", *top) 2141 } 2142 if skip != nil { 2143 queryParameters["$skip"] = autorest.Encode("query", *skip) 2144 } 2145 if len(scope) > 0 { 2146 queryParameters["scope"] = autorest.Encode("query", scope) 2147 } 2148 2149 preparer := autorest.CreatePreparer( 2150 autorest.AsGet(), 2151 autorest.WithBaseURL(client.BaseURI), 2152 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags", pathParameters), 2153 autorest.WithQueryParameters(queryParameters)) 2154 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 2155} 2156 2157// ListByServiceSender sends the ListByService request. The method will close the 2158// http.Response Body if it receives an error. 2159func (client TagClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 2160 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 2161} 2162 2163// ListByServiceResponder handles the response to the ListByService request. The method always 2164// closes the http.Response Body. 2165func (client TagClient) ListByServiceResponder(resp *http.Response) (result TagCollection, err error) { 2166 err = autorest.Respond( 2167 resp, 2168 azure.WithErrorUnlessStatusCode(http.StatusOK), 2169 autorest.ByUnmarshallingJSON(&result), 2170 autorest.ByClosing()) 2171 result.Response = autorest.Response{Response: resp} 2172 return 2173} 2174 2175// listByServiceNextResults retrieves the next set of results, if any. 2176func (client TagClient) listByServiceNextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { 2177 req, err := lastResults.tagCollectionPreparer(ctx) 2178 if err != nil { 2179 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByServiceNextResults", nil, "Failure preparing next results request") 2180 } 2181 if req == nil { 2182 return 2183 } 2184 resp, err := client.ListByServiceSender(req) 2185 if err != nil { 2186 result.Response = autorest.Response{Response: resp} 2187 return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByServiceNextResults", resp, "Failure sending next results request") 2188 } 2189 result, err = client.ListByServiceResponder(resp) 2190 if err != nil { 2191 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByServiceNextResults", resp, "Failure responding to next results request") 2192 } 2193 return 2194} 2195 2196// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 2197func (client TagClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (result TagCollectionIterator, err error) { 2198 if tracing.IsEnabled() { 2199 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByService") 2200 defer func() { 2201 sc := -1 2202 if result.Response().Response.Response != nil { 2203 sc = result.page.Response().Response.Response.StatusCode 2204 } 2205 tracing.EndSpan(ctx, sc, err) 2206 }() 2207 } 2208 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, scope) 2209 return 2210} 2211 2212// Update updates the details of the tag specified by its identifier. 2213// Parameters: 2214// resourceGroupName - the name of the resource group. 2215// serviceName - the name of the API Management service. 2216// tagID - tag identifier. Must be unique in the current API Management service instance. 2217// parameters - update parameters. 2218// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 2219// request or it should be * for unconditional update. 2220func (client TagClient) Update(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (result TagContract, err error) { 2221 if tracing.IsEnabled() { 2222 ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.Update") 2223 defer func() { 2224 sc := -1 2225 if result.Response.Response != nil { 2226 sc = result.Response.Response.StatusCode 2227 } 2228 tracing.EndSpan(ctx, sc, err) 2229 }() 2230 } 2231 if err := validation.Validate([]validation.Validation{ 2232 {TargetValue: serviceName, 2233 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 2234 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 2235 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 2236 {TargetValue: tagID, 2237 Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 2238 {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, 2239 {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 2240 return result, validation.NewError("apimanagement.TagClient", "Update", err.Error()) 2241 } 2242 2243 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, tagID, parameters, ifMatch) 2244 if err != nil { 2245 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Update", nil, "Failure preparing request") 2246 return 2247 } 2248 2249 resp, err := client.UpdateSender(req) 2250 if err != nil { 2251 result.Response = autorest.Response{Response: resp} 2252 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Update", resp, "Failure sending request") 2253 return 2254 } 2255 2256 result, err = client.UpdateResponder(resp) 2257 if err != nil { 2258 err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Update", resp, "Failure responding to request") 2259 return 2260 } 2261 2262 return 2263} 2264 2265// UpdatePreparer prepares the Update request. 2266func (client TagClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (*http.Request, error) { 2267 pathParameters := map[string]interface{}{ 2268 "resourceGroupName": autorest.Encode("path", resourceGroupName), 2269 "serviceName": autorest.Encode("path", serviceName), 2270 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 2271 "tagId": autorest.Encode("path", tagID), 2272 } 2273 2274 const APIVersion = "2020-12-01" 2275 queryParameters := map[string]interface{}{ 2276 "api-version": APIVersion, 2277 } 2278 2279 preparer := autorest.CreatePreparer( 2280 autorest.AsContentType("application/json; charset=utf-8"), 2281 autorest.AsPatch(), 2282 autorest.WithBaseURL(client.BaseURI), 2283 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), 2284 autorest.WithJSON(parameters), 2285 autorest.WithQueryParameters(queryParameters), 2286 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 2287 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 2288} 2289 2290// UpdateSender sends the Update request. The method will close the 2291// http.Response Body if it receives an error. 2292func (client TagClient) UpdateSender(req *http.Request) (*http.Response, error) { 2293 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 2294} 2295 2296// UpdateResponder handles the response to the Update request. The method always 2297// closes the http.Response Body. 2298func (client TagClient) UpdateResponder(resp *http.Response) (result TagContract, err error) { 2299 err = autorest.Respond( 2300 resp, 2301 azure.WithErrorUnlessStatusCode(http.StatusOK), 2302 autorest.ByUnmarshallingJSON(&result), 2303 autorest.ByClosing()) 2304 result.Response = autorest.Response{Response: resp} 2305 return 2306} 2307