1package customerinsights 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// ImagesClient is the the Azure Customer Insights management API provides a RESTful set of web services that interact 18// with Azure Customer Insights service to manage your resources. The API has entities that capture the relationship 19// between an end user and the Azure Customer Insights service. 20type ImagesClient struct { 21 BaseClient 22} 23 24// NewImagesClient creates an instance of the ImagesClient client. 25func NewImagesClient(subscriptionID string) ImagesClient { 26 return NewImagesClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewImagesClientWithBaseURI creates an instance of the ImagesClient client using a custom endpoint. Use this when 30// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewImagesClientWithBaseURI(baseURI string, subscriptionID string) ImagesClient { 32 return ImagesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// GetUploadURLForData gets data image upload URL. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// hubName - the name of the hub. 39// parameters - parameters supplied to the GetUploadUrlForData operation. 40func (client ImagesClient) GetUploadURLForData(ctx context.Context, resourceGroupName string, hubName string, parameters GetImageUploadURLInput) (result ImageDefinition, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.GetUploadURLForData") 43 defer func() { 44 sc := -1 45 if result.Response.Response != nil { 46 sc = result.Response.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 req, err := client.GetUploadURLForDataPreparer(ctx, resourceGroupName, hubName, parameters) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", nil, "Failure preparing request") 54 return 55 } 56 57 resp, err := client.GetUploadURLForDataSender(req) 58 if err != nil { 59 result.Response = autorest.Response{Response: resp} 60 err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", resp, "Failure sending request") 61 return 62 } 63 64 result, err = client.GetUploadURLForDataResponder(resp) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", resp, "Failure responding to request") 67 return 68 } 69 70 return 71} 72 73// GetUploadURLForDataPreparer prepares the GetUploadURLForData request. 74func (client ImagesClient) GetUploadURLForDataPreparer(ctx context.Context, resourceGroupName string, hubName string, parameters GetImageUploadURLInput) (*http.Request, error) { 75 pathParameters := map[string]interface{}{ 76 "hubName": autorest.Encode("path", hubName), 77 "resourceGroupName": autorest.Encode("path", resourceGroupName), 78 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 79 } 80 81 const APIVersion = "2017-04-26" 82 queryParameters := map[string]interface{}{ 83 "api-version": APIVersion, 84 } 85 86 preparer := autorest.CreatePreparer( 87 autorest.AsContentType("application/json; charset=utf-8"), 88 autorest.AsPost(), 89 autorest.WithBaseURL(client.BaseURI), 90 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/images/getDataImageUploadUrl", pathParameters), 91 autorest.WithJSON(parameters), 92 autorest.WithQueryParameters(queryParameters)) 93 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 94} 95 96// GetUploadURLForDataSender sends the GetUploadURLForData request. The method will close the 97// http.Response Body if it receives an error. 98func (client ImagesClient) GetUploadURLForDataSender(req *http.Request) (*http.Response, error) { 99 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 100} 101 102// GetUploadURLForDataResponder handles the response to the GetUploadURLForData request. The method always 103// closes the http.Response Body. 104func (client ImagesClient) GetUploadURLForDataResponder(resp *http.Response) (result ImageDefinition, err error) { 105 err = autorest.Respond( 106 resp, 107 azure.WithErrorUnlessStatusCode(http.StatusOK), 108 autorest.ByUnmarshallingJSON(&result), 109 autorest.ByClosing()) 110 result.Response = autorest.Response{Response: resp} 111 return 112} 113 114// GetUploadURLForEntityType gets entity type (profile or interaction) image upload URL. 115// Parameters: 116// resourceGroupName - the name of the resource group. 117// hubName - the name of the hub. 118// parameters - parameters supplied to the GetUploadUrlForEntityType operation. 119func (client ImagesClient) GetUploadURLForEntityType(ctx context.Context, resourceGroupName string, hubName string, parameters GetImageUploadURLInput) (result ImageDefinition, err error) { 120 if tracing.IsEnabled() { 121 ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.GetUploadURLForEntityType") 122 defer func() { 123 sc := -1 124 if result.Response.Response != nil { 125 sc = result.Response.Response.StatusCode 126 } 127 tracing.EndSpan(ctx, sc, err) 128 }() 129 } 130 req, err := client.GetUploadURLForEntityTypePreparer(ctx, resourceGroupName, hubName, parameters) 131 if err != nil { 132 err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", nil, "Failure preparing request") 133 return 134 } 135 136 resp, err := client.GetUploadURLForEntityTypeSender(req) 137 if err != nil { 138 result.Response = autorest.Response{Response: resp} 139 err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", resp, "Failure sending request") 140 return 141 } 142 143 result, err = client.GetUploadURLForEntityTypeResponder(resp) 144 if err != nil { 145 err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", resp, "Failure responding to request") 146 return 147 } 148 149 return 150} 151 152// GetUploadURLForEntityTypePreparer prepares the GetUploadURLForEntityType request. 153func (client ImagesClient) GetUploadURLForEntityTypePreparer(ctx context.Context, resourceGroupName string, hubName string, parameters GetImageUploadURLInput) (*http.Request, error) { 154 pathParameters := map[string]interface{}{ 155 "hubName": autorest.Encode("path", hubName), 156 "resourceGroupName": autorest.Encode("path", resourceGroupName), 157 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 158 } 159 160 const APIVersion = "2017-04-26" 161 queryParameters := map[string]interface{}{ 162 "api-version": APIVersion, 163 } 164 165 preparer := autorest.CreatePreparer( 166 autorest.AsContentType("application/json; charset=utf-8"), 167 autorest.AsPost(), 168 autorest.WithBaseURL(client.BaseURI), 169 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/images/getEntityTypeImageUploadUrl", pathParameters), 170 autorest.WithJSON(parameters), 171 autorest.WithQueryParameters(queryParameters)) 172 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 173} 174 175// GetUploadURLForEntityTypeSender sends the GetUploadURLForEntityType request. The method will close the 176// http.Response Body if it receives an error. 177func (client ImagesClient) GetUploadURLForEntityTypeSender(req *http.Request) (*http.Response, error) { 178 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 179} 180 181// GetUploadURLForEntityTypeResponder handles the response to the GetUploadURLForEntityType request. The method always 182// closes the http.Response Body. 183func (client ImagesClient) GetUploadURLForEntityTypeResponder(resp *http.Response) (result ImageDefinition, err error) { 184 err = autorest.Respond( 185 resp, 186 azure.WithErrorUnlessStatusCode(http.StatusOK), 187 autorest.ByUnmarshallingJSON(&result), 188 autorest.ByClosing()) 189 result.Response = autorest.Response{Response: resp} 190 return 191} 192