...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup/resourceguardproxy.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup

     1  package 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  
     9  import (
    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  // ResourceGuardProxyClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type ResourceGuardProxyClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewResourceGuardProxyClient creates an instance of the ResourceGuardProxyClient client.
    23  func NewResourceGuardProxyClient(subscriptionID string) ResourceGuardProxyClient {
    24  	return NewResourceGuardProxyClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewResourceGuardProxyClientWithBaseURI creates an instance of the ResourceGuardProxyClient 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).
    30  func NewResourceGuardProxyClientWithBaseURI(baseURI string, subscriptionID string) ResourceGuardProxyClient {
    31  	return ResourceGuardProxyClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Delete delete ResourceGuardProxy under vault
    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.
    38  func (client ResourceGuardProxyClient) Delete(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string) (result autorest.Response, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceGuardProxyClient.Delete")
    41  		defer func() {
    42  			sc := -1
    43  			if result.Response != nil {
    44  				sc = result.Response.StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	req, err := client.DeletePreparer(ctx, vaultName, resourceGroupName, resourceGuardProxyName)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Delete", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	resp, err := client.DeleteSender(req)
    56  	if err != nil {
    57  		result.Response = resp
    58  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Delete", resp, "Failure sending request")
    59  		return
    60  	}
    61  
    62  	result, err = client.DeleteResponder(resp)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Delete", resp, "Failure responding to request")
    65  		return
    66  	}
    67  
    68  	return
    69  }
    70  
    71  // DeletePreparer prepares the Delete request.
    72  func (client ResourceGuardProxyClient) DeletePreparer(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string) (*http.Request, error) {
    73  	pathParameters := map[string]interface{}{
    74  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
    75  		"resourceGuardProxyName": autorest.Encode("path", resourceGuardProxyName),
    76  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
    77  		"vaultName":              autorest.Encode("path", vaultName),
    78  	}
    79  
    80  	const APIVersion = "2021-12-01"
    81  	queryParameters := map[string]interface{}{
    82  		"api-version": APIVersion,
    83  	}
    84  
    85  	preparer := autorest.CreatePreparer(
    86  		autorest.AsDelete(),
    87  		autorest.WithBaseURL(client.BaseURI),
    88  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", pathParameters),
    89  		autorest.WithQueryParameters(queryParameters))
    90  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    91  }
    92  
    93  // DeleteSender sends the Delete request. The method will close the
    94  // http.Response Body if it receives an error.
    95  func (client ResourceGuardProxyClient) DeleteSender(req *http.Request) (*http.Response, error) {
    96  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    97  }
    98  
    99  // DeleteResponder handles the response to the Delete request. The method always
   100  // closes the http.Response Body.
   101  func (client ResourceGuardProxyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   102  	err = autorest.Respond(
   103  		resp,
   104  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   105  		autorest.ByClosing())
   106  	result.Response = resp
   107  	return
   108  }
   109  
   110  // Get returns ResourceGuardProxy under vault and with the name referenced in request
   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  func (client ResourceGuardProxyClient) Get(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string) (result ResourceGuardProxyBaseResource, err error) {
   115  	if tracing.IsEnabled() {
   116  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceGuardProxyClient.Get")
   117  		defer func() {
   118  			sc := -1
   119  			if result.Response.Response != nil {
   120  				sc = result.Response.Response.StatusCode
   121  			}
   122  			tracing.EndSpan(ctx, sc, err)
   123  		}()
   124  	}
   125  	req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, resourceGuardProxyName)
   126  	if err != nil {
   127  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Get", nil, "Failure preparing request")
   128  		return
   129  	}
   130  
   131  	resp, err := client.GetSender(req)
   132  	if err != nil {
   133  		result.Response = autorest.Response{Response: resp}
   134  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Get", resp, "Failure sending request")
   135  		return
   136  	}
   137  
   138  	result, err = client.GetResponder(resp)
   139  	if err != nil {
   140  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Get", resp, "Failure responding to request")
   141  		return
   142  	}
   143  
   144  	return
   145  }
   146  
   147  // GetPreparer prepares the Get request.
   148  func (client ResourceGuardProxyClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string) (*http.Request, error) {
   149  	pathParameters := map[string]interface{}{
   150  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   151  		"resourceGuardProxyName": autorest.Encode("path", resourceGuardProxyName),
   152  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   153  		"vaultName":              autorest.Encode("path", vaultName),
   154  	}
   155  
   156  	const APIVersion = "2021-12-01"
   157  	queryParameters := map[string]interface{}{
   158  		"api-version": APIVersion,
   159  	}
   160  
   161  	preparer := autorest.CreatePreparer(
   162  		autorest.AsGet(),
   163  		autorest.WithBaseURL(client.BaseURI),
   164  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", pathParameters),
   165  		autorest.WithQueryParameters(queryParameters))
   166  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   167  }
   168  
   169  // GetSender sends the Get request. The method will close the
   170  // http.Response Body if it receives an error.
   171  func (client ResourceGuardProxyClient) GetSender(req *http.Request) (*http.Response, error) {
   172  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   173  }
   174  
   175  // GetResponder handles the response to the Get request. The method always
   176  // closes the http.Response Body.
   177  func (client ResourceGuardProxyClient) GetResponder(resp *http.Response) (result ResourceGuardProxyBaseResource, err error) {
   178  	err = autorest.Respond(
   179  		resp,
   180  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   181  		autorest.ByUnmarshallingJSON(&result),
   182  		autorest.ByClosing())
   183  	result.Response = autorest.Response{Response: resp}
   184  	return
   185  }
   186  
   187  // Put add or Update ResourceGuardProxy under vault
   188  // Secures vault critical operations
   189  // Parameters:
   190  // vaultName - the name of the recovery services vault.
   191  // resourceGroupName - the name of the resource group where the recovery services vault is present.
   192  func (client ResourceGuardProxyClient) Put(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string) (result ResourceGuardProxyBaseResource, err error) {
   193  	if tracing.IsEnabled() {
   194  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceGuardProxyClient.Put")
   195  		defer func() {
   196  			sc := -1
   197  			if result.Response.Response != nil {
   198  				sc = result.Response.Response.StatusCode
   199  			}
   200  			tracing.EndSpan(ctx, sc, err)
   201  		}()
   202  	}
   203  	req, err := client.PutPreparer(ctx, vaultName, resourceGroupName, resourceGuardProxyName)
   204  	if err != nil {
   205  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Put", nil, "Failure preparing request")
   206  		return
   207  	}
   208  
   209  	resp, err := client.PutSender(req)
   210  	if err != nil {
   211  		result.Response = autorest.Response{Response: resp}
   212  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Put", resp, "Failure sending request")
   213  		return
   214  	}
   215  
   216  	result, err = client.PutResponder(resp)
   217  	if err != nil {
   218  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "Put", resp, "Failure responding to request")
   219  		return
   220  	}
   221  
   222  	return
   223  }
   224  
   225  // PutPreparer prepares the Put request.
   226  func (client ResourceGuardProxyClient) PutPreparer(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string) (*http.Request, error) {
   227  	pathParameters := map[string]interface{}{
   228  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   229  		"resourceGuardProxyName": autorest.Encode("path", resourceGuardProxyName),
   230  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   231  		"vaultName":              autorest.Encode("path", vaultName),
   232  	}
   233  
   234  	const APIVersion = "2021-12-01"
   235  	queryParameters := map[string]interface{}{
   236  		"api-version": APIVersion,
   237  	}
   238  
   239  	preparer := autorest.CreatePreparer(
   240  		autorest.AsPut(),
   241  		autorest.WithBaseURL(client.BaseURI),
   242  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", pathParameters),
   243  		autorest.WithQueryParameters(queryParameters))
   244  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   245  }
   246  
   247  // PutSender sends the Put request. The method will close the
   248  // http.Response Body if it receives an error.
   249  func (client ResourceGuardProxyClient) PutSender(req *http.Request) (*http.Response, error) {
   250  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   251  }
   252  
   253  // PutResponder handles the response to the Put request. The method always
   254  // closes the http.Response Body.
   255  func (client ResourceGuardProxyClient) PutResponder(resp *http.Response) (result ResourceGuardProxyBaseResource, err error) {
   256  	err = autorest.Respond(
   257  		resp,
   258  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   259  		autorest.ByUnmarshallingJSON(&result),
   260  		autorest.ByClosing())
   261  	result.Response = autorest.Response{Response: resp}
   262  	return
   263  }
   264  
   265  // UnlockDelete secures delete ResourceGuardProxy operations.
   266  // Parameters:
   267  // vaultName - the name of the recovery services vault.
   268  // resourceGroupName - the name of the resource group where the recovery services vault is present.
   269  // parameters - request body for operation
   270  func (client ResourceGuardProxyClient) UnlockDelete(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string, parameters UnlockDeleteRequest) (result UnlockDeleteResponse, err error) {
   271  	if tracing.IsEnabled() {
   272  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceGuardProxyClient.UnlockDelete")
   273  		defer func() {
   274  			sc := -1
   275  			if result.Response.Response != nil {
   276  				sc = result.Response.Response.StatusCode
   277  			}
   278  			tracing.EndSpan(ctx, sc, err)
   279  		}()
   280  	}
   281  	req, err := client.UnlockDeletePreparer(ctx, vaultName, resourceGroupName, resourceGuardProxyName, parameters)
   282  	if err != nil {
   283  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "UnlockDelete", nil, "Failure preparing request")
   284  		return
   285  	}
   286  
   287  	resp, err := client.UnlockDeleteSender(req)
   288  	if err != nil {
   289  		result.Response = autorest.Response{Response: resp}
   290  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "UnlockDelete", resp, "Failure sending request")
   291  		return
   292  	}
   293  
   294  	result, err = client.UnlockDeleteResponder(resp)
   295  	if err != nil {
   296  		err = autorest.NewErrorWithError(err, "backup.ResourceGuardProxyClient", "UnlockDelete", resp, "Failure responding to request")
   297  		return
   298  	}
   299  
   300  	return
   301  }
   302  
   303  // UnlockDeletePreparer prepares the UnlockDelete request.
   304  func (client ResourceGuardProxyClient) UnlockDeletePreparer(ctx context.Context, vaultName string, resourceGroupName string, resourceGuardProxyName string, parameters UnlockDeleteRequest) (*http.Request, error) {
   305  	pathParameters := map[string]interface{}{
   306  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   307  		"resourceGuardProxyName": autorest.Encode("path", resourceGuardProxyName),
   308  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   309  		"vaultName":              autorest.Encode("path", vaultName),
   310  	}
   311  
   312  	const APIVersion = "2021-12-01"
   313  	queryParameters := map[string]interface{}{
   314  		"api-version": APIVersion,
   315  	}
   316  
   317  	preparer := autorest.CreatePreparer(
   318  		autorest.AsContentType("application/json; charset=utf-8"),
   319  		autorest.AsPost(),
   320  		autorest.WithBaseURL(client.BaseURI),
   321  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete", pathParameters),
   322  		autorest.WithJSON(parameters),
   323  		autorest.WithQueryParameters(queryParameters))
   324  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   325  }
   326  
   327  // UnlockDeleteSender sends the UnlockDelete request. The method will close the
   328  // http.Response Body if it receives an error.
   329  func (client ResourceGuardProxyClient) UnlockDeleteSender(req *http.Request) (*http.Response, error) {
   330  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   331  }
   332  
   333  // UnlockDeleteResponder handles the response to the UnlockDelete request. The method always
   334  // closes the http.Response Body.
   335  func (client ResourceGuardProxyClient) UnlockDeleteResponder(resp *http.Response) (result UnlockDeleteResponse, err error) {
   336  	err = autorest.Respond(
   337  		resp,
   338  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   339  		autorest.ByUnmarshallingJSON(&result),
   340  		autorest.ByClosing())
   341  	result.Response = autorest.Response{Response: resp}
   342  	return
   343  }
   344  

View as plain text