Create a provider to use Azure Batch (#133)

* Started work on provider

* WIP Adding batch provider

* Working basic call into pool client. Need to parameterize the baseurl

* Fixed job creation by manipulating the content-type

* WIP Kicking off containers. Dirty

* [wip] More meat around scheduling simple containers.

* Working on basic task wrapper to co-schedule pods

* WIP on task wrapper

* WIP

* Working pod minimal wrapper for batch

* Integrate pod template code into provider

* Cleaning up

* Move to docker without gpu

* WIP batch integration

* partially working

* Working logs

* Tidy code

* WIP: Testing and readme

* Added readme and terraform deployment for GPU Azure Batch pool.

* Update to enable low priority nodes for gpu

* Fix log formatting bug. Return node logs when container not yet started

* Moved to golang v1.10

* Fix cri test

* Fix up minor docs Issue. Add provider to readme. Add var for vk image.
This commit is contained in:
Lawrence Gripper
2018-06-23 00:33:49 +01:00
committed by Robbie Zhang
parent 1ad6fb434e
commit d6e8b3daf7
75 changed files with 20040 additions and 6 deletions

View File

@@ -0,0 +1,175 @@
package batch
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/validation"
"github.com/satori/go.uuid"
"net/http"
)
// AccountClient is the a client for issuing REST requests to the Azure Batch service.
type AccountClient struct {
BaseClient
}
// NewAccountClient creates an instance of the AccountClient client.
func NewAccountClient() AccountClient {
return NewAccountClientWithBaseURI(DefaultBaseURI)
}
// NewAccountClientWithBaseURI creates an instance of the AccountClient client.
func NewAccountClientWithBaseURI(baseURI string) AccountClient {
return AccountClient{NewWithBaseURI(baseURI)}
}
// ListNodeAgentSkus sends the list node agent skus request.
//
// filter is an OData $filter clause. For more information on constructing this filter, see
// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-node-agent-skus. maxResults
// is the maximum number of items to return in the response. A maximum of 1000 results will be returned. timeout is
// the maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.
// clientRequestID is the caller-generated request identity, in the form of a GUID with no decoration such as curly
// braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
func (client AccountClient) ListNodeAgentSkus(ctx context.Context, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result AccountListNodeAgentSkusResultPage, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: maxResults,
Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewError("batch.AccountClient", "ListNodeAgentSkus", err.Error())
}
result.fn = client.listNodeAgentSkusNextResults
req, err := client.ListNodeAgentSkusPreparer(ctx, filter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListNodeAgentSkus", nil, "Failure preparing request")
return
}
resp, err := client.ListNodeAgentSkusSender(req)
if err != nil {
result.alnasr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListNodeAgentSkus", resp, "Failure sending request")
return
}
result.alnasr, err = client.ListNodeAgentSkusResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListNodeAgentSkus", resp, "Failure responding to request")
}
return
}
// ListNodeAgentSkusPreparer prepares the ListNodeAgentSkus request.
func (client AccountClient) ListNodeAgentSkusPreparer(ctx context.Context, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter)
}
if maxResults != nil {
queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
} else {
queryParameters["maxresults"] = autorest.Encode("query", 1000)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/nodeagentskus"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListNodeAgentSkusSender sends the ListNodeAgentSkus request. The method will close the
// http.Response Body if it receives an error.
func (client AccountClient) ListNodeAgentSkusSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// ListNodeAgentSkusResponder handles the response to the ListNodeAgentSkus request. The method always
// closes the http.Response Body.
func (client AccountClient) ListNodeAgentSkusResponder(resp *http.Response) (result AccountListNodeAgentSkusResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listNodeAgentSkusNextResults retrieves the next set of results, if any.
func (client AccountClient) listNodeAgentSkusNextResults(lastResults AccountListNodeAgentSkusResult) (result AccountListNodeAgentSkusResult, err error) {
req, err := lastResults.accountListNodeAgentSkusResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "batch.AccountClient", "listNodeAgentSkusNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListNodeAgentSkusSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "batch.AccountClient", "listNodeAgentSkusNextResults", resp, "Failure sending next results request")
}
result, err = client.ListNodeAgentSkusResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.AccountClient", "listNodeAgentSkusNextResults", resp, "Failure responding to next results request")
}
return
}
// ListNodeAgentSkusComplete enumerates all values, automatically crossing page boundaries as required.
func (client AccountClient) ListNodeAgentSkusComplete(ctx context.Context, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result AccountListNodeAgentSkusResultIterator, err error) {
result.page, err = client.ListNodeAgentSkus(ctx, filter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
return
}

View File

@@ -0,0 +1,264 @@
package batch
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/validation"
"github.com/satori/go.uuid"
"net/http"
)
// ApplicationClient is the a client for issuing REST requests to the Azure Batch service.
type ApplicationClient struct {
BaseClient
}
// NewApplicationClient creates an instance of the ApplicationClient client.
func NewApplicationClient() ApplicationClient {
return NewApplicationClientWithBaseURI(DefaultBaseURI)
}
// NewApplicationClientWithBaseURI creates an instance of the ApplicationClient client.
func NewApplicationClientWithBaseURI(baseURI string) ApplicationClient {
return ApplicationClient{NewWithBaseURI(baseURI)}
}
// Get this operation returns only applications and versions that are available for use on compute nodes; that is, that
// can be used in an application package reference. For administrator information about applications and versions that
// are not yet available to compute nodes, use the Azure portal or the Azure Resource Manager API.
//
// applicationID is the ID of the application. timeout is the maximum time that the server can spend processing the
// request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the
// form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
// returnClientRequestID is whether the server should return the client-request-id in the response. ocpDate is the
// time the request was issued. Client libraries typically set this to the current system clock time; set it
// explicitly if you are calling the REST API directly.
func (client ApplicationClient) Get(ctx context.Context, applicationID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ApplicationSummary, err error) {
req, err := client.GetPreparer(ctx, applicationID, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", nil, "Failure preparing request")
return
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client ApplicationClient) GetPreparer(ctx context.Context, applicationID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"applicationId": autorest.Encode("path", applicationID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/applications/{applicationId}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client ApplicationClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client ApplicationClient) GetResponder(resp *http.Response) (result ApplicationSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List this operation returns only applications and versions that are available for use on compute nodes; that is,
// that can be used in an application package reference. For administrator information about applications and versions
// that are not yet available to compute nodes, use the Azure portal or the Azure Resource Manager API.
//
// maxResults is the maximum number of items to return in the response. A maximum of 1000 applications can be
// returned. timeout is the maximum time that the server can spend processing the request, in seconds. The default
// is 30 seconds. clientRequestID is the caller-generated request identity, in the form of a GUID with no
// decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the
// server should return the client-request-id in the response. ocpDate is the time the request was issued. Client
// libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API
// directly.
func (client ApplicationClient) List(ctx context.Context, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ApplicationListResultPage, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: maxResults,
Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewError("batch.ApplicationClient", "List", err.Error())
}
result.fn = client.listNextResults
req, err := client.ListPreparer(ctx, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.alr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", resp, "Failure sending request")
return
}
result.alr, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client ApplicationClient) ListPreparer(ctx context.Context, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if maxResults != nil {
queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
} else {
queryParameters["maxresults"] = autorest.Encode("query", 1000)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/applications"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client ApplicationClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client ApplicationClient) ListResponder(resp *http.Response) (result ApplicationListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listNextResults retrieves the next set of results, if any.
func (client ApplicationClient) listNextResults(lastResults ApplicationListResult) (result ApplicationListResult, err error) {
req, err := lastResults.applicationListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "listNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "listNextResults", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "listNextResults", resp, "Failure responding to next results request")
}
return
}
// ListComplete enumerates all values, automatically crossing page boundaries as required.
func (client ApplicationClient) ListComplete(ctx context.Context, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ApplicationListResultIterator, err error) {
result.page, err = client.List(ctx, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
return
}

View File

@@ -0,0 +1,557 @@
package batch
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/validation"
"github.com/satori/go.uuid"
"net/http"
)
// CertificateClient is the a client for issuing REST requests to the Azure Batch service.
type CertificateClient struct {
BaseClient
}
// NewCertificateClient creates an instance of the CertificateClient client.
func NewCertificateClient() CertificateClient {
return NewCertificateClientWithBaseURI(DefaultBaseURI)
}
// NewCertificateClientWithBaseURI creates an instance of the CertificateClient client.
func NewCertificateClientWithBaseURI(baseURI string) CertificateClient {
return CertificateClient{NewWithBaseURI(baseURI)}
}
// Add sends the add request.
//
// certificate is the certificate to be added. timeout is the maximum time that the server can spend processing the
// request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the
// form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
// returnClientRequestID is whether the server should return the client-request-id in the response. ocpDate is the
// time the request was issued. Client libraries typically set this to the current system clock time; set it
// explicitly if you are calling the REST API directly.
func (client CertificateClient) Add(ctx context.Context, certificate CertificateAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: certificate,
Constraints: []validation.Constraint{{Target: "certificate.Thumbprint", Name: validation.Null, Rule: true, Chain: nil},
{Target: "certificate.ThumbprintAlgorithm", Name: validation.Null, Rule: true, Chain: nil},
{Target: "certificate.Data", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewError("batch.CertificateClient", "Add", err.Error())
}
req, err := client.AddPreparer(ctx, certificate, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Add", nil, "Failure preparing request")
return
}
resp, err := client.AddSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Add", resp, "Failure sending request")
return
}
result, err = client.AddResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Add", resp, "Failure responding to request")
}
return
}
// AddPreparer prepares the Add request.
func (client CertificateClient) AddPreparer(ctx context.Context, certificate CertificateAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/certificates"),
autorest.WithJSON(certificate),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// AddSender sends the Add request. The method will close the
// http.Response Body if it receives an error.
func (client CertificateClient) AddSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// AddResponder handles the response to the Add request. The method always
// closes the http.Response Body.
func (client CertificateClient) AddResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByClosing())
result.Response = resp
return
}
// CancelDeletion if you try to delete a certificate that is being used by a pool or compute node, the status of the
// certificate changes to deleteFailed. If you decide that you want to continue using the certificate, you can use this
// operation to set the status of the certificate back to active. If you intend to delete the certificate, you do not
// need to run this operation after the deletion failed. You must make sure that the certificate is not being used by
// any resources, and then you can try again to delete the certificate.
//
// thumbprintAlgorithm is the algorithm used to derive the thumbprint parameter. This must be sha1. thumbprint is
// the thumbprint of the certificate being deleted. timeout is the maximum time that the server can spend
// processing the request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request
// identity, in the form of a GUID with no decoration such as curly braces, e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
func (client CertificateClient) CancelDeletion(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
req, err := client.CancelDeletionPreparer(ctx, thumbprintAlgorithm, thumbprint, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "CancelDeletion", nil, "Failure preparing request")
return
}
resp, err := client.CancelDeletionSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "CancelDeletion", resp, "Failure sending request")
return
}
result, err = client.CancelDeletionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "CancelDeletion", resp, "Failure responding to request")
}
return
}
// CancelDeletionPreparer prepares the CancelDeletion request.
func (client CertificateClient) CancelDeletionPreparer(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"thumbprint": autorest.Encode("path", thumbprint),
"thumbprintAlgorithm": autorest.Encode("path", thumbprintAlgorithm),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})/canceldelete", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CancelDeletionSender sends the CancelDeletion request. The method will close the
// http.Response Body if it receives an error.
func (client CertificateClient) CancelDeletionSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CancelDeletionResponder handles the response to the CancelDeletion request. The method always
// closes the http.Response Body.
func (client CertificateClient) CancelDeletionResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// Delete you cannot delete a certificate if a resource (pool or compute node) is using it. Before you can delete a
// certificate, you must therefore make sure that the certificate is not associated with any existing pools, the
// certificate is not installed on any compute nodes (even if you remove a certificate from a pool, it is not removed
// from existing compute nodes in that pool until they restart), and no running tasks depend on the certificate. If you
// try to delete a certificate that is in use, the deletion fails. The certificate status changes to deleteFailed. You
// can use Cancel Delete Certificate to set the status back to active if you decide that you want to continue using the
// certificate.
//
// thumbprintAlgorithm is the algorithm used to derive the thumbprint parameter. This must be sha1. thumbprint is
// the thumbprint of the certificate to be deleted. timeout is the maximum time that the server can spend
// processing the request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request
// identity, in the form of a GUID with no decoration such as curly braces, e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
func (client CertificateClient) Delete(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, thumbprintAlgorithm, thumbprint, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client CertificateClient) DeletePreparer(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"thumbprint": autorest.Encode("path", thumbprint),
"thumbprintAlgorithm": autorest.Encode("path", thumbprintAlgorithm),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets information about the specified certificate.
//
// thumbprintAlgorithm is the algorithm used to derive the thumbprint parameter. This must be sha1. thumbprint is
// the thumbprint of the certificate to get. selectParameter is an OData $select clause. timeout is the maximum
// time that the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is
// the caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
func (client CertificateClient) Get(ctx context.Context, thumbprintAlgorithm string, thumbprint string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result Certificate, err error) {
req, err := client.GetPreparer(ctx, thumbprintAlgorithm, thumbprint, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Get", nil, "Failure preparing request")
return
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client CertificateClient) GetPreparer(ctx context.Context, thumbprintAlgorithm string, thumbprint string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"thumbprint": autorest.Encode("path", thumbprint),
"thumbprintAlgorithm": autorest.Encode("path", thumbprintAlgorithm),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(selectParameter) > 0 {
queryParameters["$select"] = autorest.Encode("query", selectParameter)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client CertificateClient) GetResponder(resp *http.Response) (result Certificate, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List sends the list request.
//
// filter is an OData $filter clause. For more information on constructing this filter, see
// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-certificates. selectParameter
// is an OData $select clause. maxResults is the maximum number of items to return in the response. A maximum of
// 1000 certificates can be returned. timeout is the maximum time that the server can spend processing the request,
// in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the form of
// a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID
// is whether the server should return the client-request-id in the response. ocpDate is the time the request was
// issued. Client libraries typically set this to the current system clock time; set it explicitly if you are
// calling the REST API directly.
func (client CertificateClient) List(ctx context.Context, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CertificateListResultPage, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: maxResults,
Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewError("batch.CertificateClient", "List", err.Error())
}
result.fn = client.listNextResults
req, err := client.ListPreparer(ctx, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.clr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "List", resp, "Failure sending request")
return
}
result.clr, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client CertificateClient) ListPreparer(ctx context.Context, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter)
}
if len(selectParameter) > 0 {
queryParameters["$select"] = autorest.Encode("query", selectParameter)
}
if maxResults != nil {
queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
} else {
queryParameters["maxresults"] = autorest.Encode("query", 1000)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/certificates"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client CertificateClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client CertificateClient) ListResponder(resp *http.Response) (result CertificateListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listNextResults retrieves the next set of results, if any.
func (client CertificateClient) listNextResults(lastResults CertificateListResult) (result CertificateListResult, err error) {
req, err := lastResults.certificateListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "batch.CertificateClient", "listNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "batch.CertificateClient", "listNextResults", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.CertificateClient", "listNextResults", resp, "Failure responding to next results request")
}
return
}
// ListComplete enumerates all values, automatically crossing page boundaries as required.
func (client CertificateClient) ListComplete(ctx context.Context, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CertificateListResultIterator, err error) {
result.page, err = client.List(ctx, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
return
}

View File

@@ -0,0 +1,49 @@
// Package batch implements the Azure ARM Batch service API version 2017-09-01.6.0.
//
// A client for issuing REST requests to the Azure Batch service.
package batch
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// DefaultBaseURI is the default URI used for the service Batch
DefaultBaseURI = "https://batch.core.windows.net"
)
// BaseClient is the base client for Batch.
type BaseClient struct {
autorest.Client
BaseURI string
}
// New creates an instance of the BaseClient client.
func New() BaseClient {
return NewWithBaseURI(DefaultBaseURI)
}
// NewWithBaseURI creates an instance of the BaseClient client.
func NewWithBaseURI(baseURI string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,946 @@
package batch
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/validation"
"github.com/satori/go.uuid"
"net/http"
)
// FileClient is the a client for issuing REST requests to the Azure Batch service.
type FileClient struct {
BaseClient
}
// NewFileClient creates an instance of the FileClient client.
func NewFileClient() FileClient {
return NewFileClientWithBaseURI(DefaultBaseURI)
}
// NewFileClientWithBaseURI creates an instance of the FileClient client.
func NewFileClientWithBaseURI(baseURI string) FileClient {
return FileClient{NewWithBaseURI(baseURI)}
}
// DeleteFromComputeNode sends the delete from compute node request.
//
// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node from which you
// want to delete the file. filePath is the path to the file or directory that you want to delete. recursive is
// whether to delete children of a directory. If the filePath parameter represents a directory instead of a file,
// you can set recursive to true to delete the directory and all of the files and subdirectories in it. If
// recursive is false then the directory must be empty or deletion will fail. timeout is the maximum time that the
// server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the
// caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
func (client FileClient) DeleteFromComputeNode(ctx context.Context, poolID string, nodeID string, filePath string, recursive *bool, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
req, err := client.DeleteFromComputeNodePreparer(ctx, poolID, nodeID, filePath, recursive, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromComputeNode", nil, "Failure preparing request")
return
}
resp, err := client.DeleteFromComputeNodeSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromComputeNode", resp, "Failure sending request")
return
}
result, err = client.DeleteFromComputeNodeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromComputeNode", resp, "Failure responding to request")
}
return
}
// DeleteFromComputeNodePreparer prepares the DeleteFromComputeNode request.
func (client FileClient) DeleteFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, filePath string, recursive *bool, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"filePath": autorest.Encode("path", filePath),
"nodeId": autorest.Encode("path", nodeID),
"poolId": autorest.Encode("path", poolID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if recursive != nil {
queryParameters["recursive"] = autorest.Encode("query", *recursive)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files/{filePath}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteFromComputeNodeSender sends the DeleteFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) DeleteFromComputeNodeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteFromComputeNodeResponder handles the response to the DeleteFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) DeleteFromComputeNodeResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteFromTask sends the delete from task request.
//
// jobID is the ID of the job that contains the task. taskID is the ID of the task whose file you want to delete.
// filePath is the path to the task file or directory that you want to delete. recursive is whether to delete
// children of a directory. If the filePath parameter represents a directory instead of a file, you can set
// recursive to true to delete the directory and all of the files and subdirectories in it. If recursive is false
// then the directory must be empty or deletion will fail. timeout is the maximum time that the server can spend
// processing the request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request
// identity, in the form of a GUID with no decoration such as curly braces, e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
func (client FileClient) DeleteFromTask(ctx context.Context, jobID string, taskID string, filePath string, recursive *bool, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
req, err := client.DeleteFromTaskPreparer(ctx, jobID, taskID, filePath, recursive, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromTask", nil, "Failure preparing request")
return
}
resp, err := client.DeleteFromTaskSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromTask", resp, "Failure sending request")
return
}
result, err = client.DeleteFromTaskResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromTask", resp, "Failure responding to request")
}
return
}
// DeleteFromTaskPreparer prepares the DeleteFromTask request.
func (client FileClient) DeleteFromTaskPreparer(ctx context.Context, jobID string, taskID string, filePath string, recursive *bool, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"filePath": autorest.Encode("path", filePath),
"jobId": autorest.Encode("path", jobID),
"taskId": autorest.Encode("path", taskID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if recursive != nil {
queryParameters["recursive"] = autorest.Encode("query", *recursive)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files/{filePath}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteFromTaskSender sends the DeleteFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) DeleteFromTaskSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteFromTaskResponder handles the response to the DeleteFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) DeleteFromTaskResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// GetFromComputeNode returns the content of the specified compute node file.
//
// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node that contains
// the file. filePath is the path to the compute node file that you want to get the content of. timeout is the
// maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.
// clientRequestID is the caller-generated request identity, in the form of a GUID with no decoration such as curly
// braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly. ocpRange is
// the byte range to be retrieved. The default is to retrieve the entire file. The format is
// bytes=startRange-endRange. ifModifiedSince is a timestamp indicating the last modified time of the resource
// known to the client. The operation will be performed only if the resource on the service has been modified since
// the specified time. ifUnmodifiedSince is a timestamp indicating the last modified time of the resource known to
// the client. The operation will be performed only if the resource on the service has not been modified since the
// specified time.
func (client FileClient) GetFromComputeNode(ctx context.Context, poolID string, nodeID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result ReadCloser, err error) {
req, err := client.GetFromComputeNodePreparer(ctx, poolID, nodeID, filePath, timeout, clientRequestID, returnClientRequestID, ocpDate, ocpRange, ifModifiedSince, ifUnmodifiedSince)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromComputeNode", nil, "Failure preparing request")
return
}
resp, err := client.GetFromComputeNodeSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromComputeNode", resp, "Failure sending request")
return
}
result, err = client.GetFromComputeNodeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromComputeNode", resp, "Failure responding to request")
}
return
}
// GetFromComputeNodePreparer prepares the GetFromComputeNode request.
func (client FileClient) GetFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"filePath": autorest.Encode("path", filePath),
"nodeId": autorest.Encode("path", nodeID),
"poolId": autorest.Encode("path", poolID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files/{filePath}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
if len(ocpRange) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-range", autorest.String(ocpRange)))
}
if ifModifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
}
if ifUnmodifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetFromComputeNodeSender sends the GetFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetFromComputeNodeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetFromComputeNodeResponder handles the response to the GetFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) GetFromComputeNodeResponder(resp *http.Response) (result ReadCloser, err error) {
result.Value = &resp.Body
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK))
result.Response = autorest.Response{Response: resp}
return
}
// GetFromTask returns the content of the specified task file.
//
// jobID is the ID of the job that contains the task. taskID is the ID of the task whose file you want to retrieve.
// filePath is the path to the task file that you want to get the content of. timeout is the maximum time that the
// server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the
// caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly. ocpRange is
// the byte range to be retrieved. The default is to retrieve the entire file. The format is
// bytes=startRange-endRange. ifModifiedSince is a timestamp indicating the last modified time of the resource
// known to the client. The operation will be performed only if the resource on the service has been modified since
// the specified time. ifUnmodifiedSince is a timestamp indicating the last modified time of the resource known to
// the client. The operation will be performed only if the resource on the service has not been modified since the
// specified time.
func (client FileClient) GetFromTask(ctx context.Context, jobID string, taskID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result ReadCloser, err error) {
req, err := client.GetFromTaskPreparer(ctx, jobID, taskID, filePath, timeout, clientRequestID, returnClientRequestID, ocpDate, ocpRange, ifModifiedSince, ifUnmodifiedSince)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromTask", nil, "Failure preparing request")
return
}
resp, err := client.GetFromTaskSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromTask", resp, "Failure sending request")
return
}
result, err = client.GetFromTaskResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromTask", resp, "Failure responding to request")
}
return
}
// GetFromTaskPreparer prepares the GetFromTask request.
func (client FileClient) GetFromTaskPreparer(ctx context.Context, jobID string, taskID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"filePath": autorest.Encode("path", filePath),
"jobId": autorest.Encode("path", jobID),
"taskId": autorest.Encode("path", taskID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files/{filePath}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
if len(ocpRange) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-range", autorest.String(ocpRange)))
}
if ifModifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
}
if ifUnmodifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetFromTaskSender sends the GetFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetFromTaskSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetFromTaskResponder handles the response to the GetFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) GetFromTaskResponder(resp *http.Response) (result ReadCloser, err error) {
result.Value = &resp.Body
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK))
result.Response = autorest.Response{Response: resp}
return
}
// GetPropertiesFromComputeNode gets the properties of the specified compute node file.
//
// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node that contains
// the file. filePath is the path to the compute node file that you want to get the properties of. timeout is the
// maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.
// clientRequestID is the caller-generated request identity, in the form of a GUID with no decoration such as curly
// braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
// ifModifiedSince is a timestamp indicating the last modified time of the resource known to the client. The
// operation will be performed only if the resource on the service has been modified since the specified time.
// ifUnmodifiedSince is a timestamp indicating the last modified time of the resource known to the client. The
// operation will be performed only if the resource on the service has not been modified since the specified time.
func (client FileClient) GetPropertiesFromComputeNode(ctx context.Context, poolID string, nodeID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
req, err := client.GetPropertiesFromComputeNodePreparer(ctx, poolID, nodeID, filePath, timeout, clientRequestID, returnClientRequestID, ocpDate, ifModifiedSince, ifUnmodifiedSince)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetPropertiesFromComputeNode", nil, "Failure preparing request")
return
}
resp, err := client.GetPropertiesFromComputeNodeSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetPropertiesFromComputeNode", resp, "Failure sending request")
return
}
result, err = client.GetPropertiesFromComputeNodeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetPropertiesFromComputeNode", resp, "Failure responding to request")
}
return
}
// GetPropertiesFromComputeNodePreparer prepares the GetPropertiesFromComputeNode request.
func (client FileClient) GetPropertiesFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"filePath": autorest.Encode("path", filePath),
"nodeId": autorest.Encode("path", nodeID),
"poolId": autorest.Encode("path", poolID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsHead(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files/{filePath}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
if ifModifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
}
if ifUnmodifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetPropertiesFromComputeNodeSender sends the GetPropertiesFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetPropertiesFromComputeNodeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetPropertiesFromComputeNodeResponder handles the response to the GetPropertiesFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) GetPropertiesFromComputeNodeResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// GetPropertiesFromTask gets the properties of the specified task file.
//
// jobID is the ID of the job that contains the task. taskID is the ID of the task whose file you want to get the
// properties of. filePath is the path to the task file that you want to get the properties of. timeout is the
// maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.
// clientRequestID is the caller-generated request identity, in the form of a GUID with no decoration such as curly
// braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the
// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set
// this to the current system clock time; set it explicitly if you are calling the REST API directly.
// ifModifiedSince is a timestamp indicating the last modified time of the resource known to the client. The
// operation will be performed only if the resource on the service has been modified since the specified time.
// ifUnmodifiedSince is a timestamp indicating the last modified time of the resource known to the client. The
// operation will be performed only if the resource on the service has not been modified since the specified time.
func (client FileClient) GetPropertiesFromTask(ctx context.Context, jobID string, taskID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
req, err := client.GetPropertiesFromTaskPreparer(ctx, jobID, taskID, filePath, timeout, clientRequestID, returnClientRequestID, ocpDate, ifModifiedSince, ifUnmodifiedSince)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetPropertiesFromTask", nil, "Failure preparing request")
return
}
resp, err := client.GetPropertiesFromTaskSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetPropertiesFromTask", resp, "Failure sending request")
return
}
result, err = client.GetPropertiesFromTaskResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "GetPropertiesFromTask", resp, "Failure responding to request")
}
return
}
// GetPropertiesFromTaskPreparer prepares the GetPropertiesFromTask request.
func (client FileClient) GetPropertiesFromTaskPreparer(ctx context.Context, jobID string, taskID string, filePath string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"filePath": autorest.Encode("path", filePath),
"jobId": autorest.Encode("path", jobID),
"taskId": autorest.Encode("path", taskID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsHead(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files/{filePath}", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
if ifModifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
}
if ifUnmodifiedSince != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetPropertiesFromTaskSender sends the GetPropertiesFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetPropertiesFromTaskSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetPropertiesFromTaskResponder handles the response to the GetPropertiesFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) GetPropertiesFromTaskResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// ListFromComputeNode sends the list from compute node request.
//
// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node whose files
// you want to list. filter is an OData $filter clause. For more information on constructing this filter, see
// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-compute-node-files. recursive
// is whether to list children of a directory. maxResults is the maximum number of items to return in the response.
// A maximum of 1000 files can be returned. timeout is the maximum time that the server can spend processing the
// request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the
// form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
// returnClientRequestID is whether the server should return the client-request-id in the response. ocpDate is the
// time the request was issued. Client libraries typically set this to the current system clock time; set it
// explicitly if you are calling the REST API directly.
func (client FileClient) ListFromComputeNode(ctx context.Context, poolID string, nodeID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultPage, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: maxResults,
Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewError("batch.FileClient", "ListFromComputeNode", err.Error())
}
result.fn = client.listFromComputeNodeNextResults
req, err := client.ListFromComputeNodePreparer(ctx, poolID, nodeID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromComputeNode", nil, "Failure preparing request")
return
}
resp, err := client.ListFromComputeNodeSender(req)
if err != nil {
result.nflr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromComputeNode", resp, "Failure sending request")
return
}
result.nflr, err = client.ListFromComputeNodeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromComputeNode", resp, "Failure responding to request")
}
return
}
// ListFromComputeNodePreparer prepares the ListFromComputeNode request.
func (client FileClient) ListFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeId": autorest.Encode("path", nodeID),
"poolId": autorest.Encode("path", poolID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter)
}
if recursive != nil {
queryParameters["recursive"] = autorest.Encode("query", *recursive)
}
if maxResults != nil {
queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
} else {
queryParameters["maxresults"] = autorest.Encode("query", 1000)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListFromComputeNodeSender sends the ListFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) ListFromComputeNodeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// ListFromComputeNodeResponder handles the response to the ListFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) ListFromComputeNodeResponder(resp *http.Response) (result NodeFileListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listFromComputeNodeNextResults retrieves the next set of results, if any.
func (client FileClient) listFromComputeNodeNextResults(lastResults NodeFileListResult) (result NodeFileListResult, err error) {
req, err := lastResults.nodeFileListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromComputeNodeNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListFromComputeNodeSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromComputeNodeNextResults", resp, "Failure sending next results request")
}
result, err = client.ListFromComputeNodeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "listFromComputeNodeNextResults", resp, "Failure responding to next results request")
}
return
}
// ListFromComputeNodeComplete enumerates all values, automatically crossing page boundaries as required.
func (client FileClient) ListFromComputeNodeComplete(ctx context.Context, poolID string, nodeID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultIterator, err error) {
result.page, err = client.ListFromComputeNode(ctx, poolID, nodeID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
return
}
// ListFromTask sends the list from task request.
//
// jobID is the ID of the job that contains the task. taskID is the ID of the task whose files you want to list.
// filter is an OData $filter clause. For more information on constructing this filter, see
// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-task-files. recursive is
// whether to list children of the task directory. This parameter can be used in combination with the filter
// parameter to list specific type of files. maxResults is the maximum number of items to return in the response. A
// maximum of 1000 files can be returned. timeout is the maximum time that the server can spend processing the
// request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the
// form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
// returnClientRequestID is whether the server should return the client-request-id in the response. ocpDate is the
// time the request was issued. Client libraries typically set this to the current system clock time; set it
// explicitly if you are calling the REST API directly.
func (client FileClient) ListFromTask(ctx context.Context, jobID string, taskID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultPage, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: maxResults,
Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewError("batch.FileClient", "ListFromTask", err.Error())
}
result.fn = client.listFromTaskNextResults
req, err := client.ListFromTaskPreparer(ctx, jobID, taskID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromTask", nil, "Failure preparing request")
return
}
resp, err := client.ListFromTaskSender(req)
if err != nil {
result.nflr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromTask", resp, "Failure sending request")
return
}
result.nflr, err = client.ListFromTaskResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromTask", resp, "Failure responding to request")
}
return
}
// ListFromTaskPreparer prepares the ListFromTask request.
func (client FileClient) ListFromTaskPreparer(ctx context.Context, jobID string, taskID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
pathParameters := map[string]interface{}{
"jobId": autorest.Encode("path", jobID),
"taskId": autorest.Encode("path", taskID),
}
const APIVersion = "2017-09-01.6.0"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter)
}
if recursive != nil {
queryParameters["recursive"] = autorest.Encode("query", *recursive)
}
if maxResults != nil {
queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
} else {
queryParameters["maxresults"] = autorest.Encode("query", 1000)
}
if timeout != nil {
queryParameters["timeout"] = autorest.Encode("query", *timeout)
} else {
queryParameters["timeout"] = autorest.Encode("query", 30)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if returnClientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
} else {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("return-client-request-id", autorest.String(false)))
}
if ocpDate != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListFromTaskSender sends the ListFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) ListFromTaskSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// ListFromTaskResponder handles the response to the ListFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) ListFromTaskResponder(resp *http.Response) (result NodeFileListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listFromTaskNextResults retrieves the next set of results, if any.
func (client FileClient) listFromTaskNextResults(lastResults NodeFileListResult) (result NodeFileListResult, err error) {
req, err := lastResults.nodeFileListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromTaskNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListFromTaskSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromTaskNextResults", resp, "Failure sending next results request")
}
result, err = client.ListFromTaskResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "batch.FileClient", "listFromTaskNextResults", resp, "Failure responding to next results request")
}
return
}
// ListFromTaskComplete enumerates all values, automatically crossing page boundaries as required.
func (client FileClient) ListFromTaskComplete(ctx context.Context, jobID string, taskID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultIterator, err error) {
result.page, err = client.ListFromTask(ctx, jobID, taskID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
return
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
package batch
import "github.com/Azure/azure-sdk-for-go/version"
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/" + version.Number + " batch/2017-09-01.6.0"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return version.Number
}