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