1package cdn
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/autorest/validation"
14	"github.com/Azure/go-autorest/tracing"
15	"net/http"
16)
17
18// EndpointsClient is the cdn Management Client
19type EndpointsClient struct {
20	BaseClient
21}
22
23// NewEndpointsClient creates an instance of the EndpointsClient client.
24func NewEndpointsClient(subscriptionID string) EndpointsClient {
25	return NewEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewEndpointsClientWithBaseURI creates an instance of the EndpointsClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient {
31	return EndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// Create creates a new CDN endpoint with the specified endpoint name under the specified subscription, resource group
35// and profile.
36// Parameters:
37// resourceGroupName - name of the Resource group within the Azure subscription.
38// profileName - name of the CDN profile which is unique within the resource group.
39// endpointName - name of the endpoint under the profile which is unique globally.
40// endpoint - endpoint properties
41func (client EndpointsClient) Create(ctx context.Context, resourceGroupName string, profileName string, endpointName string, endpoint Endpoint) (result EndpointsCreateFuture, err error) {
42	if tracing.IsEnabled() {
43		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Create")
44		defer func() {
45			sc := -1
46			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
47				sc = result.FutureAPI.Response().StatusCode
48			}
49			tracing.EndSpan(ctx, sc, err)
50		}()
51	}
52	if err := validation.Validate([]validation.Validation{
53		{TargetValue: resourceGroupName,
54			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
55				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
56				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
57		{TargetValue: endpoint,
58			Constraints: []validation.Constraint{{Target: "endpoint.EndpointProperties", Name: validation.Null, Rule: false,
59				Chain: []validation.Constraint{{Target: "endpoint.EndpointProperties.Origins", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
60		return result, validation.NewError("cdn.EndpointsClient", "Create", err.Error())
61	}
62
63	req, err := client.CreatePreparer(ctx, resourceGroupName, profileName, endpointName, endpoint)
64	if err != nil {
65		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure preparing request")
66		return
67	}
68
69	result, err = client.CreateSender(req)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure sending request")
72		return
73	}
74
75	return
76}
77
78// CreatePreparer prepares the Create request.
79func (client EndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string, endpoint Endpoint) (*http.Request, error) {
80	pathParameters := map[string]interface{}{
81		"endpointName":      autorest.Encode("path", endpointName),
82		"profileName":       autorest.Encode("path", profileName),
83		"resourceGroupName": autorest.Encode("path", resourceGroupName),
84		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
85	}
86
87	const APIVersion = "2019-04-15"
88	queryParameters := map[string]interface{}{
89		"api-version": APIVersion,
90	}
91
92	preparer := autorest.CreatePreparer(
93		autorest.AsContentType("application/json; charset=utf-8"),
94		autorest.AsPut(),
95		autorest.WithBaseURL(client.BaseURI),
96		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
97		autorest.WithJSON(endpoint),
98		autorest.WithQueryParameters(queryParameters))
99	return preparer.Prepare((&http.Request{}).WithContext(ctx))
100}
101
102// CreateSender sends the Create request. The method will close the
103// http.Response Body if it receives an error.
104func (client EndpointsClient) CreateSender(req *http.Request) (future EndpointsCreateFuture, err error) {
105	var resp *http.Response
106	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
107	if err != nil {
108		return
109	}
110	var azf azure.Future
111	azf, err = azure.NewFutureFromResponse(resp)
112	future.FutureAPI = &azf
113	future.Result = future.result
114	return
115}
116
117// CreateResponder handles the response to the Create request. The method always
118// closes the http.Response Body.
119func (client EndpointsClient) CreateResponder(resp *http.Response) (result Endpoint, err error) {
120	err = autorest.Respond(
121		resp,
122		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
123		autorest.ByUnmarshallingJSON(&result),
124		autorest.ByClosing())
125	result.Response = autorest.Response{Response: resp}
126	return
127}
128
129// Delete deletes an existing CDN endpoint with the specified endpoint name under the specified subscription, resource
130// group and profile.
131// Parameters:
132// resourceGroupName - name of the Resource group within the Azure subscription.
133// profileName - name of the CDN profile which is unique within the resource group.
134// endpointName - name of the endpoint under the profile which is unique globally.
135func (client EndpointsClient) Delete(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result EndpointsDeleteFuture, err error) {
136	if tracing.IsEnabled() {
137		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Delete")
138		defer func() {
139			sc := -1
140			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
141				sc = result.FutureAPI.Response().StatusCode
142			}
143			tracing.EndSpan(ctx, sc, err)
144		}()
145	}
146	if err := validation.Validate([]validation.Validation{
147		{TargetValue: resourceGroupName,
148			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
149				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
150				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
151		return result, validation.NewError("cdn.EndpointsClient", "Delete", err.Error())
152	}
153
154	req, err := client.DeletePreparer(ctx, resourceGroupName, profileName, endpointName)
155	if err != nil {
156		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure preparing request")
157		return
158	}
159
160	result, err = client.DeleteSender(req)
161	if err != nil {
162		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure sending request")
163		return
164	}
165
166	return
167}
168
169// DeletePreparer prepares the Delete request.
170func (client EndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
171	pathParameters := map[string]interface{}{
172		"endpointName":      autorest.Encode("path", endpointName),
173		"profileName":       autorest.Encode("path", profileName),
174		"resourceGroupName": autorest.Encode("path", resourceGroupName),
175		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
176	}
177
178	const APIVersion = "2019-04-15"
179	queryParameters := map[string]interface{}{
180		"api-version": APIVersion,
181	}
182
183	preparer := autorest.CreatePreparer(
184		autorest.AsDelete(),
185		autorest.WithBaseURL(client.BaseURI),
186		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
187		autorest.WithQueryParameters(queryParameters))
188	return preparer.Prepare((&http.Request{}).WithContext(ctx))
189}
190
191// DeleteSender sends the Delete request. The method will close the
192// http.Response Body if it receives an error.
193func (client EndpointsClient) DeleteSender(req *http.Request) (future EndpointsDeleteFuture, err error) {
194	var resp *http.Response
195	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
196	if err != nil {
197		return
198	}
199	var azf azure.Future
200	azf, err = azure.NewFutureFromResponse(resp)
201	future.FutureAPI = &azf
202	future.Result = future.result
203	return
204}
205
206// DeleteResponder handles the response to the Delete request. The method always
207// closes the http.Response Body.
208func (client EndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
209	err = autorest.Respond(
210		resp,
211		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
212		autorest.ByClosing())
213	result.Response = resp
214	return
215}
216
217// Get gets an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group
218// and profile.
219// Parameters:
220// resourceGroupName - name of the Resource group within the Azure subscription.
221// profileName - name of the CDN profile which is unique within the resource group.
222// endpointName - name of the endpoint under the profile which is unique globally.
223func (client EndpointsClient) Get(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result Endpoint, err error) {
224	if tracing.IsEnabled() {
225		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Get")
226		defer func() {
227			sc := -1
228			if result.Response.Response != nil {
229				sc = result.Response.Response.StatusCode
230			}
231			tracing.EndSpan(ctx, sc, err)
232		}()
233	}
234	if err := validation.Validate([]validation.Validation{
235		{TargetValue: resourceGroupName,
236			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
237				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
238				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
239		return result, validation.NewError("cdn.EndpointsClient", "Get", err.Error())
240	}
241
242	req, err := client.GetPreparer(ctx, resourceGroupName, profileName, endpointName)
243	if err != nil {
244		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", nil, "Failure preparing request")
245		return
246	}
247
248	resp, err := client.GetSender(req)
249	if err != nil {
250		result.Response = autorest.Response{Response: resp}
251		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure sending request")
252		return
253	}
254
255	result, err = client.GetResponder(resp)
256	if err != nil {
257		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure responding to request")
258		return
259	}
260
261	return
262}
263
264// GetPreparer prepares the Get request.
265func (client EndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
266	pathParameters := map[string]interface{}{
267		"endpointName":      autorest.Encode("path", endpointName),
268		"profileName":       autorest.Encode("path", profileName),
269		"resourceGroupName": autorest.Encode("path", resourceGroupName),
270		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
271	}
272
273	const APIVersion = "2019-04-15"
274	queryParameters := map[string]interface{}{
275		"api-version": APIVersion,
276	}
277
278	preparer := autorest.CreatePreparer(
279		autorest.AsGet(),
280		autorest.WithBaseURL(client.BaseURI),
281		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
282		autorest.WithQueryParameters(queryParameters))
283	return preparer.Prepare((&http.Request{}).WithContext(ctx))
284}
285
286// GetSender sends the Get request. The method will close the
287// http.Response Body if it receives an error.
288func (client EndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
289	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
290}
291
292// GetResponder handles the response to the Get request. The method always
293// closes the http.Response Body.
294func (client EndpointsClient) GetResponder(resp *http.Response) (result Endpoint, err error) {
295	err = autorest.Respond(
296		resp,
297		azure.WithErrorUnlessStatusCode(http.StatusOK),
298		autorest.ByUnmarshallingJSON(&result),
299		autorest.ByClosing())
300	result.Response = autorest.Response{Response: resp}
301	return
302}
303
304// ListByProfile lists existing CDN endpoints.
305// Parameters:
306// resourceGroupName - name of the Resource group within the Azure subscription.
307// profileName - name of the CDN profile which is unique within the resource group.
308func (client EndpointsClient) ListByProfile(ctx context.Context, resourceGroupName string, profileName string) (result EndpointListResultPage, err error) {
309	if tracing.IsEnabled() {
310		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.ListByProfile")
311		defer func() {
312			sc := -1
313			if result.elr.Response.Response != nil {
314				sc = result.elr.Response.Response.StatusCode
315			}
316			tracing.EndSpan(ctx, sc, err)
317		}()
318	}
319	if err := validation.Validate([]validation.Validation{
320		{TargetValue: resourceGroupName,
321			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
322				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
323				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
324		return result, validation.NewError("cdn.EndpointsClient", "ListByProfile", err.Error())
325	}
326
327	result.fn = client.listByProfileNextResults
328	req, err := client.ListByProfilePreparer(ctx, resourceGroupName, profileName)
329	if err != nil {
330		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing request")
331		return
332	}
333
334	resp, err := client.ListByProfileSender(req)
335	if err != nil {
336		result.elr.Response = autorest.Response{Response: resp}
337		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending request")
338		return
339	}
340
341	result.elr, err = client.ListByProfileResponder(resp)
342	if err != nil {
343		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure responding to request")
344		return
345	}
346	if result.elr.hasNextLink() && result.elr.IsEmpty() {
347		err = result.NextWithContext(ctx)
348		return
349	}
350
351	return
352}
353
354// ListByProfilePreparer prepares the ListByProfile request.
355func (client EndpointsClient) ListByProfilePreparer(ctx context.Context, resourceGroupName string, profileName string) (*http.Request, error) {
356	pathParameters := map[string]interface{}{
357		"profileName":       autorest.Encode("path", profileName),
358		"resourceGroupName": autorest.Encode("path", resourceGroupName),
359		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
360	}
361
362	const APIVersion = "2019-04-15"
363	queryParameters := map[string]interface{}{
364		"api-version": APIVersion,
365	}
366
367	preparer := autorest.CreatePreparer(
368		autorest.AsGet(),
369		autorest.WithBaseURL(client.BaseURI),
370		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints", pathParameters),
371		autorest.WithQueryParameters(queryParameters))
372	return preparer.Prepare((&http.Request{}).WithContext(ctx))
373}
374
375// ListByProfileSender sends the ListByProfile request. The method will close the
376// http.Response Body if it receives an error.
377func (client EndpointsClient) ListByProfileSender(req *http.Request) (*http.Response, error) {
378	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
379}
380
381// ListByProfileResponder handles the response to the ListByProfile request. The method always
382// closes the http.Response Body.
383func (client EndpointsClient) ListByProfileResponder(resp *http.Response) (result EndpointListResult, err error) {
384	err = autorest.Respond(
385		resp,
386		azure.WithErrorUnlessStatusCode(http.StatusOK),
387		autorest.ByUnmarshallingJSON(&result),
388		autorest.ByClosing())
389	result.Response = autorest.Response{Response: resp}
390	return
391}
392
393// listByProfileNextResults retrieves the next set of results, if any.
394func (client EndpointsClient) listByProfileNextResults(ctx context.Context, lastResults EndpointListResult) (result EndpointListResult, err error) {
395	req, err := lastResults.endpointListResultPreparer(ctx)
396	if err != nil {
397		return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "listByProfileNextResults", nil, "Failure preparing next results request")
398	}
399	if req == nil {
400		return
401	}
402	resp, err := client.ListByProfileSender(req)
403	if err != nil {
404		result.Response = autorest.Response{Response: resp}
405		return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "listByProfileNextResults", resp, "Failure sending next results request")
406	}
407	result, err = client.ListByProfileResponder(resp)
408	if err != nil {
409		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "listByProfileNextResults", resp, "Failure responding to next results request")
410	}
411	return
412}
413
414// ListByProfileComplete enumerates all values, automatically crossing page boundaries as required.
415func (client EndpointsClient) ListByProfileComplete(ctx context.Context, resourceGroupName string, profileName string) (result EndpointListResultIterator, err error) {
416	if tracing.IsEnabled() {
417		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.ListByProfile")
418		defer func() {
419			sc := -1
420			if result.Response().Response.Response != nil {
421				sc = result.page.Response().Response.Response.StatusCode
422			}
423			tracing.EndSpan(ctx, sc, err)
424		}()
425	}
426	result.page, err = client.ListByProfile(ctx, resourceGroupName, profileName)
427	return
428}
429
430// ListResourceUsage checks the quota and usage of geo filters and custom domains under the given endpoint.
431// Parameters:
432// resourceGroupName - name of the Resource group within the Azure subscription.
433// profileName - name of the CDN profile which is unique within the resource group.
434// endpointName - name of the endpoint under the profile which is unique globally.
435func (client EndpointsClient) ListResourceUsage(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result ResourceUsageListResultPage, err error) {
436	if tracing.IsEnabled() {
437		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.ListResourceUsage")
438		defer func() {
439			sc := -1
440			if result.rulr.Response.Response != nil {
441				sc = result.rulr.Response.Response.StatusCode
442			}
443			tracing.EndSpan(ctx, sc, err)
444		}()
445	}
446	if err := validation.Validate([]validation.Validation{
447		{TargetValue: resourceGroupName,
448			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
449				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
450				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
451		return result, validation.NewError("cdn.EndpointsClient", "ListResourceUsage", err.Error())
452	}
453
454	result.fn = client.listResourceUsageNextResults
455	req, err := client.ListResourceUsagePreparer(ctx, resourceGroupName, profileName, endpointName)
456	if err != nil {
457		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing request")
458		return
459	}
460
461	resp, err := client.ListResourceUsageSender(req)
462	if err != nil {
463		result.rulr.Response = autorest.Response{Response: resp}
464		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending request")
465		return
466	}
467
468	result.rulr, err = client.ListResourceUsageResponder(resp)
469	if err != nil {
470		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure responding to request")
471		return
472	}
473	if result.rulr.hasNextLink() && result.rulr.IsEmpty() {
474		err = result.NextWithContext(ctx)
475		return
476	}
477
478	return
479}
480
481// ListResourceUsagePreparer prepares the ListResourceUsage request.
482func (client EndpointsClient) ListResourceUsagePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
483	pathParameters := map[string]interface{}{
484		"endpointName":      autorest.Encode("path", endpointName),
485		"profileName":       autorest.Encode("path", profileName),
486		"resourceGroupName": autorest.Encode("path", resourceGroupName),
487		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
488	}
489
490	const APIVersion = "2019-04-15"
491	queryParameters := map[string]interface{}{
492		"api-version": APIVersion,
493	}
494
495	preparer := autorest.CreatePreparer(
496		autorest.AsPost(),
497		autorest.WithBaseURL(client.BaseURI),
498		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/checkResourceUsage", pathParameters),
499		autorest.WithQueryParameters(queryParameters))
500	return preparer.Prepare((&http.Request{}).WithContext(ctx))
501}
502
503// ListResourceUsageSender sends the ListResourceUsage request. The method will close the
504// http.Response Body if it receives an error.
505func (client EndpointsClient) ListResourceUsageSender(req *http.Request) (*http.Response, error) {
506	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
507}
508
509// ListResourceUsageResponder handles the response to the ListResourceUsage request. The method always
510// closes the http.Response Body.
511func (client EndpointsClient) ListResourceUsageResponder(resp *http.Response) (result ResourceUsageListResult, err error) {
512	err = autorest.Respond(
513		resp,
514		azure.WithErrorUnlessStatusCode(http.StatusOK),
515		autorest.ByUnmarshallingJSON(&result),
516		autorest.ByClosing())
517	result.Response = autorest.Response{Response: resp}
518	return
519}
520
521// listResourceUsageNextResults retrieves the next set of results, if any.
522func (client EndpointsClient) listResourceUsageNextResults(ctx context.Context, lastResults ResourceUsageListResult) (result ResourceUsageListResult, err error) {
523	req, err := lastResults.resourceUsageListResultPreparer(ctx)
524	if err != nil {
525		return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "listResourceUsageNextResults", nil, "Failure preparing next results request")
526	}
527	if req == nil {
528		return
529	}
530	resp, err := client.ListResourceUsageSender(req)
531	if err != nil {
532		result.Response = autorest.Response{Response: resp}
533		return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "listResourceUsageNextResults", resp, "Failure sending next results request")
534	}
535	result, err = client.ListResourceUsageResponder(resp)
536	if err != nil {
537		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "listResourceUsageNextResults", resp, "Failure responding to next results request")
538	}
539	return
540}
541
542// ListResourceUsageComplete enumerates all values, automatically crossing page boundaries as required.
543func (client EndpointsClient) ListResourceUsageComplete(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result ResourceUsageListResultIterator, err error) {
544	if tracing.IsEnabled() {
545		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.ListResourceUsage")
546		defer func() {
547			sc := -1
548			if result.Response().Response.Response != nil {
549				sc = result.page.Response().Response.Response.StatusCode
550			}
551			tracing.EndSpan(ctx, sc, err)
552		}()
553	}
554	result.page, err = client.ListResourceUsage(ctx, resourceGroupName, profileName, endpointName)
555	return
556}
557
558// LoadContent pre-loads a content to CDN. Available for Verizon Profiles.
559// Parameters:
560// resourceGroupName - name of the Resource group within the Azure subscription.
561// profileName - name of the CDN profile which is unique within the resource group.
562// endpointName - name of the endpoint under the profile which is unique globally.
563// contentFilePaths - the path to the content to be loaded. Path should be a full URL, e.g.
564// ‘/pictures/city.png' which loads a single file
565func (client EndpointsClient) LoadContent(ctx context.Context, resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters) (result EndpointsLoadContentFuture, err error) {
566	if tracing.IsEnabled() {
567		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.LoadContent")
568		defer func() {
569			sc := -1
570			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
571				sc = result.FutureAPI.Response().StatusCode
572			}
573			tracing.EndSpan(ctx, sc, err)
574		}()
575	}
576	if err := validation.Validate([]validation.Validation{
577		{TargetValue: resourceGroupName,
578			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
579				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
580				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
581		{TargetValue: contentFilePaths,
582			Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
583		return result, validation.NewError("cdn.EndpointsClient", "LoadContent", err.Error())
584	}
585
586	req, err := client.LoadContentPreparer(ctx, resourceGroupName, profileName, endpointName, contentFilePaths)
587	if err != nil {
588		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure preparing request")
589		return
590	}
591
592	result, err = client.LoadContentSender(req)
593	if err != nil {
594		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure sending request")
595		return
596	}
597
598	return
599}
600
601// LoadContentPreparer prepares the LoadContent request.
602func (client EndpointsClient) LoadContentPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters) (*http.Request, error) {
603	pathParameters := map[string]interface{}{
604		"endpointName":      autorest.Encode("path", endpointName),
605		"profileName":       autorest.Encode("path", profileName),
606		"resourceGroupName": autorest.Encode("path", resourceGroupName),
607		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
608	}
609
610	const APIVersion = "2019-04-15"
611	queryParameters := map[string]interface{}{
612		"api-version": APIVersion,
613	}
614
615	preparer := autorest.CreatePreparer(
616		autorest.AsContentType("application/json; charset=utf-8"),
617		autorest.AsPost(),
618		autorest.WithBaseURL(client.BaseURI),
619		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load", pathParameters),
620		autorest.WithJSON(contentFilePaths),
621		autorest.WithQueryParameters(queryParameters))
622	return preparer.Prepare((&http.Request{}).WithContext(ctx))
623}
624
625// LoadContentSender sends the LoadContent request. The method will close the
626// http.Response Body if it receives an error.
627func (client EndpointsClient) LoadContentSender(req *http.Request) (future EndpointsLoadContentFuture, err error) {
628	var resp *http.Response
629	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
630	if err != nil {
631		return
632	}
633	var azf azure.Future
634	azf, err = azure.NewFutureFromResponse(resp)
635	future.FutureAPI = &azf
636	future.Result = future.result
637	return
638}
639
640// LoadContentResponder handles the response to the LoadContent request. The method always
641// closes the http.Response Body.
642func (client EndpointsClient) LoadContentResponder(resp *http.Response) (result autorest.Response, err error) {
643	err = autorest.Respond(
644		resp,
645		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
646		autorest.ByClosing())
647	result.Response = resp
648	return
649}
650
651// PurgeContent removes a content from CDN.
652// Parameters:
653// resourceGroupName - name of the Resource group within the Azure subscription.
654// profileName - name of the CDN profile which is unique within the resource group.
655// endpointName - name of the endpoint under the profile which is unique globally.
656// contentFilePaths - the path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png'
657// which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders
658// and files in the directory.
659func (client EndpointsClient) PurgeContent(ctx context.Context, resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters) (result EndpointsPurgeContentFuture, err error) {
660	if tracing.IsEnabled() {
661		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.PurgeContent")
662		defer func() {
663			sc := -1
664			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
665				sc = result.FutureAPI.Response().StatusCode
666			}
667			tracing.EndSpan(ctx, sc, err)
668		}()
669	}
670	if err := validation.Validate([]validation.Validation{
671		{TargetValue: resourceGroupName,
672			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
673				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
674				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
675		{TargetValue: contentFilePaths,
676			Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
677		return result, validation.NewError("cdn.EndpointsClient", "PurgeContent", err.Error())
678	}
679
680	req, err := client.PurgeContentPreparer(ctx, resourceGroupName, profileName, endpointName, contentFilePaths)
681	if err != nil {
682		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure preparing request")
683		return
684	}
685
686	result, err = client.PurgeContentSender(req)
687	if err != nil {
688		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure sending request")
689		return
690	}
691
692	return
693}
694
695// PurgeContentPreparer prepares the PurgeContent request.
696func (client EndpointsClient) PurgeContentPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters) (*http.Request, error) {
697	pathParameters := map[string]interface{}{
698		"endpointName":      autorest.Encode("path", endpointName),
699		"profileName":       autorest.Encode("path", profileName),
700		"resourceGroupName": autorest.Encode("path", resourceGroupName),
701		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
702	}
703
704	const APIVersion = "2019-04-15"
705	queryParameters := map[string]interface{}{
706		"api-version": APIVersion,
707	}
708
709	preparer := autorest.CreatePreparer(
710		autorest.AsContentType("application/json; charset=utf-8"),
711		autorest.AsPost(),
712		autorest.WithBaseURL(client.BaseURI),
713		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge", pathParameters),
714		autorest.WithJSON(contentFilePaths),
715		autorest.WithQueryParameters(queryParameters))
716	return preparer.Prepare((&http.Request{}).WithContext(ctx))
717}
718
719// PurgeContentSender sends the PurgeContent request. The method will close the
720// http.Response Body if it receives an error.
721func (client EndpointsClient) PurgeContentSender(req *http.Request) (future EndpointsPurgeContentFuture, err error) {
722	var resp *http.Response
723	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
724	if err != nil {
725		return
726	}
727	var azf azure.Future
728	azf, err = azure.NewFutureFromResponse(resp)
729	future.FutureAPI = &azf
730	future.Result = future.result
731	return
732}
733
734// PurgeContentResponder handles the response to the PurgeContent request. The method always
735// closes the http.Response Body.
736func (client EndpointsClient) PurgeContentResponder(resp *http.Response) (result autorest.Response, err error) {
737	err = autorest.Respond(
738		resp,
739		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
740		autorest.ByClosing())
741	result.Response = resp
742	return
743}
744
745// Start starts an existing CDN endpoint that is on a stopped state.
746// Parameters:
747// resourceGroupName - name of the Resource group within the Azure subscription.
748// profileName - name of the CDN profile which is unique within the resource group.
749// endpointName - name of the endpoint under the profile which is unique globally.
750func (client EndpointsClient) Start(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result EndpointsStartFuture, err error) {
751	if tracing.IsEnabled() {
752		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Start")
753		defer func() {
754			sc := -1
755			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
756				sc = result.FutureAPI.Response().StatusCode
757			}
758			tracing.EndSpan(ctx, sc, err)
759		}()
760	}
761	if err := validation.Validate([]validation.Validation{
762		{TargetValue: resourceGroupName,
763			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
764				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
765				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
766		return result, validation.NewError("cdn.EndpointsClient", "Start", err.Error())
767	}
768
769	req, err := client.StartPreparer(ctx, resourceGroupName, profileName, endpointName)
770	if err != nil {
771		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure preparing request")
772		return
773	}
774
775	result, err = client.StartSender(req)
776	if err != nil {
777		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure sending request")
778		return
779	}
780
781	return
782}
783
784// StartPreparer prepares the Start request.
785func (client EndpointsClient) StartPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
786	pathParameters := map[string]interface{}{
787		"endpointName":      autorest.Encode("path", endpointName),
788		"profileName":       autorest.Encode("path", profileName),
789		"resourceGroupName": autorest.Encode("path", resourceGroupName),
790		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
791	}
792
793	const APIVersion = "2019-04-15"
794	queryParameters := map[string]interface{}{
795		"api-version": APIVersion,
796	}
797
798	preparer := autorest.CreatePreparer(
799		autorest.AsPost(),
800		autorest.WithBaseURL(client.BaseURI),
801		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start", pathParameters),
802		autorest.WithQueryParameters(queryParameters))
803	return preparer.Prepare((&http.Request{}).WithContext(ctx))
804}
805
806// StartSender sends the Start request. The method will close the
807// http.Response Body if it receives an error.
808func (client EndpointsClient) StartSender(req *http.Request) (future EndpointsStartFuture, err error) {
809	var resp *http.Response
810	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
811	if err != nil {
812		return
813	}
814	var azf azure.Future
815	azf, err = azure.NewFutureFromResponse(resp)
816	future.FutureAPI = &azf
817	future.Result = future.result
818	return
819}
820
821// StartResponder handles the response to the Start request. The method always
822// closes the http.Response Body.
823func (client EndpointsClient) StartResponder(resp *http.Response) (result Endpoint, err error) {
824	err = autorest.Respond(
825		resp,
826		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
827		autorest.ByUnmarshallingJSON(&result),
828		autorest.ByClosing())
829	result.Response = autorest.Response{Response: resp}
830	return
831}
832
833// Stop stops an existing running CDN endpoint.
834// Parameters:
835// resourceGroupName - name of the Resource group within the Azure subscription.
836// profileName - name of the CDN profile which is unique within the resource group.
837// endpointName - name of the endpoint under the profile which is unique globally.
838func (client EndpointsClient) Stop(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result EndpointsStopFuture, err error) {
839	if tracing.IsEnabled() {
840		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Stop")
841		defer func() {
842			sc := -1
843			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
844				sc = result.FutureAPI.Response().StatusCode
845			}
846			tracing.EndSpan(ctx, sc, err)
847		}()
848	}
849	if err := validation.Validate([]validation.Validation{
850		{TargetValue: resourceGroupName,
851			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
852				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
853				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
854		return result, validation.NewError("cdn.EndpointsClient", "Stop", err.Error())
855	}
856
857	req, err := client.StopPreparer(ctx, resourceGroupName, profileName, endpointName)
858	if err != nil {
859		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure preparing request")
860		return
861	}
862
863	result, err = client.StopSender(req)
864	if err != nil {
865		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure sending request")
866		return
867	}
868
869	return
870}
871
872// StopPreparer prepares the Stop request.
873func (client EndpointsClient) StopPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (*http.Request, error) {
874	pathParameters := map[string]interface{}{
875		"endpointName":      autorest.Encode("path", endpointName),
876		"profileName":       autorest.Encode("path", profileName),
877		"resourceGroupName": autorest.Encode("path", resourceGroupName),
878		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
879	}
880
881	const APIVersion = "2019-04-15"
882	queryParameters := map[string]interface{}{
883		"api-version": APIVersion,
884	}
885
886	preparer := autorest.CreatePreparer(
887		autorest.AsPost(),
888		autorest.WithBaseURL(client.BaseURI),
889		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop", pathParameters),
890		autorest.WithQueryParameters(queryParameters))
891	return preparer.Prepare((&http.Request{}).WithContext(ctx))
892}
893
894// StopSender sends the Stop request. The method will close the
895// http.Response Body if it receives an error.
896func (client EndpointsClient) StopSender(req *http.Request) (future EndpointsStopFuture, err error) {
897	var resp *http.Response
898	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
899	if err != nil {
900		return
901	}
902	var azf azure.Future
903	azf, err = azure.NewFutureFromResponse(resp)
904	future.FutureAPI = &azf
905	future.Result = future.result
906	return
907}
908
909// StopResponder handles the response to the Stop request. The method always
910// closes the http.Response Body.
911func (client EndpointsClient) StopResponder(resp *http.Response) (result Endpoint, err error) {
912	err = autorest.Respond(
913		resp,
914		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
915		autorest.ByUnmarshallingJSON(&result),
916		autorest.ByClosing())
917	result.Response = autorest.Response{Response: resp}
918	return
919}
920
921// Update updates an existing CDN endpoint with the specified endpoint name under the specified subscription, resource
922// group and profile. Only tags and Origin HostHeader can be updated after creating an endpoint. To update origins, use
923// the Update Origin operation. To update custom domains, use the Update Custom Domain operation.
924// Parameters:
925// resourceGroupName - name of the Resource group within the Azure subscription.
926// profileName - name of the CDN profile which is unique within the resource group.
927// endpointName - name of the endpoint under the profile which is unique globally.
928// endpointUpdateProperties - endpoint update properties
929func (client EndpointsClient) Update(ctx context.Context, resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters) (result EndpointsUpdateFuture, err error) {
930	if tracing.IsEnabled() {
931		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Update")
932		defer func() {
933			sc := -1
934			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
935				sc = result.FutureAPI.Response().StatusCode
936			}
937			tracing.EndSpan(ctx, sc, err)
938		}()
939	}
940	if err := validation.Validate([]validation.Validation{
941		{TargetValue: resourceGroupName,
942			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
943				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
944				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
945		return result, validation.NewError("cdn.EndpointsClient", "Update", err.Error())
946	}
947
948	req, err := client.UpdatePreparer(ctx, resourceGroupName, profileName, endpointName, endpointUpdateProperties)
949	if err != nil {
950		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure preparing request")
951		return
952	}
953
954	result, err = client.UpdateSender(req)
955	if err != nil {
956		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure sending request")
957		return
958	}
959
960	return
961}
962
963// UpdatePreparer prepares the Update request.
964func (client EndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters) (*http.Request, error) {
965	pathParameters := map[string]interface{}{
966		"endpointName":      autorest.Encode("path", endpointName),
967		"profileName":       autorest.Encode("path", profileName),
968		"resourceGroupName": autorest.Encode("path", resourceGroupName),
969		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
970	}
971
972	const APIVersion = "2019-04-15"
973	queryParameters := map[string]interface{}{
974		"api-version": APIVersion,
975	}
976
977	preparer := autorest.CreatePreparer(
978		autorest.AsContentType("application/json; charset=utf-8"),
979		autorest.AsPatch(),
980		autorest.WithBaseURL(client.BaseURI),
981		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", pathParameters),
982		autorest.WithJSON(endpointUpdateProperties),
983		autorest.WithQueryParameters(queryParameters))
984	return preparer.Prepare((&http.Request{}).WithContext(ctx))
985}
986
987// UpdateSender sends the Update request. The method will close the
988// http.Response Body if it receives an error.
989func (client EndpointsClient) UpdateSender(req *http.Request) (future EndpointsUpdateFuture, err error) {
990	var resp *http.Response
991	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
992	if err != nil {
993		return
994	}
995	var azf azure.Future
996	azf, err = azure.NewFutureFromResponse(resp)
997	future.FutureAPI = &azf
998	future.Result = future.result
999	return
1000}
1001
1002// UpdateResponder handles the response to the Update request. The method always
1003// closes the http.Response Body.
1004func (client EndpointsClient) UpdateResponder(resp *http.Response) (result Endpoint, err error) {
1005	err = autorest.Respond(
1006		resp,
1007		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1008		autorest.ByUnmarshallingJSON(&result),
1009		autorest.ByClosing())
1010	result.Response = autorest.Response{Response: resp}
1011	return
1012}
1013
1014// ValidateCustomDomain validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS.
1015// Parameters:
1016// resourceGroupName - name of the Resource group within the Azure subscription.
1017// profileName - name of the CDN profile which is unique within the resource group.
1018// endpointName - name of the endpoint under the profile which is unique globally.
1019// customDomainProperties - custom domain to be validated.
1020func (client EndpointsClient) ValidateCustomDomain(ctx context.Context, resourceGroupName string, profileName string, endpointName string, customDomainProperties ValidateCustomDomainInput) (result ValidateCustomDomainOutput, err error) {
1021	if tracing.IsEnabled() {
1022		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.ValidateCustomDomain")
1023		defer func() {
1024			sc := -1
1025			if result.Response.Response != nil {
1026				sc = result.Response.Response.StatusCode
1027			}
1028			tracing.EndSpan(ctx, sc, err)
1029		}()
1030	}
1031	if err := validation.Validate([]validation.Validation{
1032		{TargetValue: resourceGroupName,
1033			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1034				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1035				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
1036		{TargetValue: customDomainProperties,
1037			Constraints: []validation.Constraint{{Target: "customDomainProperties.HostName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
1038		return result, validation.NewError("cdn.EndpointsClient", "ValidateCustomDomain", err.Error())
1039	}
1040
1041	req, err := client.ValidateCustomDomainPreparer(ctx, resourceGroupName, profileName, endpointName, customDomainProperties)
1042	if err != nil {
1043		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", nil, "Failure preparing request")
1044		return
1045	}
1046
1047	resp, err := client.ValidateCustomDomainSender(req)
1048	if err != nil {
1049		result.Response = autorest.Response{Response: resp}
1050		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure sending request")
1051		return
1052	}
1053
1054	result, err = client.ValidateCustomDomainResponder(resp)
1055	if err != nil {
1056		err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure responding to request")
1057		return
1058	}
1059
1060	return
1061}
1062
1063// ValidateCustomDomainPreparer prepares the ValidateCustomDomain request.
1064func (client EndpointsClient) ValidateCustomDomainPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointName string, customDomainProperties ValidateCustomDomainInput) (*http.Request, error) {
1065	pathParameters := map[string]interface{}{
1066		"endpointName":      autorest.Encode("path", endpointName),
1067		"profileName":       autorest.Encode("path", profileName),
1068		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1069		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1070	}
1071
1072	const APIVersion = "2019-04-15"
1073	queryParameters := map[string]interface{}{
1074		"api-version": APIVersion,
1075	}
1076
1077	preparer := autorest.CreatePreparer(
1078		autorest.AsContentType("application/json; charset=utf-8"),
1079		autorest.AsPost(),
1080		autorest.WithBaseURL(client.BaseURI),
1081		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/validateCustomDomain", pathParameters),
1082		autorest.WithJSON(customDomainProperties),
1083		autorest.WithQueryParameters(queryParameters))
1084	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1085}
1086
1087// ValidateCustomDomainSender sends the ValidateCustomDomain request. The method will close the
1088// http.Response Body if it receives an error.
1089func (client EndpointsClient) ValidateCustomDomainSender(req *http.Request) (*http.Response, error) {
1090	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1091}
1092
1093// ValidateCustomDomainResponder handles the response to the ValidateCustomDomain request. The method always
1094// closes the http.Response Body.
1095func (client EndpointsClient) ValidateCustomDomainResponder(resp *http.Response) (result ValidateCustomDomainOutput, err error) {
1096	err = autorest.Respond(
1097		resp,
1098		azure.WithErrorUnlessStatusCode(http.StatusOK),
1099		autorest.ByUnmarshallingJSON(&result),
1100		autorest.ByClosing())
1101	result.Response = autorest.Response{Response: resp}
1102	return
1103}
1104