1package databoxedge 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// JobsClient is the client for the Jobs methods of the Databoxedge service. 18type JobsClient struct { 19 BaseClient 20} 21 22// NewJobsClient creates an instance of the JobsClient client. 23func NewJobsClient(subscriptionID string) JobsClient { 24 return NewJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewJobsClientWithBaseURI creates an instance of the JobsClient client using a custom endpoint. Use this when 28// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient { 30 return JobsClient{NewWithBaseURI(baseURI, subscriptionID)} 31} 32 33// Get sends the get request. 34// Parameters: 35// deviceName - the device name. 36// name - the job name. 37// resourceGroupName - the resource group name. 38func (client JobsClient) Get(ctx context.Context, deviceName string, name string, resourceGroupName string) (result Job, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.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, deviceName, name, resourceGroupName) 50 if err != nil { 51 err = autorest.NewErrorWithError(err, "databoxedge.JobsClient", "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, "databoxedge.JobsClient", "Get", resp, "Failure sending request") 59 return 60 } 61 62 result, err = client.GetResponder(resp) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "databoxedge.JobsClient", "Get", resp, "Failure responding to request") 65 return 66 } 67 68 return 69} 70 71// GetPreparer prepares the Get request. 72func (client JobsClient) GetPreparer(ctx context.Context, deviceName string, name string, resourceGroupName string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "deviceName": autorest.Encode("path", deviceName), 75 "name": autorest.Encode("path", name), 76 "resourceGroupName": autorest.Encode("path", resourceGroupName), 77 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 78 } 79 80 const APIVersion = "2020-12-01" 81 queryParameters := map[string]interface{}{ 82 "api-version": APIVersion, 83 } 84 85 preparer := autorest.CreatePreparer( 86 autorest.AsGet(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", pathParameters), 89 autorest.WithQueryParameters(queryParameters)) 90 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 91} 92 93// GetSender sends the Get request. The method will close the 94// http.Response Body if it receives an error. 95func (client JobsClient) GetSender(req *http.Request) (*http.Response, error) { 96 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 97} 98 99// GetResponder handles the response to the Get request. The method always 100// closes the http.Response Body. 101func (client JobsClient) GetResponder(resp *http.Response) (result Job, err error) { 102 err = autorest.Respond( 103 resp, 104 azure.WithErrorUnlessStatusCode(http.StatusOK), 105 autorest.ByUnmarshallingJSON(&result), 106 autorest.ByClosing()) 107 result.Response = autorest.Response{Response: resp} 108 return 109} 110