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// AuthorizationServerClient is the apiManagement Client 19type AuthorizationServerClient struct { 20 BaseClient 21} 22 23// NewAuthorizationServerClient creates an instance of the AuthorizationServerClient client. 24func NewAuthorizationServerClient(subscriptionID string) AuthorizationServerClient { 25 return NewAuthorizationServerClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewAuthorizationServerClientWithBaseURI creates an instance of the AuthorizationServerClient 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 NewAuthorizationServerClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationServerClient { 32 return AuthorizationServerClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// CreateOrUpdate creates new authorization server or updates an existing authorization server. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// serviceName - the name of the API Management service. 39// authsid - identifier of the authorization server. 40// parameters - create or update parameters. 41func (client AuthorizationServerClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerContract) (result AuthorizationServerContract, err error) { 42 if tracing.IsEnabled() { 43 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.CreateOrUpdate") 44 defer func() { 45 sc := -1 46 if result.Response.Response != nil { 47 sc = result.Response.Response.StatusCode 48 } 49 tracing.EndSpan(ctx, sc, err) 50 }() 51 } 52 if err := validation.Validate([]validation.Validation{ 53 {TargetValue: serviceName, 54 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 55 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 56 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 57 {TargetValue: authsid, 58 Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 59 {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 60 {TargetValue: parameters, 61 Constraints: []validation.Constraint{{Target: "parameters.AuthorizationServerContractProperties", Name: validation.Null, Rule: false, 62 Chain: []validation.Constraint{{Target: "parameters.AuthorizationServerContractProperties.DisplayName", Name: validation.Null, Rule: true, 63 Chain: []validation.Constraint{{Target: "parameters.AuthorizationServerContractProperties.DisplayName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 64 {Target: "parameters.AuthorizationServerContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, 65 }}, 66 {Target: "parameters.AuthorizationServerContractProperties.ClientRegistrationEndpoint", Name: validation.Null, Rule: true, Chain: nil}, 67 {Target: "parameters.AuthorizationServerContractProperties.AuthorizationEndpoint", Name: validation.Null, Rule: true, Chain: nil}, 68 {Target: "parameters.AuthorizationServerContractProperties.GrantTypes", Name: validation.Null, Rule: true, Chain: nil}, 69 {Target: "parameters.AuthorizationServerContractProperties.ClientID", Name: validation.Null, Rule: true, Chain: nil}, 70 }}}}}); err != nil { 71 return result, validation.NewError("apimanagement.AuthorizationServerClient", "CreateOrUpdate", err.Error()) 72 } 73 74 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, authsid, parameters) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "CreateOrUpdate", nil, "Failure preparing request") 77 return 78 } 79 80 resp, err := client.CreateOrUpdateSender(req) 81 if err != nil { 82 result.Response = autorest.Response{Response: resp} 83 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "CreateOrUpdate", resp, "Failure sending request") 84 return 85 } 86 87 result, err = client.CreateOrUpdateResponder(resp) 88 if err != nil { 89 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "CreateOrUpdate", resp, "Failure responding to request") 90 return 91 } 92 93 return 94} 95 96// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 97func (client AuthorizationServerClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerContract) (*http.Request, error) { 98 pathParameters := map[string]interface{}{ 99 "authsid": autorest.Encode("path", authsid), 100 "resourceGroupName": autorest.Encode("path", resourceGroupName), 101 "serviceName": autorest.Encode("path", serviceName), 102 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 103 } 104 105 const APIVersion = "2017-03-01" 106 queryParameters := map[string]interface{}{ 107 "api-version": APIVersion, 108 } 109 110 preparer := autorest.CreatePreparer( 111 autorest.AsContentType("application/json; charset=utf-8"), 112 autorest.AsPut(), 113 autorest.WithBaseURL(client.BaseURI), 114 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), 115 autorest.WithJSON(parameters), 116 autorest.WithQueryParameters(queryParameters)) 117 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 118} 119 120// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 121// http.Response Body if it receives an error. 122func (client AuthorizationServerClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 123 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 124} 125 126// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 127// closes the http.Response Body. 128func (client AuthorizationServerClient) CreateOrUpdateResponder(resp *http.Response) (result AuthorizationServerContract, err error) { 129 err = autorest.Respond( 130 resp, 131 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 132 autorest.ByUnmarshallingJSON(&result), 133 autorest.ByClosing()) 134 result.Response = autorest.Response{Response: resp} 135 return 136} 137 138// Delete deletes specific authorization server instance. 139// Parameters: 140// resourceGroupName - the name of the resource group. 141// serviceName - the name of the API Management service. 142// authsid - identifier of the authorization server. 143// ifMatch - the entity state (Etag) version of the authentication server to delete. A value of "*" can be used 144// for If-Match to unconditionally apply the operation. 145func (client AuthorizationServerClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string) (result autorest.Response, err error) { 146 if tracing.IsEnabled() { 147 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.Delete") 148 defer func() { 149 sc := -1 150 if result.Response != nil { 151 sc = result.Response.StatusCode 152 } 153 tracing.EndSpan(ctx, sc, err) 154 }() 155 } 156 if err := validation.Validate([]validation.Validation{ 157 {TargetValue: serviceName, 158 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 159 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 160 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 161 {TargetValue: authsid, 162 Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 163 {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 164 return result, validation.NewError("apimanagement.AuthorizationServerClient", "Delete", err.Error()) 165 } 166 167 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, authsid, ifMatch) 168 if err != nil { 169 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Delete", nil, "Failure preparing request") 170 return 171 } 172 173 resp, err := client.DeleteSender(req) 174 if err != nil { 175 result.Response = resp 176 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Delete", resp, "Failure sending request") 177 return 178 } 179 180 result, err = client.DeleteResponder(resp) 181 if err != nil { 182 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Delete", resp, "Failure responding to request") 183 return 184 } 185 186 return 187} 188 189// DeletePreparer prepares the Delete request. 190func (client AuthorizationServerClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string) (*http.Request, error) { 191 pathParameters := map[string]interface{}{ 192 "authsid": autorest.Encode("path", authsid), 193 "resourceGroupName": autorest.Encode("path", resourceGroupName), 194 "serviceName": autorest.Encode("path", serviceName), 195 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 196 } 197 198 const APIVersion = "2017-03-01" 199 queryParameters := map[string]interface{}{ 200 "api-version": APIVersion, 201 } 202 203 preparer := autorest.CreatePreparer( 204 autorest.AsDelete(), 205 autorest.WithBaseURL(client.BaseURI), 206 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), 207 autorest.WithQueryParameters(queryParameters), 208 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 209 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 210} 211 212// DeleteSender sends the Delete request. The method will close the 213// http.Response Body if it receives an error. 214func (client AuthorizationServerClient) DeleteSender(req *http.Request) (*http.Response, error) { 215 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 216} 217 218// DeleteResponder handles the response to the Delete request. The method always 219// closes the http.Response Body. 220func (client AuthorizationServerClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 221 err = autorest.Respond( 222 resp, 223 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 224 autorest.ByClosing()) 225 result.Response = resp 226 return 227} 228 229// Get gets the details of the authorization server specified by its identifier. 230// Parameters: 231// resourceGroupName - the name of the resource group. 232// serviceName - the name of the API Management service. 233// authsid - identifier of the authorization server. 234func (client AuthorizationServerClient) Get(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result AuthorizationServerContract, err error) { 235 if tracing.IsEnabled() { 236 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.Get") 237 defer func() { 238 sc := -1 239 if result.Response.Response != nil { 240 sc = result.Response.Response.StatusCode 241 } 242 tracing.EndSpan(ctx, sc, err) 243 }() 244 } 245 if err := validation.Validate([]validation.Validation{ 246 {TargetValue: serviceName, 247 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 248 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 249 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 250 {TargetValue: authsid, 251 Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 252 {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 253 return result, validation.NewError("apimanagement.AuthorizationServerClient", "Get", err.Error()) 254 } 255 256 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, authsid) 257 if err != nil { 258 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Get", nil, "Failure preparing request") 259 return 260 } 261 262 resp, err := client.GetSender(req) 263 if err != nil { 264 result.Response = autorest.Response{Response: resp} 265 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Get", resp, "Failure sending request") 266 return 267 } 268 269 result, err = client.GetResponder(resp) 270 if err != nil { 271 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Get", resp, "Failure responding to request") 272 return 273 } 274 275 return 276} 277 278// GetPreparer prepares the Get request. 279func (client AuthorizationServerClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (*http.Request, error) { 280 pathParameters := map[string]interface{}{ 281 "authsid": autorest.Encode("path", authsid), 282 "resourceGroupName": autorest.Encode("path", resourceGroupName), 283 "serviceName": autorest.Encode("path", serviceName), 284 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 285 } 286 287 const APIVersion = "2017-03-01" 288 queryParameters := map[string]interface{}{ 289 "api-version": APIVersion, 290 } 291 292 preparer := autorest.CreatePreparer( 293 autorest.AsGet(), 294 autorest.WithBaseURL(client.BaseURI), 295 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), 296 autorest.WithQueryParameters(queryParameters)) 297 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 298} 299 300// GetSender sends the Get request. The method will close the 301// http.Response Body if it receives an error. 302func (client AuthorizationServerClient) GetSender(req *http.Request) (*http.Response, error) { 303 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 304} 305 306// GetResponder handles the response to the Get request. The method always 307// closes the http.Response Body. 308func (client AuthorizationServerClient) GetResponder(resp *http.Response) (result AuthorizationServerContract, err error) { 309 err = autorest.Respond( 310 resp, 311 azure.WithErrorUnlessStatusCode(http.StatusOK), 312 autorest.ByUnmarshallingJSON(&result), 313 autorest.ByClosing()) 314 result.Response = autorest.Response{Response: resp} 315 return 316} 317 318// GetEntityTag gets the entity state (Etag) version of the authorizationServer specified by its identifier. 319// Parameters: 320// resourceGroupName - the name of the resource group. 321// serviceName - the name of the API Management service. 322// authsid - identifier of the authorization server. 323func (client AuthorizationServerClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result autorest.Response, err error) { 324 if tracing.IsEnabled() { 325 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.GetEntityTag") 326 defer func() { 327 sc := -1 328 if result.Response != nil { 329 sc = result.Response.StatusCode 330 } 331 tracing.EndSpan(ctx, sc, err) 332 }() 333 } 334 if err := validation.Validate([]validation.Validation{ 335 {TargetValue: serviceName, 336 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 337 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 338 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 339 {TargetValue: authsid, 340 Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 341 {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 342 return result, validation.NewError("apimanagement.AuthorizationServerClient", "GetEntityTag", err.Error()) 343 } 344 345 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, authsid) 346 if err != nil { 347 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "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.AuthorizationServerClient", "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.AuthorizationServerClient", "GetEntityTag", resp, "Failure responding to request") 361 return 362 } 363 364 return 365} 366 367// GetEntityTagPreparer prepares the GetEntityTag request. 368func (client AuthorizationServerClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (*http.Request, error) { 369 pathParameters := map[string]interface{}{ 370 "authsid": autorest.Encode("path", authsid), 371 "resourceGroupName": autorest.Encode("path", resourceGroupName), 372 "serviceName": autorest.Encode("path", serviceName), 373 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 374 } 375 376 const APIVersion = "2017-03-01" 377 queryParameters := map[string]interface{}{ 378 "api-version": APIVersion, 379 } 380 381 preparer := autorest.CreatePreparer( 382 autorest.AsHead(), 383 autorest.WithBaseURL(client.BaseURI), 384 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), 385 autorest.WithQueryParameters(queryParameters)) 386 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 387} 388 389// GetEntityTagSender sends the GetEntityTag request. The method will close the 390// http.Response Body if it receives an error. 391func (client AuthorizationServerClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { 392 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 393} 394 395// GetEntityTagResponder handles the response to the GetEntityTag request. The method always 396// closes the http.Response Body. 397func (client AuthorizationServerClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { 398 err = autorest.Respond( 399 resp, 400 azure.WithErrorUnlessStatusCode(http.StatusOK), 401 autorest.ByClosing()) 402 result.Response = resp 403 return 404} 405 406// ListByService lists a collection of authorization servers defined within a service instance. 407// Parameters: 408// resourceGroupName - the name of the resource group. 409// serviceName - the name of the API Management service. 410// filter - | Field | Supported operators | Supported functions | 411// |-------|------------------------|---------------------------------------------| 412// | id | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | 413// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | 414// top - number of records to return. 415// skip - number of records to skip. 416func (client AuthorizationServerClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result AuthorizationServerCollectionPage, err error) { 417 if tracing.IsEnabled() { 418 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.ListByService") 419 defer func() { 420 sc := -1 421 if result.asc.Response.Response != nil { 422 sc = result.asc.Response.Response.StatusCode 423 } 424 tracing.EndSpan(ctx, sc, err) 425 }() 426 } 427 if err := validation.Validate([]validation.Validation{ 428 {TargetValue: serviceName, 429 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 430 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 431 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 432 {TargetValue: top, 433 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 434 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 435 {TargetValue: skip, 436 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 437 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 438 return result, validation.NewError("apimanagement.AuthorizationServerClient", "ListByService", err.Error()) 439 } 440 441 result.fn = client.listByServiceNextResults 442 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 443 if err != nil { 444 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListByService", nil, "Failure preparing request") 445 return 446 } 447 448 resp, err := client.ListByServiceSender(req) 449 if err != nil { 450 result.asc.Response = autorest.Response{Response: resp} 451 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListByService", resp, "Failure sending request") 452 return 453 } 454 455 result.asc, err = client.ListByServiceResponder(resp) 456 if err != nil { 457 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListByService", resp, "Failure responding to request") 458 return 459 } 460 if result.asc.hasNextLink() && result.asc.IsEmpty() { 461 err = result.NextWithContext(ctx) 462 return 463 } 464 465 return 466} 467 468// ListByServicePreparer prepares the ListByService request. 469func (client AuthorizationServerClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 470 pathParameters := map[string]interface{}{ 471 "resourceGroupName": autorest.Encode("path", resourceGroupName), 472 "serviceName": autorest.Encode("path", serviceName), 473 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 474 } 475 476 const APIVersion = "2017-03-01" 477 queryParameters := map[string]interface{}{ 478 "api-version": APIVersion, 479 } 480 if len(filter) > 0 { 481 queryParameters["$filter"] = autorest.Encode("query", filter) 482 } 483 if top != nil { 484 queryParameters["$top"] = autorest.Encode("query", *top) 485 } 486 if skip != nil { 487 queryParameters["$skip"] = autorest.Encode("query", *skip) 488 } 489 490 preparer := autorest.CreatePreparer( 491 autorest.AsGet(), 492 autorest.WithBaseURL(client.BaseURI), 493 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers", pathParameters), 494 autorest.WithQueryParameters(queryParameters)) 495 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 496} 497 498// ListByServiceSender sends the ListByService request. The method will close the 499// http.Response Body if it receives an error. 500func (client AuthorizationServerClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 501 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 502} 503 504// ListByServiceResponder handles the response to the ListByService request. The method always 505// closes the http.Response Body. 506func (client AuthorizationServerClient) ListByServiceResponder(resp *http.Response) (result AuthorizationServerCollection, err error) { 507 err = autorest.Respond( 508 resp, 509 azure.WithErrorUnlessStatusCode(http.StatusOK), 510 autorest.ByUnmarshallingJSON(&result), 511 autorest.ByClosing()) 512 result.Response = autorest.Response{Response: resp} 513 return 514} 515 516// listByServiceNextResults retrieves the next set of results, if any. 517func (client AuthorizationServerClient) listByServiceNextResults(ctx context.Context, lastResults AuthorizationServerCollection) (result AuthorizationServerCollection, err error) { 518 req, err := lastResults.authorizationServerCollectionPreparer(ctx) 519 if err != nil { 520 return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "listByServiceNextResults", nil, "Failure preparing next results request") 521 } 522 if req == nil { 523 return 524 } 525 resp, err := client.ListByServiceSender(req) 526 if err != nil { 527 result.Response = autorest.Response{Response: resp} 528 return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "listByServiceNextResults", resp, "Failure sending next results request") 529 } 530 result, err = client.ListByServiceResponder(resp) 531 if err != nil { 532 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "listByServiceNextResults", resp, "Failure responding to next results request") 533 } 534 return 535} 536 537// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 538func (client AuthorizationServerClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result AuthorizationServerCollectionIterator, err error) { 539 if tracing.IsEnabled() { 540 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.ListByService") 541 defer func() { 542 sc := -1 543 if result.Response().Response.Response != nil { 544 sc = result.page.Response().Response.Response.StatusCode 545 } 546 tracing.EndSpan(ctx, sc, err) 547 }() 548 } 549 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) 550 return 551} 552 553// Update updates the details of the authorization server specified by its identifier. 554// Parameters: 555// resourceGroupName - the name of the resource group. 556// serviceName - the name of the API Management service. 557// authsid - identifier of the authorization server. 558// parameters - oAuth2 Server settings Update parameters. 559// ifMatch - the entity state (Etag) version of the authorization server to update. A value of "*" can be used 560// for If-Match to unconditionally apply the operation. 561func (client AuthorizationServerClient) Update(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerUpdateContract, ifMatch string) (result autorest.Response, err error) { 562 if tracing.IsEnabled() { 563 ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.Update") 564 defer func() { 565 sc := -1 566 if result.Response != nil { 567 sc = result.Response.StatusCode 568 } 569 tracing.EndSpan(ctx, sc, err) 570 }() 571 } 572 if err := validation.Validate([]validation.Validation{ 573 {TargetValue: serviceName, 574 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 575 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 576 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 577 {TargetValue: authsid, 578 Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 579 {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 580 return result, validation.NewError("apimanagement.AuthorizationServerClient", "Update", err.Error()) 581 } 582 583 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, authsid, parameters, ifMatch) 584 if err != nil { 585 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Update", nil, "Failure preparing request") 586 return 587 } 588 589 resp, err := client.UpdateSender(req) 590 if err != nil { 591 result.Response = resp 592 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Update", resp, "Failure sending request") 593 return 594 } 595 596 result, err = client.UpdateResponder(resp) 597 if err != nil { 598 err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Update", resp, "Failure responding to request") 599 return 600 } 601 602 return 603} 604 605// UpdatePreparer prepares the Update request. 606func (client AuthorizationServerClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerUpdateContract, ifMatch string) (*http.Request, error) { 607 pathParameters := map[string]interface{}{ 608 "authsid": autorest.Encode("path", authsid), 609 "resourceGroupName": autorest.Encode("path", resourceGroupName), 610 "serviceName": autorest.Encode("path", serviceName), 611 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 612 } 613 614 const APIVersion = "2017-03-01" 615 queryParameters := map[string]interface{}{ 616 "api-version": APIVersion, 617 } 618 619 preparer := autorest.CreatePreparer( 620 autorest.AsContentType("application/json; charset=utf-8"), 621 autorest.AsPatch(), 622 autorest.WithBaseURL(client.BaseURI), 623 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), 624 autorest.WithJSON(parameters), 625 autorest.WithQueryParameters(queryParameters), 626 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 627 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 628} 629 630// UpdateSender sends the Update request. The method will close the 631// http.Response Body if it receives an error. 632func (client AuthorizationServerClient) UpdateSender(req *http.Request) (*http.Response, error) { 633 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 634} 635 636// UpdateResponder handles the response to the Update request. The method always 637// closes the http.Response Body. 638func (client AuthorizationServerClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { 639 err = autorest.Respond( 640 resp, 641 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 642 autorest.ByClosing()) 643 result.Response = resp 644 return 645} 646