1package backup 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// ResourceVaultConfigsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 18type ResourceVaultConfigsClient struct { 19 BaseClient 20} 21 22// NewResourceVaultConfigsClient creates an instance of the ResourceVaultConfigsClient client. 23func NewResourceVaultConfigsClient(subscriptionID string) ResourceVaultConfigsClient { 24 return NewResourceVaultConfigsClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewResourceVaultConfigsClientWithBaseURI creates an instance of the ResourceVaultConfigsClient client using a custom 28// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 29// stack). 30func NewResourceVaultConfigsClientWithBaseURI(baseURI string, subscriptionID string) ResourceVaultConfigsClient { 31 return ResourceVaultConfigsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Get fetches resource vault config. 35// Parameters: 36// vaultName - the name of the recovery services vault. 37// resourceGroupName - the name of the resource group where the recovery services vault is present. 38func (client ResourceVaultConfigsClient) Get(ctx context.Context, vaultName string, resourceGroupName string) (result ResourceVaultConfigResource, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/ResourceVaultConfigsClient.Get") 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.GetPreparer(ctx, vaultName, resourceGroupName) 50 if err != nil { 51 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Get", nil, "Failure preparing request") 52 return 53 } 54 55 resp, err := client.GetSender(req) 56 if err != nil { 57 result.Response = autorest.Response{Response: resp} 58 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Get", resp, "Failure sending request") 59 return 60 } 61 62 result, err = client.GetResponder(resp) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Get", resp, "Failure responding to request") 65 return 66 } 67 68 return 69} 70 71// GetPreparer prepares the Get request. 72func (client ResourceVaultConfigsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "resourceGroupName": autorest.Encode("path", resourceGroupName), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 "vaultName": autorest.Encode("path", vaultName), 77 } 78 79 const APIVersion = "2021-01-01" 80 queryParameters := map[string]interface{}{ 81 "api-version": APIVersion, 82 } 83 84 preparer := autorest.CreatePreparer( 85 autorest.AsGet(), 86 autorest.WithBaseURL(client.BaseURI), 87 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupconfig/vaultconfig", pathParameters), 88 autorest.WithQueryParameters(queryParameters)) 89 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 90} 91 92// GetSender sends the Get request. The method will close the 93// http.Response Body if it receives an error. 94func (client ResourceVaultConfigsClient) GetSender(req *http.Request) (*http.Response, error) { 95 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 96} 97 98// GetResponder handles the response to the Get request. The method always 99// closes the http.Response Body. 100func (client ResourceVaultConfigsClient) GetResponder(resp *http.Response) (result ResourceVaultConfigResource, err error) { 101 err = autorest.Respond( 102 resp, 103 azure.WithErrorUnlessStatusCode(http.StatusOK), 104 autorest.ByUnmarshallingJSON(&result), 105 autorest.ByClosing()) 106 result.Response = autorest.Response{Response: resp} 107 return 108} 109 110// Put updates vault security config. 111// Parameters: 112// vaultName - the name of the recovery services vault. 113// resourceGroupName - the name of the resource group where the recovery services vault is present. 114// parameters - resource config request 115func (client ResourceVaultConfigsClient) Put(ctx context.Context, vaultName string, resourceGroupName string, parameters ResourceVaultConfigResource) (result ResourceVaultConfigResource, err error) { 116 if tracing.IsEnabled() { 117 ctx = tracing.StartSpan(ctx, fqdn+"/ResourceVaultConfigsClient.Put") 118 defer func() { 119 sc := -1 120 if result.Response.Response != nil { 121 sc = result.Response.Response.StatusCode 122 } 123 tracing.EndSpan(ctx, sc, err) 124 }() 125 } 126 req, err := client.PutPreparer(ctx, vaultName, resourceGroupName, parameters) 127 if err != nil { 128 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Put", nil, "Failure preparing request") 129 return 130 } 131 132 resp, err := client.PutSender(req) 133 if err != nil { 134 result.Response = autorest.Response{Response: resp} 135 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Put", resp, "Failure sending request") 136 return 137 } 138 139 result, err = client.PutResponder(resp) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Put", resp, "Failure responding to request") 142 return 143 } 144 145 return 146} 147 148// PutPreparer prepares the Put request. 149func (client ResourceVaultConfigsClient) PutPreparer(ctx context.Context, vaultName string, resourceGroupName string, parameters ResourceVaultConfigResource) (*http.Request, error) { 150 pathParameters := map[string]interface{}{ 151 "resourceGroupName": autorest.Encode("path", resourceGroupName), 152 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 153 "vaultName": autorest.Encode("path", vaultName), 154 } 155 156 const APIVersion = "2021-01-01" 157 queryParameters := map[string]interface{}{ 158 "api-version": APIVersion, 159 } 160 161 preparer := autorest.CreatePreparer( 162 autorest.AsContentType("application/json; charset=utf-8"), 163 autorest.AsPut(), 164 autorest.WithBaseURL(client.BaseURI), 165 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupconfig/vaultconfig", pathParameters), 166 autorest.WithJSON(parameters), 167 autorest.WithQueryParameters(queryParameters)) 168 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 169} 170 171// PutSender sends the Put request. The method will close the 172// http.Response Body if it receives an error. 173func (client ResourceVaultConfigsClient) PutSender(req *http.Request) (*http.Response, error) { 174 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 175} 176 177// PutResponder handles the response to the Put request. The method always 178// closes the http.Response Body. 179func (client ResourceVaultConfigsClient) PutResponder(resp *http.Response) (result ResourceVaultConfigResource, err error) { 180 err = autorest.Respond( 181 resp, 182 azure.WithErrorUnlessStatusCode(http.StatusOK), 183 autorest.ByUnmarshallingJSON(&result), 184 autorest.ByClosing()) 185 result.Response = autorest.Response{Response: resp} 186 return 187} 188 189// Update updates vault security config. 190// Parameters: 191// vaultName - the name of the recovery services vault. 192// resourceGroupName - the name of the resource group where the recovery services vault is present. 193// parameters - resource config request 194func (client ResourceVaultConfigsClient) Update(ctx context.Context, vaultName string, resourceGroupName string, parameters ResourceVaultConfigResource) (result ResourceVaultConfigResource, err error) { 195 if tracing.IsEnabled() { 196 ctx = tracing.StartSpan(ctx, fqdn+"/ResourceVaultConfigsClient.Update") 197 defer func() { 198 sc := -1 199 if result.Response.Response != nil { 200 sc = result.Response.Response.StatusCode 201 } 202 tracing.EndSpan(ctx, sc, err) 203 }() 204 } 205 req, err := client.UpdatePreparer(ctx, vaultName, resourceGroupName, parameters) 206 if err != nil { 207 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Update", nil, "Failure preparing request") 208 return 209 } 210 211 resp, err := client.UpdateSender(req) 212 if err != nil { 213 result.Response = autorest.Response{Response: resp} 214 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Update", resp, "Failure sending request") 215 return 216 } 217 218 result, err = client.UpdateResponder(resp) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "backup.ResourceVaultConfigsClient", "Update", resp, "Failure responding to request") 221 return 222 } 223 224 return 225} 226 227// UpdatePreparer prepares the Update request. 228func (client ResourceVaultConfigsClient) UpdatePreparer(ctx context.Context, vaultName string, resourceGroupName string, parameters ResourceVaultConfigResource) (*http.Request, error) { 229 pathParameters := map[string]interface{}{ 230 "resourceGroupName": autorest.Encode("path", resourceGroupName), 231 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 232 "vaultName": autorest.Encode("path", vaultName), 233 } 234 235 const APIVersion = "2021-01-01" 236 queryParameters := map[string]interface{}{ 237 "api-version": APIVersion, 238 } 239 240 preparer := autorest.CreatePreparer( 241 autorest.AsContentType("application/json; charset=utf-8"), 242 autorest.AsPatch(), 243 autorest.WithBaseURL(client.BaseURI), 244 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupconfig/vaultconfig", pathParameters), 245 autorest.WithJSON(parameters), 246 autorest.WithQueryParameters(queryParameters)) 247 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 248} 249 250// UpdateSender sends the Update request. The method will close the 251// http.Response Body if it receives an error. 252func (client ResourceVaultConfigsClient) UpdateSender(req *http.Request) (*http.Response, error) { 253 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 254} 255 256// UpdateResponder handles the response to the Update request. The method always 257// closes the http.Response Body. 258func (client ResourceVaultConfigsClient) UpdateResponder(resp *http.Response) (result ResourceVaultConfigResource, err error) { 259 err = autorest.Respond( 260 resp, 261 azure.WithErrorUnlessStatusCode(http.StatusOK), 262 autorest.ByUnmarshallingJSON(&result), 263 autorest.ByClosing()) 264 result.Response = autorest.Response{Response: resp} 265 return 266} 267