1package apimanagement
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// APIPolicyClient is the apiManagement Client
19type APIPolicyClient struct {
20	BaseClient
21}
22
23// NewAPIPolicyClient creates an instance of the APIPolicyClient client.
24func NewAPIPolicyClient(subscriptionID string) APIPolicyClient {
25	return NewAPIPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewAPIPolicyClientWithBaseURI creates an instance of the APIPolicyClient 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 NewAPIPolicyClientWithBaseURI(baseURI string, subscriptionID string) APIPolicyClient {
31	return APIPolicyClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate creates or updates policy configuration for the API.
35// Parameters:
36// resourceGroupName - the name of the resource group.
37// serviceName - the name of the API Management service.
38// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
39// revision has ;rev=n as a suffix where n is the revision number.
40// parameters - the policy contents to apply.
41// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity.
42func (client APIPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters PolicyContract, ifMatch string) (result PolicyContract, err error) {
43	if tracing.IsEnabled() {
44		ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.CreateOrUpdate")
45		defer func() {
46			sc := -1
47			if result.Response.Response != nil {
48				sc = result.Response.Response.StatusCode
49			}
50			tracing.EndSpan(ctx, sc, err)
51		}()
52	}
53	if err := validation.Validate([]validation.Validation{
54		{TargetValue: serviceName,
55			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
56				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
57				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
58		{TargetValue: apiid,
59			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
60				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
61				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
62		{TargetValue: parameters,
63			Constraints: []validation.Constraint{{Target: "parameters.PolicyContractProperties", Name: validation.Null, Rule: false,
64				Chain: []validation.Constraint{{Target: "parameters.PolicyContractProperties.Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
65		return result, validation.NewError("apimanagement.APIPolicyClient", "CreateOrUpdate", err.Error())
66	}
67
68	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, parameters, ifMatch)
69	if err != nil {
70		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", nil, "Failure preparing request")
71		return
72	}
73
74	resp, err := client.CreateOrUpdateSender(req)
75	if err != nil {
76		result.Response = autorest.Response{Response: resp}
77		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", resp, "Failure sending request")
78		return
79	}
80
81	result, err = client.CreateOrUpdateResponder(resp)
82	if err != nil {
83		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", resp, "Failure responding to request")
84		return
85	}
86
87	return
88}
89
90// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
91func (client APIPolicyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters PolicyContract, ifMatch string) (*http.Request, error) {
92	pathParameters := map[string]interface{}{
93		"apiId":             autorest.Encode("path", apiid),
94		"policyId":          autorest.Encode("path", "policy"),
95		"resourceGroupName": autorest.Encode("path", resourceGroupName),
96		"serviceName":       autorest.Encode("path", serviceName),
97		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
98	}
99
100	const APIVersion = "2019-12-01-preview"
101	queryParameters := map[string]interface{}{
102		"api-version": APIVersion,
103	}
104
105	preparer := autorest.CreatePreparer(
106		autorest.AsContentType("application/json; charset=utf-8"),
107		autorest.AsPut(),
108		autorest.WithBaseURL(client.BaseURI),
109		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters),
110		autorest.WithJSON(parameters),
111		autorest.WithQueryParameters(queryParameters))
112	if len(ifMatch) > 0 {
113		preparer = autorest.DecoratePreparer(preparer,
114			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
115	}
116	return preparer.Prepare((&http.Request{}).WithContext(ctx))
117}
118
119// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
120// http.Response Body if it receives an error.
121func (client APIPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
122	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
123}
124
125// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
126// closes the http.Response Body.
127func (client APIPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyContract, err error) {
128	err = autorest.Respond(
129		resp,
130		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
131		autorest.ByUnmarshallingJSON(&result),
132		autorest.ByClosing())
133	result.Response = autorest.Response{Response: resp}
134	return
135}
136
137// Delete deletes the policy configuration at the Api.
138// Parameters:
139// resourceGroupName - the name of the resource group.
140// serviceName - the name of the API Management service.
141// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
142// revision has ;rev=n as a suffix where n is the revision number.
143// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
144// request or it should be * for unconditional update.
145func (client APIPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (result autorest.Response, err error) {
146	if tracing.IsEnabled() {
147		ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.Delete")
148		defer func() {
149			sc := -1
150			if result.Response != nil {
151				sc = result.Response.StatusCode
152			}
153			tracing.EndSpan(ctx, sc, err)
154		}()
155	}
156	if err := validation.Validate([]validation.Validation{
157		{TargetValue: serviceName,
158			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
159				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
160				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
161		{TargetValue: apiid,
162			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
163				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
164				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
165		return result, validation.NewError("apimanagement.APIPolicyClient", "Delete", err.Error())
166	}
167
168	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, ifMatch)
169	if err != nil {
170		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", nil, "Failure preparing request")
171		return
172	}
173
174	resp, err := client.DeleteSender(req)
175	if err != nil {
176		result.Response = resp
177		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", resp, "Failure sending request")
178		return
179	}
180
181	result, err = client.DeleteResponder(resp)
182	if err != nil {
183		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", resp, "Failure responding to request")
184		return
185	}
186
187	return
188}
189
190// DeletePreparer prepares the Delete request.
191func (client APIPolicyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (*http.Request, error) {
192	pathParameters := map[string]interface{}{
193		"apiId":             autorest.Encode("path", apiid),
194		"policyId":          autorest.Encode("path", "policy"),
195		"resourceGroupName": autorest.Encode("path", resourceGroupName),
196		"serviceName":       autorest.Encode("path", serviceName),
197		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
198	}
199
200	const APIVersion = "2019-12-01-preview"
201	queryParameters := map[string]interface{}{
202		"api-version": APIVersion,
203	}
204
205	preparer := autorest.CreatePreparer(
206		autorest.AsDelete(),
207		autorest.WithBaseURL(client.BaseURI),
208		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters),
209		autorest.WithQueryParameters(queryParameters),
210		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
211	return preparer.Prepare((&http.Request{}).WithContext(ctx))
212}
213
214// DeleteSender sends the Delete request. The method will close the
215// http.Response Body if it receives an error.
216func (client APIPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) {
217	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
218}
219
220// DeleteResponder handles the response to the Delete request. The method always
221// closes the http.Response Body.
222func (client APIPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
223	err = autorest.Respond(
224		resp,
225		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
226		autorest.ByClosing())
227	result.Response = resp
228	return
229}
230
231// Get get the policy configuration at the API level.
232// Parameters:
233// resourceGroupName - the name of the resource group.
234// serviceName - the name of the API Management service.
235// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
236// revision has ;rev=n as a suffix where n is the revision number.
237// formatParameter - policy Export Format.
238func (client APIPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter PolicyExportFormat) (result PolicyContract, err error) {
239	if tracing.IsEnabled() {
240		ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.Get")
241		defer func() {
242			sc := -1
243			if result.Response.Response != nil {
244				sc = result.Response.Response.StatusCode
245			}
246			tracing.EndSpan(ctx, sc, err)
247		}()
248	}
249	if err := validation.Validate([]validation.Validation{
250		{TargetValue: serviceName,
251			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
252				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
253				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
254		{TargetValue: apiid,
255			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
256				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
257				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
258		return result, validation.NewError("apimanagement.APIPolicyClient", "Get", err.Error())
259	}
260
261	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, formatParameter)
262	if err != nil {
263		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", nil, "Failure preparing request")
264		return
265	}
266
267	resp, err := client.GetSender(req)
268	if err != nil {
269		result.Response = autorest.Response{Response: resp}
270		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure sending request")
271		return
272	}
273
274	result, err = client.GetResponder(resp)
275	if err != nil {
276		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure responding to request")
277		return
278	}
279
280	return
281}
282
283// GetPreparer prepares the Get request.
284func (client APIPolicyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter PolicyExportFormat) (*http.Request, error) {
285	pathParameters := map[string]interface{}{
286		"apiId":             autorest.Encode("path", apiid),
287		"policyId":          autorest.Encode("path", "policy"),
288		"resourceGroupName": autorest.Encode("path", resourceGroupName),
289		"serviceName":       autorest.Encode("path", serviceName),
290		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
291	}
292
293	const APIVersion = "2019-12-01-preview"
294	queryParameters := map[string]interface{}{
295		"api-version": APIVersion,
296	}
297	if len(string(formatParameter)) > 0 {
298		queryParameters["format"] = autorest.Encode("query", formatParameter)
299	} else {
300		queryParameters["format"] = autorest.Encode("query", "xml")
301	}
302
303	preparer := autorest.CreatePreparer(
304		autorest.AsGet(),
305		autorest.WithBaseURL(client.BaseURI),
306		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters),
307		autorest.WithQueryParameters(queryParameters))
308	return preparer.Prepare((&http.Request{}).WithContext(ctx))
309}
310
311// GetSender sends the Get request. The method will close the
312// http.Response Body if it receives an error.
313func (client APIPolicyClient) GetSender(req *http.Request) (*http.Response, error) {
314	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
315}
316
317// GetResponder handles the response to the Get request. The method always
318// closes the http.Response Body.
319func (client APIPolicyClient) GetResponder(resp *http.Response) (result PolicyContract, err error) {
320	err = autorest.Respond(
321		resp,
322		azure.WithErrorUnlessStatusCode(http.StatusOK),
323		autorest.ByUnmarshallingJSON(&result),
324		autorest.ByClosing())
325	result.Response = autorest.Response{Response: resp}
326	return
327}
328
329// GetEntityTag gets the entity state (Etag) version of the API policy specified by its identifier.
330// Parameters:
331// resourceGroupName - the name of the resource group.
332// serviceName - the name of the API Management service.
333// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
334// revision has ;rev=n as a suffix where n is the revision number.
335func (client APIPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result autorest.Response, err error) {
336	if tracing.IsEnabled() {
337		ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.GetEntityTag")
338		defer func() {
339			sc := -1
340			if result.Response != nil {
341				sc = result.Response.StatusCode
342			}
343			tracing.EndSpan(ctx, sc, err)
344		}()
345	}
346	if err := validation.Validate([]validation.Validation{
347		{TargetValue: serviceName,
348			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
349				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
350				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
351		{TargetValue: apiid,
352			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
353				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
354				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
355		return result, validation.NewError("apimanagement.APIPolicyClient", "GetEntityTag", err.Error())
356	}
357
358	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid)
359	if err != nil {
360		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", nil, "Failure preparing request")
361		return
362	}
363
364	resp, err := client.GetEntityTagSender(req)
365	if err != nil {
366		result.Response = resp
367		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", resp, "Failure sending request")
368		return
369	}
370
371	result, err = client.GetEntityTagResponder(resp)
372	if err != nil {
373		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", resp, "Failure responding to request")
374		return
375	}
376
377	return
378}
379
380// GetEntityTagPreparer prepares the GetEntityTag request.
381func (client APIPolicyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) {
382	pathParameters := map[string]interface{}{
383		"apiId":             autorest.Encode("path", apiid),
384		"policyId":          autorest.Encode("path", "policy"),
385		"resourceGroupName": autorest.Encode("path", resourceGroupName),
386		"serviceName":       autorest.Encode("path", serviceName),
387		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
388	}
389
390	const APIVersion = "2019-12-01-preview"
391	queryParameters := map[string]interface{}{
392		"api-version": APIVersion,
393	}
394
395	preparer := autorest.CreatePreparer(
396		autorest.AsHead(),
397		autorest.WithBaseURL(client.BaseURI),
398		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters),
399		autorest.WithQueryParameters(queryParameters))
400	return preparer.Prepare((&http.Request{}).WithContext(ctx))
401}
402
403// GetEntityTagSender sends the GetEntityTag request. The method will close the
404// http.Response Body if it receives an error.
405func (client APIPolicyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
406	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
407}
408
409// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
410// closes the http.Response Body.
411func (client APIPolicyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
412	err = autorest.Respond(
413		resp,
414		azure.WithErrorUnlessStatusCode(http.StatusOK),
415		autorest.ByClosing())
416	result.Response = resp
417	return
418}
419
420// ListByAPI get the policy configuration at the API level.
421// Parameters:
422// resourceGroupName - the name of the resource group.
423// serviceName - the name of the API Management service.
424// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current
425// revision has ;rev=n as a suffix where n is the revision number.
426func (client APIPolicyClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result PolicyCollection, err error) {
427	if tracing.IsEnabled() {
428		ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.ListByAPI")
429		defer func() {
430			sc := -1
431			if result.Response.Response != nil {
432				sc = result.Response.Response.StatusCode
433			}
434			tracing.EndSpan(ctx, sc, err)
435		}()
436	}
437	if err := validation.Validate([]validation.Validation{
438		{TargetValue: serviceName,
439			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
440				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
441				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
442		{TargetValue: apiid,
443			Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil},
444				{Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil},
445				{Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
446		return result, validation.NewError("apimanagement.APIPolicyClient", "ListByAPI", err.Error())
447	}
448
449	req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid)
450	if err != nil {
451		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", nil, "Failure preparing request")
452		return
453	}
454
455	resp, err := client.ListByAPISender(req)
456	if err != nil {
457		result.Response = autorest.Response{Response: resp}
458		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", resp, "Failure sending request")
459		return
460	}
461
462	result, err = client.ListByAPIResponder(resp)
463	if err != nil {
464		err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", resp, "Failure responding to request")
465		return
466	}
467
468	return
469}
470
471// ListByAPIPreparer prepares the ListByAPI request.
472func (client APIPolicyClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) {
473	pathParameters := map[string]interface{}{
474		"apiId":             autorest.Encode("path", apiid),
475		"resourceGroupName": autorest.Encode("path", resourceGroupName),
476		"serviceName":       autorest.Encode("path", serviceName),
477		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
478	}
479
480	const APIVersion = "2019-12-01-preview"
481	queryParameters := map[string]interface{}{
482		"api-version": APIVersion,
483	}
484
485	preparer := autorest.CreatePreparer(
486		autorest.AsGet(),
487		autorest.WithBaseURL(client.BaseURI),
488		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies", pathParameters),
489		autorest.WithQueryParameters(queryParameters))
490	return preparer.Prepare((&http.Request{}).WithContext(ctx))
491}
492
493// ListByAPISender sends the ListByAPI request. The method will close the
494// http.Response Body if it receives an error.
495func (client APIPolicyClient) ListByAPISender(req *http.Request) (*http.Response, error) {
496	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
497}
498
499// ListByAPIResponder handles the response to the ListByAPI request. The method always
500// closes the http.Response Body.
501func (client APIPolicyClient) ListByAPIResponder(resp *http.Response) (result PolicyCollection, err error) {
502	err = autorest.Respond(
503		resp,
504		azure.WithErrorUnlessStatusCode(http.StatusOK),
505		autorest.ByUnmarshallingJSON(&result),
506		autorest.ByClosing())
507	result.Response = autorest.Response{Response: resp}
508	return
509}
510