1package apimanagement
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/autorest/validation"
25	"github.com/Azure/go-autorest/tracing"
26	"net/http"
27)
28
29// LoggersClient is the apiManagement Client
30type LoggersClient struct {
31	BaseClient
32}
33
34// NewLoggersClient creates an instance of the LoggersClient client.
35func NewLoggersClient(subscriptionID string) LoggersClient {
36	return NewLoggersClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewLoggersClientWithBaseURI creates an instance of the LoggersClient client.
40func NewLoggersClientWithBaseURI(baseURI string, subscriptionID string) LoggersClient {
41	return LoggersClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CreateOrUpdate creates or Updates a logger.
45// Parameters:
46// resourceGroupName - the name of the resource group.
47// serviceName - the name of the API Management service.
48// loggerid - logger identifier. Must be unique in the API Management service instance.
49// parameters - create parameters.
50func (client LoggersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, loggerid string, parameters LoggerCreateParameters) (result autorest.Response, err error) {
51	if tracing.IsEnabled() {
52		ctx = tracing.StartSpan(ctx, fqdn+"/LoggersClient.CreateOrUpdate")
53		defer func() {
54			sc := -1
55			if result.Response != nil {
56				sc = result.Response.StatusCode
57			}
58			tracing.EndSpan(ctx, sc, err)
59		}()
60	}
61	if err := validation.Validate([]validation.Validation{
62		{TargetValue: serviceName,
63			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
64				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
65				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
66		{TargetValue: loggerid,
67			Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil},
68				{Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
69		{TargetValue: parameters,
70			Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil},
71				{Target: "parameters.Credentials", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
72		return result, validation.NewError("apimanagement.LoggersClient", "CreateOrUpdate", err.Error())
73	}
74
75	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, loggerid, parameters)
76	if err != nil {
77		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", nil, "Failure preparing request")
78		return
79	}
80
81	resp, err := client.CreateOrUpdateSender(req)
82	if err != nil {
83		result.Response = resp
84		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", resp, "Failure sending request")
85		return
86	}
87
88	result, err = client.CreateOrUpdateResponder(resp)
89	if err != nil {
90		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", resp, "Failure responding to request")
91	}
92
93	return
94}
95
96// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
97func (client LoggersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerid string, parameters LoggerCreateParameters) (*http.Request, error) {
98	pathParameters := map[string]interface{}{
99		"loggerid":          autorest.Encode("path", loggerid),
100		"resourceGroupName": autorest.Encode("path", resourceGroupName),
101		"serviceName":       autorest.Encode("path", serviceName),
102		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
103	}
104
105	const APIVersion = "2016-10-10"
106	queryParameters := map[string]interface{}{
107		"api-version": APIVersion,
108	}
109
110	preparer := autorest.CreatePreparer(
111		autorest.AsContentType("application/json; charset=utf-8"),
112		autorest.AsPut(),
113		autorest.WithBaseURL(client.BaseURI),
114		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerid}", pathParameters),
115		autorest.WithJSON(parameters),
116		autorest.WithQueryParameters(queryParameters))
117	return preparer.Prepare((&http.Request{}).WithContext(ctx))
118}
119
120// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
121// http.Response Body if it receives an error.
122func (client LoggersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
123	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
124	return autorest.SendWithSender(client, req, sd...)
125}
126
127// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
128// closes the http.Response Body.
129func (client LoggersClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
130	err = autorest.Respond(
131		resp,
132		client.ByInspecting(),
133		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
134		autorest.ByClosing())
135	result.Response = resp
136	return
137}
138
139// Delete deletes the specified logger.
140// Parameters:
141// resourceGroupName - the name of the resource group.
142// serviceName - the name of the API Management service.
143// loggerid - logger identifier. Must be unique in the API Management service instance.
144// ifMatch - the entity state (Etag) version of the logger to delete. A value of "*" can be used for If-Match
145// to unconditionally apply the operation.
146func (client LoggersClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, loggerid string, ifMatch string) (result autorest.Response, err error) {
147	if tracing.IsEnabled() {
148		ctx = tracing.StartSpan(ctx, fqdn+"/LoggersClient.Delete")
149		defer func() {
150			sc := -1
151			if result.Response != nil {
152				sc = result.Response.StatusCode
153			}
154			tracing.EndSpan(ctx, sc, err)
155		}()
156	}
157	if err := validation.Validate([]validation.Validation{
158		{TargetValue: serviceName,
159			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
160				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
161				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
162		{TargetValue: loggerid,
163			Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil},
164				{Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
165		return result, validation.NewError("apimanagement.LoggersClient", "Delete", err.Error())
166	}
167
168	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, loggerid, ifMatch)
169	if err != nil {
170		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "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.LoggersClient", "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.LoggersClient", "Delete", resp, "Failure responding to request")
184	}
185
186	return
187}
188
189// DeletePreparer prepares the Delete request.
190func (client LoggersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerid string, ifMatch string) (*http.Request, error) {
191	pathParameters := map[string]interface{}{
192		"loggerid":          autorest.Encode("path", loggerid),
193		"resourceGroupName": autorest.Encode("path", resourceGroupName),
194		"serviceName":       autorest.Encode("path", serviceName),
195		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
196	}
197
198	const APIVersion = "2016-10-10"
199	queryParameters := map[string]interface{}{
200		"api-version": APIVersion,
201	}
202
203	preparer := autorest.CreatePreparer(
204		autorest.AsDelete(),
205		autorest.WithBaseURL(client.BaseURI),
206		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerid}", pathParameters),
207		autorest.WithQueryParameters(queryParameters),
208		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
209	return preparer.Prepare((&http.Request{}).WithContext(ctx))
210}
211
212// DeleteSender sends the Delete request. The method will close the
213// http.Response Body if it receives an error.
214func (client LoggersClient) DeleteSender(req *http.Request) (*http.Response, error) {
215	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
216	return autorest.SendWithSender(client, req, sd...)
217}
218
219// DeleteResponder handles the response to the Delete request. The method always
220// closes the http.Response Body.
221func (client LoggersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
222	err = autorest.Respond(
223		resp,
224		client.ByInspecting(),
225		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
226		autorest.ByClosing())
227	result.Response = resp
228	return
229}
230
231// Get gets the details of the logger specified by its identifier.
232// Parameters:
233// resourceGroupName - the name of the resource group.
234// serviceName - the name of the API Management service.
235// loggerid - logger identifier. Must be unique in the API Management service instance.
236func (client LoggersClient) Get(ctx context.Context, resourceGroupName string, serviceName string, loggerid string) (result LoggerResponse, err error) {
237	if tracing.IsEnabled() {
238		ctx = tracing.StartSpan(ctx, fqdn+"/LoggersClient.Get")
239		defer func() {
240			sc := -1
241			if result.Response.Response != nil {
242				sc = result.Response.Response.StatusCode
243			}
244			tracing.EndSpan(ctx, sc, err)
245		}()
246	}
247	if err := validation.Validate([]validation.Validation{
248		{TargetValue: serviceName,
249			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
250				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
251				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
252		{TargetValue: loggerid,
253			Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil},
254				{Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
255		return result, validation.NewError("apimanagement.LoggersClient", "Get", err.Error())
256	}
257
258	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, loggerid)
259	if err != nil {
260		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", nil, "Failure preparing request")
261		return
262	}
263
264	resp, err := client.GetSender(req)
265	if err != nil {
266		result.Response = autorest.Response{Response: resp}
267		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", resp, "Failure sending request")
268		return
269	}
270
271	result, err = client.GetResponder(resp)
272	if err != nil {
273		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", resp, "Failure responding to request")
274	}
275
276	return
277}
278
279// GetPreparer prepares the Get request.
280func (client LoggersClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerid string) (*http.Request, error) {
281	pathParameters := map[string]interface{}{
282		"loggerid":          autorest.Encode("path", loggerid),
283		"resourceGroupName": autorest.Encode("path", resourceGroupName),
284		"serviceName":       autorest.Encode("path", serviceName),
285		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
286	}
287
288	const APIVersion = "2016-10-10"
289	queryParameters := map[string]interface{}{
290		"api-version": APIVersion,
291	}
292
293	preparer := autorest.CreatePreparer(
294		autorest.AsGet(),
295		autorest.WithBaseURL(client.BaseURI),
296		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerid}", pathParameters),
297		autorest.WithQueryParameters(queryParameters))
298	return preparer.Prepare((&http.Request{}).WithContext(ctx))
299}
300
301// GetSender sends the Get request. The method will close the
302// http.Response Body if it receives an error.
303func (client LoggersClient) GetSender(req *http.Request) (*http.Response, error) {
304	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
305	return autorest.SendWithSender(client, req, sd...)
306}
307
308// GetResponder handles the response to the Get request. The method always
309// closes the http.Response Body.
310func (client LoggersClient) GetResponder(resp *http.Response) (result LoggerResponse, err error) {
311	err = autorest.Respond(
312		resp,
313		client.ByInspecting(),
314		azure.WithErrorUnlessStatusCode(http.StatusOK),
315		autorest.ByUnmarshallingJSON(&result),
316		autorest.ByClosing())
317	result.Response = autorest.Response{Response: resp}
318	return
319}
320
321// ListByService lists a collection of loggers in the specified service instance.
322// Parameters:
323// resourceGroupName - the name of the resource group.
324// serviceName - the name of the API Management service.
325// filter - | Field | Supported operators    | Supported functions                         |
326// |-------|------------------------|---------------------------------------------|
327// | id    | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
328// | type  | eq                     |                                             |
329// top - number of records to return.
330// skip - number of records to skip.
331func (client LoggersClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result LoggerCollectionPage, err error) {
332	if tracing.IsEnabled() {
333		ctx = tracing.StartSpan(ctx, fqdn+"/LoggersClient.ListByService")
334		defer func() {
335			sc := -1
336			if result.lc.Response.Response != nil {
337				sc = result.lc.Response.Response.StatusCode
338			}
339			tracing.EndSpan(ctx, sc, err)
340		}()
341	}
342	if err := validation.Validate([]validation.Validation{
343		{TargetValue: serviceName,
344			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
345				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
346				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
347		{TargetValue: top,
348			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
349				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
350		{TargetValue: skip,
351			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
352				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
353		return result, validation.NewError("apimanagement.LoggersClient", "ListByService", err.Error())
354	}
355
356	result.fn = client.listByServiceNextResults
357	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip)
358	if err != nil {
359		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", nil, "Failure preparing request")
360		return
361	}
362
363	resp, err := client.ListByServiceSender(req)
364	if err != nil {
365		result.lc.Response = autorest.Response{Response: resp}
366		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", resp, "Failure sending request")
367		return
368	}
369
370	result.lc, err = client.ListByServiceResponder(resp)
371	if err != nil {
372		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", resp, "Failure responding to request")
373	}
374
375	return
376}
377
378// ListByServicePreparer prepares the ListByService request.
379func (client LoggersClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) {
380	pathParameters := map[string]interface{}{
381		"resourceGroupName": autorest.Encode("path", resourceGroupName),
382		"serviceName":       autorest.Encode("path", serviceName),
383		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
384	}
385
386	const APIVersion = "2016-10-10"
387	queryParameters := map[string]interface{}{
388		"api-version": APIVersion,
389	}
390	if len(filter) > 0 {
391		queryParameters["$filter"] = autorest.Encode("query", filter)
392	}
393	if top != nil {
394		queryParameters["$top"] = autorest.Encode("query", *top)
395	}
396	if skip != nil {
397		queryParameters["$skip"] = autorest.Encode("query", *skip)
398	}
399
400	preparer := autorest.CreatePreparer(
401		autorest.AsGet(),
402		autorest.WithBaseURL(client.BaseURI),
403		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers", pathParameters),
404		autorest.WithQueryParameters(queryParameters))
405	return preparer.Prepare((&http.Request{}).WithContext(ctx))
406}
407
408// ListByServiceSender sends the ListByService request. The method will close the
409// http.Response Body if it receives an error.
410func (client LoggersClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
411	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
412	return autorest.SendWithSender(client, req, sd...)
413}
414
415// ListByServiceResponder handles the response to the ListByService request. The method always
416// closes the http.Response Body.
417func (client LoggersClient) ListByServiceResponder(resp *http.Response) (result LoggerCollection, err error) {
418	err = autorest.Respond(
419		resp,
420		client.ByInspecting(),
421		azure.WithErrorUnlessStatusCode(http.StatusOK),
422		autorest.ByUnmarshallingJSON(&result),
423		autorest.ByClosing())
424	result.Response = autorest.Response{Response: resp}
425	return
426}
427
428// listByServiceNextResults retrieves the next set of results, if any.
429func (client LoggersClient) listByServiceNextResults(ctx context.Context, lastResults LoggerCollection) (result LoggerCollection, err error) {
430	req, err := lastResults.loggerCollectionPreparer(ctx)
431	if err != nil {
432		return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "listByServiceNextResults", nil, "Failure preparing next results request")
433	}
434	if req == nil {
435		return
436	}
437	resp, err := client.ListByServiceSender(req)
438	if err != nil {
439		result.Response = autorest.Response{Response: resp}
440		return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "listByServiceNextResults", resp, "Failure sending next results request")
441	}
442	result, err = client.ListByServiceResponder(resp)
443	if err != nil {
444		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "listByServiceNextResults", resp, "Failure responding to next results request")
445	}
446	return
447}
448
449// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required.
450func (client LoggersClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result LoggerCollectionIterator, err error) {
451	if tracing.IsEnabled() {
452		ctx = tracing.StartSpan(ctx, fqdn+"/LoggersClient.ListByService")
453		defer func() {
454			sc := -1
455			if result.Response().Response.Response != nil {
456				sc = result.page.Response().Response.Response.StatusCode
457			}
458			tracing.EndSpan(ctx, sc, err)
459		}()
460	}
461	result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip)
462	return
463}
464
465// Update updates an existing logger.
466// Parameters:
467// resourceGroupName - the name of the resource group.
468// serviceName - the name of the API Management service.
469// loggerid - logger identifier. Must be unique in the API Management service instance.
470// parameters - update parameters.
471// ifMatch - the entity state (Etag) version of the logger to update. A value of "*" can be used for If-Match
472// to unconditionally apply the operation.
473func (client LoggersClient) Update(ctx context.Context, resourceGroupName string, serviceName string, loggerid string, parameters LoggerUpdateParameters, ifMatch string) (result autorest.Response, err error) {
474	if tracing.IsEnabled() {
475		ctx = tracing.StartSpan(ctx, fqdn+"/LoggersClient.Update")
476		defer func() {
477			sc := -1
478			if result.Response != nil {
479				sc = result.Response.StatusCode
480			}
481			tracing.EndSpan(ctx, sc, err)
482		}()
483	}
484	if err := validation.Validate([]validation.Validation{
485		{TargetValue: serviceName,
486			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
487				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
488				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
489		{TargetValue: loggerid,
490			Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil},
491				{Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
492		return result, validation.NewError("apimanagement.LoggersClient", "Update", err.Error())
493	}
494
495	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, loggerid, parameters, ifMatch)
496	if err != nil {
497		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", nil, "Failure preparing request")
498		return
499	}
500
501	resp, err := client.UpdateSender(req)
502	if err != nil {
503		result.Response = resp
504		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", resp, "Failure sending request")
505		return
506	}
507
508	result, err = client.UpdateResponder(resp)
509	if err != nil {
510		err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", resp, "Failure responding to request")
511	}
512
513	return
514}
515
516// UpdatePreparer prepares the Update request.
517func (client LoggersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerid string, parameters LoggerUpdateParameters, ifMatch string) (*http.Request, error) {
518	pathParameters := map[string]interface{}{
519		"loggerid":          autorest.Encode("path", loggerid),
520		"resourceGroupName": autorest.Encode("path", resourceGroupName),
521		"serviceName":       autorest.Encode("path", serviceName),
522		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
523	}
524
525	const APIVersion = "2016-10-10"
526	queryParameters := map[string]interface{}{
527		"api-version": APIVersion,
528	}
529
530	preparer := autorest.CreatePreparer(
531		autorest.AsContentType("application/json; charset=utf-8"),
532		autorest.AsPatch(),
533		autorest.WithBaseURL(client.BaseURI),
534		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerid}", pathParameters),
535		autorest.WithJSON(parameters),
536		autorest.WithQueryParameters(queryParameters),
537		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
538	return preparer.Prepare((&http.Request{}).WithContext(ctx))
539}
540
541// UpdateSender sends the Update request. The method will close the
542// http.Response Body if it receives an error.
543func (client LoggersClient) UpdateSender(req *http.Request) (*http.Response, error) {
544	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
545	return autorest.SendWithSender(client, req, sd...)
546}
547
548// UpdateResponder handles the response to the Update request. The method always
549// closes the http.Response Body.
550func (client LoggersClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
551	err = autorest.Respond(
552		resp,
553		client.ByInspecting(),
554		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
555		autorest.ByClosing())
556	result.Response = resp
557	return
558}
559