Exemple #1
0
// NewOperationResourceRequest allocates and returns a new http.Request to retrieve the
// OperationResource for an asynchronous operation.
func NewOperationResourceRequest(resp *http.Response, cancel <-chan struct{}) (*http.Request, error) {
	location := GetAsyncOperation(resp)
	if location == "" {
		return nil, autorest.NewErrorWithResponse("azure", "NewOperationResourceRequest", resp, "Azure-AsyncOperation header missing from response that requires polling")
	}

	req, err := autorest.Prepare(&http.Request{Cancel: cancel},
		autorest.AsGet(),
		autorest.WithBaseURL(location))
	if err != nil {
		return nil, autorest.NewErrorWithError(err, "azure", "NewOperationResourceRequest", nil, "Failure creating poll request to %s", location)
	}

	return req, nil
}
Exemple #2
0
// NewAsyncPollingRequest allocates and returns a new http.Request to poll an Azure long-running
// operation. If it successfully creates the request, it will also close the body of the passed
// response, otherwise the body remains open.
func NewAsyncPollingRequest(resp *http.Response, c autorest.Client) (*http.Request, error) {
	location := GetAsyncOperation(resp)
	if location == "" {
		return nil, autorest.NewErrorWithResponse("azure", "NewAsyncPollingRequest", resp, "Azure-AsyncOperation header missing from response that requires polling")
	}

	req, err := autorest.Prepare(&http.Request{},
		autorest.AsGet(),
		autorest.WithBaseURL(location))
	if err != nil {
		return nil, autorest.NewErrorWithError(err, "azure", "NewAsyncPollingRequest", nil, "Failure creating poll request to %s", location)
	}

	autorest.Respond(resp,
		c.ByInspecting(),
		autorest.ByClosing())

	return req, nil
}