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