1package web 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/tracing" 14 "net/http" 15) 16 17// CertificatesClient is the webSite Management Client 18type CertificatesClient struct { 19 BaseClient 20} 21 22// NewCertificatesClient creates an instance of the CertificatesClient client. 23func NewCertificatesClient(subscriptionID string) CertificatesClient { 24 return NewCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewCertificatesClientWithBaseURI creates an instance of the CertificatesClient client using a custom endpoint. Use 28// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewCertificatesClientWithBaseURI(baseURI string, subscriptionID string) CertificatesClient { 30 return CertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} 31} 32 33// CreateOrUpdateCertificate sends the create or update certificate request. 34// Parameters: 35// resourceGroupName - name of the resource group 36// name - name of the certificate. 37// certificateEnvelope - details of certificate if it exists already. 38func (client CertificatesClient) CreateOrUpdateCertificate(ctx context.Context, resourceGroupName string, name string, certificateEnvelope Certificate) (result Certificate, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.CreateOrUpdateCertificate") 41 defer func() { 42 sc := -1 43 if result.Response.Response != nil { 44 sc = result.Response.Response.StatusCode 45 } 46 tracing.EndSpan(ctx, sc, err) 47 }() 48 } 49 req, err := client.CreateOrUpdateCertificatePreparer(ctx, resourceGroupName, name, certificateEnvelope) 50 if err != nil { 51 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "CreateOrUpdateCertificate", nil, "Failure preparing request") 52 return 53 } 54 55 resp, err := client.CreateOrUpdateCertificateSender(req) 56 if err != nil { 57 result.Response = autorest.Response{Response: resp} 58 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "CreateOrUpdateCertificate", resp, "Failure sending request") 59 return 60 } 61 62 result, err = client.CreateOrUpdateCertificateResponder(resp) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "CreateOrUpdateCertificate", resp, "Failure responding to request") 65 return 66 } 67 68 return 69} 70 71// CreateOrUpdateCertificatePreparer prepares the CreateOrUpdateCertificate request. 72func (client CertificatesClient) CreateOrUpdateCertificatePreparer(ctx context.Context, resourceGroupName string, name string, certificateEnvelope Certificate) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "name": autorest.Encode("path", name), 75 "resourceGroupName": autorest.Encode("path", resourceGroupName), 76 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 77 } 78 79 const APIVersion = "2015-08-01" 80 queryParameters := map[string]interface{}{ 81 "api-version": APIVersion, 82 } 83 84 preparer := autorest.CreatePreparer( 85 autorest.AsContentType("application/json; charset=utf-8"), 86 autorest.AsPut(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{name}", pathParameters), 89 autorest.WithJSON(certificateEnvelope), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// CreateOrUpdateCertificateSender sends the CreateOrUpdateCertificate request. The method will close the 95// http.Response Body if it receives an error. 96func (client CertificatesClient) CreateOrUpdateCertificateSender(req *http.Request) (*http.Response, error) { 97 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 98} 99 100// CreateOrUpdateCertificateResponder handles the response to the CreateOrUpdateCertificate request. The method always 101// closes the http.Response Body. 102func (client CertificatesClient) CreateOrUpdateCertificateResponder(resp *http.Response) (result Certificate, err error) { 103 err = autorest.Respond( 104 resp, 105 azure.WithErrorUnlessStatusCode(http.StatusOK), 106 autorest.ByUnmarshallingJSON(&result), 107 autorest.ByClosing()) 108 result.Response = autorest.Response{Response: resp} 109 return 110} 111 112// CreateOrUpdateCsr sends the create or update csr request. 113// Parameters: 114// resourceGroupName - name of the resource group 115// name - name of the certificate. 116// csrEnvelope - details of certificate signing request if it exists already. 117func (client CertificatesClient) CreateOrUpdateCsr(ctx context.Context, resourceGroupName string, name string, csrEnvelope Csr) (result Csr, err error) { 118 if tracing.IsEnabled() { 119 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.CreateOrUpdateCsr") 120 defer func() { 121 sc := -1 122 if result.Response.Response != nil { 123 sc = result.Response.Response.StatusCode 124 } 125 tracing.EndSpan(ctx, sc, err) 126 }() 127 } 128 req, err := client.CreateOrUpdateCsrPreparer(ctx, resourceGroupName, name, csrEnvelope) 129 if err != nil { 130 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "CreateOrUpdateCsr", nil, "Failure preparing request") 131 return 132 } 133 134 resp, err := client.CreateOrUpdateCsrSender(req) 135 if err != nil { 136 result.Response = autorest.Response{Response: resp} 137 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "CreateOrUpdateCsr", resp, "Failure sending request") 138 return 139 } 140 141 result, err = client.CreateOrUpdateCsrResponder(resp) 142 if err != nil { 143 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "CreateOrUpdateCsr", resp, "Failure responding to request") 144 return 145 } 146 147 return 148} 149 150// CreateOrUpdateCsrPreparer prepares the CreateOrUpdateCsr request. 151func (client CertificatesClient) CreateOrUpdateCsrPreparer(ctx context.Context, resourceGroupName string, name string, csrEnvelope Csr) (*http.Request, error) { 152 pathParameters := map[string]interface{}{ 153 "name": autorest.Encode("path", name), 154 "resourceGroupName": autorest.Encode("path", resourceGroupName), 155 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 156 } 157 158 const APIVersion = "2015-08-01" 159 queryParameters := map[string]interface{}{ 160 "api-version": APIVersion, 161 } 162 163 preparer := autorest.CreatePreparer( 164 autorest.AsContentType("application/json; charset=utf-8"), 165 autorest.AsPut(), 166 autorest.WithBaseURL(client.BaseURI), 167 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs/{name}", pathParameters), 168 autorest.WithJSON(csrEnvelope), 169 autorest.WithQueryParameters(queryParameters)) 170 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 171} 172 173// CreateOrUpdateCsrSender sends the CreateOrUpdateCsr request. The method will close the 174// http.Response Body if it receives an error. 175func (client CertificatesClient) CreateOrUpdateCsrSender(req *http.Request) (*http.Response, error) { 176 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 177} 178 179// CreateOrUpdateCsrResponder handles the response to the CreateOrUpdateCsr request. The method always 180// closes the http.Response Body. 181func (client CertificatesClient) CreateOrUpdateCsrResponder(resp *http.Response) (result Csr, err error) { 182 err = autorest.Respond( 183 resp, 184 azure.WithErrorUnlessStatusCode(http.StatusOK), 185 autorest.ByUnmarshallingJSON(&result), 186 autorest.ByClosing()) 187 result.Response = autorest.Response{Response: resp} 188 return 189} 190 191// DeleteCertificate sends the delete certificate request. 192// Parameters: 193// resourceGroupName - name of the resource group 194// name - name of the certificate to be deleted. 195func (client CertificatesClient) DeleteCertificate(ctx context.Context, resourceGroupName string, name string) (result SetObject, err error) { 196 if tracing.IsEnabled() { 197 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.DeleteCertificate") 198 defer func() { 199 sc := -1 200 if result.Response.Response != nil { 201 sc = result.Response.Response.StatusCode 202 } 203 tracing.EndSpan(ctx, sc, err) 204 }() 205 } 206 req, err := client.DeleteCertificatePreparer(ctx, resourceGroupName, name) 207 if err != nil { 208 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "DeleteCertificate", nil, "Failure preparing request") 209 return 210 } 211 212 resp, err := client.DeleteCertificateSender(req) 213 if err != nil { 214 result.Response = autorest.Response{Response: resp} 215 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "DeleteCertificate", resp, "Failure sending request") 216 return 217 } 218 219 result, err = client.DeleteCertificateResponder(resp) 220 if err != nil { 221 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "DeleteCertificate", resp, "Failure responding to request") 222 return 223 } 224 225 return 226} 227 228// DeleteCertificatePreparer prepares the DeleteCertificate request. 229func (client CertificatesClient) DeleteCertificatePreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { 230 pathParameters := map[string]interface{}{ 231 "name": autorest.Encode("path", name), 232 "resourceGroupName": autorest.Encode("path", resourceGroupName), 233 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 234 } 235 236 const APIVersion = "2015-08-01" 237 queryParameters := map[string]interface{}{ 238 "api-version": APIVersion, 239 } 240 241 preparer := autorest.CreatePreparer( 242 autorest.AsDelete(), 243 autorest.WithBaseURL(client.BaseURI), 244 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{name}", pathParameters), 245 autorest.WithQueryParameters(queryParameters)) 246 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 247} 248 249// DeleteCertificateSender sends the DeleteCertificate request. The method will close the 250// http.Response Body if it receives an error. 251func (client CertificatesClient) DeleteCertificateSender(req *http.Request) (*http.Response, error) { 252 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 253} 254 255// DeleteCertificateResponder handles the response to the DeleteCertificate request. The method always 256// closes the http.Response Body. 257func (client CertificatesClient) DeleteCertificateResponder(resp *http.Response) (result SetObject, err error) { 258 err = autorest.Respond( 259 resp, 260 azure.WithErrorUnlessStatusCode(http.StatusOK), 261 autorest.ByUnmarshallingJSON(&result.Value), 262 autorest.ByClosing()) 263 result.Response = autorest.Response{Response: resp} 264 return 265} 266 267// DeleteCsr sends the delete csr request. 268// Parameters: 269// resourceGroupName - name of the resource group 270// name - name of the certificate signing request. 271func (client CertificatesClient) DeleteCsr(ctx context.Context, resourceGroupName string, name string) (result SetObject, err error) { 272 if tracing.IsEnabled() { 273 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.DeleteCsr") 274 defer func() { 275 sc := -1 276 if result.Response.Response != nil { 277 sc = result.Response.Response.StatusCode 278 } 279 tracing.EndSpan(ctx, sc, err) 280 }() 281 } 282 req, err := client.DeleteCsrPreparer(ctx, resourceGroupName, name) 283 if err != nil { 284 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "DeleteCsr", nil, "Failure preparing request") 285 return 286 } 287 288 resp, err := client.DeleteCsrSender(req) 289 if err != nil { 290 result.Response = autorest.Response{Response: resp} 291 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "DeleteCsr", resp, "Failure sending request") 292 return 293 } 294 295 result, err = client.DeleteCsrResponder(resp) 296 if err != nil { 297 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "DeleteCsr", resp, "Failure responding to request") 298 return 299 } 300 301 return 302} 303 304// DeleteCsrPreparer prepares the DeleteCsr request. 305func (client CertificatesClient) DeleteCsrPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { 306 pathParameters := map[string]interface{}{ 307 "name": autorest.Encode("path", name), 308 "resourceGroupName": autorest.Encode("path", resourceGroupName), 309 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 310 } 311 312 const APIVersion = "2015-08-01" 313 queryParameters := map[string]interface{}{ 314 "api-version": APIVersion, 315 } 316 317 preparer := autorest.CreatePreparer( 318 autorest.AsDelete(), 319 autorest.WithBaseURL(client.BaseURI), 320 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs/{name}", pathParameters), 321 autorest.WithQueryParameters(queryParameters)) 322 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 323} 324 325// DeleteCsrSender sends the DeleteCsr request. The method will close the 326// http.Response Body if it receives an error. 327func (client CertificatesClient) DeleteCsrSender(req *http.Request) (*http.Response, error) { 328 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 329} 330 331// DeleteCsrResponder handles the response to the DeleteCsr request. The method always 332// closes the http.Response Body. 333func (client CertificatesClient) DeleteCsrResponder(resp *http.Response) (result SetObject, err error) { 334 err = autorest.Respond( 335 resp, 336 azure.WithErrorUnlessStatusCode(http.StatusOK), 337 autorest.ByUnmarshallingJSON(&result.Value), 338 autorest.ByClosing()) 339 result.Response = autorest.Response{Response: resp} 340 return 341} 342 343// GetCertificate sends the get certificate request. 344// Parameters: 345// resourceGroupName - name of the resource group 346// name - name of the certificate. 347func (client CertificatesClient) GetCertificate(ctx context.Context, resourceGroupName string, name string) (result Certificate, err error) { 348 if tracing.IsEnabled() { 349 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.GetCertificate") 350 defer func() { 351 sc := -1 352 if result.Response.Response != nil { 353 sc = result.Response.Response.StatusCode 354 } 355 tracing.EndSpan(ctx, sc, err) 356 }() 357 } 358 req, err := client.GetCertificatePreparer(ctx, resourceGroupName, name) 359 if err != nil { 360 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCertificate", nil, "Failure preparing request") 361 return 362 } 363 364 resp, err := client.GetCertificateSender(req) 365 if err != nil { 366 result.Response = autorest.Response{Response: resp} 367 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCertificate", resp, "Failure sending request") 368 return 369 } 370 371 result, err = client.GetCertificateResponder(resp) 372 if err != nil { 373 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCertificate", resp, "Failure responding to request") 374 return 375 } 376 377 return 378} 379 380// GetCertificatePreparer prepares the GetCertificate request. 381func (client CertificatesClient) GetCertificatePreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { 382 pathParameters := map[string]interface{}{ 383 "name": autorest.Encode("path", name), 384 "resourceGroupName": autorest.Encode("path", resourceGroupName), 385 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 386 } 387 388 const APIVersion = "2015-08-01" 389 queryParameters := map[string]interface{}{ 390 "api-version": APIVersion, 391 } 392 393 preparer := autorest.CreatePreparer( 394 autorest.AsGet(), 395 autorest.WithBaseURL(client.BaseURI), 396 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{name}", pathParameters), 397 autorest.WithQueryParameters(queryParameters)) 398 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 399} 400 401// GetCertificateSender sends the GetCertificate request. The method will close the 402// http.Response Body if it receives an error. 403func (client CertificatesClient) GetCertificateSender(req *http.Request) (*http.Response, error) { 404 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 405} 406 407// GetCertificateResponder handles the response to the GetCertificate request. The method always 408// closes the http.Response Body. 409func (client CertificatesClient) GetCertificateResponder(resp *http.Response) (result Certificate, err error) { 410 err = autorest.Respond( 411 resp, 412 azure.WithErrorUnlessStatusCode(http.StatusOK), 413 autorest.ByUnmarshallingJSON(&result), 414 autorest.ByClosing()) 415 result.Response = autorest.Response{Response: resp} 416 return 417} 418 419// GetCertificates sends the get certificates request. 420// Parameters: 421// resourceGroupName - name of the resource group 422func (client CertificatesClient) GetCertificates(ctx context.Context, resourceGroupName string) (result CertificateCollectionPage, err error) { 423 if tracing.IsEnabled() { 424 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.GetCertificates") 425 defer func() { 426 sc := -1 427 if result.cc.Response.Response != nil { 428 sc = result.cc.Response.Response.StatusCode 429 } 430 tracing.EndSpan(ctx, sc, err) 431 }() 432 } 433 result.fn = client.getCertificatesNextResults 434 req, err := client.GetCertificatesPreparer(ctx, resourceGroupName) 435 if err != nil { 436 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCertificates", nil, "Failure preparing request") 437 return 438 } 439 440 resp, err := client.GetCertificatesSender(req) 441 if err != nil { 442 result.cc.Response = autorest.Response{Response: resp} 443 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCertificates", resp, "Failure sending request") 444 return 445 } 446 447 result.cc, err = client.GetCertificatesResponder(resp) 448 if err != nil { 449 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCertificates", resp, "Failure responding to request") 450 return 451 } 452 if result.cc.hasNextLink() && result.cc.IsEmpty() { 453 err = result.NextWithContext(ctx) 454 return 455 } 456 457 return 458} 459 460// GetCertificatesPreparer prepares the GetCertificates request. 461func (client CertificatesClient) GetCertificatesPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 462 pathParameters := map[string]interface{}{ 463 "resourceGroupName": autorest.Encode("path", resourceGroupName), 464 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 465 } 466 467 const APIVersion = "2015-08-01" 468 queryParameters := map[string]interface{}{ 469 "api-version": APIVersion, 470 } 471 472 preparer := autorest.CreatePreparer( 473 autorest.AsGet(), 474 autorest.WithBaseURL(client.BaseURI), 475 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates", pathParameters), 476 autorest.WithQueryParameters(queryParameters)) 477 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 478} 479 480// GetCertificatesSender sends the GetCertificates request. The method will close the 481// http.Response Body if it receives an error. 482func (client CertificatesClient) GetCertificatesSender(req *http.Request) (*http.Response, error) { 483 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 484} 485 486// GetCertificatesResponder handles the response to the GetCertificates request. The method always 487// closes the http.Response Body. 488func (client CertificatesClient) GetCertificatesResponder(resp *http.Response) (result CertificateCollection, err error) { 489 err = autorest.Respond( 490 resp, 491 azure.WithErrorUnlessStatusCode(http.StatusOK), 492 autorest.ByUnmarshallingJSON(&result), 493 autorest.ByClosing()) 494 result.Response = autorest.Response{Response: resp} 495 return 496} 497 498// getCertificatesNextResults retrieves the next set of results, if any. 499func (client CertificatesClient) getCertificatesNextResults(ctx context.Context, lastResults CertificateCollection) (result CertificateCollection, err error) { 500 req, err := lastResults.certificateCollectionPreparer(ctx) 501 if err != nil { 502 return result, autorest.NewErrorWithError(err, "web.CertificatesClient", "getCertificatesNextResults", nil, "Failure preparing next results request") 503 } 504 if req == nil { 505 return 506 } 507 resp, err := client.GetCertificatesSender(req) 508 if err != nil { 509 result.Response = autorest.Response{Response: resp} 510 return result, autorest.NewErrorWithError(err, "web.CertificatesClient", "getCertificatesNextResults", resp, "Failure sending next results request") 511 } 512 result, err = client.GetCertificatesResponder(resp) 513 if err != nil { 514 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "getCertificatesNextResults", resp, "Failure responding to next results request") 515 } 516 return 517} 518 519// GetCertificatesComplete enumerates all values, automatically crossing page boundaries as required. 520func (client CertificatesClient) GetCertificatesComplete(ctx context.Context, resourceGroupName string) (result CertificateCollectionIterator, err error) { 521 if tracing.IsEnabled() { 522 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.GetCertificates") 523 defer func() { 524 sc := -1 525 if result.Response().Response.Response != nil { 526 sc = result.page.Response().Response.Response.StatusCode 527 } 528 tracing.EndSpan(ctx, sc, err) 529 }() 530 } 531 result.page, err = client.GetCertificates(ctx, resourceGroupName) 532 return 533} 534 535// GetCsr sends the get csr request. 536// Parameters: 537// resourceGroupName - name of the resource group 538// name - name of the certificate. 539func (client CertificatesClient) GetCsr(ctx context.Context, resourceGroupName string, name string) (result Csr, err error) { 540 if tracing.IsEnabled() { 541 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.GetCsr") 542 defer func() { 543 sc := -1 544 if result.Response.Response != nil { 545 sc = result.Response.Response.StatusCode 546 } 547 tracing.EndSpan(ctx, sc, err) 548 }() 549 } 550 req, err := client.GetCsrPreparer(ctx, resourceGroupName, name) 551 if err != nil { 552 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCsr", nil, "Failure preparing request") 553 return 554 } 555 556 resp, err := client.GetCsrSender(req) 557 if err != nil { 558 result.Response = autorest.Response{Response: resp} 559 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCsr", resp, "Failure sending request") 560 return 561 } 562 563 result, err = client.GetCsrResponder(resp) 564 if err != nil { 565 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCsr", resp, "Failure responding to request") 566 return 567 } 568 569 return 570} 571 572// GetCsrPreparer prepares the GetCsr request. 573func (client CertificatesClient) GetCsrPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { 574 pathParameters := map[string]interface{}{ 575 "name": autorest.Encode("path", name), 576 "resourceGroupName": autorest.Encode("path", resourceGroupName), 577 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 578 } 579 580 const APIVersion = "2015-08-01" 581 queryParameters := map[string]interface{}{ 582 "api-version": APIVersion, 583 } 584 585 preparer := autorest.CreatePreparer( 586 autorest.AsGet(), 587 autorest.WithBaseURL(client.BaseURI), 588 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs/{name}", pathParameters), 589 autorest.WithQueryParameters(queryParameters)) 590 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 591} 592 593// GetCsrSender sends the GetCsr request. The method will close the 594// http.Response Body if it receives an error. 595func (client CertificatesClient) GetCsrSender(req *http.Request) (*http.Response, error) { 596 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 597} 598 599// GetCsrResponder handles the response to the GetCsr request. The method always 600// closes the http.Response Body. 601func (client CertificatesClient) GetCsrResponder(resp *http.Response) (result Csr, err error) { 602 err = autorest.Respond( 603 resp, 604 azure.WithErrorUnlessStatusCode(http.StatusOK), 605 autorest.ByUnmarshallingJSON(&result), 606 autorest.ByClosing()) 607 result.Response = autorest.Response{Response: resp} 608 return 609} 610 611// GetCsrs sends the get csrs request. 612// Parameters: 613// resourceGroupName - name of the resource group 614func (client CertificatesClient) GetCsrs(ctx context.Context, resourceGroupName string) (result ListCsr, err error) { 615 if tracing.IsEnabled() { 616 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.GetCsrs") 617 defer func() { 618 sc := -1 619 if result.Response.Response != nil { 620 sc = result.Response.Response.StatusCode 621 } 622 tracing.EndSpan(ctx, sc, err) 623 }() 624 } 625 req, err := client.GetCsrsPreparer(ctx, resourceGroupName) 626 if err != nil { 627 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCsrs", nil, "Failure preparing request") 628 return 629 } 630 631 resp, err := client.GetCsrsSender(req) 632 if err != nil { 633 result.Response = autorest.Response{Response: resp} 634 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCsrs", resp, "Failure sending request") 635 return 636 } 637 638 result, err = client.GetCsrsResponder(resp) 639 if err != nil { 640 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "GetCsrs", resp, "Failure responding to request") 641 return 642 } 643 644 return 645} 646 647// GetCsrsPreparer prepares the GetCsrs request. 648func (client CertificatesClient) GetCsrsPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 649 pathParameters := map[string]interface{}{ 650 "resourceGroupName": autorest.Encode("path", resourceGroupName), 651 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 652 } 653 654 const APIVersion = "2015-08-01" 655 queryParameters := map[string]interface{}{ 656 "api-version": APIVersion, 657 } 658 659 preparer := autorest.CreatePreparer( 660 autorest.AsGet(), 661 autorest.WithBaseURL(client.BaseURI), 662 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs", pathParameters), 663 autorest.WithQueryParameters(queryParameters)) 664 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 665} 666 667// GetCsrsSender sends the GetCsrs request. The method will close the 668// http.Response Body if it receives an error. 669func (client CertificatesClient) GetCsrsSender(req *http.Request) (*http.Response, error) { 670 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 671} 672 673// GetCsrsResponder handles the response to the GetCsrs request. The method always 674// closes the http.Response Body. 675func (client CertificatesClient) GetCsrsResponder(resp *http.Response) (result ListCsr, err error) { 676 err = autorest.Respond( 677 resp, 678 azure.WithErrorUnlessStatusCode(http.StatusOK), 679 autorest.ByUnmarshallingJSON(&result.Value), 680 autorest.ByClosing()) 681 result.Response = autorest.Response{Response: resp} 682 return 683} 684 685// UpdateCertificate sends the update certificate request. 686// Parameters: 687// resourceGroupName - name of the resource group 688// name - name of the certificate. 689// certificateEnvelope - details of certificate if it exists already. 690func (client CertificatesClient) UpdateCertificate(ctx context.Context, resourceGroupName string, name string, certificateEnvelope Certificate) (result Certificate, err error) { 691 if tracing.IsEnabled() { 692 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.UpdateCertificate") 693 defer func() { 694 sc := -1 695 if result.Response.Response != nil { 696 sc = result.Response.Response.StatusCode 697 } 698 tracing.EndSpan(ctx, sc, err) 699 }() 700 } 701 req, err := client.UpdateCertificatePreparer(ctx, resourceGroupName, name, certificateEnvelope) 702 if err != nil { 703 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "UpdateCertificate", nil, "Failure preparing request") 704 return 705 } 706 707 resp, err := client.UpdateCertificateSender(req) 708 if err != nil { 709 result.Response = autorest.Response{Response: resp} 710 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "UpdateCertificate", resp, "Failure sending request") 711 return 712 } 713 714 result, err = client.UpdateCertificateResponder(resp) 715 if err != nil { 716 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "UpdateCertificate", resp, "Failure responding to request") 717 return 718 } 719 720 return 721} 722 723// UpdateCertificatePreparer prepares the UpdateCertificate request. 724func (client CertificatesClient) UpdateCertificatePreparer(ctx context.Context, resourceGroupName string, name string, certificateEnvelope Certificate) (*http.Request, error) { 725 pathParameters := map[string]interface{}{ 726 "name": autorest.Encode("path", name), 727 "resourceGroupName": autorest.Encode("path", resourceGroupName), 728 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 729 } 730 731 const APIVersion = "2015-08-01" 732 queryParameters := map[string]interface{}{ 733 "api-version": APIVersion, 734 } 735 736 preparer := autorest.CreatePreparer( 737 autorest.AsContentType("application/json; charset=utf-8"), 738 autorest.AsPatch(), 739 autorest.WithBaseURL(client.BaseURI), 740 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{name}", pathParameters), 741 autorest.WithJSON(certificateEnvelope), 742 autorest.WithQueryParameters(queryParameters)) 743 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 744} 745 746// UpdateCertificateSender sends the UpdateCertificate request. The method will close the 747// http.Response Body if it receives an error. 748func (client CertificatesClient) UpdateCertificateSender(req *http.Request) (*http.Response, error) { 749 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 750} 751 752// UpdateCertificateResponder handles the response to the UpdateCertificate request. The method always 753// closes the http.Response Body. 754func (client CertificatesClient) UpdateCertificateResponder(resp *http.Response) (result Certificate, err error) { 755 err = autorest.Respond( 756 resp, 757 azure.WithErrorUnlessStatusCode(http.StatusOK), 758 autorest.ByUnmarshallingJSON(&result), 759 autorest.ByClosing()) 760 result.Response = autorest.Response{Response: resp} 761 return 762} 763 764// UpdateCsr sends the update csr request. 765// Parameters: 766// resourceGroupName - name of the resource group 767// name - name of the certificate. 768// csrEnvelope - details of certificate signing request if it exists already. 769func (client CertificatesClient) UpdateCsr(ctx context.Context, resourceGroupName string, name string, csrEnvelope Csr) (result Csr, err error) { 770 if tracing.IsEnabled() { 771 ctx = tracing.StartSpan(ctx, fqdn+"/CertificatesClient.UpdateCsr") 772 defer func() { 773 sc := -1 774 if result.Response.Response != nil { 775 sc = result.Response.Response.StatusCode 776 } 777 tracing.EndSpan(ctx, sc, err) 778 }() 779 } 780 req, err := client.UpdateCsrPreparer(ctx, resourceGroupName, name, csrEnvelope) 781 if err != nil { 782 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "UpdateCsr", nil, "Failure preparing request") 783 return 784 } 785 786 resp, err := client.UpdateCsrSender(req) 787 if err != nil { 788 result.Response = autorest.Response{Response: resp} 789 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "UpdateCsr", resp, "Failure sending request") 790 return 791 } 792 793 result, err = client.UpdateCsrResponder(resp) 794 if err != nil { 795 err = autorest.NewErrorWithError(err, "web.CertificatesClient", "UpdateCsr", resp, "Failure responding to request") 796 return 797 } 798 799 return 800} 801 802// UpdateCsrPreparer prepares the UpdateCsr request. 803func (client CertificatesClient) UpdateCsrPreparer(ctx context.Context, resourceGroupName string, name string, csrEnvelope Csr) (*http.Request, error) { 804 pathParameters := map[string]interface{}{ 805 "name": autorest.Encode("path", name), 806 "resourceGroupName": autorest.Encode("path", resourceGroupName), 807 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 808 } 809 810 const APIVersion = "2015-08-01" 811 queryParameters := map[string]interface{}{ 812 "api-version": APIVersion, 813 } 814 815 preparer := autorest.CreatePreparer( 816 autorest.AsContentType("application/json; charset=utf-8"), 817 autorest.AsPatch(), 818 autorest.WithBaseURL(client.BaseURI), 819 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs/{name}", pathParameters), 820 autorest.WithJSON(csrEnvelope), 821 autorest.WithQueryParameters(queryParameters)) 822 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 823} 824 825// UpdateCsrSender sends the UpdateCsr request. The method will close the 826// http.Response Body if it receives an error. 827func (client CertificatesClient) UpdateCsrSender(req *http.Request) (*http.Response, error) { 828 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 829} 830 831// UpdateCsrResponder handles the response to the UpdateCsr request. The method always 832// closes the http.Response Body. 833func (client CertificatesClient) UpdateCsrResponder(resp *http.Response) (result Csr, err error) { 834 err = autorest.Respond( 835 resp, 836 azure.WithErrorUnlessStatusCode(http.StatusOK), 837 autorest.ByUnmarshallingJSON(&result), 838 autorest.ByClosing()) 839 result.Response = autorest.Response{Response: resp} 840 return 841} 842