1package apimanagement 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// TenantAccessClient is the apiManagement Client 19type TenantAccessClient struct { 20 BaseClient 21} 22 23// NewTenantAccessClient creates an instance of the TenantAccessClient client. 24func NewTenantAccessClient(subscriptionID string) TenantAccessClient { 25 return NewTenantAccessClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewTenantAccessClientWithBaseURI creates an instance of the TenantAccessClient client using a custom endpoint. Use 29// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewTenantAccessClientWithBaseURI(baseURI string, subscriptionID string) TenantAccessClient { 31 return TenantAccessClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Create update tenant access information details. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// serviceName - the name of the API Management service. 38// parameters - parameters supplied to retrieve the Tenant Access Information. 39// accessName - the identifier of the Access configuration. 40// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 41// request or it should be * for unconditional update. 42func (client TenantAccessClient) Create(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationCreateParameters, accessName AccessIDName, ifMatch string) (result AccessInformationContract, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.Create") 45 defer func() { 46 sc := -1 47 if result.Response.Response != nil { 48 sc = result.Response.Response.StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 if err := validation.Validate([]validation.Validation{ 54 {TargetValue: serviceName, 55 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 56 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 57 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 58 return result, validation.NewError("apimanagement.TenantAccessClient", "Create", err.Error()) 59 } 60 61 req, err := client.CreatePreparer(ctx, resourceGroupName, serviceName, parameters, accessName, ifMatch) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Create", nil, "Failure preparing request") 64 return 65 } 66 67 resp, err := client.CreateSender(req) 68 if err != nil { 69 result.Response = autorest.Response{Response: resp} 70 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Create", resp, "Failure sending request") 71 return 72 } 73 74 result, err = client.CreateResponder(resp) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Create", resp, "Failure responding to request") 77 return 78 } 79 80 return 81} 82 83// CreatePreparer prepares the Create request. 84func (client TenantAccessClient) CreatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationCreateParameters, accessName AccessIDName, ifMatch string) (*http.Request, error) { 85 pathParameters := map[string]interface{}{ 86 "accessName": autorest.Encode("path", accessName), 87 "resourceGroupName": autorest.Encode("path", resourceGroupName), 88 "serviceName": autorest.Encode("path", serviceName), 89 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 90 } 91 92 const APIVersion = "2020-12-01" 93 queryParameters := map[string]interface{}{ 94 "api-version": APIVersion, 95 } 96 97 preparer := autorest.CreatePreparer( 98 autorest.AsContentType("application/json; charset=utf-8"), 99 autorest.AsPut(), 100 autorest.WithBaseURL(client.BaseURI), 101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), 102 autorest.WithJSON(parameters), 103 autorest.WithQueryParameters(queryParameters), 104 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 105 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 106} 107 108// CreateSender sends the Create request. The method will close the 109// http.Response Body if it receives an error. 110func (client TenantAccessClient) CreateSender(req *http.Request) (*http.Response, error) { 111 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 112} 113 114// CreateResponder handles the response to the Create request. The method always 115// closes the http.Response Body. 116func (client TenantAccessClient) CreateResponder(resp *http.Response) (result AccessInformationContract, err error) { 117 err = autorest.Respond( 118 resp, 119 azure.WithErrorUnlessStatusCode(http.StatusOK), 120 autorest.ByUnmarshallingJSON(&result), 121 autorest.ByClosing()) 122 result.Response = autorest.Response{Response: resp} 123 return 124} 125 126// Get get tenant access information details without secrets. 127// Parameters: 128// resourceGroupName - the name of the resource group. 129// serviceName - the name of the API Management service. 130// accessName - the identifier of the Access configuration. 131func (client TenantAccessClient) Get(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result AccessInformationContract, err error) { 132 if tracing.IsEnabled() { 133 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.Get") 134 defer func() { 135 sc := -1 136 if result.Response.Response != nil { 137 sc = result.Response.Response.StatusCode 138 } 139 tracing.EndSpan(ctx, sc, err) 140 }() 141 } 142 if err := validation.Validate([]validation.Validation{ 143 {TargetValue: serviceName, 144 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 145 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 146 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 147 return result, validation.NewError("apimanagement.TenantAccessClient", "Get", err.Error()) 148 } 149 150 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, accessName) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", nil, "Failure preparing request") 153 return 154 } 155 156 resp, err := client.GetSender(req) 157 if err != nil { 158 result.Response = autorest.Response{Response: resp} 159 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", resp, "Failure sending request") 160 return 161 } 162 163 result, err = client.GetResponder(resp) 164 if err != nil { 165 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", resp, "Failure responding to request") 166 return 167 } 168 169 return 170} 171 172// GetPreparer prepares the Get request. 173func (client TenantAccessClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { 174 pathParameters := map[string]interface{}{ 175 "accessName": autorest.Encode("path", accessName), 176 "resourceGroupName": autorest.Encode("path", resourceGroupName), 177 "serviceName": autorest.Encode("path", serviceName), 178 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 179 } 180 181 const APIVersion = "2020-12-01" 182 queryParameters := map[string]interface{}{ 183 "api-version": APIVersion, 184 } 185 186 preparer := autorest.CreatePreparer( 187 autorest.AsGet(), 188 autorest.WithBaseURL(client.BaseURI), 189 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), 190 autorest.WithQueryParameters(queryParameters)) 191 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 192} 193 194// GetSender sends the Get request. The method will close the 195// http.Response Body if it receives an error. 196func (client TenantAccessClient) GetSender(req *http.Request) (*http.Response, error) { 197 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 198} 199 200// GetResponder handles the response to the Get request. The method always 201// closes the http.Response Body. 202func (client TenantAccessClient) GetResponder(resp *http.Response) (result AccessInformationContract, err error) { 203 err = autorest.Respond( 204 resp, 205 azure.WithErrorUnlessStatusCode(http.StatusOK), 206 autorest.ByUnmarshallingJSON(&result), 207 autorest.ByClosing()) 208 result.Response = autorest.Response{Response: resp} 209 return 210} 211 212// GetEntityTag tenant access metadata 213// Parameters: 214// resourceGroupName - the name of the resource group. 215// serviceName - the name of the API Management service. 216// accessName - the identifier of the Access configuration. 217func (client TenantAccessClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { 218 if tracing.IsEnabled() { 219 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.GetEntityTag") 220 defer func() { 221 sc := -1 222 if result.Response != nil { 223 sc = result.Response.StatusCode 224 } 225 tracing.EndSpan(ctx, sc, err) 226 }() 227 } 228 if err := validation.Validate([]validation.Validation{ 229 {TargetValue: serviceName, 230 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 231 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 232 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 233 return result, validation.NewError("apimanagement.TenantAccessClient", "GetEntityTag", err.Error()) 234 } 235 236 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, accessName) 237 if err != nil { 238 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "GetEntityTag", nil, "Failure preparing request") 239 return 240 } 241 242 resp, err := client.GetEntityTagSender(req) 243 if err != nil { 244 result.Response = resp 245 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "GetEntityTag", resp, "Failure sending request") 246 return 247 } 248 249 result, err = client.GetEntityTagResponder(resp) 250 if err != nil { 251 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "GetEntityTag", resp, "Failure responding to request") 252 return 253 } 254 255 return 256} 257 258// GetEntityTagPreparer prepares the GetEntityTag request. 259func (client TenantAccessClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { 260 pathParameters := map[string]interface{}{ 261 "accessName": autorest.Encode("path", accessName), 262 "resourceGroupName": autorest.Encode("path", resourceGroupName), 263 "serviceName": autorest.Encode("path", serviceName), 264 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 265 } 266 267 const APIVersion = "2020-12-01" 268 queryParameters := map[string]interface{}{ 269 "api-version": APIVersion, 270 } 271 272 preparer := autorest.CreatePreparer( 273 autorest.AsHead(), 274 autorest.WithBaseURL(client.BaseURI), 275 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), 276 autorest.WithQueryParameters(queryParameters)) 277 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 278} 279 280// GetEntityTagSender sends the GetEntityTag request. The method will close the 281// http.Response Body if it receives an error. 282func (client TenantAccessClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { 283 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 284} 285 286// GetEntityTagResponder handles the response to the GetEntityTag request. The method always 287// closes the http.Response Body. 288func (client TenantAccessClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { 289 err = autorest.Respond( 290 resp, 291 azure.WithErrorUnlessStatusCode(http.StatusOK), 292 autorest.ByClosing()) 293 result.Response = resp 294 return 295} 296 297// ListByService returns list of access infos - for Git and Management endpoints. 298// Parameters: 299// resourceGroupName - the name of the resource group. 300// serviceName - the name of the API Management service. 301// filter - not used 302func (client TenantAccessClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result AccessInformationCollectionPage, err error) { 303 if tracing.IsEnabled() { 304 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.ListByService") 305 defer func() { 306 sc := -1 307 if result.aic.Response.Response != nil { 308 sc = result.aic.Response.Response.StatusCode 309 } 310 tracing.EndSpan(ctx, sc, err) 311 }() 312 } 313 if err := validation.Validate([]validation.Validation{ 314 {TargetValue: serviceName, 315 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 316 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 317 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 318 return result, validation.NewError("apimanagement.TenantAccessClient", "ListByService", err.Error()) 319 } 320 321 result.fn = client.listByServiceNextResults 322 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter) 323 if err != nil { 324 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListByService", nil, "Failure preparing request") 325 return 326 } 327 328 resp, err := client.ListByServiceSender(req) 329 if err != nil { 330 result.aic.Response = autorest.Response{Response: resp} 331 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListByService", resp, "Failure sending request") 332 return 333 } 334 335 result.aic, err = client.ListByServiceResponder(resp) 336 if err != nil { 337 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListByService", resp, "Failure responding to request") 338 return 339 } 340 if result.aic.hasNextLink() && result.aic.IsEmpty() { 341 err = result.NextWithContext(ctx) 342 return 343 } 344 345 return 346} 347 348// ListByServicePreparer prepares the ListByService request. 349func (client TenantAccessClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string) (*http.Request, error) { 350 pathParameters := map[string]interface{}{ 351 "resourceGroupName": autorest.Encode("path", resourceGroupName), 352 "serviceName": autorest.Encode("path", serviceName), 353 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 354 } 355 356 const APIVersion = "2020-12-01" 357 queryParameters := map[string]interface{}{ 358 "api-version": APIVersion, 359 } 360 if len(filter) > 0 { 361 queryParameters["$filter"] = autorest.Encode("query", filter) 362 } 363 364 preparer := autorest.CreatePreparer( 365 autorest.AsGet(), 366 autorest.WithBaseURL(client.BaseURI), 367 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant", pathParameters), 368 autorest.WithQueryParameters(queryParameters)) 369 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 370} 371 372// ListByServiceSender sends the ListByService request. The method will close the 373// http.Response Body if it receives an error. 374func (client TenantAccessClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 375 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 376} 377 378// ListByServiceResponder handles the response to the ListByService request. The method always 379// closes the http.Response Body. 380func (client TenantAccessClient) ListByServiceResponder(resp *http.Response) (result AccessInformationCollection, err error) { 381 err = autorest.Respond( 382 resp, 383 azure.WithErrorUnlessStatusCode(http.StatusOK), 384 autorest.ByUnmarshallingJSON(&result), 385 autorest.ByClosing()) 386 result.Response = autorest.Response{Response: resp} 387 return 388} 389 390// listByServiceNextResults retrieves the next set of results, if any. 391func (client TenantAccessClient) listByServiceNextResults(ctx context.Context, lastResults AccessInformationCollection) (result AccessInformationCollection, err error) { 392 req, err := lastResults.accessInformationCollectionPreparer(ctx) 393 if err != nil { 394 return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "listByServiceNextResults", nil, "Failure preparing next results request") 395 } 396 if req == nil { 397 return 398 } 399 resp, err := client.ListByServiceSender(req) 400 if err != nil { 401 result.Response = autorest.Response{Response: resp} 402 return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "listByServiceNextResults", resp, "Failure sending next results request") 403 } 404 result, err = client.ListByServiceResponder(resp) 405 if err != nil { 406 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "listByServiceNextResults", resp, "Failure responding to next results request") 407 } 408 return 409} 410 411// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 412func (client TenantAccessClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result AccessInformationCollectionIterator, err error) { 413 if tracing.IsEnabled() { 414 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.ListByService") 415 defer func() { 416 sc := -1 417 if result.Response().Response.Response != nil { 418 sc = result.page.Response().Response.Response.StatusCode 419 } 420 tracing.EndSpan(ctx, sc, err) 421 }() 422 } 423 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter) 424 return 425} 426 427// ListSecrets get tenant access information details. 428// Parameters: 429// resourceGroupName - the name of the resource group. 430// serviceName - the name of the API Management service. 431// accessName - the identifier of the Access configuration. 432func (client TenantAccessClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result AccessInformationSecretsContract, err error) { 433 if tracing.IsEnabled() { 434 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.ListSecrets") 435 defer func() { 436 sc := -1 437 if result.Response.Response != nil { 438 sc = result.Response.Response.StatusCode 439 } 440 tracing.EndSpan(ctx, sc, err) 441 }() 442 } 443 if err := validation.Validate([]validation.Validation{ 444 {TargetValue: serviceName, 445 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 446 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 447 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 448 return result, validation.NewError("apimanagement.TenantAccessClient", "ListSecrets", err.Error()) 449 } 450 451 req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, accessName) 452 if err != nil { 453 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListSecrets", nil, "Failure preparing request") 454 return 455 } 456 457 resp, err := client.ListSecretsSender(req) 458 if err != nil { 459 result.Response = autorest.Response{Response: resp} 460 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListSecrets", resp, "Failure sending request") 461 return 462 } 463 464 result, err = client.ListSecretsResponder(resp) 465 if err != nil { 466 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListSecrets", resp, "Failure responding to request") 467 return 468 } 469 470 return 471} 472 473// ListSecretsPreparer prepares the ListSecrets request. 474func (client TenantAccessClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { 475 pathParameters := map[string]interface{}{ 476 "accessName": autorest.Encode("path", accessName), 477 "resourceGroupName": autorest.Encode("path", resourceGroupName), 478 "serviceName": autorest.Encode("path", serviceName), 479 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 480 } 481 482 const APIVersion = "2020-12-01" 483 queryParameters := map[string]interface{}{ 484 "api-version": APIVersion, 485 } 486 487 preparer := autorest.CreatePreparer( 488 autorest.AsPost(), 489 autorest.WithBaseURL(client.BaseURI), 490 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets", pathParameters), 491 autorest.WithQueryParameters(queryParameters)) 492 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 493} 494 495// ListSecretsSender sends the ListSecrets request. The method will close the 496// http.Response Body if it receives an error. 497func (client TenantAccessClient) ListSecretsSender(req *http.Request) (*http.Response, error) { 498 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 499} 500 501// ListSecretsResponder handles the response to the ListSecrets request. The method always 502// closes the http.Response Body. 503func (client TenantAccessClient) ListSecretsResponder(resp *http.Response) (result AccessInformationSecretsContract, err error) { 504 err = autorest.Respond( 505 resp, 506 azure.WithErrorUnlessStatusCode(http.StatusOK), 507 autorest.ByUnmarshallingJSON(&result), 508 autorest.ByClosing()) 509 result.Response = autorest.Response{Response: resp} 510 return 511} 512 513// RegeneratePrimaryKey regenerate primary access key 514// Parameters: 515// resourceGroupName - the name of the resource group. 516// serviceName - the name of the API Management service. 517// accessName - the identifier of the Access configuration. 518func (client TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { 519 if tracing.IsEnabled() { 520 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.RegeneratePrimaryKey") 521 defer func() { 522 sc := -1 523 if result.Response != nil { 524 sc = result.Response.StatusCode 525 } 526 tracing.EndSpan(ctx, sc, err) 527 }() 528 } 529 if err := validation.Validate([]validation.Validation{ 530 {TargetValue: serviceName, 531 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 532 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 533 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 534 return result, validation.NewError("apimanagement.TenantAccessClient", "RegeneratePrimaryKey", err.Error()) 535 } 536 537 req, err := client.RegeneratePrimaryKeyPreparer(ctx, resourceGroupName, serviceName, accessName) 538 if err != nil { 539 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", nil, "Failure preparing request") 540 return 541 } 542 543 resp, err := client.RegeneratePrimaryKeySender(req) 544 if err != nil { 545 result.Response = resp 546 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", resp, "Failure sending request") 547 return 548 } 549 550 result, err = client.RegeneratePrimaryKeyResponder(resp) 551 if err != nil { 552 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", resp, "Failure responding to request") 553 return 554 } 555 556 return 557} 558 559// RegeneratePrimaryKeyPreparer prepares the RegeneratePrimaryKey request. 560func (client TenantAccessClient) RegeneratePrimaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { 561 pathParameters := map[string]interface{}{ 562 "accessName": autorest.Encode("path", accessName), 563 "resourceGroupName": autorest.Encode("path", resourceGroupName), 564 "serviceName": autorest.Encode("path", serviceName), 565 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 566 } 567 568 const APIVersion = "2020-12-01" 569 queryParameters := map[string]interface{}{ 570 "api-version": APIVersion, 571 } 572 573 preparer := autorest.CreatePreparer( 574 autorest.AsPost(), 575 autorest.WithBaseURL(client.BaseURI), 576 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey", pathParameters), 577 autorest.WithQueryParameters(queryParameters)) 578 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 579} 580 581// RegeneratePrimaryKeySender sends the RegeneratePrimaryKey request. The method will close the 582// http.Response Body if it receives an error. 583func (client TenantAccessClient) RegeneratePrimaryKeySender(req *http.Request) (*http.Response, error) { 584 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 585} 586 587// RegeneratePrimaryKeyResponder handles the response to the RegeneratePrimaryKey request. The method always 588// closes the http.Response Body. 589func (client TenantAccessClient) RegeneratePrimaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { 590 err = autorest.Respond( 591 resp, 592 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 593 autorest.ByClosing()) 594 result.Response = resp 595 return 596} 597 598// RegenerateSecondaryKey regenerate secondary access key 599// Parameters: 600// resourceGroupName - the name of the resource group. 601// serviceName - the name of the API Management service. 602// accessName - the identifier of the Access configuration. 603func (client TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { 604 if tracing.IsEnabled() { 605 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.RegenerateSecondaryKey") 606 defer func() { 607 sc := -1 608 if result.Response != nil { 609 sc = result.Response.StatusCode 610 } 611 tracing.EndSpan(ctx, sc, err) 612 }() 613 } 614 if err := validation.Validate([]validation.Validation{ 615 {TargetValue: serviceName, 616 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 617 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 618 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 619 return result, validation.NewError("apimanagement.TenantAccessClient", "RegenerateSecondaryKey", err.Error()) 620 } 621 622 req, err := client.RegenerateSecondaryKeyPreparer(ctx, resourceGroupName, serviceName, accessName) 623 if err != nil { 624 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", nil, "Failure preparing request") 625 return 626 } 627 628 resp, err := client.RegenerateSecondaryKeySender(req) 629 if err != nil { 630 result.Response = resp 631 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", resp, "Failure sending request") 632 return 633 } 634 635 result, err = client.RegenerateSecondaryKeyResponder(resp) 636 if err != nil { 637 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", resp, "Failure responding to request") 638 return 639 } 640 641 return 642} 643 644// RegenerateSecondaryKeyPreparer prepares the RegenerateSecondaryKey request. 645func (client TenantAccessClient) RegenerateSecondaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { 646 pathParameters := map[string]interface{}{ 647 "accessName": autorest.Encode("path", accessName), 648 "resourceGroupName": autorest.Encode("path", resourceGroupName), 649 "serviceName": autorest.Encode("path", serviceName), 650 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 651 } 652 653 const APIVersion = "2020-12-01" 654 queryParameters := map[string]interface{}{ 655 "api-version": APIVersion, 656 } 657 658 preparer := autorest.CreatePreparer( 659 autorest.AsPost(), 660 autorest.WithBaseURL(client.BaseURI), 661 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey", pathParameters), 662 autorest.WithQueryParameters(queryParameters)) 663 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 664} 665 666// RegenerateSecondaryKeySender sends the RegenerateSecondaryKey request. The method will close the 667// http.Response Body if it receives an error. 668func (client TenantAccessClient) RegenerateSecondaryKeySender(req *http.Request) (*http.Response, error) { 669 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 670} 671 672// RegenerateSecondaryKeyResponder handles the response to the RegenerateSecondaryKey request. The method always 673// closes the http.Response Body. 674func (client TenantAccessClient) RegenerateSecondaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { 675 err = autorest.Respond( 676 resp, 677 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 678 autorest.ByClosing()) 679 result.Response = resp 680 return 681} 682 683// Update update tenant access information details. 684// Parameters: 685// resourceGroupName - the name of the resource group. 686// serviceName - the name of the API Management service. 687// parameters - parameters supplied to retrieve the Tenant Access Information. 688// accessName - the identifier of the Access configuration. 689// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 690// request or it should be * for unconditional update. 691func (client TenantAccessClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationUpdateParameters, accessName AccessIDName, ifMatch string) (result AccessInformationContract, err error) { 692 if tracing.IsEnabled() { 693 ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.Update") 694 defer func() { 695 sc := -1 696 if result.Response.Response != nil { 697 sc = result.Response.Response.StatusCode 698 } 699 tracing.EndSpan(ctx, sc, err) 700 }() 701 } 702 if err := validation.Validate([]validation.Validation{ 703 {TargetValue: serviceName, 704 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 705 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 706 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 707 return result, validation.NewError("apimanagement.TenantAccessClient", "Update", err.Error()) 708 } 709 710 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters, accessName, ifMatch) 711 if err != nil { 712 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", nil, "Failure preparing request") 713 return 714 } 715 716 resp, err := client.UpdateSender(req) 717 if err != nil { 718 result.Response = autorest.Response{Response: resp} 719 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", resp, "Failure sending request") 720 return 721 } 722 723 result, err = client.UpdateResponder(resp) 724 if err != nil { 725 err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", resp, "Failure responding to request") 726 return 727 } 728 729 return 730} 731 732// UpdatePreparer prepares the Update request. 733func (client TenantAccessClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationUpdateParameters, accessName AccessIDName, ifMatch string) (*http.Request, error) { 734 pathParameters := map[string]interface{}{ 735 "accessName": autorest.Encode("path", accessName), 736 "resourceGroupName": autorest.Encode("path", resourceGroupName), 737 "serviceName": autorest.Encode("path", serviceName), 738 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 739 } 740 741 const APIVersion = "2020-12-01" 742 queryParameters := map[string]interface{}{ 743 "api-version": APIVersion, 744 } 745 746 preparer := autorest.CreatePreparer( 747 autorest.AsContentType("application/json; charset=utf-8"), 748 autorest.AsPatch(), 749 autorest.WithBaseURL(client.BaseURI), 750 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), 751 autorest.WithJSON(parameters), 752 autorest.WithQueryParameters(queryParameters), 753 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 754 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 755} 756 757// UpdateSender sends the Update request. The method will close the 758// http.Response Body if it receives an error. 759func (client TenantAccessClient) UpdateSender(req *http.Request) (*http.Response, error) { 760 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 761} 762 763// UpdateResponder handles the response to the Update request. The method always 764// closes the http.Response Body. 765func (client TenantAccessClient) UpdateResponder(resp *http.Response) (result AccessInformationContract, err error) { 766 err = autorest.Respond( 767 resp, 768 azure.WithErrorUnlessStatusCode(http.StatusOK), 769 autorest.ByUnmarshallingJSON(&result), 770 autorest.ByClosing()) 771 result.Response = autorest.Response{Response: resp} 772 return 773} 774