2017-10-01 08:13:39 +00:00
|
|
|
// Package cdn implements the Azure ARM Cdn service API version 2017-04-02.
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// 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.
|
2017-08-05 18:30:20 +00:00
|
|
|
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.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
2017-08-05 18:30:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Azure/go-autorest/autorest"
|
|
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
|
|
"github.com/Azure/go-autorest/autorest/validation"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// DefaultBaseURI is the default URI used for the service Cdn
|
|
|
|
DefaultBaseURI = "https://management.azure.com"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ManagementClient is the base client for Cdn.
|
|
|
|
type ManagementClient struct {
|
|
|
|
autorest.Client
|
|
|
|
BaseURI string
|
|
|
|
SubscriptionID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// New creates an instance of the ManagementClient client.
|
|
|
|
func New(subscriptionID string) ManagementClient {
|
|
|
|
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewWithBaseURI creates an instance of the ManagementClient client.
|
|
|
|
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
|
|
|
|
return ManagementClient{
|
|
|
|
Client: autorest.NewClientWithUserAgent(UserAgent()),
|
|
|
|
BaseURI: baseURI,
|
|
|
|
SubscriptionID: subscriptionID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// CheckNameAvailability check the availability of a resource name. This is needed for resources where name is globally
|
|
|
|
// unique, such as a CDN endpoint.
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
|
|
|
// checkNameAvailabilityInput is input to check.
|
|
|
|
func (client ManagementClient) CheckNameAvailability(checkNameAvailabilityInput CheckNameAvailabilityInput) (result CheckNameAvailabilityOutput, err error) {
|
|
|
|
if err := validation.Validate([]validation.Validation{
|
|
|
|
{TargetValue: checkNameAvailabilityInput,
|
|
|
|
Constraints: []validation.Constraint{{Target: "checkNameAvailabilityInput.Name", Name: validation.Null, Rule: true, Chain: nil},
|
|
|
|
{Target: "checkNameAvailabilityInput.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
|
|
return result, validation.NewErrorWithValidationError(err, "cdn.ManagementClient", "CheckNameAvailability")
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := client.CheckNameAvailabilityPreparer(checkNameAvailabilityInput)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.CheckNameAvailabilitySender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.CheckNameAvailabilityResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request.
|
|
|
|
func (client ManagementClient) CheckNameAvailabilityPreparer(checkNameAvailabilityInput CheckNameAvailabilityInput) (*http.Request, error) {
|
2017-10-01 08:13:39 +00:00
|
|
|
const APIVersion = "2017-04-02"
|
2017-08-05 18:30:20 +00:00
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsJSON(),
|
|
|
|
autorest.AsPost(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPath("/providers/Microsoft.Cdn/checkNameAvailability"),
|
|
|
|
autorest.WithJSON(checkNameAvailabilityInput),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client ManagementClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
|
|
|
|
return autorest.SendWithSender(client, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client ManagementClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityOutput, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ValidateProbe check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file
|
|
|
|
// hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is
|
|
|
|
// relative to the origin path specified in the endpoint configuration.
|
|
|
|
//
|
|
|
|
// validateProbeInput is input to check.
|
|
|
|
func (client ManagementClient) ValidateProbe(validateProbeInput ValidateProbeInput) (result ValidateProbeOutput, err error) {
|
|
|
|
if err := validation.Validate([]validation.Validation{
|
|
|
|
{TargetValue: validateProbeInput,
|
|
|
|
Constraints: []validation.Constraint{{Target: "validateProbeInput.ProbeURL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
|
|
return result, validation.NewErrorWithValidationError(err, "cdn.ManagementClient", "ValidateProbe")
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
req, err := client.ValidateProbePreparer(validateProbeInput)
|
2017-08-05 18:30:20 +00:00
|
|
|
if err != nil {
|
2017-10-01 08:13:39 +00:00
|
|
|
err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ValidateProbe", nil, "Failure preparing request")
|
2017-08-05 18:30:20 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
resp, err := client.ValidateProbeSender(req)
|
2017-08-05 18:30:20 +00:00
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
2017-10-01 08:13:39 +00:00
|
|
|
err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ValidateProbe", resp, "Failure sending request")
|
2017-08-05 18:30:20 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
result, err = client.ValidateProbeResponder(resp)
|
2017-08-05 18:30:20 +00:00
|
|
|
if err != nil {
|
2017-10-01 08:13:39 +00:00
|
|
|
err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ValidateProbe", resp, "Failure responding to request")
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ValidateProbePreparer prepares the ValidateProbe request.
|
|
|
|
func (client ManagementClient) ValidateProbePreparer(validateProbeInput ValidateProbeInput) (*http.Request, error) {
|
2017-08-05 18:30:20 +00:00
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
const APIVersion = "2017-04-02"
|
2017-08-05 18:30:20 +00:00
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
2017-10-01 08:13:39 +00:00
|
|
|
autorest.AsJSON(),
|
2017-08-05 18:30:20 +00:00
|
|
|
autorest.AsPost(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
2017-10-01 08:13:39 +00:00
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe", pathParameters),
|
|
|
|
autorest.WithJSON(validateProbeInput),
|
2017-08-05 18:30:20 +00:00
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ValidateProbeSender sends the ValidateProbe request. The method will close the
|
2017-08-05 18:30:20 +00:00
|
|
|
// http.Response Body if it receives an error.
|
2017-10-01 08:13:39 +00:00
|
|
|
func (client ManagementClient) ValidateProbeSender(req *http.Request) (*http.Response, error) {
|
2017-08-05 18:30:20 +00:00
|
|
|
return autorest.SendWithSender(client, req)
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ValidateProbeResponder handles the response to the ValidateProbe request. The method always
|
2017-08-05 18:30:20 +00:00
|
|
|
// closes the http.Response Body.
|
2017-10-01 08:13:39 +00:00
|
|
|
func (client ManagementClient) ValidateProbeResponder(resp *http.Response) (result ValidateProbeOutput, err error) {
|
2017-08-05 18:30:20 +00:00
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|