当前位置: 首页>>代码示例>>Golang>>正文


Golang autorest.NewErrorWithError函数代码示例

本文整理汇总了Golang中github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest.NewErrorWithError函数的典型用法代码示例。如果您正苦于以下问题:Golang NewErrorWithError函数的具体用法?Golang NewErrorWithError怎么用?Golang NewErrorWithError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewErrorWithError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Refresh

// Refresh obtains a fresh token for the Service Principal.
func (spt *ServicePrincipalToken) Refresh() error {
	p := map[string]interface{}{
		"tenantID":    spt.tenantID,
		"requestType": "token",
	}

	v := url.Values{}
	v.Set("client_id", spt.clientID)
	v.Set("grant_type", "client_credentials")
	v.Set("resource", spt.resource)

	err := spt.secret.SetAuthenticationValues(spt, &v)
	if err != nil {
		return err
	}

	req, err := autorest.Prepare(&http.Request{},
		autorest.AsPost(),
		autorest.AsFormURLEncoded(),
		autorest.WithBaseURL(oauthURL),
		autorest.WithPathParameters(p),
		autorest.WithFormData(v))
	if err != nil {
		return err
	}

	resp, err := autorest.SendWithSender(spt.sender, req)
	if err != nil {
		return autorest.NewErrorWithError(err,
			"azure.ServicePrincipalToken", "Refresh", resp.StatusCode, "Failure sending request for Service Principal %s",
			spt.clientID)
	}

	var newToken Token

	err = autorest.Respond(resp,
		autorest.WithErrorUnlessOK(),
		autorest.ByUnmarshallingJSON(&newToken),
		autorest.ByClosing())
	if err != nil {
		return autorest.NewErrorWithError(err,
			"azure.ServicePrincipalToken", "Refresh", resp.StatusCode, "Failure handling response to Service Principal %s request",
			spt.clientID)
	}

	spt.Token = newToken

	return nil
}
开发者ID:higebu,项目名称:terraform,代码行数:50,代码来源:token.go

示例2: List

// List the List ExpressRouteServiceProvider opertion retrieves all the
// available ExpressRouteServiceProviders.
func (client ExpressRouteServiceProvidersClient) List() (result ExpressRouteServiceProviderListResult, ae error) {
	req, err := client.ListPreparer()
	if err != nil {
		return result, autorest.NewErrorWithError(err, "network/ExpressRouteServiceProvidersClient", "List", "Failure preparing request")
	}

	resp, err := client.ListSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "network/ExpressRouteServiceProvidersClient", "List", "Failure sending request")
	}

	result, err = client.ListResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "network/ExpressRouteServiceProvidersClient", "List", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:21,代码来源:expressrouteserviceproviders.go

示例3: CreateOrUpdate

// CreateOrUpdate the Put VirtualNetwork operation creates/updates a virtual
// network in the specified resource group.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. parameters is parameters supplied to the
// create/update Virtual Network operation
func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork) (result VirtualNetwork, ae error) {
	req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "network/VirtualNetworksClient", "CreateOrUpdate", "Failure preparing request")
	}

	resp, err := client.CreateOrUpdateSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "network/VirtualNetworksClient", "CreateOrUpdate", "Failure sending request")
	}

	result, err = client.CreateOrUpdateResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "network/VirtualNetworksClient", "CreateOrUpdate", "Failure responding to request")
	}

	return
}
开发者ID:kbxkb,项目名称:azure-sdk-for-go,代码行数:25,代码来源:virtualnetworks.go

示例4: Get

// Get the Get VirtualNetwork operation retrieves information about the
// specified virtual network.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network.
func (client VirtualNetworksClient) Get(resourceGroupName string, virtualNetworkName string) (result VirtualNetwork, ae error) {
	req, err := client.GetPreparer(resourceGroupName, virtualNetworkName)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "network/VirtualNetworksClient", "Get", "Failure preparing request")
	}

	resp, err := client.GetSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "network/VirtualNetworksClient", "Get", "Failure sending request")
	}

	result, err = client.GetResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "network/VirtualNetworksClient", "Get", "Failure responding to request")
	}

	return
}
开发者ID:kbxkb,项目名称:azure-sdk-for-go,代码行数:24,代码来源:virtualnetworks.go

示例5: Validate

