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