...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-01-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  // JobsGroupClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type JobsGroupClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewJobsGroupClient creates an instance of the JobsGroupClient client.
    23  func NewJobsGroupClient(subscriptionID string) JobsGroupClient {
    24  	return NewJobsGroupClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewJobsGroupClientWithBaseURI creates an instance of the JobsGroupClient client using a custom endpoint.  Use this
    28  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    29  func NewJobsGroupClientWithBaseURI(baseURI string, subscriptionID string) JobsGroupClient {
    30  	return JobsGroupClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // Export triggers export of jobs specified by filters and returns an OperationID to track.
    34  // Parameters:
    35  // vaultName - the name of the recovery services vault.
    36  // resourceGroupName - the name of the resource group where the recovery services vault is present.
    37  // filter - oData filter options.
    38  func (client JobsGroupClient) Export(ctx context.Context, vaultName string, resourceGroupName string, filter string) (result autorest.Response, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsGroupClient.Export")
    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.ExportPreparer(ctx, vaultName, resourceGroupName, filter)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "backup.JobsGroupClient", "Export", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	resp, err := client.ExportSender(req)
    56  	if err != nil {
    57  		result.Response = resp
    58  		err = autorest.NewErrorWithError(err, "backup.JobsGroupClient", "Export", resp, "Failure sending request")
    59  		return
    60  	}
    61  
    62  	result, err = client.ExportResponder(resp)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "backup.JobsGroupClient", "Export", resp, "Failure responding to request")
    65  		return
    66  	}
    67  
    68  	return
    69  }
    70  
    71  // ExportPreparer prepares the Export request.
    72  func (client JobsGroupClient) ExportPreparer(ctx context.Context, vaultName string, resourceGroupName string, filter 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  	if len(filter) > 0 {
    84  		queryParameters["$filter"] = autorest.Encode("query", filter)
    85  	}
    86  
    87  	preparer := autorest.CreatePreparer(
    88  		autorest.AsPost(),
    89  		autorest.WithBaseURL(client.BaseURI),
    90  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupJobsExport", pathParameters),
    91  		autorest.WithQueryParameters(queryParameters))
    92  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    93  }
    94  
    95  // ExportSender sends the Export request. The method will close the
    96  // http.Response Body if it receives an error.
    97  func (client JobsGroupClient) ExportSender(req *http.Request) (*http.Response, error) {
    98  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    99  }
   100  
   101  // ExportResponder handles the response to the Export request. The method always
   102  // closes the http.Response Body.
   103  func (client JobsGroupClient) ExportResponder(resp *http.Response) (result autorest.Response, err error) {
   104  	err = autorest.Respond(
   105  		resp,
   106  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   107  		autorest.ByClosing())
   108  	result.Response = resp
   109  	return
   110  }
   111  

View as plain text