// GetPreparer prepare the Get request. func (client VirtualMachineExtensionsClient) GetPreparer(resourceGroupName string, vmName string, vmExtensionName string, expand *string) (*http.Request, error) { pathParameters := map[string]interface{}{} pathParameters["resourceGroupName"] = url.QueryEscape(resourceGroupName) pathParameters["vmName"] = url.QueryEscape(vmName) pathParameters["vmExtensionName"] = url.QueryEscape(vmExtensionName) pathParameters["subscriptionId"] = client.GetSubscriptionId() queryParameters := map[string]interface{}{} queryParameters["api-version"] = client.GetApiVersion() if expand != nil { queryParameters["$expand"] = expand } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListForResourcePreparer prepares the ListForResource request. func (client PolicyAssignmentsClient) ListForResourcePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": url.QueryEscape(parentResourcePath), "resourceGroupName": url.QueryEscape(resourceGroupName), "resourceName": url.QueryEscape(resourceName), "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), "resourceType": url.QueryEscape(resourceType), "subscriptionId": url.QueryEscape(client.SubscriptionID), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = filter } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}providers/Microsoft.Authorization/policyAssignments"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListPreparer prepares the List request. func (client VirtualMachineScaleSetVMsClient) ListPreparer(resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": url.QueryEscape(resourceGroupName), "subscriptionId": url.QueryEscape(client.SubscriptionID), "virtualMachineScaleSetName": url.QueryEscape(virtualMachineScaleSetName), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = filter } if len(selectParameter) > 0 { queryParameters["$select"] = selectParameter } if len(expand) > 0 { queryParameters["$expand"] = expand } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListJobHistoryPreparer prepares the ListJobHistory request. func (client JobsClient) ListJobHistoryPreparer(resourceGroupName string, jobCollectionName string, jobName string, top *int32, skip *int32, filter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "jobCollectionName": url.QueryEscape(jobCollectionName), "jobName": url.QueryEscape(jobName), "resourceGroupName": url.QueryEscape(resourceGroupName), "subscriptionId": url.QueryEscape(client.SubscriptionID), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if top != nil { queryParameters["$top"] = top } if skip != nil { queryParameters["$skip"] = skip } if len(filter) > 0 { queryParameters["$filter"] = filter } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}/history"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
func getResourceGroups(client *autorest.Client) (*string, error) { var p map[string]interface{} var req *http.Request p = map[string]interface{}{ "subscription-id": subscriptionID, } q := map[string]interface{}{ "api-version": apiVersion, } req, _ = autorest.Prepare(&http.Request{}, autorest.AsGet(), autorest.WithBaseURL(resourceGroupURLTemplate), autorest.WithPathParameters(p), autorest.WithQueryParameters(q)) resp, err := client.Send(req, http.StatusOK) if err != nil { return nil, err } defer resp.Body.Close() contents, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } contentsString := string(contents) return &contentsString, nil }
// InitiateDeviceAuth initiates a device auth flow. It returns a DeviceCode // that can be used with CheckForUserCompletion or WaitForUserCompletion. func InitiateDeviceAuth(client *autorest.Client, oauthConfig OAuthConfig, clientID, resource string) (*DeviceCode, error) { req, _ := autorest.Prepare( &http.Request{}, autorest.AsPost(), autorest.AsFormURLEncoded(), autorest.WithBaseURL(oauthConfig.DeviceCodeEndpoint.String()), autorest.WithFormData(url.Values{ "client_id": []string{clientID}, "resource": []string{resource}, }), ) resp, err := client.Send(req) if err != nil { return nil, fmt.Errorf("%s %s: %s", logPrefix, errCodeSendingFails, err) } var code DeviceCode err = autorest.Respond( resp, autorest.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&code), autorest.ByClosing()) if err != nil { return nil, fmt.Errorf("%s %s: %s", logPrefix, errCodeHandlingFails, err) } code.ClientID = clientID code.Resource = resource code.OAuthConfig = oauthConfig return &code, nil }
// ListVersionsPreparer prepare the ListVersions request. func (client VirtualMachineExtensionImagesClient) ListVersionsPreparer(location string, publisherName string, typeParameter string, filter *string, top *int32, orderBy *string) (*http.Request, error) { pathParameters := map[string]interface{}{} pathParameters["location"] = url.QueryEscape(location) pathParameters["publisherName"] = url.QueryEscape(publisherName) pathParameters["type"] = url.QueryEscape(typeParameter) pathParameters["subscriptionId"] = client.GetSubscriptionId() queryParameters := map[string]interface{}{} queryParameters["api-version"] = client.GetApiVersion() if filter != nil { queryParameters["$filter"] = filter } if top != nil { queryParameters["$top"] = top } if orderBy != nil { queryParameters["$orderBy"] = orderBy } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListPreparer prepares the List request. func (client WorkflowRunActionsClient) ListPreparer(resourceGroupName string, workflowName string, runName string, top *int32, filter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": url.QueryEscape(resourceGroupName), "runName": url.QueryEscape(runName), "subscriptionId": url.QueryEscape(client.SubscriptionID), "workflowName": url.QueryEscape(workflowName), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if top != nil { queryParameters["$top"] = top } if len(filter) > 0 { queryParameters["$filter"] = filter } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/runs/{runName}/actions"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListPreparer prepares the List request. func (client VirtualMachineImagesClient) ListPreparer(location string, publisherName string, offer string, skus string, filter string, top *int, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ "location": url.QueryEscape(location), "offer": url.QueryEscape(offer), "publisherName": url.QueryEscape(publisherName), "skus": url.QueryEscape(skus), "subscriptionId": url.QueryEscape(client.SubscriptionID), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = filter } if top != nil { queryParameters["$top"] = top } if len(orderby) > 0 { queryParameters["$orderby"] = orderby } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListPreparer prepare the List request. func (client VirtualMachineScaleSetVMsClient) ListPreparer(resourceGroupName string, virtualMachineScaleSetName string, filter *string, selectParameter *string, expand *string) (*http.Request, error) { pathParameters := map[string]interface{}{} pathParameters["resourceGroupName"] = url.QueryEscape(resourceGroupName) pathParameters["virtualMachineScaleSetName"] = url.QueryEscape(virtualMachineScaleSetName) pathParameters["subscriptionId"] = client.GetSubscriptionId() queryParameters := map[string]interface{}{} queryParameters["api-version"] = client.GetApiVersion() if filter != nil { queryParameters["$filter"] = filter } if selectParameter != nil { queryParameters["$select"] = selectParameter } if expand != nil { queryParameters["$expand"] = expand } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// GetMAMUserFlaggedEnrolledAppsPreparer prepares the GetMAMUserFlaggedEnrolledApps request. func (client ManagementClient) GetMAMUserFlaggedEnrolledAppsPreparer(hostName string, userName string, filter string, top *int, selectParameter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "hostName": url.QueryEscape(hostName), "userName": url.QueryEscape(userName), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = filter } if top != nil { queryParameters["$top"] = top } if len(selectParameter) > 0 { queryParameters["$select"] = selectParameter } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers/{userName}/flaggedEnrolledApps"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// GetMAMPoliciesPreparer prepares the GetMAMPolicies request. func (client AndroidClient) GetMAMPoliciesPreparer(hostName string, filter string, top *int32, selectParameter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "hostName": url.QueryEscape(hostName), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = filter } if top != nil { queryParameters["$top"] = top } if len(selectParameter) > 0 { queryParameters["$select"] = selectParameter } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/providers/Microsoft.Intune/locations/{hostName}/androidPolicies"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
// ListAllPreparer prepares the ListAll request. func (client RecordSetsClient) ListAllPreparer(resourceGroupName string, zoneName string, top string, filter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": url.QueryEscape(resourceGroupName), "subscriptionId": url.QueryEscape(client.SubscriptionID), "zoneName": url.QueryEscape(zoneName), } queryParameters := map[string]interface{}{ "api-version": APIVersion, } if len(top) > 0 { queryParameters["$top"] = top } if len(filter) > 0 { queryParameters["$filter"] = filter } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnszones/{zoneName}/recordsets"), autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) }
func TestServicePrincipalTokenWithAuthorizationReturnsErrorIfCannotRefresh(t *testing.T) { spt := newServicePrincipalToken() _, err := autorest.Prepare(&http.Request{}, spt.WithAuthorization()) if err == nil { t.Fatal("azure: ServicePrincipalToken#WithAuthorization failed to return an error when refresh fails") } }
// NodeResourcesPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client NodeResources) NodeResourcesPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// EventHubConsumerGroupsListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client EventHubConsumerGroupsListResult) EventHubConsumerGroupsListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// ClassicAdministratorListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client ClassicAdministratorListResult) ClassicAdministratorListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// ProviderOperationsMetadataListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client ProviderOperationsMetadataListResult) ProviderOperationsMetadataListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// DataLakeStoreFirewallRuleListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client DataLakeStoreFirewallRuleListResult) DataLakeStoreFirewallRuleListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// VirtualMachineScaleSetVMListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist func (client VirtualMachineScaleSetVMListResult) VirtualMachineScaleSetVMListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// SharedAccessSignatureAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client SharedAccessSignatureAuthorizationRuleListResult) SharedAccessSignatureAuthorizationRuleListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// ResponseWithContinuationVirtualNetworkPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client ResponseWithContinuationVirtualNetwork) ResponseWithContinuationVirtualNetworkPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// ManagementLockListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client ManagementLockListResult) ManagementLockListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// WorkflowTriggerHistoryListResultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client WorkflowTriggerHistoryListResult) WorkflowTriggerHistoryListResultPreparer() (*http.Request, error) { if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.NextLink))) }
// StatusesDefaultPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client StatusesDefault) StatusesDefaultPreparer() (*http.Request, error) { if client.Nextlink == nil || len(to.String(client.Nextlink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.Nextlink))) }
// OperationResultCollectionPreparer prepares a request to retrieve the next set of results. It returns // nil if no more results exist. func (client OperationResultCollection) OperationResultCollectionPreparer() (*http.Request, error) { if client.Nextlink == nil || len(to.String(client.Nextlink)) <= 0 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), autorest.WithBaseURL(to.String(client.Nextlink))) }
func TestWithClientID(t *testing.T) { uuid := "71FDB9F4-5E49-4C12-B266-DE7B4FD999A6" req, _ := autorest.Prepare(&http.Request{}, WithClientID(uuid)) if req.Header.Get(HeaderClientID) != uuid { t.Fatalf("azure: WithClientID failed to set %s -- expected %s, received %s", HeaderClientID, uuid, req.Header.Get(HeaderClientID)) } }
func TestTokenWithAuthorization(t *testing.T) { tk := newToken() req, err := autorest.Prepare(&http.Request{}, tk.WithAuthorization()) if err != nil { t.Errorf("azure: Token WithAuthorization returned an error (%v)", err) } else if req.Header.Get(http.CanonicalHeaderKey("Authorization")) != fmt.Sprintf("Bearer %s", tk.AccessToken) { t.Error("azure: Token WithAuthorization failed to set Authorization header") } }
func TestWithReturnClientID(t *testing.T) { b := false req, _ := autorest.Prepare(&http.Request{}, WithReturnClientID(b)) if req.Header.Get(HeaderReturnClientID) != strconv.FormatBool(b) { t.Fatalf("azure: WithReturnClientID failed to set %s -- expected %s, received %s", HeaderClientID, strconv.FormatBool(b), req.Header.Get(HeaderClientID)) } }
func TestServicePrincipalTokenWithAuthorization(t *testing.T) { spt := newServicePrincipalToken() setTokenToExpireIn(&spt.Token, 1000*time.Second) req, err := autorest.Prepare(&http.Request{}, spt.WithAuthorization()) if err != nil { t.Fatalf("azure: ServicePrincipalToken#WithAuthorization returned an error (%v)", err) } else if req.Header.Get(http.CanonicalHeaderKey("Authorization")) != fmt.Sprintf("Bearer %s", spt.AccessToken) { t.Fatal("azure: ServicePrincipalToken#WithAuthorization failed to set Authorization header") } }