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// IdentityProviderClient is the apiManagement Client 19type IdentityProviderClient struct { 20 BaseClient 21} 22 23// NewIdentityProviderClient creates an instance of the IdentityProviderClient client. 24func NewIdentityProviderClient(subscriptionID string) IdentityProviderClient { 25 return NewIdentityProviderClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewIdentityProviderClientWithBaseURI creates an instance of the IdentityProviderClient client using a custom 29// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 30// stack). 31func NewIdentityProviderClientWithBaseURI(baseURI string, subscriptionID string) IdentityProviderClient { 32 return IdentityProviderClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// CreateOrUpdate creates or Updates the IdentityProvider configuration. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// serviceName - the name of the API Management service. 39// identityProviderName - identity Provider Type identifier. 40// parameters - create parameters. 41// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. 42func (client IdentityProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderCreateContract, ifMatch string) (result IdentityProviderContract, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.CreateOrUpdate") 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}}}, 58 {TargetValue: parameters, 59 Constraints: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties", Name: validation.Null, Rule: false, 60 Chain: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties.ClientID", Name: validation.Null, Rule: true, 61 Chain: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties.ClientID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 62 {Target: "parameters.IdentityProviderCreateContractProperties.ClientSecret", Name: validation.Null, Rule: true, 63 Chain: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties.ClientSecret", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 64 }}}}}); err != nil { 65 return result, validation.NewError("apimanagement.IdentityProviderClient", "CreateOrUpdate", err.Error()) 66 } 67 68 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, identityProviderName, parameters, ifMatch) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "CreateOrUpdate", nil, "Failure preparing request") 71 return 72 } 73 74 resp, err := client.CreateOrUpdateSender(req) 75 if err != nil { 76 result.Response = autorest.Response{Response: resp} 77 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "CreateOrUpdate", resp, "Failure sending request") 78 return 79 } 80 81 result, err = client.CreateOrUpdateResponder(resp) 82 if err != nil { 83 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "CreateOrUpdate", resp, "Failure responding to request") 84 return 85 } 86 87 return 88} 89 90// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 91func (client IdentityProviderClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderCreateContract, ifMatch string) (*http.Request, error) { 92 pathParameters := map[string]interface{}{ 93 "identityProviderName": autorest.Encode("path", identityProviderName), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "serviceName": autorest.Encode("path", serviceName), 96 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 97 } 98 99 const APIVersion = "2019-12-01" 100 queryParameters := map[string]interface{}{ 101 "api-version": APIVersion, 102 } 103 104 preparer := autorest.CreatePreparer( 105 autorest.AsContentType("application/json; charset=utf-8"), 106 autorest.AsPut(), 107 autorest.WithBaseURL(client.BaseURI), 108 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), 109 autorest.WithJSON(parameters), 110 autorest.WithQueryParameters(queryParameters)) 111 if len(ifMatch) > 0 { 112 preparer = autorest.DecoratePreparer(preparer, 113 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 114 } 115 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 116} 117 118// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 119// http.Response Body if it receives an error. 120func (client IdentityProviderClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 121 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 122} 123 124// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 125// closes the http.Response Body. 126func (client IdentityProviderClient) CreateOrUpdateResponder(resp *http.Response) (result IdentityProviderContract, err error) { 127 err = autorest.Respond( 128 resp, 129 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 130 autorest.ByUnmarshallingJSON(&result), 131 autorest.ByClosing()) 132 result.Response = autorest.Response{Response: resp} 133 return 134} 135 136// Delete deletes the specified identity provider configuration. 137// Parameters: 138// resourceGroupName - the name of the resource group. 139// serviceName - the name of the API Management service. 140// identityProviderName - identity Provider Type identifier. 141// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 142// request or it should be * for unconditional update. 143func (client IdentityProviderClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string) (result autorest.Response, err error) { 144 if tracing.IsEnabled() { 145 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.Delete") 146 defer func() { 147 sc := -1 148 if result.Response != nil { 149 sc = result.Response.StatusCode 150 } 151 tracing.EndSpan(ctx, sc, err) 152 }() 153 } 154 if err := validation.Validate([]validation.Validation{ 155 {TargetValue: serviceName, 156 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 157 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 158 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 159 return result, validation.NewError("apimanagement.IdentityProviderClient", "Delete", err.Error()) 160 } 161 162 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, identityProviderName, ifMatch) 163 if err != nil { 164 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Delete", nil, "Failure preparing request") 165 return 166 } 167 168 resp, err := client.DeleteSender(req) 169 if err != nil { 170 result.Response = resp 171 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Delete", resp, "Failure sending request") 172 return 173 } 174 175 result, err = client.DeleteResponder(resp) 176 if err != nil { 177 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Delete", resp, "Failure responding to request") 178 return 179 } 180 181 return 182} 183 184// DeletePreparer prepares the Delete request. 185func (client IdentityProviderClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string) (*http.Request, error) { 186 pathParameters := map[string]interface{}{ 187 "identityProviderName": autorest.Encode("path", identityProviderName), 188 "resourceGroupName": autorest.Encode("path", resourceGroupName), 189 "serviceName": autorest.Encode("path", serviceName), 190 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 191 } 192 193 const APIVersion = "2019-12-01" 194 queryParameters := map[string]interface{}{ 195 "api-version": APIVersion, 196 } 197 198 preparer := autorest.CreatePreparer( 199 autorest.AsDelete(), 200 autorest.WithBaseURL(client.BaseURI), 201 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), 202 autorest.WithQueryParameters(queryParameters), 203 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 204 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 205} 206 207// DeleteSender sends the Delete request. The method will close the 208// http.Response Body if it receives an error. 209func (client IdentityProviderClient) DeleteSender(req *http.Request) (*http.Response, error) { 210 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 211} 212 213// DeleteResponder handles the response to the Delete request. The method always 214// closes the http.Response Body. 215func (client IdentityProviderClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 216 err = autorest.Respond( 217 resp, 218 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 219 autorest.ByClosing()) 220 result.Response = resp 221 return 222} 223 224// Get gets the configuration details of the identity Provider configured in specified service instance. 225// Parameters: 226// resourceGroupName - the name of the resource group. 227// serviceName - the name of the API Management service. 228// identityProviderName - identity Provider Type identifier. 229func (client IdentityProviderClient) Get(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (result IdentityProviderContract, err error) { 230 if tracing.IsEnabled() { 231 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.Get") 232 defer func() { 233 sc := -1 234 if result.Response.Response != nil { 235 sc = result.Response.Response.StatusCode 236 } 237 tracing.EndSpan(ctx, sc, err) 238 }() 239 } 240 if err := validation.Validate([]validation.Validation{ 241 {TargetValue: serviceName, 242 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 243 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 244 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 245 return result, validation.NewError("apimanagement.IdentityProviderClient", "Get", err.Error()) 246 } 247 248 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, identityProviderName) 249 if err != nil { 250 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Get", nil, "Failure preparing request") 251 return 252 } 253 254 resp, err := client.GetSender(req) 255 if err != nil { 256 result.Response = autorest.Response{Response: resp} 257 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Get", resp, "Failure sending request") 258 return 259 } 260 261 result, err = client.GetResponder(resp) 262 if err != nil { 263 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Get", resp, "Failure responding to request") 264 return 265 } 266 267 return 268} 269 270// GetPreparer prepares the Get request. 271func (client IdentityProviderClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (*http.Request, error) { 272 pathParameters := map[string]interface{}{ 273 "identityProviderName": autorest.Encode("path", identityProviderName), 274 "resourceGroupName": autorest.Encode("path", resourceGroupName), 275 "serviceName": autorest.Encode("path", serviceName), 276 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 277 } 278 279 const APIVersion = "2019-12-01" 280 queryParameters := map[string]interface{}{ 281 "api-version": APIVersion, 282 } 283 284 preparer := autorest.CreatePreparer( 285 autorest.AsGet(), 286 autorest.WithBaseURL(client.BaseURI), 287 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), 288 autorest.WithQueryParameters(queryParameters)) 289 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 290} 291 292// GetSender sends the Get request. The method will close the 293// http.Response Body if it receives an error. 294func (client IdentityProviderClient) GetSender(req *http.Request) (*http.Response, error) { 295 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 296} 297 298// GetResponder handles the response to the Get request. The method always 299// closes the http.Response Body. 300func (client IdentityProviderClient) GetResponder(resp *http.Response) (result IdentityProviderContract, err error) { 301 err = autorest.Respond( 302 resp, 303 azure.WithErrorUnlessStatusCode(http.StatusOK), 304 autorest.ByUnmarshallingJSON(&result), 305 autorest.ByClosing()) 306 result.Response = autorest.Response{Response: resp} 307 return 308} 309 310// GetEntityTag gets the entity state (Etag) version of the identityProvider specified by its identifier. 311// Parameters: 312// resourceGroupName - the name of the resource group. 313// serviceName - the name of the API Management service. 314// identityProviderName - identity Provider Type identifier. 315func (client IdentityProviderClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (result autorest.Response, err error) { 316 if tracing.IsEnabled() { 317 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.GetEntityTag") 318 defer func() { 319 sc := -1 320 if result.Response != nil { 321 sc = result.Response.StatusCode 322 } 323 tracing.EndSpan(ctx, sc, err) 324 }() 325 } 326 if err := validation.Validate([]validation.Validation{ 327 {TargetValue: serviceName, 328 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 329 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 330 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 331 return result, validation.NewError("apimanagement.IdentityProviderClient", "GetEntityTag", err.Error()) 332 } 333 334 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, identityProviderName) 335 if err != nil { 336 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "GetEntityTag", nil, "Failure preparing request") 337 return 338 } 339 340 resp, err := client.GetEntityTagSender(req) 341 if err != nil { 342 result.Response = resp 343 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "GetEntityTag", resp, "Failure sending request") 344 return 345 } 346 347 result, err = client.GetEntityTagResponder(resp) 348 if err != nil { 349 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "GetEntityTag", resp, "Failure responding to request") 350 return 351 } 352 353 return 354} 355 356// GetEntityTagPreparer prepares the GetEntityTag request. 357func (client IdentityProviderClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (*http.Request, error) { 358 pathParameters := map[string]interface{}{ 359 "identityProviderName": autorest.Encode("path", identityProviderName), 360 "resourceGroupName": autorest.Encode("path", resourceGroupName), 361 "serviceName": autorest.Encode("path", serviceName), 362 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 363 } 364 365 const APIVersion = "2019-12-01" 366 queryParameters := map[string]interface{}{ 367 "api-version": APIVersion, 368 } 369 370 preparer := autorest.CreatePreparer( 371 autorest.AsHead(), 372 autorest.WithBaseURL(client.BaseURI), 373 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), 374 autorest.WithQueryParameters(queryParameters)) 375 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 376} 377 378// GetEntityTagSender sends the GetEntityTag request. The method will close the 379// http.Response Body if it receives an error. 380func (client IdentityProviderClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { 381 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 382} 383 384// GetEntityTagResponder handles the response to the GetEntityTag request. The method always 385// closes the http.Response Body. 386func (client IdentityProviderClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { 387 err = autorest.Respond( 388 resp, 389 azure.WithErrorUnlessStatusCode(http.StatusOK), 390 autorest.ByClosing()) 391 result.Response = resp 392 return 393} 394 395// ListByService lists a collection of Identity Provider configured in the specified service instance. 396// Parameters: 397// resourceGroupName - the name of the resource group. 398// serviceName - the name of the API Management service. 399func (client IdentityProviderClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result IdentityProviderListPage, err error) { 400 if tracing.IsEnabled() { 401 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.ListByService") 402 defer func() { 403 sc := -1 404 if result.ipl.Response.Response != nil { 405 sc = result.ipl.Response.Response.StatusCode 406 } 407 tracing.EndSpan(ctx, sc, err) 408 }() 409 } 410 if err := validation.Validate([]validation.Validation{ 411 {TargetValue: serviceName, 412 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 413 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 414 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 415 return result, validation.NewError("apimanagement.IdentityProviderClient", "ListByService", err.Error()) 416 } 417 418 result.fn = client.listByServiceNextResults 419 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) 420 if err != nil { 421 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListByService", nil, "Failure preparing request") 422 return 423 } 424 425 resp, err := client.ListByServiceSender(req) 426 if err != nil { 427 result.ipl.Response = autorest.Response{Response: resp} 428 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListByService", resp, "Failure sending request") 429 return 430 } 431 432 result.ipl, err = client.ListByServiceResponder(resp) 433 if err != nil { 434 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListByService", resp, "Failure responding to request") 435 return 436 } 437 if result.ipl.hasNextLink() && result.ipl.IsEmpty() { 438 err = result.NextWithContext(ctx) 439 return 440 } 441 442 return 443} 444 445// ListByServicePreparer prepares the ListByService request. 446func (client IdentityProviderClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 447 pathParameters := map[string]interface{}{ 448 "resourceGroupName": autorest.Encode("path", resourceGroupName), 449 "serviceName": autorest.Encode("path", serviceName), 450 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 451 } 452 453 const APIVersion = "2019-12-01" 454 queryParameters := map[string]interface{}{ 455 "api-version": APIVersion, 456 } 457 458 preparer := autorest.CreatePreparer( 459 autorest.AsGet(), 460 autorest.WithBaseURL(client.BaseURI), 461 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders", pathParameters), 462 autorest.WithQueryParameters(queryParameters)) 463 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 464} 465 466// ListByServiceSender sends the ListByService request. The method will close the 467// http.Response Body if it receives an error. 468func (client IdentityProviderClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 469 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 470} 471 472// ListByServiceResponder handles the response to the ListByService request. The method always 473// closes the http.Response Body. 474func (client IdentityProviderClient) ListByServiceResponder(resp *http.Response) (result IdentityProviderList, err error) { 475 err = autorest.Respond( 476 resp, 477 azure.WithErrorUnlessStatusCode(http.StatusOK), 478 autorest.ByUnmarshallingJSON(&result), 479 autorest.ByClosing()) 480 result.Response = autorest.Response{Response: resp} 481 return 482} 483 484// listByServiceNextResults retrieves the next set of results, if any. 485func (client IdentityProviderClient) listByServiceNextResults(ctx context.Context, lastResults IdentityProviderList) (result IdentityProviderList, err error) { 486 req, err := lastResults.identityProviderListPreparer(ctx) 487 if err != nil { 488 return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "listByServiceNextResults", nil, "Failure preparing next results request") 489 } 490 if req == nil { 491 return 492 } 493 resp, err := client.ListByServiceSender(req) 494 if err != nil { 495 result.Response = autorest.Response{Response: resp} 496 return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "listByServiceNextResults", resp, "Failure sending next results request") 497 } 498 result, err = client.ListByServiceResponder(resp) 499 if err != nil { 500 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "listByServiceNextResults", resp, "Failure responding to next results request") 501 } 502 return 503} 504 505// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 506func (client IdentityProviderClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result IdentityProviderListIterator, err error) { 507 if tracing.IsEnabled() { 508 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.ListByService") 509 defer func() { 510 sc := -1 511 if result.Response().Response.Response != nil { 512 sc = result.page.Response().Response.Response.StatusCode 513 } 514 tracing.EndSpan(ctx, sc, err) 515 }() 516 } 517 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName) 518 return 519} 520 521// ListSecrets gets the client secret details of the Identity Provider. 522// Parameters: 523// resourceGroupName - the name of the resource group. 524// serviceName - the name of the API Management service. 525// identityProviderName - identity Provider Type identifier. 526func (client IdentityProviderClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (result ClientSecretContract, err error) { 527 if tracing.IsEnabled() { 528 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.ListSecrets") 529 defer func() { 530 sc := -1 531 if result.Response.Response != nil { 532 sc = result.Response.Response.StatusCode 533 } 534 tracing.EndSpan(ctx, sc, err) 535 }() 536 } 537 if err := validation.Validate([]validation.Validation{ 538 {TargetValue: serviceName, 539 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 540 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 541 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 542 return result, validation.NewError("apimanagement.IdentityProviderClient", "ListSecrets", err.Error()) 543 } 544 545 req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, identityProviderName) 546 if err != nil { 547 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListSecrets", nil, "Failure preparing request") 548 return 549 } 550 551 resp, err := client.ListSecretsSender(req) 552 if err != nil { 553 result.Response = autorest.Response{Response: resp} 554 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListSecrets", resp, "Failure sending request") 555 return 556 } 557 558 result, err = client.ListSecretsResponder(resp) 559 if err != nil { 560 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListSecrets", resp, "Failure responding to request") 561 return 562 } 563 564 return 565} 566 567// ListSecretsPreparer prepares the ListSecrets request. 568func (client IdentityProviderClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (*http.Request, error) { 569 pathParameters := map[string]interface{}{ 570 "identityProviderName": autorest.Encode("path", identityProviderName), 571 "resourceGroupName": autorest.Encode("path", resourceGroupName), 572 "serviceName": autorest.Encode("path", serviceName), 573 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 574 } 575 576 const APIVersion = "2019-12-01" 577 queryParameters := map[string]interface{}{ 578 "api-version": APIVersion, 579 } 580 581 preparer := autorest.CreatePreparer( 582 autorest.AsPost(), 583 autorest.WithBaseURL(client.BaseURI), 584 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets", pathParameters), 585 autorest.WithQueryParameters(queryParameters)) 586 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 587} 588 589// ListSecretsSender sends the ListSecrets request. The method will close the 590// http.Response Body if it receives an error. 591func (client IdentityProviderClient) ListSecretsSender(req *http.Request) (*http.Response, error) { 592 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 593} 594 595// ListSecretsResponder handles the response to the ListSecrets request. The method always 596// closes the http.Response Body. 597func (client IdentityProviderClient) ListSecretsResponder(resp *http.Response) (result ClientSecretContract, err error) { 598 err = autorest.Respond( 599 resp, 600 azure.WithErrorUnlessStatusCode(http.StatusOK), 601 autorest.ByUnmarshallingJSON(&result), 602 autorest.ByClosing()) 603 result.Response = autorest.Response{Response: resp} 604 return 605} 606 607// Update updates an existing IdentityProvider configuration. 608// Parameters: 609// resourceGroupName - the name of the resource group. 610// serviceName - the name of the API Management service. 611// identityProviderName - identity Provider Type identifier. 612// parameters - update parameters. 613// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 614// request or it should be * for unconditional update. 615func (client IdentityProviderClient) Update(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderUpdateParameters, ifMatch string) (result autorest.Response, err error) { 616 if tracing.IsEnabled() { 617 ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.Update") 618 defer func() { 619 sc := -1 620 if result.Response != nil { 621 sc = result.Response.StatusCode 622 } 623 tracing.EndSpan(ctx, sc, err) 624 }() 625 } 626 if err := validation.Validate([]validation.Validation{ 627 {TargetValue: serviceName, 628 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 629 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 630 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 631 return result, validation.NewError("apimanagement.IdentityProviderClient", "Update", err.Error()) 632 } 633 634 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, identityProviderName, parameters, ifMatch) 635 if err != nil { 636 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Update", nil, "Failure preparing request") 637 return 638 } 639 640 resp, err := client.UpdateSender(req) 641 if err != nil { 642 result.Response = resp 643 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Update", resp, "Failure sending request") 644 return 645 } 646 647 result, err = client.UpdateResponder(resp) 648 if err != nil { 649 err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Update", resp, "Failure responding to request") 650 return 651 } 652 653 return 654} 655 656// UpdatePreparer prepares the Update request. 657func (client IdentityProviderClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderUpdateParameters, ifMatch string) (*http.Request, error) { 658 pathParameters := map[string]interface{}{ 659 "identityProviderName": autorest.Encode("path", identityProviderName), 660 "resourceGroupName": autorest.Encode("path", resourceGroupName), 661 "serviceName": autorest.Encode("path", serviceName), 662 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 663 } 664 665 const APIVersion = "2019-12-01" 666 queryParameters := map[string]interface{}{ 667 "api-version": APIVersion, 668 } 669 670 preparer := autorest.CreatePreparer( 671 autorest.AsContentType("application/json; charset=utf-8"), 672 autorest.AsPatch(), 673 autorest.WithBaseURL(client.BaseURI), 674 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), 675 autorest.WithJSON(parameters), 676 autorest.WithQueryParameters(queryParameters), 677 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 678 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 679} 680 681// UpdateSender sends the Update request. The method will close the 682// http.Response Body if it receives an error. 683func (client IdentityProviderClient) UpdateSender(req *http.Request) (*http.Response, error) { 684 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 685} 686 687// UpdateResponder handles the response to the Update request. The method always 688// closes the http.Response Body. 689func (client IdentityProviderClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { 690 err = autorest.Respond( 691 resp, 692 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 693 autorest.ByClosing()) 694 result.Response = resp 695 return 696} 697