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// PropertyClient is the apiManagement Client
30type PropertyClient struct {
31	BaseClient
32}
33
34// NewPropertyClient creates an instance of the PropertyClient client.
35func NewPropertyClient(subscriptionID string) PropertyClient {
36	return NewPropertyClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewPropertyClientWithBaseURI creates an instance of the PropertyClient client using a custom endpoint.  Use this
40// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
41func NewPropertyClientWithBaseURI(baseURI string, subscriptionID string) PropertyClient {
42	return PropertyClient{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// CreateOrUpdate creates or updates a property.
46// Parameters:
47// resourceGroupName - the name of the resource group.
48// serviceName - the name of the API Management service.
49// propID - identifier of the property.
50// parameters - create parameters.
51// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity.
52func (client PropertyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, propID string, parameters PropertyContract, ifMatch string) (result PropertyContract, err error) {
53	if tracing.IsEnabled() {
54		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.CreateOrUpdate")
55		defer func() {
56			sc := -1
57			if result.Response.Response != nil {
58				sc = result.Response.Response.StatusCode
59			}
60			tracing.EndSpan(ctx, sc, err)
61		}()
62	}
63	if err := validation.Validate([]validation.Validation{
64		{TargetValue: serviceName,
65			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
66				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
67				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
68		{TargetValue: propID,
69			Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 80, Chain: nil},
70				{Target: "propID", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}},
71		{TargetValue: parameters,
72			Constraints: []validation.Constraint{{Target: "parameters.PropertyContractProperties", Name: validation.Null, Rule: false,
73				Chain: []validation.Constraint{{Target: "parameters.PropertyContractProperties.DisplayName", Name: validation.Null, Rule: true,
74					Chain: []validation.Constraint{{Target: "parameters.PropertyContractProperties.DisplayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
75						{Target: "parameters.PropertyContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil},
76						{Target: "parameters.PropertyContractProperties.DisplayName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-._]+$`, Chain: nil},
77					}},
78					{Target: "parameters.PropertyContractProperties.Value", Name: validation.Null, Rule: true,
79						Chain: []validation.Constraint{{Target: "parameters.PropertyContractProperties.Value", Name: validation.MaxLength, Rule: 4096, Chain: nil},
80							{Target: "parameters.PropertyContractProperties.Value", Name: validation.MinLength, Rule: 1, Chain: nil},
81						}},
82				}}}}}); err != nil {
83		return result, validation.NewError("apimanagement.PropertyClient", "CreateOrUpdate", err.Error())
84	}
85
86	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, propID, parameters, ifMatch)
87	if err != nil {
88		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", nil, "Failure preparing request")
89		return
90	}
91
92	resp, err := client.CreateOrUpdateSender(req)
93	if err != nil {
94		result.Response = autorest.Response{Response: resp}
95		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", resp, "Failure sending request")
96		return
97	}
98
99	result, err = client.CreateOrUpdateResponder(resp)
100	if err != nil {
101		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", resp, "Failure responding to request")
102	}
103
104	return
105}
106
107// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
108func (client PropertyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, propID string, parameters PropertyContract, ifMatch string) (*http.Request, error) {
109	pathParameters := map[string]interface{}{
110		"propId":            autorest.Encode("path", propID),
111		"resourceGroupName": autorest.Encode("path", resourceGroupName),
112		"serviceName":       autorest.Encode("path", serviceName),
113		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
114	}
115
116	const APIVersion = "2018-01-01"
117	queryParameters := map[string]interface{}{
118		"api-version": APIVersion,
119	}
120
121	preparer := autorest.CreatePreparer(
122		autorest.AsContentType("application/json; charset=utf-8"),
123		autorest.AsPut(),
124		autorest.WithBaseURL(client.BaseURI),
125		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties/{propId}", pathParameters),
126		autorest.WithJSON(parameters),
127		autorest.WithQueryParameters(queryParameters))
128	if len(ifMatch) > 0 {
129		preparer = autorest.DecoratePreparer(preparer,
130			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
131	}
132	return preparer.Prepare((&http.Request{}).WithContext(ctx))
133}
134
135// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
136// http.Response Body if it receives an error.
137func (client PropertyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
138	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
139}
140
141// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
142// closes the http.Response Body.
143func (client PropertyClient) CreateOrUpdateResponder(resp *http.Response) (result PropertyContract, err error) {
144	err = autorest.Respond(
145		resp,
146		client.ByInspecting(),
147		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
148		autorest.ByUnmarshallingJSON(&result),
149		autorest.ByClosing())
150	result.Response = autorest.Response{Response: resp}
151	return
152}
153
154// Delete deletes specific property from the API Management service instance.
155// Parameters:
156// resourceGroupName - the name of the resource group.
157// serviceName - the name of the API Management service.
158// propID - identifier of the property.
159// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
160// request or it should be * for unconditional update.
161func (client PropertyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, propID string, ifMatch string) (result autorest.Response, err error) {
162	if tracing.IsEnabled() {
163		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.Delete")
164		defer func() {
165			sc := -1
166			if result.Response != nil {
167				sc = result.Response.StatusCode
168			}
169			tracing.EndSpan(ctx, sc, err)
170		}()
171	}
172	if err := validation.Validate([]validation.Validation{
173		{TargetValue: serviceName,
174			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
175				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
176				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
177		{TargetValue: propID,
178			Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 80, Chain: nil},
179				{Target: "propID", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}}}); err != nil {
180		return result, validation.NewError("apimanagement.PropertyClient", "Delete", err.Error())
181	}
182
183	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, propID, ifMatch)
184	if err != nil {
185		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", nil, "Failure preparing request")
186		return
187	}
188
189	resp, err := client.DeleteSender(req)
190	if err != nil {
191		result.Response = resp
192		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", resp, "Failure sending request")
193		return
194	}
195
196	result, err = client.DeleteResponder(resp)
197	if err != nil {
198		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", resp, "Failure responding to request")
199	}
200
201	return
202}
203
204// DeletePreparer prepares the Delete request.
205func (client PropertyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, propID string, ifMatch string) (*http.Request, error) {
206	pathParameters := map[string]interface{}{
207		"propId":            autorest.Encode("path", propID),
208		"resourceGroupName": autorest.Encode("path", resourceGroupName),
209		"serviceName":       autorest.Encode("path", serviceName),
210		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
211	}
212
213	const APIVersion = "2018-01-01"
214	queryParameters := map[string]interface{}{
215		"api-version": APIVersion,
216	}
217
218	preparer := autorest.CreatePreparer(
219		autorest.AsDelete(),
220		autorest.WithBaseURL(client.BaseURI),
221		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties/{propId}", pathParameters),
222		autorest.WithQueryParameters(queryParameters),
223		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
224	return preparer.Prepare((&http.Request{}).WithContext(ctx))
225}
226
227// DeleteSender sends the Delete request. The method will close the
228// http.Response Body if it receives an error.
229func (client PropertyClient) DeleteSender(req *http.Request) (*http.Response, error) {
230	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
231}
232
233// DeleteResponder handles the response to the Delete request. The method always
234// closes the http.Response Body.
235func (client PropertyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
236	err = autorest.Respond(
237		resp,
238		client.ByInspecting(),
239		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
240		autorest.ByClosing())
241	result.Response = resp
242	return
243}
244
245// Get gets the details of the property specified by its identifier.
246// Parameters:
247// resourceGroupName - the name of the resource group.
248// serviceName - the name of the API Management service.
249// propID - identifier of the property.
250func (client PropertyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, propID string) (result PropertyContract, err error) {
251	if tracing.IsEnabled() {
252		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.Get")
253		defer func() {
254			sc := -1
255			if result.Response.Response != nil {
256				sc = result.Response.Response.StatusCode
257			}
258			tracing.EndSpan(ctx, sc, err)
259		}()
260	}
261	if err := validation.Validate([]validation.Validation{
262		{TargetValue: serviceName,
263			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
264				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
265				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
266		{TargetValue: propID,
267			Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 80, Chain: nil},
268				{Target: "propID", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}}}); err != nil {
269		return result, validation.NewError("apimanagement.PropertyClient", "Get", err.Error())
270	}
271
272	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, propID)
273	if err != nil {
274		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", nil, "Failure preparing request")
275		return
276	}
277
278	resp, err := client.GetSender(req)
279	if err != nil {
280		result.Response = autorest.Response{Response: resp}
281		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", resp, "Failure sending request")
282		return
283	}
284
285	result, err = client.GetResponder(resp)
286	if err != nil {
287		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", resp, "Failure responding to request")
288	}
289
290	return
291}
292
293// GetPreparer prepares the Get request.
294func (client PropertyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, propID string) (*http.Request, error) {
295	pathParameters := map[string]interface{}{
296		"propId":            autorest.Encode("path", propID),
297		"resourceGroupName": autorest.Encode("path", resourceGroupName),
298		"serviceName":       autorest.Encode("path", serviceName),
299		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
300	}
301
302	const APIVersion = "2018-01-01"
303	queryParameters := map[string]interface{}{
304		"api-version": APIVersion,
305	}
306
307	preparer := autorest.CreatePreparer(
308		autorest.AsGet(),
309		autorest.WithBaseURL(client.BaseURI),
310		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties/{propId}", pathParameters),
311		autorest.WithQueryParameters(queryParameters))
312	return preparer.Prepare((&http.Request{}).WithContext(ctx))
313}
314
315// GetSender sends the Get request. The method will close the
316// http.Response Body if it receives an error.
317func (client PropertyClient) GetSender(req *http.Request) (*http.Response, error) {
318	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
319}
320
321// GetResponder handles the response to the Get request. The method always
322// closes the http.Response Body.
323func (client PropertyClient) GetResponder(resp *http.Response) (result PropertyContract, err error) {
324	err = autorest.Respond(
325		resp,
326		client.ByInspecting(),
327		azure.WithErrorUnlessStatusCode(http.StatusOK),
328		autorest.ByUnmarshallingJSON(&result),
329		autorest.ByClosing())
330	result.Response = autorest.Response{Response: resp}
331	return
332}
333
334// GetEntityTag gets the entity state (Etag) version of the property specified by its identifier.
335// Parameters:
336// resourceGroupName - the name of the resource group.
337// serviceName - the name of the API Management service.
338// propID - identifier of the property.
339func (client PropertyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, propID string) (result autorest.Response, err error) {
340	if tracing.IsEnabled() {
341		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.GetEntityTag")
342		defer func() {
343			sc := -1
344			if result.Response != nil {
345				sc = result.Response.StatusCode
346			}
347			tracing.EndSpan(ctx, sc, err)
348		}()
349	}
350	if err := validation.Validate([]validation.Validation{
351		{TargetValue: serviceName,
352			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
353				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
354				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
355		{TargetValue: propID,
356			Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 80, Chain: nil},
357				{Target: "propID", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}}}); err != nil {
358		return result, validation.NewError("apimanagement.PropertyClient", "GetEntityTag", err.Error())
359	}
360
361	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, propID)
362	if err != nil {
363		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "GetEntityTag", nil, "Failure preparing request")
364		return
365	}
366
367	resp, err := client.GetEntityTagSender(req)
368	if err != nil {
369		result.Response = resp
370		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "GetEntityTag", resp, "Failure sending request")
371		return
372	}
373
374	result, err = client.GetEntityTagResponder(resp)
375	if err != nil {
376		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "GetEntityTag", resp, "Failure responding to request")
377	}
378
379	return
380}
381
382// GetEntityTagPreparer prepares the GetEntityTag request.
383func (client PropertyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, propID string) (*http.Request, error) {
384	pathParameters := map[string]interface{}{
385		"propId":            autorest.Encode("path", propID),
386		"resourceGroupName": autorest.Encode("path", resourceGroupName),
387		"serviceName":       autorest.Encode("path", serviceName),
388		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
389	}
390
391	const APIVersion = "2018-01-01"
392	queryParameters := map[string]interface{}{
393		"api-version": APIVersion,
394	}
395
396	preparer := autorest.CreatePreparer(
397		autorest.AsHead(),
398		autorest.WithBaseURL(client.BaseURI),
399		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties/{propId}", pathParameters),
400		autorest.WithQueryParameters(queryParameters))
401	return preparer.Prepare((&http.Request{}).WithContext(ctx))
402}
403
404// GetEntityTagSender sends the GetEntityTag request. The method will close the
405// http.Response Body if it receives an error.
406func (client PropertyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
407	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
408}
409
410// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
411// closes the http.Response Body.
412func (client PropertyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
413	err = autorest.Respond(
414		resp,
415		client.ByInspecting(),
416		azure.WithErrorUnlessStatusCode(http.StatusOK),
417		autorest.ByClosing())
418	result.Response = resp
419	return
420}
421
422// ListByService lists a collection of properties defined within a service instance.
423// Parameters:
424// resourceGroupName - the name of the resource group.
425// serviceName - the name of the API Management service.
426// filter - | Field | Supported operators    | Supported functions                                   |
427// |-------|------------------------|-------------------------------------------------------|
428// | tags  | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
429// | name  | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith           |
430// top - number of records to return.
431// skip - number of records to skip.
432func (client PropertyClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PropertyCollectionPage, err error) {
433	if tracing.IsEnabled() {
434		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.ListByService")
435		defer func() {
436			sc := -1
437			if result.pc.Response.Response != nil {
438				sc = result.pc.Response.Response.StatusCode
439			}
440			tracing.EndSpan(ctx, sc, err)
441		}()
442	}
443	if err := validation.Validate([]validation.Validation{
444		{TargetValue: serviceName,
445			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
446				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
447				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
448		{TargetValue: top,
449			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
450				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
451		{TargetValue: skip,
452			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
453				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
454		return result, validation.NewError("apimanagement.PropertyClient", "ListByService", err.Error())
455	}
456
457	result.fn = client.listByServiceNextResults
458	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip)
459	if err != nil {
460		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", nil, "Failure preparing request")
461		return
462	}
463
464	resp, err := client.ListByServiceSender(req)
465	if err != nil {
466		result.pc.Response = autorest.Response{Response: resp}
467		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", resp, "Failure sending request")
468		return
469	}
470
471	result.pc, err = client.ListByServiceResponder(resp)
472	if err != nil {
473		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", resp, "Failure responding to request")
474	}
475
476	return
477}
478
479// ListByServicePreparer prepares the ListByService request.
480func (client PropertyClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) {
481	pathParameters := map[string]interface{}{
482		"resourceGroupName": autorest.Encode("path", resourceGroupName),
483		"serviceName":       autorest.Encode("path", serviceName),
484		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
485	}
486
487	const APIVersion = "2018-01-01"
488	queryParameters := map[string]interface{}{
489		"api-version": APIVersion,
490	}
491	if len(filter) > 0 {
492		queryParameters["$filter"] = autorest.Encode("query", filter)
493	}
494	if top != nil {
495		queryParameters["$top"] = autorest.Encode("query", *top)
496	}
497	if skip != nil {
498		queryParameters["$skip"] = autorest.Encode("query", *skip)
499	}
500
501	preparer := autorest.CreatePreparer(
502		autorest.AsGet(),
503		autorest.WithBaseURL(client.BaseURI),
504		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties", pathParameters),
505		autorest.WithQueryParameters(queryParameters))
506	return preparer.Prepare((&http.Request{}).WithContext(ctx))
507}
508
509// ListByServiceSender sends the ListByService request. The method will close the
510// http.Response Body if it receives an error.
511func (client PropertyClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
512	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
513}
514
515// ListByServiceResponder handles the response to the ListByService request. The method always
516// closes the http.Response Body.
517func (client PropertyClient) ListByServiceResponder(resp *http.Response) (result PropertyCollection, err error) {
518	err = autorest.Respond(
519		resp,
520		client.ByInspecting(),
521		azure.WithErrorUnlessStatusCode(http.StatusOK),
522		autorest.ByUnmarshallingJSON(&result),
523		autorest.ByClosing())
524	result.Response = autorest.Response{Response: resp}
525	return
526}
527
528// listByServiceNextResults retrieves the next set of results, if any.
529func (client PropertyClient) listByServiceNextResults(ctx context.Context, lastResults PropertyCollection) (result PropertyCollection, err error) {
530	req, err := lastResults.propertyCollectionPreparer(ctx)
531	if err != nil {
532		return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "listByServiceNextResults", nil, "Failure preparing next results request")
533	}
534	if req == nil {
535		return
536	}
537	resp, err := client.ListByServiceSender(req)
538	if err != nil {
539		result.Response = autorest.Response{Response: resp}
540		return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "listByServiceNextResults", resp, "Failure sending next results request")
541	}
542	result, err = client.ListByServiceResponder(resp)
543	if err != nil {
544		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "listByServiceNextResults", resp, "Failure responding to next results request")
545	}
546	return
547}
548
549// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required.
550func (client PropertyClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PropertyCollectionIterator, err error) {
551	if tracing.IsEnabled() {
552		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.ListByService")
553		defer func() {
554			sc := -1
555			if result.Response().Response.Response != nil {
556				sc = result.page.Response().Response.Response.StatusCode
557			}
558			tracing.EndSpan(ctx, sc, err)
559		}()
560	}
561	result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip)
562	return
563}
564
565// Update updates the specific property.
566// Parameters:
567// resourceGroupName - the name of the resource group.
568// serviceName - the name of the API Management service.
569// propID - identifier of the property.
570// parameters - update parameters.
571// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
572// request or it should be * for unconditional update.
573func (client PropertyClient) Update(ctx context.Context, resourceGroupName string, serviceName string, propID string, parameters PropertyUpdateParameters, ifMatch string) (result autorest.Response, err error) {
574	if tracing.IsEnabled() {
575		ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.Update")
576		defer func() {
577			sc := -1
578			if result.Response != nil {
579				sc = result.Response.StatusCode
580			}
581			tracing.EndSpan(ctx, sc, err)
582		}()
583	}
584	if err := validation.Validate([]validation.Validation{
585		{TargetValue: serviceName,
586			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
587				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
588				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
589		{TargetValue: propID,
590			Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 80, Chain: nil},
591				{Target: "propID", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}}}); err != nil {
592		return result, validation.NewError("apimanagement.PropertyClient", "Update", err.Error())
593	}
594
595	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, propID, parameters, ifMatch)
596	if err != nil {
597		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", nil, "Failure preparing request")
598		return
599	}
600
601	resp, err := client.UpdateSender(req)
602	if err != nil {
603		result.Response = resp
604		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", resp, "Failure sending request")
605		return
606	}
607
608	result, err = client.UpdateResponder(resp)
609	if err != nil {
610		err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", resp, "Failure responding to request")
611	}
612
613	return
614}
615
616// UpdatePreparer prepares the Update request.
617func (client PropertyClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, propID string, parameters PropertyUpdateParameters, ifMatch string) (*http.Request, error) {
618	pathParameters := map[string]interface{}{
619		"propId":            autorest.Encode("path", propID),
620		"resourceGroupName": autorest.Encode("path", resourceGroupName),
621		"serviceName":       autorest.Encode("path", serviceName),
622		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
623	}
624
625	const APIVersion = "2018-01-01"
626	queryParameters := map[string]interface{}{
627		"api-version": APIVersion,
628	}
629
630	preparer := autorest.CreatePreparer(
631		autorest.AsContentType("application/json; charset=utf-8"),
632		autorest.AsPatch(),
633		autorest.WithBaseURL(client.BaseURI),
634		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties/{propId}", pathParameters),
635		autorest.WithJSON(parameters),
636		autorest.WithQueryParameters(queryParameters),
637		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
638	return preparer.Prepare((&http.Request{}).WithContext(ctx))
639}
640
641// UpdateSender sends the Update request. The method will close the
642// http.Response Body if it receives an error.
643func (client PropertyClient) UpdateSender(req *http.Request) (*http.Response, error) {
644	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
645}
646
647// UpdateResponder handles the response to the Update request. The method always
648// closes the http.Response Body.
649func (client PropertyClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
650	err = autorest.Respond(
651		resp,
652		client.ByInspecting(),
653		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
654		autorest.ByClosing())
655	result.Response = resp
656	return
657}
658