// Validate validates a workflow.
//
// resourceGroupName is the resource group name. workflowName is the workflow
// name. workflow is the workflow.
func (client WorkflowsClient) Validate(resourceGroupName string, workflowName string, workflow Workflow) (result autorest.Response, ae error) {
	req, err := client.ValidatePreparer(resourceGroupName, workflowName, workflow)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "logic/WorkflowsClient", "Validate", "Failure preparing request")
	}

	resp, err := client.ValidateSender(req)
	if err != nil {
		result.Response = resp
		return result, autorest.NewErrorWithError(err, "logic/WorkflowsClient", "Validate", "Failure sending request")
	}

	result, err = client.ValidateResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "logic/WorkflowsClient", "Validate", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:23,代码来源:workflows.go

示例6: ListBySubscription

// ListBySubscription gets a list of workflows by subscription.
//
// top is the number of items to be included in the result. filter is the
// filter to apply on the operation.
func (client WorkflowsClient) ListBySubscription(top *int, filter string) (result WorkflowListResult, ae error) {
	req, err := client.ListBySubscriptionPreparer(top, filter)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "logic/WorkflowsClient", "ListBySubscription", "Failure preparing request")
	}

	resp, err := client.ListBySubscriptionSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "logic/WorkflowsClient", "ListBySubscription", "Failure sending request")
	}

	result, err = client.ListBySubscriptionResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "logic/WorkflowsClient", "ListBySubscription", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:23,代码来源:workflows.go

示例7: CreateOrUpdate

// CreateOrUpdate creates a RecordSet within a DNS zone.
//
// resourceGroupName is the name of the resource group. zoneName is the name
// of the zone without a terminating dot. recordType is the type of DNS
// record. Possible values for this parameter include: 'A', 'AAAA', 'CNAME',
// 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' relativeRecordSetName is the name
// of the RecordSet, relative to the name of the zone. parameters is
// parameters supplied to the CreateOrUpdate operation. ifMatch is the etag
// of RecordSet. ifNoneMatch is defines the If-None-Match condition. Set to
// '*' to force Create-If-Not-Exist. Other values will be ignored.
func (client RecordSetsClient) CreateOrUpdate(resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string, parameters RecordSetCreateOrUpdateParameters, ifMatch string, ifNoneMatch string) (result RecordSet, ae error) {
	req, err := client.CreateOrUpdatePreparer(resourceGroupName, zoneName, recordType, relativeRecordSetName, parameters, ifMatch, ifNoneMatch)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "dns/RecordSetsClient", "CreateOrUpdate", autorest.UndefinedStatusCode, "Failure preparing request")
	}

	resp, err := client.CreateOrUpdateSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "dns/RecordSetsClient", "CreateOrUpdate", resp.StatusCode, "Failure sending request")
	}

	result, err = client.CreateOrUpdateResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "dns/RecordSetsClient", "CreateOrUpdate", resp.StatusCode, "Failure responding to request")
	}

	return
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:29,代码来源:recordsets.go

示例8: Get

// Get gets a RecordSet.
//
// resourceGroupName is the name of the resource group. zoneName is the name
// of the zone without a terminating dot. recordType is the type of DNS
// record. Possible values for this parameter include: 'A', 'AAAA', 'CNAME',
// 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' relativeRecordSetName is the name
// of the RecordSet, relative to the name of the zone.
func (client RecordSetsClient) Get(resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string) (result RecordSet, ae error) {
	req, err := client.GetPreparer(resourceGroupName, zoneName, recordType, relativeRecordSetName)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "dns/RecordSetsClient", "Get", autorest.UndefinedStatusCode, "Failure preparing request")
	}

	resp, err := client.GetSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "dns/RecordSetsClient", "Get", resp.StatusCode, "Failure sending request")
	}

	result, err = client.GetResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "dns/RecordSetsClient", "Get", resp.StatusCode, "Failure responding to request")
	}

	return
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:26,代码来源:recordsets.go

示例9: List

// List lists compute usages for a subscription.
//
// location is the location upon which resource usage is queried.
func (client UsageOperationsClient) List(location string) (result ListUsagesResult, ae error) {
	req, err := client.ListPreparer(location)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "compute/UsageOperationsClient", "List", "Failure preparing request")
	}

	resp, err := client.ListSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "compute/UsageOperationsClient", "List", "Failure sending request")
	}

	result, err = client.ListResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "compute/UsageOperationsClient", "List", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:22,代码来源:usageoperations.go

