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