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// PortalRevisionClient is the apiManagement Client
19type PortalRevisionClient struct {
20	BaseClient
21}
22
23// NewPortalRevisionClient creates an instance of the PortalRevisionClient client.
24func NewPortalRevisionClient(subscriptionID string) PortalRevisionClient {
25	return NewPortalRevisionClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewPortalRevisionClientWithBaseURI creates an instance of the PortalRevisionClient client using a custom endpoint.
29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewPortalRevisionClientWithBaseURI(baseURI string, subscriptionID string) PortalRevisionClient {
31	return PortalRevisionClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate creates a new developer portal revision.
35// Parameters:
36// resourceGroupName - the name of the resource group.
37// serviceName - the name of the API Management service.
38// portalRevisionID - portal revision identifier. Must be unique in the current API Management service
39// instance.
40func (client PortalRevisionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract) (result PortalRevisionCreateOrUpdateFuture, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.CreateOrUpdate")
43		defer func() {
44			sc := -1
45			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46				sc = result.FutureAPI.Response().StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: serviceName,
53			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
54				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
55				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
56		{TargetValue: portalRevisionID,
57			Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil},
58				{Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
59		{TargetValue: parameters,
60			Constraints: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties", Name: validation.Null, Rule: false,
61				Chain: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties.Description", Name: validation.Null, Rule: false,
62					Chain: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties.Description", Name: validation.MaxLength, Rule: 2000, Chain: nil}}},
63					{Target: "parameters.PortalRevisionContractProperties.StatusDetails", Name: validation.Null, Rule: false,
64						Chain: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties.StatusDetails", Name: validation.MaxLength, Rule: 2000, Chain: nil}}},
65				}}}}}); err != nil {
66		return result, validation.NewError("apimanagement.PortalRevisionClient", "CreateOrUpdate", err.Error())
67	}
68
69	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, portalRevisionID, parameters)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "CreateOrUpdate", nil, "Failure preparing request")
72		return
73	}
74
75	result, err = client.CreateOrUpdateSender(req)
76	if err != nil {
77		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "CreateOrUpdate", nil, "Failure sending request")
78		return
79	}
80
81	return
82}
83
84// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
85func (client PortalRevisionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract) (*http.Request, error) {
86	pathParameters := map[string]interface{}{
87		"portalRevisionId":  autorest.Encode("path", portalRevisionID),
88		"resourceGroupName": autorest.Encode("path", resourceGroupName),
89		"serviceName":       autorest.Encode("path", serviceName),
90		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
91	}
92
93	const APIVersion = "2020-12-01"
94	queryParameters := map[string]interface{}{
95		"api-version": APIVersion,
96	}
97
98	preparer := autorest.CreatePreparer(
99		autorest.AsContentType("application/json; charset=utf-8"),
100		autorest.AsPut(),
101		autorest.WithBaseURL(client.BaseURI),
102		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters),
103		autorest.WithJSON(parameters),
104		autorest.WithQueryParameters(queryParameters))
105	return preparer.Prepare((&http.Request{}).WithContext(ctx))
106}
107
108// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
109// http.Response Body if it receives an error.
110func (client PortalRevisionClient) CreateOrUpdateSender(req *http.Request) (future PortalRevisionCreateOrUpdateFuture, err error) {
111	var resp *http.Response
112	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
113	if err != nil {
114		return
115	}
116	var azf azure.Future
117	azf, err = azure.NewFutureFromResponse(resp)
118	future.FutureAPI = &azf
119	future.Result = future.result
120	return
121}
122
123// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
124// closes the http.Response Body.
125func (client PortalRevisionClient) CreateOrUpdateResponder(resp *http.Response) (result PortalRevisionContract, err error) {
126	err = autorest.Respond(
127		resp,
128		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
129		autorest.ByUnmarshallingJSON(&result),
130		autorest.ByClosing())
131	result.Response = autorest.Response{Response: resp}
132	return
133}
134
135// Get gets developer portal revision specified by its identifier.
136// Parameters:
137// resourceGroupName - the name of the resource group.
138// serviceName - the name of the API Management service.
139// portalRevisionID - portal revision identifier. Must be unique in the current API Management service
140// instance.
141func (client PortalRevisionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (result PortalRevisionContract, err error) {
142	if tracing.IsEnabled() {
143		ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.Get")
144		defer func() {
145			sc := -1
146			if result.Response.Response != nil {
147				sc = result.Response.Response.StatusCode
148			}
149			tracing.EndSpan(ctx, sc, err)
150		}()
151	}
152	if err := validation.Validate([]validation.Validation{
153		{TargetValue: serviceName,
154			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
155				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
156				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
157		{TargetValue: portalRevisionID,
158			Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil},
159				{Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
160		return result, validation.NewError("apimanagement.PortalRevisionClient", "Get", err.Error())
161	}
162
163	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, portalRevisionID)
164	if err != nil {
165		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Get", nil, "Failure preparing request")
166		return
167	}
168
169	resp, err := client.GetSender(req)
170	if err != nil {
171		result.Response = autorest.Response{Response: resp}
172		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Get", resp, "Failure sending request")
173		return
174	}
175
176	result, err = client.GetResponder(resp)
177	if err != nil {
178		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Get", resp, "Failure responding to request")
179		return
180	}
181
182	return
183}
184
185// GetPreparer prepares the Get request.
186func (client PortalRevisionClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (*http.Request, error) {
187	pathParameters := map[string]interface{}{
188		"portalRevisionId":  autorest.Encode("path", portalRevisionID),
189		"resourceGroupName": autorest.Encode("path", resourceGroupName),
190		"serviceName":       autorest.Encode("path", serviceName),
191		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
192	}
193
194	const APIVersion = "2020-12-01"
195	queryParameters := map[string]interface{}{
196		"api-version": APIVersion,
197	}
198
199	preparer := autorest.CreatePreparer(
200		autorest.AsGet(),
201		autorest.WithBaseURL(client.BaseURI),
202		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters),
203		autorest.WithQueryParameters(queryParameters))
204	return preparer.Prepare((&http.Request{}).WithContext(ctx))
205}
206
207// GetSender sends the Get request. The method will close the
208// http.Response Body if it receives an error.
209func (client PortalRevisionClient) GetSender(req *http.Request) (*http.Response, error) {
210	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
211}
212
213// GetResponder handles the response to the Get request. The method always
214// closes the http.Response Body.
215func (client PortalRevisionClient) GetResponder(resp *http.Response) (result PortalRevisionContract, 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// GetEntityTag gets developer portal revision specified by its identifier.
226// Parameters:
227// resourceGroupName - the name of the resource group.
228// serviceName - the name of the API Management service.
229// portalRevisionID - portal revision identifier. Must be unique in the current API Management service
230// instance.
231func (client PortalRevisionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (result autorest.Response, err error) {
232	if tracing.IsEnabled() {
233		ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.GetEntityTag")
234		defer func() {
235			sc := -1
236			if result.Response != nil {
237				sc = result.Response.StatusCode
238			}
239			tracing.EndSpan(ctx, sc, err)
240		}()
241	}
242	if err := validation.Validate([]validation.Validation{
243		{TargetValue: serviceName,
244			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
245				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
246				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
247		{TargetValue: portalRevisionID,
248			Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil},
249				{Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
250		return result, validation.NewError("apimanagement.PortalRevisionClient", "GetEntityTag", err.Error())
251	}
252
253	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, portalRevisionID)
254	if err != nil {
255		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "GetEntityTag", nil, "Failure preparing request")
256		return
257	}
258
259	resp, err := client.GetEntityTagSender(req)
260	if err != nil {
261		result.Response = resp
262		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "GetEntityTag", resp, "Failure sending request")
263		return
264	}
265
266	result, err = client.GetEntityTagResponder(resp)
267	if err != nil {
268		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "GetEntityTag", resp, "Failure responding to request")
269		return
270	}
271
272	return
273}
274
275// GetEntityTagPreparer prepares the GetEntityTag request.
276func (client PortalRevisionClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (*http.Request, error) {
277	pathParameters := map[string]interface{}{
278		"portalRevisionId":  autorest.Encode("path", portalRevisionID),
279		"resourceGroupName": autorest.Encode("path", resourceGroupName),
280		"serviceName":       autorest.Encode("path", serviceName),
281		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
282	}
283
284	const APIVersion = "2020-12-01"
285	queryParameters := map[string]interface{}{
286		"api-version": APIVersion,
287	}
288
289	preparer := autorest.CreatePreparer(
290		autorest.AsHead(),
291		autorest.WithBaseURL(client.BaseURI),
292		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters),
293		autorest.WithQueryParameters(queryParameters))
294	return preparer.Prepare((&http.Request{}).WithContext(ctx))
295}
296
297// GetEntityTagSender sends the GetEntityTag request. The method will close the
298// http.Response Body if it receives an error.
299func (client PortalRevisionClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
300	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
301}
302
303// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
304// closes the http.Response Body.
305func (client PortalRevisionClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
306	err = autorest.Respond(
307		resp,
308		azure.WithErrorUnlessStatusCode(http.StatusOK),
309		autorest.ByClosing())
310	result.Response = resp
311	return
312}
313
314// ListByService lists a collection of developer portal revision entities.
315// Parameters:
316// resourceGroupName - the name of the resource group.
317// serviceName - the name of the API Management service.
318// filter - | Field       | Supported operators    | Supported functions               |
319// |-------------|------------------------|-----------------------------------|
320//
321// |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith|
322// |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith|
323// |isCurrent | eq, ne |    |
324// top - number of records to return.
325// skip - number of records to skip.
326func (client PortalRevisionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PortalRevisionCollectionPage, err error) {
327	if tracing.IsEnabled() {
328		ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.ListByService")
329		defer func() {
330			sc := -1
331			if result.prc.Response.Response != nil {
332				sc = result.prc.Response.Response.StatusCode
333			}
334			tracing.EndSpan(ctx, sc, err)
335		}()
336	}
337	if err := validation.Validate([]validation.Validation{
338		{TargetValue: serviceName,
339			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
340				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
341				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
342		{TargetValue: top,
343			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
344				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
345		{TargetValue: skip,
346			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
347				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
348		return result, validation.NewError("apimanagement.PortalRevisionClient", "ListByService", err.Error())
349	}
350
351	result.fn = client.listByServiceNextResults
352	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip)
353	if err != nil {
354		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "ListByService", nil, "Failure preparing request")
355		return
356	}
357
358	resp, err := client.ListByServiceSender(req)
359	if err != nil {
360		result.prc.Response = autorest.Response{Response: resp}
361		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "ListByService", resp, "Failure sending request")
362		return
363	}
364
365	result.prc, err = client.ListByServiceResponder(resp)
366	if err != nil {
367		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "ListByService", resp, "Failure responding to request")
368		return
369	}
370	if result.prc.hasNextLink() && result.prc.IsEmpty() {
371		err = result.NextWithContext(ctx)
372		return
373	}
374
375	return
376}
377
378// ListByServicePreparer prepares the ListByService request.
379func (client PortalRevisionClient) 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 = "2020-12-01"
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}/portalRevisions", 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 PortalRevisionClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
411	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
412}
413
414// ListByServiceResponder handles the response to the ListByService request. The method always
415// closes the http.Response Body.
416func (client PortalRevisionClient) ListByServiceResponder(resp *http.Response) (result PortalRevisionCollection, err error) {
417	err = autorest.Respond(
418		resp,
419		azure.WithErrorUnlessStatusCode(http.StatusOK),
420		autorest.ByUnmarshallingJSON(&result),
421		autorest.ByClosing())
422	result.Response = autorest.Response{Response: resp}
423	return
424}
425
426// listByServiceNextResults retrieves the next set of results, if any.
427func (client PortalRevisionClient) listByServiceNextResults(ctx context.Context, lastResults PortalRevisionCollection) (result PortalRevisionCollection, err error) {
428	req, err := lastResults.portalRevisionCollectionPreparer(ctx)
429	if err != nil {
430		return result, autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "listByServiceNextResults", nil, "Failure preparing next results request")
431	}
432	if req == nil {
433		return
434	}
435	resp, err := client.ListByServiceSender(req)
436	if err != nil {
437		result.Response = autorest.Response{Response: resp}
438		return result, autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "listByServiceNextResults", resp, "Failure sending next results request")
439	}
440	result, err = client.ListByServiceResponder(resp)
441	if err != nil {
442		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "listByServiceNextResults", resp, "Failure responding to next results request")
443	}
444	return
445}
446
447// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required.
448func (client PortalRevisionClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PortalRevisionCollectionIterator, err error) {
449	if tracing.IsEnabled() {
450		ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.ListByService")
451		defer func() {
452			sc := -1
453			if result.Response().Response.Response != nil {
454				sc = result.page.Response().Response.Response.StatusCode
455			}
456			tracing.EndSpan(ctx, sc, err)
457		}()
458	}
459	result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip)
460	return
461}
462
463// Update updates the description of specified portal revision or makes it current.
464// Parameters:
465// resourceGroupName - the name of the resource group.
466// serviceName - the name of the API Management service.
467// portalRevisionID - portal revision identifier. Must be unique in the current API Management service
468// instance.
469// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
470// request or it should be * for unconditional update.
471func (client PortalRevisionClient) Update(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, ifMatch string) (result PortalRevisionUpdateFuture, err error) {
472	if tracing.IsEnabled() {
473		ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.Update")
474		defer func() {
475			sc := -1
476			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
477				sc = result.FutureAPI.Response().StatusCode
478			}
479			tracing.EndSpan(ctx, sc, err)
480		}()
481	}
482	if err := validation.Validate([]validation.Validation{
483		{TargetValue: serviceName,
484			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
485				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
486				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
487		{TargetValue: portalRevisionID,
488			Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil},
489				{Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
490		return result, validation.NewError("apimanagement.PortalRevisionClient", "Update", err.Error())
491	}
492
493	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, portalRevisionID, parameters, ifMatch)
494	if err != nil {
495		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Update", nil, "Failure preparing request")
496		return
497	}
498
499	result, err = client.UpdateSender(req)
500	if err != nil {
501		err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Update", nil, "Failure sending request")
502		return
503	}
504
505	return
506}
507
508// UpdatePreparer prepares the Update request.
509func (client PortalRevisionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, ifMatch string) (*http.Request, error) {
510	pathParameters := map[string]interface{}{
511		"portalRevisionId":  autorest.Encode("path", portalRevisionID),
512		"resourceGroupName": autorest.Encode("path", resourceGroupName),
513		"serviceName":       autorest.Encode("path", serviceName),
514		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
515	}
516
517	const APIVersion = "2020-12-01"
518	queryParameters := map[string]interface{}{
519		"api-version": APIVersion,
520	}
521
522	preparer := autorest.CreatePreparer(
523		autorest.AsContentType("application/json; charset=utf-8"),
524		autorest.AsPatch(),
525		autorest.WithBaseURL(client.BaseURI),
526		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters),
527		autorest.WithJSON(parameters),
528		autorest.WithQueryParameters(queryParameters),
529		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
530	return preparer.Prepare((&http.Request{}).WithContext(ctx))
531}
532
533// UpdateSender sends the Update request. The method will close the
534// http.Response Body if it receives an error.
535func (client PortalRevisionClient) UpdateSender(req *http.Request) (future PortalRevisionUpdateFuture, err error) {
536	var resp *http.Response
537	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
538	if err != nil {
539		return
540	}
541	var azf azure.Future
542	azf, err = azure.NewFutureFromResponse(resp)
543	future.FutureAPI = &azf
544	future.Result = future.result
545	return
546}
547
548// UpdateResponder handles the response to the Update request. The method always
549// closes the http.Response Body.
550func (client PortalRevisionClient) UpdateResponder(resp *http.Response) (result PortalRevisionContract, err error) {
551	err = autorest.Respond(
552		resp,
553		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
554		autorest.ByUnmarshallingJSON(&result),
555		autorest.ByClosing())
556	result.Response = autorest.Response{Response: resp}
557	return
558}
559