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