本文整理汇总了Golang中github.com/Azure/go-autorest/autorest.DoErrorUnlessStatusCode函数的典型用法代码示例。如果您正苦于以下问题:Golang DoErrorUnlessStatusCode函数的具体用法?Golang DoErrorUnlessStatusCode怎么用?Golang DoErrorUnlessStatusCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DoErrorUnlessStatusCode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateOrUpdate
// CreateOrUpdate create a resource group.
//
// resourceGroupName is the name of the resource group to be created or
// updated. parameters is parameters supplied to the create or update
// resource group service operation.
func (client ResourceGroupsClient) CreateOrUpdate(resourceGroupName string, parameters ResourceGroup) (result ResourceGroup, ae autorest.Error) {
req, err := client.NewCreateOrUpdateRequest(resourceGroupName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourceGroupsClient", "CreateOrUpdate", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourceGroupsClient", "CreateOrUpdate", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusCreated, http.StatusOK, http.StatusAccepted))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "resources.ResourceGroupsClient", "CreateOrUpdate", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "resources.ResourceGroupsClient", "CreateOrUpdate", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例2: Capture
// Capture captures the VM by copying VirtualHardDisks of the VM and outputs a
// template that can be used to create similar VMs.
//
// resourceGroupName is the name of the resource group. vmName is the name of
// the virtual machine. parameters is parameters supplied to the Capture
// Virtual Machine operation.
func (client VirtualMachinesClient) Capture(resourceGroupName string, vmName string, parameters VirtualMachineCaptureParameters) (result ComputeLongRunningOperationResult, ae autorest.Error) {
req, err := client.NewCaptureRequest(resourceGroupName, vmName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例3: Start
// Start the operation to start a virtual machine.
//
// resourceGroupName is the name of the resource group. vmName is the name of
// the virtual machine.
func (client VirtualMachinesClient) Start(resourceGroupName string, vmName string) (result autorest.Response, ae autorest.Error) {
req, err := client.NewStartRequest(resourceGroupName, vmName)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusAccepted))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK())
if err != nil {
ae = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = resp
return
}
示例4: DeleteAtSubscriptionLevel
// DeleteAtSubscriptionLevel deletes the management lock of a subscription.
//
// lockName is the name of lock.
func (client ManagementLocksClient) DeleteAtSubscriptionLevel(lockName string) (result autorest.Response, ae autorest.Error) {
req, err := client.NewDeleteAtSubscriptionLevelRequest(lockName)
if err != nil {
return result, autorest.NewErrorWithError(err, "authorization.ManagementLocksClient", "DeleteAtSubscriptionLevel", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "authorization.ManagementLocksClient", "DeleteAtSubscriptionLevel", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK, http.StatusAccepted))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK())
if err != nil {
ae = autorest.NewErrorWithError(err, "authorization.ManagementLocksClient", "DeleteAtSubscriptionLevel", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "authorization.ManagementLocksClient", "DeleteAtSubscriptionLevel", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = resp
return
}
示例5: MoveResources
// MoveResources move resources within or across subscriptions.
//
// sourceResourceGroupName is source resource group name. parameters is move
// resources' parameters.
func (client ResourcesClient) MoveResources(sourceResourceGroupName string, parameters ResourcesMoveInfo) (result autorest.Response, ae autorest.Error) {
req, err := client.NewMoveResourcesRequest(sourceResourceGroupName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourcesClient", "MoveResources", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourcesClient", "MoveResources", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusAccepted))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK())
if err != nil {
ae = autorest.NewErrorWithError(err, "resources.ResourcesClient", "MoveResources", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "resources.ResourcesClient", "MoveResources", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = resp
return
}
示例6: Delete
// Delete the Delete LocalNetworkGateway operation deletes the specifed local
// network Gateway through Network resource provider.
//
// resourceGroupName is the name of the resource group.
// localNetworkGatewayName is the name of the local network gateway.
func (client LocalNetworkGatewaysClient) Delete(resourceGroupName string, localNetworkGatewayName string) (result autorest.Response, ae autorest.Error) {
req, err := client.NewDeleteRequest(resourceGroupName, localNetworkGatewayName)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK())
if err != nil {
ae = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = resp
return
}
示例7: Delete
// Delete delete resource and all of its resources.
//
// resourceGroupName is the name of the resource group. The name is case
// insensitive. resourceProviderNamespace is resource identity.
// parentResourcePath is resource identity. resourceType is resource
// identity. resourceName is resource identity.
func (client ResourcesClient) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result autorest.Response, ae autorest.Error) {
req, err := client.NewDeleteRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion)
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourcesClient", "Delete", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourcesClient", "Delete", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted))
if err == nil {
err = client.IsPollingAllowed(resp)
if err == nil {
resp, err = client.PollAsNeeded(resp)
}
}
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK())
if err != nil {
ae = autorest.NewErrorWithError(err, "resources.ResourcesClient", "Delete", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "resources.ResourcesClient", "Delete", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = resp
return
}
示例8: Get
// Get get a deployment.
//
// resourceGroupName is the name of the resource group to get. The name is
// case insensitive. deploymentName is the name of the deployment.
func (client DeploymentsClient) Get(resourceGroupName string, deploymentName string) (result DeploymentExtended, ae autorest.Error) {
req, err := client.NewGetRequest(resourceGroupName, deploymentName)
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例9: CreateOrUpdate
// CreateOrUpdate provisions a new job collection or updates an existing job
// collection.
//
// resourceGroupName is the resource group name. jobCollectionName is the job
// collection name. jobCollection is the job collection definition.
func (client JobCollectionsClient) CreateOrUpdate(resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition) (result JobCollectionDefinition, ae autorest.Error) {
req, err := client.NewCreateOrUpdateRequest(resourceGroupName, jobCollectionName, jobCollection)
if err != nil {
return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK, http.StatusCreated))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例10: Get
// Get gets details about particular subscription.
//
// subscriptionId is id of the subscription.
func (client SubscriptionsClient) Get(subscriptionId string) (result Subscription, ae autorest.Error) {
req, err := client.NewGetRequest(subscriptionId)
if err != nil {
return result, autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例11: ListAll
// ListAll gets a list of previewed features for all the providers in the
// current subscription.
func (client FeaturesClient) ListAll() (result FeatureOperationsListResult, ae autorest.Error) {
req, err := client.NewListAllRequest()
if err != nil {
return result, autorest.NewErrorWithError(err, "features.FeaturesClient", "ListAll", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "features.FeaturesClient", "ListAll", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "features.FeaturesClient", "ListAll", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "features.FeaturesClient", "ListAll", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例12: CheckNameAvailability
// CheckNameAvailability checks that account name is valid and is not in use.
//
// accountName is the name of the storage account within the specified
// resource group. Storage account names must be between 3 and 24 characters
// in length and use numbers and lower-case letters only.
func (client StorageAccountsClient) CheckNameAvailability(accountName StorageAccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, ae autorest.Error) {
req, err := client.NewCheckNameAvailabilityRequest(accountName)
if err != nil {
return result, autorest.NewErrorWithError(err, "storage.StorageAccountsClient", "CheckNameAvailability", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "storage.StorageAccountsClient", "CheckNameAvailability", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "storage.StorageAccountsClient", "CheckNameAvailability", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "storage.StorageAccountsClient", "CheckNameAvailability", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例13: CreateOrUpdate
// CreateOrUpdate the operation to create or update the extension.
//
// resourceGroupName is the name of the resource group. vmName is the name of
// the virtual machine where the extension should be create or updated.
// vmExtensionName is the name of the virtual machine extension.
// extensionParameters is parameters supplied to the Create Virtual Machine
// Extension operation.
func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension) (result VirtualMachineExtension, ae autorest.Error) {
req, err := client.NewCreateOrUpdateRequest(resourceGroupName, vmName, vmExtensionName, extensionParameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusCreated, http.StatusOK))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例14: Register
// Register registers for a previewed feature of a resource provider.
//
// resourceProviderNamespace is namespace of the resource provider.
// featureName is previewed feature name in the resource provider.
func (client FeaturesClient) Register(resourceProviderNamespace string, featureName string) (result FeatureResult, ae autorest.Error) {
req, err := client.NewRegisterRequest(resourceProviderNamespace, featureName)
if err != nil {
return result, autorest.NewErrorWithError(err, "features.FeaturesClient", "Register", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "features.FeaturesClient", "Register", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "features.FeaturesClient", "Register", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "features.FeaturesClient", "Register", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
示例15: List
// List gets a list of resource providers.
//
// resourceProviderNamespace is resource identity.
func (client ResourceProviderOperationDetailsClient) List(resourceProviderNamespace string, apiVersion string) (result ResourceProviderOperationDetailListResult, ae autorest.Error) {
req, err := client.NewListRequest(resourceProviderNamespace, apiVersion)
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourceProviderOperationDetailsClient", "List", "Failure creating request")
}
req, err = autorest.Prepare(
req,
client.WithAuthorization(),
client.WithInspection())
if err != nil {
return result, autorest.NewErrorWithError(err, "resources.ResourceProviderOperationDetailsClient", "List", "Failure preparing request")
}
resp, err := autorest.SendWithSender(
client,
req,
autorest.DoErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent))
if err == nil {
err = autorest.Respond(
resp,
client.ByInspecting(),
autorest.WithErrorUnlessOK(),
autorest.ByUnmarshallingJSON(&result))
if err != nil {
ae = autorest.NewErrorWithError(err, "resources.ResourceProviderOperationDetailsClient", "List", "Failure responding to request")
}
} else {
ae = autorest.NewErrorWithError(err, "resources.ResourceProviderOperationDetailsClient", "List", "Failure sending request")
}
autorest.Respond(resp,
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}