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// OpenIDConnectProviderClient is the apiManagement Client
30type OpenIDConnectProviderClient struct {
31	BaseClient
32}
33
34// NewOpenIDConnectProviderClient creates an instance of the OpenIDConnectProviderClient client.
35func NewOpenIDConnectProviderClient(subscriptionID string) OpenIDConnectProviderClient {
36	return NewOpenIDConnectProviderClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewOpenIDConnectProviderClientWithBaseURI creates an instance of the OpenIDConnectProviderClient 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 NewOpenIDConnectProviderClientWithBaseURI(baseURI string, subscriptionID string) OpenIDConnectProviderClient {
43	return OpenIDConnectProviderClient{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.
52// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity.
53func (client OpenIDConnectProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderContract, ifMatch string) (result OpenidConnectProviderContract, err error) {
54	if tracing.IsEnabled() {
55		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.CreateOrUpdate")
56		defer func() {
57			sc := -1
58			if result.Response.Response != nil {
59				sc = result.Response.Response.StatusCode
60			}
61			tracing.EndSpan(ctx, sc, err)
62		}()
63	}
64	if err := validation.Validate([]validation.Validation{
65		{TargetValue: serviceName,
66			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
67				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
68				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
69		{TargetValue: opid,
70			Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil},
71				{Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
72		{TargetValue: parameters,
73			Constraints: []validation.Constraint{{Target: "parameters.OpenidConnectProviderContractProperties", Name: validation.Null, Rule: false,
74				Chain: []validation.Constraint{{Target: "parameters.OpenidConnectProviderContractProperties.DisplayName", Name: validation.Null, Rule: true,
75					Chain: []validation.Constraint{{Target: "parameters.OpenidConnectProviderContractProperties.DisplayName", Name: validation.MaxLength, Rule: 50, Chain: nil}}},
76					{Target: "parameters.OpenidConnectProviderContractProperties.MetadataEndpoint", Name: validation.Null, Rule: true, Chain: nil},
77					{Target: "parameters.OpenidConnectProviderContractProperties.ClientID", Name: validation.Null, Rule: true, Chain: nil},
78				}}}}}); err != nil {
79		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", err.Error())
80	}
81
82	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, opid, parameters, ifMatch)
83	if err != nil {
84		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", nil, "Failure preparing request")
85		return
86	}
87
88	resp, err := client.CreateOrUpdateSender(req)
89	if err != nil {
90		result.Response = autorest.Response{Response: resp}
91		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", resp, "Failure sending request")
92		return
93	}
94
95	result, err = client.CreateOrUpdateResponder(resp)
96	if err != nil {
97		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", resp, "Failure responding to request")
98		return
99	}
100
101	return
102}
103
104// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
105func (client OpenIDConnectProviderClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderContract, ifMatch string) (*http.Request, error) {
106	pathParameters := map[string]interface{}{
107		"opid":              autorest.Encode("path", opid),
108		"resourceGroupName": autorest.Encode("path", resourceGroupName),
109		"serviceName":       autorest.Encode("path", serviceName),
110		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
111	}
112
113	const APIVersion = "2019-12-01"
114	queryParameters := map[string]interface{}{
115		"api-version": APIVersion,
116	}
117
118	preparer := autorest.CreatePreparer(
119		autorest.AsContentType("application/json; charset=utf-8"),
120		autorest.AsPut(),
121		autorest.WithBaseURL(client.BaseURI),
122		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters),
123		autorest.WithJSON(parameters),
124		autorest.WithQueryParameters(queryParameters))
125	if len(ifMatch) > 0 {
126		preparer = autorest.DecoratePreparer(preparer,
127			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
128	}
129	return preparer.Prepare((&http.Request{}).WithContext(ctx))
130}
131
132// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
133// http.Response Body if it receives an error.
134func (client OpenIDConnectProviderClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
135	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
136}
137
138// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
139// closes the http.Response Body.
140func (client OpenIDConnectProviderClient) CreateOrUpdateResponder(resp *http.Response) (result OpenidConnectProviderContract, err error) {
141	err = autorest.Respond(
142		resp,
143		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
144		autorest.ByUnmarshallingJSON(&result),
145		autorest.ByClosing())
146	result.Response = autorest.Response{Response: resp}
147	return
148}
149
150// Delete deletes specific OpenID Connect Provider of the API Management service instance.
151// Parameters:
152// resourceGroupName - the name of the resource group.
153// serviceName - the name of the API Management service.
154// opid - identifier of the OpenID Connect Provider.
155// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
156// request or it should be * for unconditional update.
157func (client OpenIDConnectProviderClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string) (result autorest.Response, err error) {
158	if tracing.IsEnabled() {
159		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.Delete")
160		defer func() {
161			sc := -1
162			if result.Response != nil {
163				sc = result.Response.StatusCode
164			}
165			tracing.EndSpan(ctx, sc, err)
166		}()
167	}
168	if err := validation.Validate([]validation.Validation{
169		{TargetValue: serviceName,
170			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
171				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
172				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
173		{TargetValue: opid,
174			Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil},
175				{Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
176		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "Delete", err.Error())
177	}
178
179	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, opid, ifMatch)
180	if err != nil {
181		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Delete", nil, "Failure preparing request")
182		return
183	}
184
185	resp, err := client.DeleteSender(req)
186	if err != nil {
187		result.Response = resp
188		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Delete", resp, "Failure sending request")
189		return
190	}
191
192	result, err = client.DeleteResponder(resp)
193	if err != nil {
194		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Delete", resp, "Failure responding to request")
195		return
196	}
197
198	return
199}
200
201// DeletePreparer prepares the Delete request.
202func (client OpenIDConnectProviderClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string) (*http.Request, error) {
203	pathParameters := map[string]interface{}{
204		"opid":              autorest.Encode("path", opid),
205		"resourceGroupName": autorest.Encode("path", resourceGroupName),
206		"serviceName":       autorest.Encode("path", serviceName),
207		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
208	}
209
210	const APIVersion = "2019-12-01"
211	queryParameters := map[string]interface{}{
212		"api-version": APIVersion,
213	}
214
215	preparer := autorest.CreatePreparer(
216		autorest.AsDelete(),
217		autorest.WithBaseURL(client.BaseURI),
218		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters),
219		autorest.WithQueryParameters(queryParameters),
220		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
221	return preparer.Prepare((&http.Request{}).WithContext(ctx))
222}
223
224// DeleteSender sends the Delete request. The method will close the
225// http.Response Body if it receives an error.
226func (client OpenIDConnectProviderClient) DeleteSender(req *http.Request) (*http.Response, error) {
227	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
228}
229
230// DeleteResponder handles the response to the Delete request. The method always
231// closes the http.Response Body.
232func (client OpenIDConnectProviderClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
233	err = autorest.Respond(
234		resp,
235		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
236		autorest.ByClosing())
237	result.Response = resp
238	return
239}
240
241// Get gets specific OpenID Connect Provider.
242// Parameters:
243// resourceGroupName - the name of the resource group.
244// serviceName - the name of the API Management service.
245// opid - identifier of the OpenID Connect Provider.
246func (client OpenIDConnectProviderClient) Get(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result OpenidConnectProviderContract, err error) {
247	if tracing.IsEnabled() {
248		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.Get")
249		defer func() {
250			sc := -1
251			if result.Response.Response != nil {
252				sc = result.Response.Response.StatusCode
253			}
254			tracing.EndSpan(ctx, sc, err)
255		}()
256	}
257	if err := validation.Validate([]validation.Validation{
258		{TargetValue: serviceName,
259			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
260				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
261				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
262		{TargetValue: opid,
263			Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil},
264				{Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
265		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "Get", err.Error())
266	}
267
268	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, opid)
269	if err != nil {
270		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Get", nil, "Failure preparing request")
271		return
272	}
273
274	resp, err := client.GetSender(req)
275	if err != nil {
276		result.Response = autorest.Response{Response: resp}
277		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Get", resp, "Failure sending request")
278		return
279	}
280
281	result, err = client.GetResponder(resp)
282	if err != nil {
283		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Get", resp, "Failure responding to request")
284		return
285	}
286
287	return
288}
289
290// GetPreparer prepares the Get request.
291func (client OpenIDConnectProviderClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string) (*http.Request, error) {
292	pathParameters := map[string]interface{}{
293		"opid":              autorest.Encode("path", opid),
294		"resourceGroupName": autorest.Encode("path", resourceGroupName),
295		"serviceName":       autorest.Encode("path", serviceName),
296		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
297	}
298
299	const APIVersion = "2019-12-01"
300	queryParameters := map[string]interface{}{
301		"api-version": APIVersion,
302	}
303
304	preparer := autorest.CreatePreparer(
305		autorest.AsGet(),
306		autorest.WithBaseURL(client.BaseURI),
307		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters),
308		autorest.WithQueryParameters(queryParameters))
309	return preparer.Prepare((&http.Request{}).WithContext(ctx))
310}
311
312// GetSender sends the Get request. The method will close the
313// http.Response Body if it receives an error.
314func (client OpenIDConnectProviderClient) GetSender(req *http.Request) (*http.Response, error) {
315	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
316}
317
318// GetResponder handles the response to the Get request. The method always
319// closes the http.Response Body.
320func (client OpenIDConnectProviderClient) GetResponder(resp *http.Response) (result OpenidConnectProviderContract, err error) {
321	err = autorest.Respond(
322		resp,
323		azure.WithErrorUnlessStatusCode(http.StatusOK),
324		autorest.ByUnmarshallingJSON(&result),
325		autorest.ByClosing())
326	result.Response = autorest.Response{Response: resp}
327	return
328}
329
330// GetEntityTag gets the entity state (Etag) version of the openIdConnectProvider specified by its identifier.
331// Parameters:
332// resourceGroupName - the name of the resource group.
333// serviceName - the name of the API Management service.
334// opid - identifier of the OpenID Connect Provider.
335func (client OpenIDConnectProviderClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result autorest.Response, err error) {
336	if tracing.IsEnabled() {
337		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.GetEntityTag")
338		defer func() {
339			sc := -1
340			if result.Response != nil {
341				sc = result.Response.StatusCode
342			}
343			tracing.EndSpan(ctx, sc, err)
344		}()
345	}
346	if err := validation.Validate([]validation.Validation{
347		{TargetValue: serviceName,
348			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
349				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
350				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
351		{TargetValue: opid,
352			Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil},
353				{Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
354		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "GetEntityTag", err.Error())
355	}
356
357	req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, opid)
358	if err != nil {
359		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "GetEntityTag", nil, "Failure preparing request")
360		return
361	}
362
363	resp, err := client.GetEntityTagSender(req)
364	if err != nil {
365		result.Response = resp
366		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "GetEntityTag", resp, "Failure sending request")
367		return
368	}
369
370	result, err = client.GetEntityTagResponder(resp)
371	if err != nil {
372		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "GetEntityTag", resp, "Failure responding to request")
373		return
374	}
375
376	return
377}
378
379// GetEntityTagPreparer prepares the GetEntityTag request.
380func (client OpenIDConnectProviderClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string) (*http.Request, error) {
381	pathParameters := map[string]interface{}{
382		"opid":              autorest.Encode("path", opid),
383		"resourceGroupName": autorest.Encode("path", resourceGroupName),
384		"serviceName":       autorest.Encode("path", serviceName),
385		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
386	}
387
388	const APIVersion = "2019-12-01"
389	queryParameters := map[string]interface{}{
390		"api-version": APIVersion,
391	}
392
393	preparer := autorest.CreatePreparer(
394		autorest.AsHead(),
395		autorest.WithBaseURL(client.BaseURI),
396		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters),
397		autorest.WithQueryParameters(queryParameters))
398	return preparer.Prepare((&http.Request{}).WithContext(ctx))
399}
400
401// GetEntityTagSender sends the GetEntityTag request. The method will close the
402// http.Response Body if it receives an error.
403func (client OpenIDConnectProviderClient) GetEntityTagSender(req *http.Request) (*http.Response, error) {
404	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
405}
406
407// GetEntityTagResponder handles the response to the GetEntityTag request. The method always
408// closes the http.Response Body.
409func (client OpenIDConnectProviderClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) {
410	err = autorest.Respond(
411		resp,
412		azure.WithErrorUnlessStatusCode(http.StatusOK),
413		autorest.ByClosing())
414	result.Response = resp
415	return
416}
417
418// ListByService lists of all the OpenId Connect Providers.
419// Parameters:
420// resourceGroupName - the name of the resource group.
421// serviceName - the name of the API Management service.
422// filter - |   Field     |     Usage     |     Supported operators     |     Supported functions
423// |</br>|-------------|-------------|-------------|-------------|</br>| name | filter | ge, le, eq, ne, gt, lt
424// | substringof, contains, startswith, endswith | </br>| displayName | filter | ge, le, eq, ne, gt, lt |
425// substringof, contains, startswith, endswith | </br>
426// top - number of records to return.
427// skip - number of records to skip.
428func (client OpenIDConnectProviderClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result OpenIDConnectProviderCollectionPage, err error) {
429	if tracing.IsEnabled() {
430		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.ListByService")
431		defer func() {
432			sc := -1
433			if result.oicpc.Response.Response != nil {
434				sc = result.oicpc.Response.Response.StatusCode
435			}
436			tracing.EndSpan(ctx, sc, err)
437		}()
438	}
439	if err := validation.Validate([]validation.Validation{
440		{TargetValue: serviceName,
441			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
442				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
443				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
444		{TargetValue: top,
445			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
446				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
447		{TargetValue: skip,
448			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
449				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
450		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "ListByService", err.Error())
451	}
452
453	result.fn = client.listByServiceNextResults
454	req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip)
455	if err != nil {
456		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListByService", nil, "Failure preparing request")
457		return
458	}
459
460	resp, err := client.ListByServiceSender(req)
461	if err != nil {
462		result.oicpc.Response = autorest.Response{Response: resp}
463		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListByService", resp, "Failure sending request")
464		return
465	}
466
467	result.oicpc, err = client.ListByServiceResponder(resp)
468	if err != nil {
469		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListByService", resp, "Failure responding to request")
470		return
471	}
472	if result.oicpc.hasNextLink() && result.oicpc.IsEmpty() {
473		err = result.NextWithContext(ctx)
474		return
475	}
476
477	return
478}
479
480// ListByServicePreparer prepares the ListByService request.
481func (client OpenIDConnectProviderClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) {
482	pathParameters := map[string]interface{}{
483		"resourceGroupName": autorest.Encode("path", resourceGroupName),
484		"serviceName":       autorest.Encode("path", serviceName),
485		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
486	}
487
488	const APIVersion = "2019-12-01"
489	queryParameters := map[string]interface{}{
490		"api-version": APIVersion,
491	}
492	if len(filter) > 0 {
493		queryParameters["$filter"] = autorest.Encode("query", filter)
494	}
495	if top != nil {
496		queryParameters["$top"] = autorest.Encode("query", *top)
497	}
498	if skip != nil {
499		queryParameters["$skip"] = autorest.Encode("query", *skip)
500	}
501
502	preparer := autorest.CreatePreparer(
503		autorest.AsGet(),
504		autorest.WithBaseURL(client.BaseURI),
505		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders", pathParameters),
506		autorest.WithQueryParameters(queryParameters))
507	return preparer.Prepare((&http.Request{}).WithContext(ctx))
508}
509
510// ListByServiceSender sends the ListByService request. The method will close the
511// http.Response Body if it receives an error.
512func (client OpenIDConnectProviderClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
513	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
514}
515
516// ListByServiceResponder handles the response to the ListByService request. The method always
517// closes the http.Response Body.
518func (client OpenIDConnectProviderClient) ListByServiceResponder(resp *http.Response) (result OpenIDConnectProviderCollection, err error) {
519	err = autorest.Respond(
520		resp,
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 OpenIDConnectProviderClient) listByServiceNextResults(ctx context.Context, lastResults OpenIDConnectProviderCollection) (result OpenIDConnectProviderCollection, err error) {
530	req, err := lastResults.openIDConnectProviderCollectionPreparer(ctx)
531	if err != nil {
532		return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "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.OpenIDConnectProviderClient", "listByServiceNextResults", resp, "Failure sending next results request")
541	}
542	result, err = client.ListByServiceResponder(resp)
543	if err != nil {
544		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "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 OpenIDConnectProviderClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result OpenIDConnectProviderCollectionIterator, err error) {
551	if tracing.IsEnabled() {
552		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.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// ListSecrets gets the client secret details of the OpenID Connect Provider.
566// Parameters:
567// resourceGroupName - the name of the resource group.
568// serviceName - the name of the API Management service.
569// opid - identifier of the OpenID Connect Provider.
570func (client OpenIDConnectProviderClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result ClientSecretContract, err error) {
571	if tracing.IsEnabled() {
572		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.ListSecrets")
573		defer func() {
574			sc := -1
575			if result.Response.Response != nil {
576				sc = result.Response.Response.StatusCode
577			}
578			tracing.EndSpan(ctx, sc, err)
579		}()
580	}
581	if err := validation.Validate([]validation.Validation{
582		{TargetValue: serviceName,
583			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
584				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
585				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
586		{TargetValue: opid,
587			Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil},
588				{Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
589		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "ListSecrets", err.Error())
590	}
591
592	req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, opid)
593	if err != nil {
594		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListSecrets", nil, "Failure preparing request")
595		return
596	}
597
598	resp, err := client.ListSecretsSender(req)
599	if err != nil {
600		result.Response = autorest.Response{Response: resp}
601		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListSecrets", resp, "Failure sending request")
602		return
603	}
604
605	result, err = client.ListSecretsResponder(resp)
606	if err != nil {
607		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListSecrets", resp, "Failure responding to request")
608		return
609	}
610
611	return
612}
613
614// ListSecretsPreparer prepares the ListSecrets request.
615func (client OpenIDConnectProviderClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string) (*http.Request, error) {
616	pathParameters := map[string]interface{}{
617		"opid":              autorest.Encode("path", opid),
618		"resourceGroupName": autorest.Encode("path", resourceGroupName),
619		"serviceName":       autorest.Encode("path", serviceName),
620		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
621	}
622
623	const APIVersion = "2019-12-01"
624	queryParameters := map[string]interface{}{
625		"api-version": APIVersion,
626	}
627
628	preparer := autorest.CreatePreparer(
629		autorest.AsPost(),
630		autorest.WithBaseURL(client.BaseURI),
631		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets", pathParameters),
632		autorest.WithQueryParameters(queryParameters))
633	return preparer.Prepare((&http.Request{}).WithContext(ctx))
634}
635
636// ListSecretsSender sends the ListSecrets request. The method will close the
637// http.Response Body if it receives an error.
638func (client OpenIDConnectProviderClient) ListSecretsSender(req *http.Request) (*http.Response, error) {
639	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
640}
641
642// ListSecretsResponder handles the response to the ListSecrets request. The method always
643// closes the http.Response Body.
644func (client OpenIDConnectProviderClient) ListSecretsResponder(resp *http.Response) (result ClientSecretContract, err error) {
645	err = autorest.Respond(
646		resp,
647		azure.WithErrorUnlessStatusCode(http.StatusOK),
648		autorest.ByUnmarshallingJSON(&result),
649		autorest.ByClosing())
650	result.Response = autorest.Response{Response: resp}
651	return
652}
653
654// Update updates the specific OpenID Connect Provider.
655// Parameters:
656// resourceGroupName - the name of the resource group.
657// serviceName - the name of the API Management service.
658// opid - identifier of the OpenID Connect Provider.
659// parameters - update parameters.
660// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET
661// request or it should be * for unconditional update.
662func (client OpenIDConnectProviderClient) Update(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderUpdateContract, ifMatch string) (result autorest.Response, err error) {
663	if tracing.IsEnabled() {
664		ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.Update")
665		defer func() {
666			sc := -1
667			if result.Response != nil {
668				sc = result.Response.StatusCode
669			}
670			tracing.EndSpan(ctx, sc, err)
671		}()
672	}
673	if err := validation.Validate([]validation.Validation{
674		{TargetValue: serviceName,
675			Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
676				{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
677				{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
678		{TargetValue: opid,
679			Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil},
680				{Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
681		return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "Update", err.Error())
682	}
683
684	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, opid, parameters, ifMatch)
685	if err != nil {
686		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Update", nil, "Failure preparing request")
687		return
688	}
689
690	resp, err := client.UpdateSender(req)
691	if err != nil {
692		result.Response = resp
693		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Update", resp, "Failure sending request")
694		return
695	}
696
697	result, err = client.UpdateResponder(resp)
698	if err != nil {
699		err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Update", resp, "Failure responding to request")
700		return
701	}
702
703	return
704}
705
706// UpdatePreparer prepares the Update request.
707func (client OpenIDConnectProviderClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderUpdateContract, ifMatch string) (*http.Request, error) {
708	pathParameters := map[string]interface{}{
709		"opid":              autorest.Encode("path", opid),
710		"resourceGroupName": autorest.Encode("path", resourceGroupName),
711		"serviceName":       autorest.Encode("path", serviceName),
712		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
713	}
714
715	const APIVersion = "2019-12-01"
716	queryParameters := map[string]interface{}{
717		"api-version": APIVersion,
718	}
719
720	preparer := autorest.CreatePreparer(
721		autorest.AsContentType("application/json; charset=utf-8"),
722		autorest.AsPatch(),
723		autorest.WithBaseURL(client.BaseURI),
724		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters),
725		autorest.WithJSON(parameters),
726		autorest.WithQueryParameters(queryParameters),
727		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
728	return preparer.Prepare((&http.Request{}).WithContext(ctx))
729}
730
731// UpdateSender sends the Update request. The method will close the
732// http.Response Body if it receives an error.
733func (client OpenIDConnectProviderClient) UpdateSender(req *http.Request) (*http.Response, error) {
734	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
735}
736
737// UpdateResponder handles the response to the Update request. The method always
738// closes the http.Response Body.
739func (client OpenIDConnectProviderClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
740	err = autorest.Respond(
741		resp,
742		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
743		autorest.ByClosing())
744	result.Response = resp
745	return
746}
747