示例10: List

// List returns the primary and secondary API keys for the given Azure Search
// service.
//
// resourceGroupName is the name of the resource group within the current
// subscription. serviceName is the name of the Search service for which to
// list admin keys.
func (client AdminKeysClient) List(resourceGroupName string, serviceName string) (result AdminKeyResult, ae error) {
	req, err := client.ListPreparer(resourceGroupName, serviceName)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "search/AdminKeysClient", "List", "Failure preparing request")
	}

	resp, err := client.ListSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "search/AdminKeysClient", "List", "Failure sending request")
	}

	result, err = client.ListResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "search/AdminKeysClient", "List", "Failure responding to request")
	}

	return
}
开发者ID:kbxkb,项目名称:azure-sdk-for-go,代码行数:25,代码来源:adminkeys.go

示例11: List

// List gets a list of resource providers.
//
// resourceProviderNamespace is resource identity.
func (client ProviderOperationDetailsClient) List(resourceProviderNamespace string, apiVersion string) (result ResourceProviderOperationDetailListResult, ae error) {
	req, err := client.ListPreparer(resourceProviderNamespace, apiVersion)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "resources/ProviderOperationDetailsClient", "List", autorest.UndefinedStatusCode, "Failure preparing request")
	}

	resp, err := client.ListSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "resources/ProviderOperationDetailsClient", "List", resp.StatusCode, "Failure sending request")
	}

	result, err = client.ListResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "resources/ProviderOperationDetailsClient", "List", resp.StatusCode, "Failure responding to request")
	}

	return
}
开发者ID:higebu,项目名称:terraform,代码行数:22,代码来源:provideroperationdetails.go

示例12: CheckExistence

// CheckExistence checks whether resource exists.
//
// 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 ManagementClient) CheckExistence(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result autorest.Response, ae error) {
	req, err := client.CheckExistencePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "CheckExistence", "Failure preparing request")
	}

	resp, err := client.CheckExistenceSender(req)
	if err != nil {
		result.Response = resp
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "CheckExistence", "Failure sending request")
	}

	result, err = client.CheckExistenceResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "resources/ManagementClient", "CheckExistence", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:25,代码来源:client.go

示例13: MoveResources

// MoveResources begin moving resources.To determine whether the operation has
// finished processing the request, call GetLongRunningOperationStatus.
//
// sourceResourceGroupName is source resource group name. parameters is move
// resources' parameters.
func (client ManagementClient) MoveResources(sourceResourceGroupName string, parameters MoveInfo) (result autorest.Response, ae error) {
	req, err := client.MoveResourcesPreparer(sourceResourceGroupName, parameters)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "MoveResources", "Failure preparing request")
	}

	resp, err := client.MoveResourcesSender(req)
	if err != nil {
		result.Response = resp
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "MoveResources", "Failure sending request")
	}

	result, err = client.MoveResourcesResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "resources/ManagementClient", "MoveResources", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:24,代码来源:client.go

示例14: List

// List get all of the resources under a subscription.
//
// filter is the filter to apply on the operation. top is query parameters. If
// null is passed returns all resource groups.
func (client ManagementClient) List(filter string, top *int) (result ResourceListResult, ae error) {
	req, err := client.ListPreparer(filter, top)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "List", "Failure preparing request")
	}

	resp, err := client.ListSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "List", "Failure sending request")
	}

	result, err = client.ListResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "resources/ManagementClient", "List", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:23,代码来源:client.go

示例15: Get

// Get returns a resource belonging to a resource group.
//
// 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 ManagementClient) Get(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result GenericResource, ae error) {
	req, err := client.GetPreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion)
	if err != nil {
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "Get", "Failure preparing request")
	}

	resp, err := client.GetSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "resources/ManagementClient", "Get", "Failure sending request")
	}

	result, err = client.GetResponder(resp)
	if err != nil {
		ae = autorest.NewErrorWithError(err, "resources/ManagementClient", "Get", "Failure responding to request")
	}

	return
}
开发者ID:axier,项目名称:azure-sdk-for-go,代码行数:25,代码来源:client.go


注:本文中的github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest.NewErrorWithError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。