946c8399e2
Exclude minio-go for now (pin to 3.x.y).
228 lines
8.5 KiB
Go
228 lines
8.5 KiB
Go
package trafficmanager
|
|
|
|
// 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"
|
|
"net/http"
|
|
)
|
|
|
|
// UserMetricsKeysClient is the client for the UserMetricsKeys methods of the Trafficmanager service.
|
|
type UserMetricsKeysClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewUserMetricsKeysClient creates an instance of the UserMetricsKeysClient client.
|
|
func NewUserMetricsKeysClient(subscriptionID string) UserMetricsKeysClient {
|
|
return NewUserMetricsKeysClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
}
|
|
|
|
// NewUserMetricsKeysClientWithBaseURI creates an instance of the UserMetricsKeysClient client.
|
|
func NewUserMetricsKeysClientWithBaseURI(baseURI string, subscriptionID string) UserMetricsKeysClient {
|
|
return UserMetricsKeysClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
}
|
|
|
|
// CreateOrUpdate create or update a subscription-level key used for Realtime User Metrics collection.
|
|
func (client UserMetricsKeysClient) CreateOrUpdate() (result UserMetricsKeyModel, err error) {
|
|
req, err := client.CreateOrUpdatePreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "CreateOrUpdate", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.CreateOrUpdateSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "CreateOrUpdate", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateOrUpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "CreateOrUpdate", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
|
func (client UserMetricsKeysClient) CreateOrUpdatePreparer() (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-09-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPut(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client UserMetricsKeysClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
|
// closes the http.Response Body.
|
|
func (client UserMetricsKeysClient) CreateOrUpdateResponder(resp *http.Response) (result UserMetricsKeyModel, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// Delete delete a subscription-level key used for Realtime User Metrics collection.
|
|
func (client UserMetricsKeysClient) Delete() (result DeleteOperationResult, err error) {
|
|
req, err := client.DeletePreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client UserMetricsKeysClient) DeletePreparer() (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-09-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsDelete(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// DeleteSender sends the Delete request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client UserMetricsKeysClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// DeleteResponder handles the response to the Delete request. The method always
|
|
// closes the http.Response Body.
|
|
func (client UserMetricsKeysClient) DeleteResponder(resp *http.Response) (result DeleteOperationResult, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// GetDefault get the subscription-level key used for Realtime User Metrics collection.
|
|
func (client UserMetricsKeysClient) GetDefault() (result UserMetricsKeyModel, err error) {
|
|
req, err := client.GetDefaultPreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "GetDefault", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetDefaultSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "GetDefault", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetDefaultResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "trafficmanager.UserMetricsKeysClient", "GetDefault", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetDefaultPreparer prepares the GetDefault request.
|
|
func (client UserMetricsKeysClient) GetDefaultPreparer() (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-09-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetDefaultSender sends the GetDefault request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client UserMetricsKeysClient) GetDefaultSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// GetDefaultResponder handles the response to the GetDefault request. The method always
|
|
// closes the http.Response Body.
|
|
func (client UserMetricsKeysClient) GetDefaultResponder(resp *http.Response) (result UserMetricsKeyModel, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|