1package apimanagement 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// SignInSettingsClient is the client for the SignInSettings methods of the Apimanagement service. 18type SignInSettingsClient struct { 19 BaseClient 20} 21 22// NewSignInSettingsClient creates an instance of the SignInSettingsClient client. 23func NewSignInSettingsClient() SignInSettingsClient { 24 return SignInSettingsClient{New()} 25} 26 27// CreateOrUpdate create or Update Sign-In settings. 28// Parameters: 29// apimBaseURL - the management endpoint of the API Management service, for example 30// https://myapimservice.management.azure-api.net. 31// parameters - create or update parameters. 32func (client SignInSettingsClient) CreateOrUpdate(ctx context.Context, apimBaseURL string, parameters PortalSigninSettings) (result PortalSigninSettings, err error) { 33 if tracing.IsEnabled() { 34 ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.CreateOrUpdate") 35 defer func() { 36 sc := -1 37 if result.Response.Response != nil { 38 sc = result.Response.Response.StatusCode 39 } 40 tracing.EndSpan(ctx, sc, err) 41 }() 42 } 43 req, err := client.CreateOrUpdatePreparer(ctx, apimBaseURL, parameters) 44 if err != nil { 45 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") 46 return 47 } 48 49 resp, err := client.CreateOrUpdateSender(req) 50 if err != nil { 51 result.Response = autorest.Response{Response: resp} 52 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "CreateOrUpdate", resp, "Failure sending request") 53 return 54 } 55 56 result, err = client.CreateOrUpdateResponder(resp) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") 59 return 60 } 61 62 return 63} 64 65// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 66func (client SignInSettingsClient) CreateOrUpdatePreparer(ctx context.Context, apimBaseURL string, parameters PortalSigninSettings) (*http.Request, error) { 67 urlParameters := map[string]interface{}{ 68 "apimBaseUrl": apimBaseURL, 69 } 70 71 const APIVersion = "2017-03-01" 72 queryParameters := map[string]interface{}{ 73 "api-version": APIVersion, 74 } 75 76 preparer := autorest.CreatePreparer( 77 autorest.AsContentType("application/json; charset=utf-8"), 78 autorest.AsPut(), 79 autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters), 80 autorest.WithPath("/portalsettings/signin"), 81 autorest.WithJSON(parameters), 82 autorest.WithQueryParameters(queryParameters)) 83 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 84} 85 86// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 87// http.Response Body if it receives an error. 88func (client SignInSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 89 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 90} 91 92// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 93// closes the http.Response Body. 94func (client SignInSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result PortalSigninSettings, err error) { 95 err = autorest.Respond( 96 resp, 97 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 98 autorest.ByUnmarshallingJSON(&result), 99 autorest.ByClosing()) 100 result.Response = autorest.Response{Response: resp} 101 return 102} 103 104// Get get Sign-In settings. 105// Parameters: 106// apimBaseURL - the management endpoint of the API Management service, for example 107// https://myapimservice.management.azure-api.net. 108func (client SignInSettingsClient) Get(ctx context.Context, apimBaseURL string) (result PortalSigninSettings, err error) { 109 if tracing.IsEnabled() { 110 ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.Get") 111 defer func() { 112 sc := -1 113 if result.Response.Response != nil { 114 sc = result.Response.Response.StatusCode 115 } 116 tracing.EndSpan(ctx, sc, err) 117 }() 118 } 119 req, err := client.GetPreparer(ctx, apimBaseURL) 120 if err != nil { 121 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Get", nil, "Failure preparing request") 122 return 123 } 124 125 resp, err := client.GetSender(req) 126 if err != nil { 127 result.Response = autorest.Response{Response: resp} 128 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Get", resp, "Failure sending request") 129 return 130 } 131 132 result, err = client.GetResponder(resp) 133 if err != nil { 134 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Get", resp, "Failure responding to request") 135 return 136 } 137 138 return 139} 140 141// GetPreparer prepares the Get request. 142func (client SignInSettingsClient) GetPreparer(ctx context.Context, apimBaseURL string) (*http.Request, error) { 143 urlParameters := map[string]interface{}{ 144 "apimBaseUrl": apimBaseURL, 145 } 146 147 const APIVersion = "2017-03-01" 148 queryParameters := map[string]interface{}{ 149 "api-version": APIVersion, 150 } 151 152 preparer := autorest.CreatePreparer( 153 autorest.AsGet(), 154 autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters), 155 autorest.WithPath("/portalsettings/signin"), 156 autorest.WithQueryParameters(queryParameters)) 157 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 158} 159 160// GetSender sends the Get request. The method will close the 161// http.Response Body if it receives an error. 162func (client SignInSettingsClient) GetSender(req *http.Request) (*http.Response, error) { 163 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 164} 165 166// GetResponder handles the response to the Get request. The method always 167// closes the http.Response Body. 168func (client SignInSettingsClient) GetResponder(resp *http.Response) (result PortalSigninSettings, err error) { 169 err = autorest.Respond( 170 resp, 171 azure.WithErrorUnlessStatusCode(http.StatusOK), 172 autorest.ByUnmarshallingJSON(&result), 173 autorest.ByClosing()) 174 result.Response = autorest.Response{Response: resp} 175 return 176} 177 178// Update update Sign-In settings. 179// Parameters: 180// apimBaseURL - the management endpoint of the API Management service, for example 181// https://myapimservice.management.azure-api.net. 182// parameters - update Sign-In settings. 183// ifMatch - the entity state (Etag) version of the property to update. A value of "*" can be used for If-Match 184// to unconditionally apply the operation. 185func (client SignInSettingsClient) Update(ctx context.Context, apimBaseURL string, parameters PortalSigninSettings, ifMatch string) (result autorest.Response, err error) { 186 if tracing.IsEnabled() { 187 ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.Update") 188 defer func() { 189 sc := -1 190 if result.Response != nil { 191 sc = result.Response.StatusCode 192 } 193 tracing.EndSpan(ctx, sc, err) 194 }() 195 } 196 req, err := client.UpdatePreparer(ctx, apimBaseURL, parameters, ifMatch) 197 if err != nil { 198 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Update", nil, "Failure preparing request") 199 return 200 } 201 202 resp, err := client.UpdateSender(req) 203 if err != nil { 204 result.Response = resp 205 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Update", resp, "Failure sending request") 206 return 207 } 208 209 result, err = client.UpdateResponder(resp) 210 if err != nil { 211 err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Update", resp, "Failure responding to request") 212 return 213 } 214 215 return 216} 217 218// UpdatePreparer prepares the Update request. 219func (client SignInSettingsClient) UpdatePreparer(ctx context.Context, apimBaseURL string, parameters PortalSigninSettings, ifMatch string) (*http.Request, error) { 220 urlParameters := map[string]interface{}{ 221 "apimBaseUrl": apimBaseURL, 222 } 223 224 const APIVersion = "2017-03-01" 225 queryParameters := map[string]interface{}{ 226 "api-version": APIVersion, 227 } 228 229 preparer := autorest.CreatePreparer( 230 autorest.AsContentType("application/json; charset=utf-8"), 231 autorest.AsPatch(), 232 autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters), 233 autorest.WithPath("/portalsettings/signin"), 234 autorest.WithJSON(parameters), 235 autorest.WithQueryParameters(queryParameters), 236 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 237 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 238} 239 240// UpdateSender sends the Update request. The method will close the 241// http.Response Body if it receives an error. 242func (client SignInSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { 243 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 244} 245 246// UpdateResponder handles the response to the Update request. The method always 247// closes the http.Response Body. 248func (client SignInSettingsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { 249 err = autorest.Respond( 250 resp, 251 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 252 autorest.ByClosing()) 253 result.Response = resp 254 return 255} 256