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// GatewayCertificateAuthorityClient is the apiManagement Client 19type GatewayCertificateAuthorityClient struct { 20 BaseClient 21} 22 23// NewGatewayCertificateAuthorityClient creates an instance of the GatewayCertificateAuthorityClient client. 24func NewGatewayCertificateAuthorityClient(subscriptionID string) GatewayCertificateAuthorityClient { 25 return NewGatewayCertificateAuthorityClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewGatewayCertificateAuthorityClientWithBaseURI creates an instance of the GatewayCertificateAuthorityClient client 29// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign 30// clouds, Azure stack). 31func NewGatewayCertificateAuthorityClientWithBaseURI(baseURI string, subscriptionID string) GatewayCertificateAuthorityClient { 32 return GatewayCertificateAuthorityClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// CreateOrUpdate assign Certificate entity to Gateway entity as Certificate Authority. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// serviceName - the name of the API Management service. 39// gatewayID - gateway entity identifier. Must be unique in the current API Management service instance. Must 40// not have value 'managed' 41// certificateID - identifier of the certificate entity. Must be unique in the current API Management service 42// instance. 43// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. 44func (client GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters GatewayCertificateAuthorityContract, ifMatch string) (result GatewayCertificateAuthorityContract, err error) { 45 if tracing.IsEnabled() { 46 ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.CreateOrUpdate") 47 defer func() { 48 sc := -1 49 if result.Response.Response != nil { 50 sc = result.Response.Response.StatusCode 51 } 52 tracing.EndSpan(ctx, sc, err) 53 }() 54 } 55 if err := validation.Validate([]validation.Validation{ 56 {TargetValue: serviceName, 57 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 58 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 59 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 60 {TargetValue: gatewayID, 61 Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 62 {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 63 {TargetValue: certificateID, 64 Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 65 {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, 66 {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 67 return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", err.Error()) 68 } 69 70 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID, parameters, ifMatch) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", nil, "Failure preparing request") 73 return 74 } 75 76 resp, err := client.CreateOrUpdateSender(req) 77 if err != nil { 78 result.Response = autorest.Response{Response: resp} 79 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", resp, "Failure sending request") 80 return 81 } 82 83 result, err = client.CreateOrUpdateResponder(resp) 84 if err != nil { 85 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", resp, "Failure responding to request") 86 return 87 } 88 89 return 90} 91 92// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 93func (client GatewayCertificateAuthorityClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters GatewayCertificateAuthorityContract, ifMatch string) (*http.Request, error) { 94 pathParameters := map[string]interface{}{ 95 "certificateId": autorest.Encode("path", certificateID), 96 "gatewayId": autorest.Encode("path", gatewayID), 97 "resourceGroupName": autorest.Encode("path", resourceGroupName), 98 "serviceName": autorest.Encode("path", serviceName), 99 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 100 } 101 102 const APIVersion = "2021-01-01-preview" 103 queryParameters := map[string]interface{}{ 104 "api-version": APIVersion, 105 } 106 107 preparer := autorest.CreatePreparer( 108 autorest.AsContentType("application/json; charset=utf-8"), 109 autorest.AsPut(), 110 autorest.WithBaseURL(client.BaseURI), 111 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), 112 autorest.WithJSON(parameters), 113 autorest.WithQueryParameters(queryParameters)) 114 if len(ifMatch) > 0 { 115 preparer = autorest.DecoratePreparer(preparer, 116 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 117 } 118 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 119} 120 121// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 122// http.Response Body if it receives an error. 123func (client GatewayCertificateAuthorityClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 124 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 125} 126 127// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 128// closes the http.Response Body. 129func (client GatewayCertificateAuthorityClient) CreateOrUpdateResponder(resp *http.Response) (result GatewayCertificateAuthorityContract, err error) { 130 err = autorest.Respond( 131 resp, 132 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 133 autorest.ByUnmarshallingJSON(&result), 134 autorest.ByClosing()) 135 result.Response = autorest.Response{Response: resp} 136 return 137} 138 139// Delete remove relationship between Certificate Authority and Gateway entity. 140// Parameters: 141// resourceGroupName - the name of the resource group. 142// serviceName - the name of the API Management service. 143// gatewayID - gateway entity identifier. Must be unique in the current API Management service instance. Must 144// not have value 'managed' 145// certificateID - identifier of the certificate entity. Must be unique in the current API Management service 146// instance. 147// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 148// request or it should be * for unconditional update. 149func (client GatewayCertificateAuthorityClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string) (result autorest.Response, err error) { 150 if tracing.IsEnabled() { 151 ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.Delete") 152 defer func() { 153 sc := -1 154 if result.Response != nil { 155 sc = result.Response.StatusCode 156 } 157 tracing.EndSpan(ctx, sc, err) 158 }() 159 } 160 if err := validation.Validate([]validation.Validation{ 161 {TargetValue: serviceName, 162 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 163 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 164 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 165 {TargetValue: gatewayID, 166 Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 167 {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 168 {TargetValue: certificateID, 169 Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 170 {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, 171 {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 172 return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "Delete", err.Error()) 173 } 174 175 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID, ifMatch) 176 if err != nil { 177 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Delete", nil, "Failure preparing request") 178 return 179 } 180 181 resp, err := client.DeleteSender(req) 182 if err != nil { 183 result.Response = resp 184 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Delete", resp, "Failure sending request") 185 return 186 } 187 188 result, err = client.DeleteResponder(resp) 189 if err != nil { 190 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Delete", resp, "Failure responding to request") 191 return 192 } 193 194 return 195} 196 197// DeletePreparer prepares the Delete request. 198func (client GatewayCertificateAuthorityClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string) (*http.Request, error) { 199 pathParameters := map[string]interface{}{ 200 "certificateId": autorest.Encode("path", certificateID), 201 "gatewayId": autorest.Encode("path", gatewayID), 202 "resourceGroupName": autorest.Encode("path", resourceGroupName), 203 "serviceName": autorest.Encode("path", serviceName), 204 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 205 } 206 207 const APIVersion = "2021-01-01-preview" 208 queryParameters := map[string]interface{}{ 209 "api-version": APIVersion, 210 } 211 212 preparer := autorest.CreatePreparer( 213 autorest.AsDelete(), 214 autorest.WithBaseURL(client.BaseURI), 215 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), 216 autorest.WithQueryParameters(queryParameters), 217 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 218 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 219} 220 221// DeleteSender sends the Delete request. The method will close the 222// http.Response Body if it receives an error. 223func (client GatewayCertificateAuthorityClient) DeleteSender(req *http.Request) (*http.Response, error) { 224 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 225} 226 227// DeleteResponder handles the response to the Delete request. The method always 228// closes the http.Response Body. 229func (client GatewayCertificateAuthorityClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 230 err = autorest.Respond( 231 resp, 232 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 233 autorest.ByClosing()) 234 result.Response = resp 235 return 236} 237 238// Get get assigned Gateway Certificate Authority details. 239// Parameters: 240// resourceGroupName - the name of the resource group. 241// serviceName - the name of the API Management service. 242// gatewayID - gateway entity identifier. Must be unique in the current API Management service instance. Must 243// not have value 'managed' 244// certificateID - identifier of the certificate entity. Must be unique in the current API Management service 245// instance. 246func (client GatewayCertificateAuthorityClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (result GatewayCertificateAuthorityContract, err error) { 247 if tracing.IsEnabled() { 248 ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.Get") 249 defer func() { 250 sc := -1 251 if result.Response.Response != nil { 252 sc = result.Response.Response.StatusCode 253 } 254 tracing.EndSpan(ctx, sc, err) 255 }() 256 } 257 if err := validation.Validate([]validation.Validation{ 258 {TargetValue: serviceName, 259 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 260 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 261 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 262 {TargetValue: gatewayID, 263 Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 264 {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 265 {TargetValue: certificateID, 266 Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 267 {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, 268 {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 269 return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "Get", err.Error()) 270 } 271 272 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID) 273 if err != nil { 274 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Get", nil, "Failure preparing request") 275 return 276 } 277 278 resp, err := client.GetSender(req) 279 if err != nil { 280 result.Response = autorest.Response{Response: resp} 281 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Get", resp, "Failure sending request") 282 return 283 } 284 285 result, err = client.GetResponder(resp) 286 if err != nil { 287 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Get", resp, "Failure responding to request") 288 return 289 } 290 291 return 292} 293 294// GetPreparer prepares the Get request. 295func (client GatewayCertificateAuthorityClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (*http.Request, error) { 296 pathParameters := map[string]interface{}{ 297 "certificateId": autorest.Encode("path", certificateID), 298 "gatewayId": autorest.Encode("path", gatewayID), 299 "resourceGroupName": autorest.Encode("path", resourceGroupName), 300 "serviceName": autorest.Encode("path", serviceName), 301 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 302 } 303 304 const APIVersion = "2021-01-01-preview" 305 queryParameters := map[string]interface{}{ 306 "api-version": APIVersion, 307 } 308 309 preparer := autorest.CreatePreparer( 310 autorest.AsGet(), 311 autorest.WithBaseURL(client.BaseURI), 312 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), 313 autorest.WithQueryParameters(queryParameters)) 314 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 315} 316 317// GetSender sends the Get request. The method will close the 318// http.Response Body if it receives an error. 319func (client GatewayCertificateAuthorityClient) GetSender(req *http.Request) (*http.Response, error) { 320 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 321} 322 323// GetResponder handles the response to the Get request. The method always 324// closes the http.Response Body. 325func (client GatewayCertificateAuthorityClient) GetResponder(resp *http.Response) (result GatewayCertificateAuthorityContract, err error) { 326 err = autorest.Respond( 327 resp, 328 azure.WithErrorUnlessStatusCode(http.StatusOK), 329 autorest.ByUnmarshallingJSON(&result), 330 autorest.ByClosing()) 331 result.Response = autorest.Response{Response: resp} 332 return 333} 334 335// GetEntityTag checks if Certificate entity is assigned to Gateway entity as Certificate Authority. 336// Parameters: 337// resourceGroupName - the name of the resource group. 338// serviceName - the name of the API Management service. 339// gatewayID - gateway entity identifier. Must be unique in the current API Management service instance. Must 340// not have value 'managed' 341// certificateID - identifier of the certificate entity. Must be unique in the current API Management service 342// instance. 343func (client GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (result autorest.Response, err error) { 344 if tracing.IsEnabled() { 345 ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.GetEntityTag") 346 defer func() { 347 sc := -1 348 if result.Response != nil { 349 sc = result.Response.StatusCode 350 } 351 tracing.EndSpan(ctx, sc, err) 352 }() 353 } 354 if err := validation.Validate([]validation.Validation{ 355 {TargetValue: serviceName, 356 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 357 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 358 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 359 {TargetValue: gatewayID, 360 Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 361 {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 362 {TargetValue: certificateID, 363 Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 364 {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, 365 {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 366 return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", err.Error()) 367 } 368 369 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID) 370 if err != nil { 371 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", nil, "Failure preparing request") 372 return 373 } 374 375 resp, err := client.GetEntityTagSender(req) 376 if err != nil { 377 result.Response = resp 378 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", resp, "Failure sending request") 379 return 380 } 381 382 result, err = client.GetEntityTagResponder(resp) 383 if err != nil { 384 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", resp, "Failure responding to request") 385 return 386 } 387 388 return 389} 390 391// GetEntityTagPreparer prepares the GetEntityTag request. 392func (client GatewayCertificateAuthorityClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (*http.Request, error) { 393 pathParameters := map[string]interface{}{ 394 "certificateId": autorest.Encode("path", certificateID), 395 "gatewayId": autorest.Encode("path", gatewayID), 396 "resourceGroupName": autorest.Encode("path", resourceGroupName), 397 "serviceName": autorest.Encode("path", serviceName), 398 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 399 } 400 401 const APIVersion = "2021-01-01-preview" 402 queryParameters := map[string]interface{}{ 403 "api-version": APIVersion, 404 } 405 406 preparer := autorest.CreatePreparer( 407 autorest.AsHead(), 408 autorest.WithBaseURL(client.BaseURI), 409 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), 410 autorest.WithQueryParameters(queryParameters)) 411 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 412} 413 414// GetEntityTagSender sends the GetEntityTag request. The method will close the 415// http.Response Body if it receives an error. 416func (client GatewayCertificateAuthorityClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { 417 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 418} 419 420// GetEntityTagResponder handles the response to the GetEntityTag request. The method always 421// closes the http.Response Body. 422func (client GatewayCertificateAuthorityClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { 423 err = autorest.Respond( 424 resp, 425 azure.WithErrorUnlessStatusCode(http.StatusOK), 426 autorest.ByClosing()) 427 result.Response = resp 428 return 429} 430 431// ListByService lists the collection of Certificate Authorities for the specified Gateway entity. 432// Parameters: 433// resourceGroupName - the name of the resource group. 434// serviceName - the name of the API Management service. 435// gatewayID - gateway entity identifier. Must be unique in the current API Management service instance. Must 436// not have value 'managed' 437// filter - | Field | Usage | Supported operators | Supported functions 438// |</br>|-------------|-------------|-------------|-------------|</br>| name | filter | eq, ne | |</br> 439// top - number of records to return. 440// skip - number of records to skip. 441func (client GatewayCertificateAuthorityClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result GatewayCertificateAuthorityCollectionPage, err error) { 442 if tracing.IsEnabled() { 443 ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.ListByService") 444 defer func() { 445 sc := -1 446 if result.gcac.Response.Response != nil { 447 sc = result.gcac.Response.Response.StatusCode 448 } 449 tracing.EndSpan(ctx, sc, err) 450 }() 451 } 452 if err := validation.Validate([]validation.Validation{ 453 {TargetValue: serviceName, 454 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 455 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 456 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 457 {TargetValue: gatewayID, 458 Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 459 {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 460 {TargetValue: top, 461 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 462 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 463 {TargetValue: skip, 464 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 465 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 466 return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "ListByService", err.Error()) 467 } 468 469 result.fn = client.listByServiceNextResults 470 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) 471 if err != nil { 472 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "ListByService", nil, "Failure preparing request") 473 return 474 } 475 476 resp, err := client.ListByServiceSender(req) 477 if err != nil { 478 result.gcac.Response = autorest.Response{Response: resp} 479 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "ListByService", resp, "Failure sending request") 480 return 481 } 482 483 result.gcac, err = client.ListByServiceResponder(resp) 484 if err != nil { 485 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "ListByService", resp, "Failure responding to request") 486 return 487 } 488 if result.gcac.hasNextLink() && result.gcac.IsEmpty() { 489 err = result.NextWithContext(ctx) 490 return 491 } 492 493 return 494} 495 496// ListByServicePreparer prepares the ListByService request. 497func (client GatewayCertificateAuthorityClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (*http.Request, error) { 498 pathParameters := map[string]interface{}{ 499 "gatewayId": autorest.Encode("path", gatewayID), 500 "resourceGroupName": autorest.Encode("path", resourceGroupName), 501 "serviceName": autorest.Encode("path", serviceName), 502 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 503 } 504 505 const APIVersion = "2021-01-01-preview" 506 queryParameters := map[string]interface{}{ 507 "api-version": APIVersion, 508 } 509 if len(filter) > 0 { 510 queryParameters["$filter"] = autorest.Encode("query", filter) 511 } 512 if top != nil { 513 queryParameters["$top"] = autorest.Encode("query", *top) 514 } 515 if skip != nil { 516 queryParameters["$skip"] = autorest.Encode("query", *skip) 517 } 518 519 preparer := autorest.CreatePreparer( 520 autorest.AsGet(), 521 autorest.WithBaseURL(client.BaseURI), 522 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities", pathParameters), 523 autorest.WithQueryParameters(queryParameters)) 524 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 525} 526 527// ListByServiceSender sends the ListByService request. The method will close the 528// http.Response Body if it receives an error. 529func (client GatewayCertificateAuthorityClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 530 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 531} 532 533// ListByServiceResponder handles the response to the ListByService request. The method always 534// closes the http.Response Body. 535func (client GatewayCertificateAuthorityClient) ListByServiceResponder(resp *http.Response) (result GatewayCertificateAuthorityCollection, err error) { 536 err = autorest.Respond( 537 resp, 538 azure.WithErrorUnlessStatusCode(http.StatusOK), 539 autorest.ByUnmarshallingJSON(&result), 540 autorest.ByClosing()) 541 result.Response = autorest.Response{Response: resp} 542 return 543} 544 545// listByServiceNextResults retrieves the next set of results, if any. 546func (client GatewayCertificateAuthorityClient) listByServiceNextResults(ctx context.Context, lastResults GatewayCertificateAuthorityCollection) (result GatewayCertificateAuthorityCollection, err error) { 547 req, err := lastResults.gatewayCertificateAuthorityCollectionPreparer(ctx) 548 if err != nil { 549 return result, autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "listByServiceNextResults", nil, "Failure preparing next results request") 550 } 551 if req == nil { 552 return 553 } 554 resp, err := client.ListByServiceSender(req) 555 if err != nil { 556 result.Response = autorest.Response{Response: resp} 557 return result, autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "listByServiceNextResults", resp, "Failure sending next results request") 558 } 559 result, err = client.ListByServiceResponder(resp) 560 if err != nil { 561 err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "listByServiceNextResults", resp, "Failure responding to next results request") 562 } 563 return 564} 565 566// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 567func (client GatewayCertificateAuthorityClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result GatewayCertificateAuthorityCollectionIterator, err error) { 568 if tracing.IsEnabled() { 569 ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.ListByService") 570 defer func() { 571 sc := -1 572 if result.Response().Response.Response != nil { 573 sc = result.page.Response().Response.Response.StatusCode 574 } 575 tracing.EndSpan(ctx, sc, err) 576 }() 577 } 578 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) 579 return 580} 581