mirror of
https://github.com/octoleo/restic.git
synced 2024-12-04 02:48:21 +00:00
61cb1cc6f8
This includes github.com/kurin/blazer 0.2.0, which resolves #1291
1174 lines
48 KiB
Go
Executable File
1174 lines
48 KiB
Go
Executable File
package cdn
|
||
|
||
// 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"
|
||
"github.com/Azure/go-autorest/autorest/azure"
|
||
"github.com/Azure/go-autorest/autorest/validation"
|
||
"net/http"
|
||
)
|
||
|
||
// EndpointsClient is the use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must
|
||
// make sure that requests made to these resources are secure.
|
||
type EndpointsClient struct {
|
||
ManagementClient
|
||
}
|
||
|
||
// NewEndpointsClient creates an instance of the EndpointsClient client.
|
||
func NewEndpointsClient(subscriptionID string) EndpointsClient {
|
||
return NewEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||
}
|
||
|
||
// NewEndpointsClientWithBaseURI creates an instance of the EndpointsClient client.
|
||
func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient {
|
||
return EndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||
}
|
||
|
||
// Create creates a new CDN endpoint with the specified endpoint name under the specified subscription, resource group
|
||
// and profile. This method may poll for completion. Polling can be canceled by passing the cancel channel argument.
|
||
// The channel will be used to cancel polling and any outstanding HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally. endpoint is endpoint properties
|
||
func (client EndpointsClient) Create(resourceGroupName string, profileName string, endpointName string, endpoint Endpoint, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) {
|
||
resultChan := make(chan Endpoint, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
|
||
{TargetValue: endpoint,
|
||
Constraints: []validation.Constraint{{Target: "endpoint.EndpointProperties", Name: validation.Null, Rule: false,
|
||
Chain: []validation.Constraint{{Target: "endpoint.EndpointProperties.Origins", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Create")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result Endpoint
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, endpoint, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.CreateSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.CreateResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// CreatePreparer prepares the Create request.
|
||
func (client EndpointsClient) CreatePreparer(resourceGroupName string, profileName string, endpointName string, endpoint Endpoint, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsJSON(),
|
||
autorest.AsPut(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
|
||
autorest.WithJSON(endpoint),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// CreateSender sends the Create request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) CreateSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// CreateResponder handles the response to the Create request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) CreateResponder(resp *http.Response) (result Endpoint, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// Delete deletes an existing CDN endpoint with the specified endpoint name under the specified subscription, resource
|
||
// group and profile. This method may poll for completion. Polling can be canceled by passing the cancel channel
|
||
// argument. The channel will be used to cancel polling and any outstanding HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally.
|
||
func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
||
resultChan := make(chan autorest.Response, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Delete")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result autorest.Response
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.DeleteSender(req)
|
||
if err != nil {
|
||
result.Response = resp
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.DeleteResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// DeletePreparer prepares the Delete request.
|
||
func (client EndpointsClient) DeletePreparer(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsDelete(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// DeleteSender sends the Delete request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// DeleteResponder handles the response to the Delete request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||
autorest.ByClosing())
|
||
result.Response = resp
|
||
return
|
||
}
|
||
|
||
// Get gets an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group
|
||
// and profile.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally.
|
||
func (client EndpointsClient) Get(resourceGroupName string, profileName string, endpointName string) (result Endpoint, err error) {
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Get")
|
||
}
|
||
|
||
req, err := client.GetPreparer(resourceGroupName, profileName, endpointName)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.GetSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.GetResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure responding to request")
|
||
}
|
||
|
||
return
|
||
}
|
||
|
||
// GetPreparer prepares the Get request.
|
||
func (client EndpointsClient) GetPreparer(resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsGet(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{})
|
||
}
|
||
|
||
// GetSender sends the Get request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client, req)
|
||
}
|
||
|
||
// GetResponder handles the response to the Get request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) GetResponder(resp *http.Response) (result Endpoint, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// ListByProfile lists existing CDN endpoints.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group.
|
||
func (client EndpointsClient) ListByProfile(resourceGroupName string, profileName string) (result EndpointListResult, err error) {
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "ListByProfile")
|
||
}
|
||
|
||
req, err := client.ListByProfilePreparer(resourceGroupName, profileName)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.ListByProfileSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.ListByProfileResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure responding to request")
|
||
}
|
||
|
||
return
|
||
}
|
||
|
||
// ListByProfilePreparer prepares the ListByProfile request.
|
||
func (client EndpointsClient) ListByProfilePreparer(resourceGroupName string, profileName string) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsGet(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints", pathParameters),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{})
|
||
}
|
||
|
||
// ListByProfileSender sends the ListByProfile request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) ListByProfileSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client, req)
|
||
}
|
||
|
||
// ListByProfileResponder handles the response to the ListByProfile request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) ListByProfileResponder(resp *http.Response) (result EndpointListResult, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// ListByProfileNextResults retrieves the next set of results, if any.
|
||
func (client EndpointsClient) ListByProfileNextResults(lastResults EndpointListResult) (result EndpointListResult, err error) {
|
||
req, err := lastResults.EndpointListResultPreparer()
|
||
if err != nil {
|
||
return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing next results request")
|
||
}
|
||
if req == nil {
|
||
return
|
||
}
|
||
|
||
resp, err := client.ListByProfileSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending next results request")
|
||
}
|
||
|
||
result, err = client.ListByProfileResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure responding to next results request")
|
||
}
|
||
|
||
return
|
||
}
|
||
|
||
// ListByProfileComplete gets all elements from the list without paging.
|
||
func (client EndpointsClient) ListByProfileComplete(resourceGroupName string, profileName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) {
|
||
resultChan := make(chan Endpoint)
|
||
errChan := make(chan error, 1)
|
||
go func() {
|
||
defer func() {
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
list, err := client.ListByProfile(resourceGroupName, profileName)
|
||
if err != nil {
|
||
errChan <- err
|
||
return
|
||
}
|
||
if list.Value != nil {
|
||
for _, item := range *list.Value {
|
||
select {
|
||
case <-cancel:
|
||
return
|
||
case resultChan <- item:
|
||
// Intentionally left blank
|
||
}
|
||
}
|
||
}
|
||
for list.NextLink != nil {
|
||
list, err = client.ListByProfileNextResults(list)
|
||
if err != nil {
|
||
errChan <- err
|
||
return
|
||
}
|
||
if list.Value != nil {
|
||
for _, item := range *list.Value {
|
||
select {
|
||
case <-cancel:
|
||
return
|
||
case resultChan <- item:
|
||
// Intentionally left blank
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// ListResourceUsage checks the quota and usage of geo filters and custom domains under the given endpoint.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally.
|
||
func (client EndpointsClient) ListResourceUsage(resourceGroupName string, profileName string, endpointName string) (result ResourceUsageListResult, err error) {
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "ListResourceUsage")
|
||
}
|
||
|
||
req, err := client.ListResourceUsagePreparer(resourceGroupName, profileName, endpointName)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.ListResourceUsageSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.ListResourceUsageResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure responding to request")
|
||
}
|
||
|
||
return
|
||
}
|
||
|
||
// ListResourceUsagePreparer prepares the ListResourceUsage request.
|
||
func (client EndpointsClient) ListResourceUsagePreparer(resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsPost(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/checkResourceUsage", pathParameters),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{})
|
||
}
|
||
|
||
// ListResourceUsageSender sends the ListResourceUsage request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) ListResourceUsageSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client, req)
|
||
}
|
||
|
||
// ListResourceUsageResponder handles the response to the ListResourceUsage request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) ListResourceUsageResponder(resp *http.Response) (result ResourceUsageListResult, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// ListResourceUsageNextResults retrieves the next set of results, if any.
|
||
func (client EndpointsClient) ListResourceUsageNextResults(lastResults ResourceUsageListResult) (result ResourceUsageListResult, err error) {
|
||
req, err := lastResults.ResourceUsageListResultPreparer()
|
||
if err != nil {
|
||
return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing next results request")
|
||
}
|
||
if req == nil {
|
||
return
|
||
}
|
||
|
||
resp, err := client.ListResourceUsageSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending next results request")
|
||
}
|
||
|
||
result, err = client.ListResourceUsageResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure responding to next results request")
|
||
}
|
||
|
||
return
|
||
}
|
||
|
||
// ListResourceUsageComplete gets all elements from the list without paging.
|
||
func (client EndpointsClient) ListResourceUsageComplete(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan ResourceUsage, <-chan error) {
|
||
resultChan := make(chan ResourceUsage)
|
||
errChan := make(chan error, 1)
|
||
go func() {
|
||
defer func() {
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
list, err := client.ListResourceUsage(resourceGroupName, profileName, endpointName)
|
||
if err != nil {
|
||
errChan <- err
|
||
return
|
||
}
|
||
if list.Value != nil {
|
||
for _, item := range *list.Value {
|
||
select {
|
||
case <-cancel:
|
||
return
|
||
case resultChan <- item:
|
||
// Intentionally left blank
|
||
}
|
||
}
|
||
}
|
||
for list.NextLink != nil {
|
||
list, err = client.ListResourceUsageNextResults(list)
|
||
if err != nil {
|
||
errChan <- err
|
||
return
|
||
}
|
||
if list.Value != nil {
|
||
for _, item := range *list.Value {
|
||
select {
|
||
case <-cancel:
|
||
return
|
||
case resultChan <- item:
|
||
// Intentionally left blank
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// LoadContent pre-loads a content to CDN. Available for Verizon Profiles. This method may poll for completion. Polling
|
||
// can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any
|
||
// outstanding HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally. contentFilePaths is the path to the content to be loaded. Path should be a full URL, e.g.
|
||
// ‘/pictires/city.png' which loads a single file
|
||
func (client EndpointsClient) LoadContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
||
resultChan := make(chan autorest.Response, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
|
||
{TargetValue: contentFilePaths,
|
||
Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "LoadContent")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result autorest.Response
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.LoadContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.LoadContentSender(req)
|
||
if err != nil {
|
||
result.Response = resp
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.LoadContentResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// LoadContentPreparer prepares the LoadContent request.
|
||
func (client EndpointsClient) LoadContentPreparer(resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsJSON(),
|
||
autorest.AsPost(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load", pathParameters),
|
||
autorest.WithJSON(contentFilePaths),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// LoadContentSender sends the LoadContent request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) LoadContentSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// LoadContentResponder handles the response to the LoadContent request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) LoadContentResponder(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
|
||
}
|
||
|
||
// PurgeContent removes a content from CDN. This method may poll for completion. Polling can be canceled by passing the
|
||
// cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally. contentFilePaths is the path to the content to be purged. Path can be a full URL, e.g.
|
||
// '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes
|
||
// all folders and files in the directory.
|
||
func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
||
resultChan := make(chan autorest.Response, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
|
||
{TargetValue: contentFilePaths,
|
||
Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "PurgeContent")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result autorest.Response
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.PurgeContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.PurgeContentSender(req)
|
||
if err != nil {
|
||
result.Response = resp
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.PurgeContentResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// PurgeContentPreparer prepares the PurgeContent request.
|
||
func (client EndpointsClient) PurgeContentPreparer(resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsJSON(),
|
||
autorest.AsPost(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge", pathParameters),
|
||
autorest.WithJSON(contentFilePaths),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// PurgeContentSender sends the PurgeContent request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) PurgeContentSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// PurgeContentResponder handles the response to the PurgeContent request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) PurgeContentResponder(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
|
||
}
|
||
|
||
// Start starts an existing CDN endpoint that is on a stopped state. This method may poll for completion. Polling can
|
||
// be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding
|
||
// HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally.
|
||
func (client EndpointsClient) Start(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) {
|
||
resultChan := make(chan Endpoint, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Start")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result Endpoint
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.StartPreparer(resourceGroupName, profileName, endpointName, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.StartSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.StartResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// StartPreparer prepares the Start request.
|
||
func (client EndpointsClient) StartPreparer(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsPost(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start", pathParameters),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// StartSender sends the Start request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) StartSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// StartResponder handles the response to the Start request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) StartResponder(resp *http.Response) (result Endpoint, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// Stop stops an existing running CDN endpoint. This method may poll for completion. Polling can be canceled by passing
|
||
// the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally.
|
||
func (client EndpointsClient) Stop(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) {
|
||
resultChan := make(chan Endpoint, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Stop")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result Endpoint
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.StopPreparer(resourceGroupName, profileName, endpointName, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.StopSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.StopResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// StopPreparer prepares the Stop request.
|
||
func (client EndpointsClient) StopPreparer(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsPost(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop", pathParameters),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// StopSender sends the Stop request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) StopSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// StopResponder handles the response to the Stop request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) StopResponder(resp *http.Response) (result Endpoint, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// Update updates an existing CDN endpoint with the specified endpoint name under the specified subscription, resource
|
||
// group and profile. Only tags and Origin HostHeader can be updated after creating an endpoint. To update origins, use
|
||
// the Update Origin operation. To update custom domains, use the Update Custom Domain operation. This method may poll
|
||
// for completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel
|
||
// polling and any outstanding HTTP requests.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally. endpointUpdateProperties is endpoint update properties
|
||
func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) {
|
||
resultChan := make(chan Endpoint, 1)
|
||
errChan := make(chan error, 1)
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
|
||
errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Update")
|
||
close(errChan)
|
||
close(resultChan)
|
||
return resultChan, errChan
|
||
}
|
||
|
||
go func() {
|
||
var err error
|
||
var result Endpoint
|
||
defer func() {
|
||
if err != nil {
|
||
errChan <- err
|
||
}
|
||
resultChan <- result
|
||
close(resultChan)
|
||
close(errChan)
|
||
}()
|
||
req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, endpointUpdateProperties, cancel)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.UpdateSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.UpdateResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure responding to request")
|
||
}
|
||
}()
|
||
return resultChan, errChan
|
||
}
|
||
|
||
// UpdatePreparer prepares the Update request.
|
||
func (client EndpointsClient) UpdatePreparer(resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters, cancel <-chan struct{}) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsJSON(),
|
||
autorest.AsPatch(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
|
||
autorest.WithJSON(endpointUpdateProperties),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||
}
|
||
|
||
// UpdateSender sends the Update request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client,
|
||
req,
|
||
azure.DoPollForAsynchronous(client.PollingDelay))
|
||
}
|
||
|
||
// UpdateResponder handles the response to the Update request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) UpdateResponder(resp *http.Response) (result Endpoint, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|
||
|
||
// ValidateCustomDomain validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS.
|
||
//
|
||
// resourceGroupName is name of the Resource group within the Azure subscription. profileName is name of the CDN
|
||
// profile which is unique within the resource group. endpointName is name of the endpoint under the profile which is
|
||
// unique globally. customDomainProperties is custom domain to be validated.
|
||
func (client EndpointsClient) ValidateCustomDomain(resourceGroupName string, profileName string, endpointName string, customDomainProperties ValidateCustomDomainInput) (result ValidateCustomDomainOutput, err error) {
|
||
if err := validation.Validate([]validation.Validation{
|
||
{TargetValue: resourceGroupName,
|
||
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
|
||
{TargetValue: customDomainProperties,
|
||
Constraints: []validation.Constraint{{Target: "customDomainProperties.HostName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||
return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "ValidateCustomDomain")
|
||
}
|
||
|
||
req, err := client.ValidateCustomDomainPreparer(resourceGroupName, profileName, endpointName, customDomainProperties)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", nil, "Failure preparing request")
|
||
return
|
||
}
|
||
|
||
resp, err := client.ValidateCustomDomainSender(req)
|
||
if err != nil {
|
||
result.Response = autorest.Response{Response: resp}
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure sending request")
|
||
return
|
||
}
|
||
|
||
result, err = client.ValidateCustomDomainResponder(resp)
|
||
if err != nil {
|
||
err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure responding to request")
|
||
}
|
||
|
||
return
|
||
}
|
||
|
||
// ValidateCustomDomainPreparer prepares the ValidateCustomDomain request.
|
||
func (client EndpointsClient) ValidateCustomDomainPreparer(resourceGroupName string, profileName string, endpointName string, customDomainProperties ValidateCustomDomainInput) (*http.Request, error) {
|
||
pathParameters := map[string]interface{}{
|
||
"endpointName": autorest.Encode("path", endpointName),
|
||
"profileName": autorest.Encode("path", profileName),
|
||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
}
|
||
|
||
const APIVersion = "2017-04-02"
|
||
queryParameters := map[string]interface{}{
|
||
"api-version": APIVersion,
|
||
}
|
||
|
||
preparer := autorest.CreatePreparer(
|
||
autorest.AsJSON(),
|
||
autorest.AsPost(),
|
||
autorest.WithBaseURL(client.BaseURI),
|
||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/validateCustomDomain", pathParameters),
|
||
autorest.WithJSON(customDomainProperties),
|
||
autorest.WithQueryParameters(queryParameters))
|
||
return preparer.Prepare(&http.Request{})
|
||
}
|
||
|
||
// ValidateCustomDomainSender sends the ValidateCustomDomain request. The method will close the
|
||
// http.Response Body if it receives an error.
|
||
func (client EndpointsClient) ValidateCustomDomainSender(req *http.Request) (*http.Response, error) {
|
||
return autorest.SendWithSender(client, req)
|
||
}
|
||
|
||
// ValidateCustomDomainResponder handles the response to the ValidateCustomDomain request. The method always
|
||
// closes the http.Response Body.
|
||
func (client EndpointsClient) ValidateCustomDomainResponder(resp *http.Response) (result ValidateCustomDomainOutput, err error) {
|
||
err = autorest.Respond(
|
||
resp,
|
||
client.ByInspecting(),
|
||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
autorest.ByUnmarshallingJSON(&result),
|
||
autorest.ByClosing())
|
||
result.Response = autorest.Response{Response: resp}
|
||
return
|
||
}
|