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// CertificateRegistrationProviderClient is the webSite Management Client 29type CertificateRegistrationProviderClient struct { 30 BaseClient 31} 32 33// NewCertificateRegistrationProviderClient creates an instance of the CertificateRegistrationProviderClient client. 34func NewCertificateRegistrationProviderClient(subscriptionID string) CertificateRegistrationProviderClient { 35 return NewCertificateRegistrationProviderClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewCertificateRegistrationProviderClientWithBaseURI creates an instance of the CertificateRegistrationProviderClient 39// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI 40// (sovereign clouds, Azure stack). 41func NewCertificateRegistrationProviderClientWithBaseURI(baseURI string, subscriptionID string) CertificateRegistrationProviderClient { 42 return CertificateRegistrationProviderClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// ListOperations implements Csm operations Api to exposes the list of available Csm Apis under the resource provider 46func (client CertificateRegistrationProviderClient) ListOperations(ctx context.Context) (result CsmOperationCollectionPage, err error) { 47 if tracing.IsEnabled() { 48 ctx = tracing.StartSpan(ctx, fqdn+"/CertificateRegistrationProviderClient.ListOperations") 49 defer func() { 50 sc := -1 51 if result.coc.Response.Response != nil { 52 sc = result.coc.Response.Response.StatusCode 53 } 54 tracing.EndSpan(ctx, sc, err) 55 }() 56 } 57 result.fn = client.listOperationsNextResults 58 req, err := client.ListOperationsPreparer(ctx) 59 if err != nil { 60 err = autorest.NewErrorWithError(err, "web.CertificateRegistrationProviderClient", "ListOperations", nil, "Failure preparing request") 61 return 62 } 63 64 resp, err := client.ListOperationsSender(req) 65 if err != nil { 66 result.coc.Response = autorest.Response{Response: resp} 67 err = autorest.NewErrorWithError(err, "web.CertificateRegistrationProviderClient", "ListOperations", resp, "Failure sending request") 68 return 69 } 70 71 result.coc, err = client.ListOperationsResponder(resp) 72 if err != nil { 73 err = autorest.NewErrorWithError(err, "web.CertificateRegistrationProviderClient", "ListOperations", resp, "Failure responding to request") 74 } 75 76 return 77} 78 79// ListOperationsPreparer prepares the ListOperations request. 80func (client CertificateRegistrationProviderClient) ListOperationsPreparer(ctx context.Context) (*http.Request, error) { 81 const APIVersion = "2015-08-01" 82 queryParameters := map[string]interface{}{ 83 "api-version": APIVersion, 84 } 85 86 preparer := autorest.CreatePreparer( 87 autorest.AsGet(), 88 autorest.WithBaseURL(client.BaseURI), 89 autorest.WithPath("/providers/Microsoft.CertificateRegistration/operations"), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// ListOperationsSender sends the ListOperations request. The method will close the 95// http.Response Body if it receives an error. 96func (client CertificateRegistrationProviderClient) ListOperationsSender(req *http.Request) (*http.Response, error) { 97 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 98} 99 100// ListOperationsResponder handles the response to the ListOperations request. The method always 101// closes the http.Response Body. 102func (client CertificateRegistrationProviderClient) ListOperationsResponder(resp *http.Response) (result CsmOperationCollection, err error) { 103 err = autorest.Respond( 104 resp, 105 client.ByInspecting(), 106 azure.WithErrorUnlessStatusCode(http.StatusOK), 107 autorest.ByUnmarshallingJSON(&result), 108 autorest.ByClosing()) 109 result.Response = autorest.Response{Response: resp} 110 return 111} 112 113// listOperationsNextResults retrieves the next set of results, if any. 114func (client CertificateRegistrationProviderClient) listOperationsNextResults(ctx context.Context, lastResults CsmOperationCollection) (result CsmOperationCollection, err error) { 115 req, err := lastResults.csmOperationCollectionPreparer(ctx) 116 if err != nil { 117 return result, autorest.NewErrorWithError(err, "web.CertificateRegistrationProviderClient", "listOperationsNextResults", nil, "Failure preparing next results request") 118 } 119 if req == nil { 120 return 121 } 122 resp, err := client.ListOperationsSender(req) 123 if err != nil { 124 result.Response = autorest.Response{Response: resp} 125 return result, autorest.NewErrorWithError(err, "web.CertificateRegistrationProviderClient", "listOperationsNextResults", resp, "Failure sending next results request") 126 } 127 result, err = client.ListOperationsResponder(resp) 128 if err != nil { 129 err = autorest.NewErrorWithError(err, "web.CertificateRegistrationProviderClient", "listOperationsNextResults", resp, "Failure responding to next results request") 130 } 131 return 132} 133 134// ListOperationsComplete enumerates all values, automatically crossing page boundaries as required. 135func (client CertificateRegistrationProviderClient) ListOperationsComplete(ctx context.Context) (result CsmOperationCollectionIterator, err error) { 136 if tracing.IsEnabled() { 137 ctx = tracing.StartSpan(ctx, fqdn+"/CertificateRegistrationProviderClient.ListOperations") 138 defer func() { 139 sc := -1 140 if result.Response().Response.Response != nil { 141 sc = result.page.Response().Response.Response.StatusCode 142 } 143 tracing.EndSpan(ctx, sc, err) 144 }() 145 } 146 result.page, err = client.ListOperations(ctx) 147 return 148} 149