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/date"
14	"github.com/Azure/go-autorest/autorest/validation"
15	"github.com/Azure/go-autorest/tracing"
16	"net/http"
17)
18
19// LogAnalyticsClient is the cdn Management Client
20type LogAnalyticsClient struct {
21	BaseClient
22}
23
24// NewLogAnalyticsClient creates an instance of the LogAnalyticsClient client.
25func NewLogAnalyticsClient(subscriptionID string) LogAnalyticsClient {
26	return NewLogAnalyticsClientWithBaseURI(DefaultBaseURI, subscriptionID)
27}
28
29// NewLogAnalyticsClientWithBaseURI creates an instance of the LogAnalyticsClient client using a custom endpoint.  Use
30// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
31func NewLogAnalyticsClientWithBaseURI(baseURI string, subscriptionID string) LogAnalyticsClient {
32	return LogAnalyticsClient{NewWithBaseURI(baseURI, subscriptionID)}
33}
34
35// GetLogAnalyticsLocations get all available location names for AFD log analytics report.
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.
39func (client LogAnalyticsClient) GetLogAnalyticsLocations(ctx context.Context, resourceGroupName string, profileName string) (result ContinentsResponse, err error) {
40	if tracing.IsEnabled() {
41		ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.GetLogAnalyticsLocations")
42		defer func() {
43			sc := -1
44			if result.Response.Response != nil {
45				sc = result.Response.Response.StatusCode
46			}
47			tracing.EndSpan(ctx, sc, err)
48		}()
49	}
50	if err := validation.Validate([]validation.Validation{
51		{TargetValue: resourceGroupName,
52			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
53				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
54				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
55		return result, validation.NewError("cdn.LogAnalyticsClient", "GetLogAnalyticsLocations", err.Error())
56	}
57
58	req, err := client.GetLogAnalyticsLocationsPreparer(ctx, resourceGroupName, profileName)
59	if err != nil {
60		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsLocations", nil, "Failure preparing request")
61		return
62	}
63
64	resp, err := client.GetLogAnalyticsLocationsSender(req)
65	if err != nil {
66		result.Response = autorest.Response{Response: resp}
67		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsLocations", resp, "Failure sending request")
68		return
69	}
70
71	result, err = client.GetLogAnalyticsLocationsResponder(resp)
72	if err != nil {
73		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsLocations", resp, "Failure responding to request")
74		return
75	}
76
77	return
78}
79
80// GetLogAnalyticsLocationsPreparer prepares the GetLogAnalyticsLocations request.
81func (client LogAnalyticsClient) GetLogAnalyticsLocationsPreparer(ctx context.Context, resourceGroupName string, profileName string) (*http.Request, error) {
82	pathParameters := map[string]interface{}{
83		"profileName":       autorest.Encode("path", profileName),
84		"resourceGroupName": autorest.Encode("path", resourceGroupName),
85		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
86	}
87
88	const APIVersion = "2020-09-01"
89	queryParameters := map[string]interface{}{
90		"api-version": APIVersion,
91	}
92
93	preparer := autorest.CreatePreparer(
94		autorest.AsGet(),
95		autorest.WithBaseURL(client.BaseURI),
96		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations", pathParameters),
97		autorest.WithQueryParameters(queryParameters))
98	return preparer.Prepare((&http.Request{}).WithContext(ctx))
99}
100
101// GetLogAnalyticsLocationsSender sends the GetLogAnalyticsLocations request. The method will close the
102// http.Response Body if it receives an error.
103func (client LogAnalyticsClient) GetLogAnalyticsLocationsSender(req *http.Request) (*http.Response, error) {
104	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
105}
106
107// GetLogAnalyticsLocationsResponder handles the response to the GetLogAnalyticsLocations request. The method always
108// closes the http.Response Body.
109func (client LogAnalyticsClient) GetLogAnalyticsLocationsResponder(resp *http.Response) (result ContinentsResponse, err error) {
110	err = autorest.Respond(
111		resp,
112		azure.WithErrorUnlessStatusCode(http.StatusOK),
113		autorest.ByUnmarshallingJSON(&result),
114		autorest.ByClosing())
115	result.Response = autorest.Response{Response: resp}
116	return
117}
118
119// GetLogAnalyticsMetrics get log report for AFD profile
120// Parameters:
121// resourceGroupName - name of the Resource group within the Azure subscription.
122// profileName - name of the CDN profile which is unique within the resource group.
123// granularity -
124func (client LogAnalyticsClient) GetLogAnalyticsMetrics(ctx context.Context, resourceGroupName string, profileName string, metrics []string, dateTimeBegin date.Time, dateTimeEnd date.Time, granularity string, groupBy []string, continents []string, countryOrRegions []string, customDomains []string, protocols []string) (result MetricsResponse, err error) {
125	if tracing.IsEnabled() {
126		ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.GetLogAnalyticsMetrics")
127		defer func() {
128			sc := -1
129			if result.Response.Response != nil {
130				sc = result.Response.Response.StatusCode
131			}
132			tracing.EndSpan(ctx, sc, err)
133		}()
134	}
135	if err := validation.Validate([]validation.Validation{
136		{TargetValue: resourceGroupName,
137			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
138				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
139				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
140		{TargetValue: metrics,
141			Constraints: []validation.Constraint{{Target: "metrics", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
142		return result, validation.NewError("cdn.LogAnalyticsClient", "GetLogAnalyticsMetrics", err.Error())
143	}
144
145	req, err := client.GetLogAnalyticsMetricsPreparer(ctx, resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, groupBy, continents, countryOrRegions, customDomains, protocols)
146	if err != nil {
147		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsMetrics", nil, "Failure preparing request")
148		return
149	}
150
151	resp, err := client.GetLogAnalyticsMetricsSender(req)
152	if err != nil {
153		result.Response = autorest.Response{Response: resp}
154		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsMetrics", resp, "Failure sending request")
155		return
156	}
157
158	result, err = client.GetLogAnalyticsMetricsResponder(resp)
159	if err != nil {
160		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsMetrics", resp, "Failure responding to request")
161		return
162	}
163
164	return
165}
166
167// GetLogAnalyticsMetricsPreparer prepares the GetLogAnalyticsMetrics request.
168func (client LogAnalyticsClient) GetLogAnalyticsMetricsPreparer(ctx context.Context, resourceGroupName string, profileName string, metrics []string, dateTimeBegin date.Time, dateTimeEnd date.Time, granularity string, groupBy []string, continents []string, countryOrRegions []string, customDomains []string, protocols []string) (*http.Request, error) {
169	pathParameters := map[string]interface{}{
170		"profileName":       autorest.Encode("path", profileName),
171		"resourceGroupName": autorest.Encode("path", resourceGroupName),
172		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
173	}
174
175	const APIVersion = "2020-09-01"
176	queryParameters := map[string]interface{}{
177		"api-version":   APIVersion,
178		"dateTimeBegin": autorest.Encode("query", dateTimeBegin),
179		"dateTimeEnd":   autorest.Encode("query", dateTimeEnd),
180		"granularity":   autorest.Encode("query", granularity),
181		"metrics":       autorest.Encode("query", metrics, ","),
182	}
183	if groupBy != nil && len(groupBy) > 0 {
184		queryParameters["groupBy"] = autorest.Encode("query", groupBy, ",")
185	}
186	if continents != nil && len(continents) > 0 {
187		queryParameters["continents"] = autorest.Encode("query", continents, ",")
188	}
189	if countryOrRegions != nil && len(countryOrRegions) > 0 {
190		queryParameters["countryOrRegions"] = autorest.Encode("query", countryOrRegions, ",")
191	}
192	if customDomains != nil && len(customDomains) > 0 {
193		queryParameters["customDomains"] = autorest.Encode("query", customDomains, ",")
194	}
195	if protocols != nil && len(protocols) > 0 {
196		queryParameters["protocols"] = autorest.Encode("query", protocols, ",")
197	}
198
199	preparer := autorest.CreatePreparer(
200		autorest.AsGet(),
201		autorest.WithBaseURL(client.BaseURI),
202		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics", pathParameters),
203		autorest.WithQueryParameters(queryParameters))
204	return preparer.Prepare((&http.Request{}).WithContext(ctx))
205}
206
207// GetLogAnalyticsMetricsSender sends the GetLogAnalyticsMetrics request. The method will close the
208// http.Response Body if it receives an error.
209func (client LogAnalyticsClient) GetLogAnalyticsMetricsSender(req *http.Request) (*http.Response, error) {
210	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
211}
212
213// GetLogAnalyticsMetricsResponder handles the response to the GetLogAnalyticsMetrics request. The method always
214// closes the http.Response Body.
215func (client LogAnalyticsClient) GetLogAnalyticsMetricsResponder(resp *http.Response) (result MetricsResponse, err error) {
216	err = autorest.Respond(
217		resp,
218		azure.WithErrorUnlessStatusCode(http.StatusOK),
219		autorest.ByUnmarshallingJSON(&result),
220		autorest.ByClosing())
221	result.Response = autorest.Response{Response: resp}
222	return
223}
224
225// GetLogAnalyticsRankings get log analytics ranking report for AFD profile
226// Parameters:
227// resourceGroupName - name of the Resource group within the Azure subscription.
228// profileName - name of the CDN profile which is unique within the resource group.
229func (client LogAnalyticsClient) GetLogAnalyticsRankings(ctx context.Context, resourceGroupName string, profileName string, rankings []string, metrics []string, maxRanking int32, dateTimeBegin date.Time, dateTimeEnd date.Time, customDomains []string) (result RankingsResponse, err error) {
230	if tracing.IsEnabled() {
231		ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.GetLogAnalyticsRankings")
232		defer func() {
233			sc := -1
234			if result.Response.Response != nil {
235				sc = result.Response.Response.StatusCode
236			}
237			tracing.EndSpan(ctx, sc, err)
238		}()
239	}
240	if err := validation.Validate([]validation.Validation{
241		{TargetValue: resourceGroupName,
242			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
243				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
244				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
245		{TargetValue: rankings,
246			Constraints: []validation.Constraint{{Target: "rankings", Name: validation.Null, Rule: true, Chain: nil}}},
247		{TargetValue: metrics,
248			Constraints: []validation.Constraint{{Target: "metrics", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
249		return result, validation.NewError("cdn.LogAnalyticsClient", "GetLogAnalyticsRankings", err.Error())
250	}
251
252	req, err := client.GetLogAnalyticsRankingsPreparer(ctx, resourceGroupName, profileName, rankings, metrics, maxRanking, dateTimeBegin, dateTimeEnd, customDomains)
253	if err != nil {
254		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsRankings", nil, "Failure preparing request")
255		return
256	}
257
258	resp, err := client.GetLogAnalyticsRankingsSender(req)
259	if err != nil {
260		result.Response = autorest.Response{Response: resp}
261		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsRankings", resp, "Failure sending request")
262		return
263	}
264
265	result, err = client.GetLogAnalyticsRankingsResponder(resp)
266	if err != nil {
267		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsRankings", resp, "Failure responding to request")
268		return
269	}
270
271	return
272}
273
274// GetLogAnalyticsRankingsPreparer prepares the GetLogAnalyticsRankings request.
275func (client LogAnalyticsClient) GetLogAnalyticsRankingsPreparer(ctx context.Context, resourceGroupName string, profileName string, rankings []string, metrics []string, maxRanking int32, dateTimeBegin date.Time, dateTimeEnd date.Time, customDomains []string) (*http.Request, error) {
276	pathParameters := map[string]interface{}{
277		"profileName":       autorest.Encode("path", profileName),
278		"resourceGroupName": autorest.Encode("path", resourceGroupName),
279		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
280	}
281
282	const APIVersion = "2020-09-01"
283	queryParameters := map[string]interface{}{
284		"api-version":   APIVersion,
285		"dateTimeBegin": autorest.Encode("query", dateTimeBegin),
286		"dateTimeEnd":   autorest.Encode("query", dateTimeEnd),
287		"maxRanking":    autorest.Encode("query", maxRanking),
288		"metrics":       autorest.Encode("query", metrics, ","),
289		"rankings":      autorest.Encode("query", rankings, ","),
290	}
291	if customDomains != nil && len(customDomains) > 0 {
292		queryParameters["customDomains"] = autorest.Encode("query", customDomains, ",")
293	}
294
295	preparer := autorest.CreatePreparer(
296		autorest.AsGet(),
297		autorest.WithBaseURL(client.BaseURI),
298		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings", pathParameters),
299		autorest.WithQueryParameters(queryParameters))
300	return preparer.Prepare((&http.Request{}).WithContext(ctx))
301}
302
303// GetLogAnalyticsRankingsSender sends the GetLogAnalyticsRankings request. The method will close the
304// http.Response Body if it receives an error.
305func (client LogAnalyticsClient) GetLogAnalyticsRankingsSender(req *http.Request) (*http.Response, error) {
306	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
307}
308
309// GetLogAnalyticsRankingsResponder handles the response to the GetLogAnalyticsRankings request. The method always
310// closes the http.Response Body.
311func (client LogAnalyticsClient) GetLogAnalyticsRankingsResponder(resp *http.Response) (result RankingsResponse, err error) {
312	err = autorest.Respond(
313		resp,
314		azure.WithErrorUnlessStatusCode(http.StatusOK),
315		autorest.ByUnmarshallingJSON(&result),
316		autorest.ByClosing())
317	result.Response = autorest.Response{Response: resp}
318	return
319}
320
321// GetLogAnalyticsResources get all endpoints and custom domains available for AFD log report
322// Parameters:
323// resourceGroupName - name of the Resource group within the Azure subscription.
324// profileName - name of the CDN profile which is unique within the resource group.
325func (client LogAnalyticsClient) GetLogAnalyticsResources(ctx context.Context, resourceGroupName string, profileName string) (result ResourcesResponse, err error) {
326	if tracing.IsEnabled() {
327		ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.GetLogAnalyticsResources")
328		defer func() {
329			sc := -1
330			if result.Response.Response != nil {
331				sc = result.Response.Response.StatusCode
332			}
333			tracing.EndSpan(ctx, sc, err)
334		}()
335	}
336	if err := validation.Validate([]validation.Validation{
337		{TargetValue: resourceGroupName,
338			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
339				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
340				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
341		return result, validation.NewError("cdn.LogAnalyticsClient", "GetLogAnalyticsResources", err.Error())
342	}
343
344	req, err := client.GetLogAnalyticsResourcesPreparer(ctx, resourceGroupName, profileName)
345	if err != nil {
346		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsResources", nil, "Failure preparing request")
347		return
348	}
349
350	resp, err := client.GetLogAnalyticsResourcesSender(req)
351	if err != nil {
352		result.Response = autorest.Response{Response: resp}
353		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsResources", resp, "Failure sending request")
354		return
355	}
356
357	result, err = client.GetLogAnalyticsResourcesResponder(resp)
358	if err != nil {
359		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetLogAnalyticsResources", resp, "Failure responding to request")
360		return
361	}
362
363	return
364}
365
366// GetLogAnalyticsResourcesPreparer prepares the GetLogAnalyticsResources request.
367func (client LogAnalyticsClient) GetLogAnalyticsResourcesPreparer(ctx context.Context, resourceGroupName string, profileName string) (*http.Request, error) {
368	pathParameters := map[string]interface{}{
369		"profileName":       autorest.Encode("path", profileName),
370		"resourceGroupName": autorest.Encode("path", resourceGroupName),
371		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
372	}
373
374	const APIVersion = "2020-09-01"
375	queryParameters := map[string]interface{}{
376		"api-version": APIVersion,
377	}
378
379	preparer := autorest.CreatePreparer(
380		autorest.AsGet(),
381		autorest.WithBaseURL(client.BaseURI),
382		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources", pathParameters),
383		autorest.WithQueryParameters(queryParameters))
384	return preparer.Prepare((&http.Request{}).WithContext(ctx))
385}
386
387// GetLogAnalyticsResourcesSender sends the GetLogAnalyticsResources request. The method will close the
388// http.Response Body if it receives an error.
389func (client LogAnalyticsClient) GetLogAnalyticsResourcesSender(req *http.Request) (*http.Response, error) {
390	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
391}
392
393// GetLogAnalyticsResourcesResponder handles the response to the GetLogAnalyticsResources request. The method always
394// closes the http.Response Body.
395func (client LogAnalyticsClient) GetLogAnalyticsResourcesResponder(resp *http.Response) (result ResourcesResponse, err error) {
396	err = autorest.Respond(
397		resp,
398		azure.WithErrorUnlessStatusCode(http.StatusOK),
399		autorest.ByUnmarshallingJSON(&result),
400		autorest.ByClosing())
401	result.Response = autorest.Response{Response: resp}
402	return
403}
404
405// GetWafLogAnalyticsMetrics get Waf related log analytics report for AFD profile.
406// Parameters:
407// resourceGroupName - name of the Resource group within the Azure subscription.
408// profileName - name of the CDN profile which is unique within the resource group.
409// granularity -
410func (client LogAnalyticsClient) GetWafLogAnalyticsMetrics(ctx context.Context, resourceGroupName string, profileName string, metrics []string, dateTimeBegin date.Time, dateTimeEnd date.Time, granularity string, actions []string, groupBy []string, ruleTypes []string) (result WafMetricsResponse, err error) {
411	if tracing.IsEnabled() {
412		ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.GetWafLogAnalyticsMetrics")
413		defer func() {
414			sc := -1
415			if result.Response.Response != nil {
416				sc = result.Response.Response.StatusCode
417			}
418			tracing.EndSpan(ctx, sc, err)
419		}()
420	}
421	if err := validation.Validate([]validation.Validation{
422		{TargetValue: resourceGroupName,
423			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
424				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
425				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
426		{TargetValue: metrics,
427			Constraints: []validation.Constraint{{Target: "metrics", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
428		return result, validation.NewError("cdn.LogAnalyticsClient", "GetWafLogAnalyticsMetrics", err.Error())
429	}
430
431	req, err := client.GetWafLogAnalyticsMetricsPreparer(ctx, resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, actions, groupBy, ruleTypes)
432	if err != nil {
433		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetWafLogAnalyticsMetrics", nil, "Failure preparing request")
434		return
435	}
436
437	resp, err := client.GetWafLogAnalyticsMetricsSender(req)
438	if err != nil {
439		result.Response = autorest.Response{Response: resp}
440		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetWafLogAnalyticsMetrics", resp, "Failure sending request")
441		return
442	}
443
444	result, err = client.GetWafLogAnalyticsMetricsResponder(resp)
445	if err != nil {
446		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetWafLogAnalyticsMetrics", resp, "Failure responding to request")
447		return
448	}
449
450	return
451}
452
453// GetWafLogAnalyticsMetricsPreparer prepares the GetWafLogAnalyticsMetrics request.
454func (client LogAnalyticsClient) GetWafLogAnalyticsMetricsPreparer(ctx context.Context, resourceGroupName string, profileName string, metrics []string, dateTimeBegin date.Time, dateTimeEnd date.Time, granularity string, actions []string, groupBy []string, ruleTypes []string) (*http.Request, error) {
455	pathParameters := map[string]interface{}{
456		"profileName":       autorest.Encode("path", profileName),
457		"resourceGroupName": autorest.Encode("path", resourceGroupName),
458		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
459	}
460
461	const APIVersion = "2020-09-01"
462	queryParameters := map[string]interface{}{
463		"api-version":   APIVersion,
464		"dateTimeBegin": autorest.Encode("query", dateTimeBegin),
465		"dateTimeEnd":   autorest.Encode("query", dateTimeEnd),
466		"granularity":   autorest.Encode("query", granularity),
467		"metrics":       autorest.Encode("query", metrics, ","),
468	}
469	if actions != nil && len(actions) > 0 {
470		queryParameters["actions"] = autorest.Encode("query", actions, ",")
471	}
472	if groupBy != nil && len(groupBy) > 0 {
473		queryParameters["groupBy"] = autorest.Encode("query", groupBy, ",")
474	}
475	if ruleTypes != nil && len(ruleTypes) > 0 {
476		queryParameters["ruleTypes"] = autorest.Encode("query", ruleTypes, ",")
477	}
478
479	preparer := autorest.CreatePreparer(
480		autorest.AsGet(),
481		autorest.WithBaseURL(client.BaseURI),
482		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics", pathParameters),
483		autorest.WithQueryParameters(queryParameters))
484	return preparer.Prepare((&http.Request{}).WithContext(ctx))
485}
486
487// GetWafLogAnalyticsMetricsSender sends the GetWafLogAnalyticsMetrics request. The method will close the
488// http.Response Body if it receives an error.
489func (client LogAnalyticsClient) GetWafLogAnalyticsMetricsSender(req *http.Request) (*http.Response, error) {
490	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
491}
492
493// GetWafLogAnalyticsMetricsResponder handles the response to the GetWafLogAnalyticsMetrics request. The method always
494// closes the http.Response Body.
495func (client LogAnalyticsClient) GetWafLogAnalyticsMetricsResponder(resp *http.Response) (result WafMetricsResponse, err error) {
496	err = autorest.Respond(
497		resp,
498		azure.WithErrorUnlessStatusCode(http.StatusOK),
499		autorest.ByUnmarshallingJSON(&result),
500		autorest.ByClosing())
501	result.Response = autorest.Response{Response: resp}
502	return
503}
504
505// GetWafLogAnalyticsRankings get WAF log analytics charts for AFD profile
506// Parameters:
507// resourceGroupName - name of the Resource group within the Azure subscription.
508// profileName - name of the CDN profile which is unique within the resource group.
509func (client LogAnalyticsClient) GetWafLogAnalyticsRankings(ctx context.Context, resourceGroupName string, profileName string, metrics []string, dateTimeBegin date.Time, dateTimeEnd date.Time, maxRanking int32, rankings []string, actions []string, ruleTypes []string) (result WafRankingsResponse, err error) {
510	if tracing.IsEnabled() {
511		ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.GetWafLogAnalyticsRankings")
512		defer func() {
513			sc := -1
514			if result.Response.Response != nil {
515				sc = result.Response.Response.StatusCode
516			}
517			tracing.EndSpan(ctx, sc, err)
518		}()
519	}
520	if err := validation.Validate([]validation.Validation{
521		{TargetValue: resourceGroupName,
522			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
523				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
524				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
525		{TargetValue: metrics,
526			Constraints: []validation.Constraint{{Target: "metrics", Name: validation.Null, Rule: true, Chain: nil}}},
527		{TargetValue: rankings,
528			Constraints: []validation.Constraint{{Target: "rankings", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
529		return result, validation.NewError("cdn.LogAnalyticsClient", "GetWafLogAnalyticsRankings", err.Error())
530	}
531
532	req, err := client.GetWafLogAnalyticsRankingsPreparer(ctx, resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, maxRanking, rankings, actions, ruleTypes)
533	if err != nil {
534		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetWafLogAnalyticsRankings", nil, "Failure preparing request")
535		return
536	}
537
538	resp, err := client.GetWafLogAnalyticsRankingsSender(req)
539	if err != nil {
540		result.Response = autorest.Response{Response: resp}
541		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetWafLogAnalyticsRankings", resp, "Failure sending request")
542		return
543	}
544
545	result, err = client.GetWafLogAnalyticsRankingsResponder(resp)
546	if err != nil {
547		err = autorest.NewErrorWithError(err, "cdn.LogAnalyticsClient", "GetWafLogAnalyticsRankings", resp, "Failure responding to request")
548		return
549	}
550
551	return
552}
553
554// GetWafLogAnalyticsRankingsPreparer prepares the GetWafLogAnalyticsRankings request.
555func (client LogAnalyticsClient) GetWafLogAnalyticsRankingsPreparer(ctx context.Context, resourceGroupName string, profileName string, metrics []string, dateTimeBegin date.Time, dateTimeEnd date.Time, maxRanking int32, rankings []string, actions []string, ruleTypes []string) (*http.Request, error) {
556	pathParameters := map[string]interface{}{
557		"profileName":       autorest.Encode("path", profileName),
558		"resourceGroupName": autorest.Encode("path", resourceGroupName),
559		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
560	}
561
562	const APIVersion = "2020-09-01"
563	queryParameters := map[string]interface{}{
564		"api-version":   APIVersion,
565		"dateTimeBegin": autorest.Encode("query", dateTimeBegin),
566		"dateTimeEnd":   autorest.Encode("query", dateTimeEnd),
567		"maxRanking":    autorest.Encode("query", maxRanking),
568		"metrics":       autorest.Encode("query", metrics, ","),
569		"rankings":      autorest.Encode("query", rankings, ","),
570	}
571	if actions != nil && len(actions) > 0 {
572		queryParameters["actions"] = autorest.Encode("query", actions, ",")
573	}
574	if ruleTypes != nil && len(ruleTypes) > 0 {
575		queryParameters["ruleTypes"] = autorest.Encode("query", ruleTypes, ",")
576	}
577
578	preparer := autorest.CreatePreparer(
579		autorest.AsGet(),
580		autorest.WithBaseURL(client.BaseURI),
581		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings", pathParameters),
582		autorest.WithQueryParameters(queryParameters))
583	return preparer.Prepare((&http.Request{}).WithContext(ctx))
584}
585
586// GetWafLogAnalyticsRankingsSender sends the GetWafLogAnalyticsRankings request. The method will close the
587// http.Response Body if it receives an error.
588func (client LogAnalyticsClient) GetWafLogAnalyticsRankingsSender(req *http.Request) (*http.Response, error) {
589	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
590}
591
592// GetWafLogAnalyticsRankingsResponder handles the response to the GetWafLogAnalyticsRankings request. The method always
593// closes the http.Response Body.
594func (client LogAnalyticsClient) GetWafLogAnalyticsRankingsResponder(resp *http.Response) (result WafRankingsResponse, err error) {
595	err = autorest.Respond(
596		resp,
597		azure.WithErrorUnlessStatusCode(http.StatusOK),
598		autorest.ByUnmarshallingJSON(&result),
599		autorest.ByClosing())
600	result.Response = autorest.Response{Response: resp}
601	return
602}
603