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// APIPolicyClient is the apiManagement Client 30type APIPolicyClient struct { 31 BaseClient 32} 33 34// NewAPIPolicyClient creates an instance of the APIPolicyClient client. 35func NewAPIPolicyClient(subscriptionID string) APIPolicyClient { 36 return NewAPIPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewAPIPolicyClientWithBaseURI creates an instance of the APIPolicyClient client using a custom endpoint. Use this 40// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 41func NewAPIPolicyClientWithBaseURI(baseURI string, subscriptionID string) APIPolicyClient { 42 return APIPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// CreateOrUpdate creates or updates policy configuration for the API. 46// Parameters: 47// resourceGroupName - the name of the resource group. 48// serviceName - the name of the API Management service. 49// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 50// revision has ;rev=n as a suffix where n is the revision number. 51// parameters - the policy contents to apply. 52// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. 53func (client APIPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters PolicyContract, ifMatch string) (result PolicyContract, err error) { 54 if tracing.IsEnabled() { 55 ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.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: apiid, 70 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 71 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 72 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 73 {TargetValue: parameters, 74 Constraints: []validation.Constraint{{Target: "parameters.PolicyContractProperties", Name: validation.Null, Rule: false, 75 Chain: []validation.Constraint{{Target: "parameters.PolicyContractProperties.PolicyContent", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 76 return result, validation.NewError("apimanagement.APIPolicyClient", "CreateOrUpdate", err.Error()) 77 } 78 79 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, parameters, ifMatch) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") 82 return 83 } 84 85 resp, err := client.CreateOrUpdateSender(req) 86 if err != nil { 87 result.Response = autorest.Response{Response: resp} 88 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "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.APIPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") 95 } 96 97 return 98} 99 100// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 101func (client APIPolicyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters PolicyContract, ifMatch string) (*http.Request, error) { 102 pathParameters := map[string]interface{}{ 103 "apiId": autorest.Encode("path", apiid), 104 "policyId": autorest.Encode("path", "policy"), 105 "resourceGroupName": autorest.Encode("path", resourceGroupName), 106 "serviceName": autorest.Encode("path", serviceName), 107 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 108 } 109 110 const APIVersion = "2018-06-01-preview" 111 queryParameters := map[string]interface{}{ 112 "api-version": APIVersion, 113 } 114 115 preparer := autorest.CreatePreparer( 116 autorest.AsContentType("application/json; charset=utf-8"), 117 autorest.AsPut(), 118 autorest.WithBaseURL(client.BaseURI), 119 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), 120 autorest.WithJSON(parameters), 121 autorest.WithQueryParameters(queryParameters)) 122 if len(ifMatch) > 0 { 123 preparer = autorest.DecoratePreparer(preparer, 124 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 125 } 126 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 127} 128 129// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 130// http.Response Body if it receives an error. 131func (client APIPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 132 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 133} 134 135// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 136// closes the http.Response Body. 137func (client APIPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyContract, err error) { 138 err = autorest.Respond( 139 resp, 140 client.ByInspecting(), 141 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 142 autorest.ByUnmarshallingJSON(&result), 143 autorest.ByClosing()) 144 result.Response = autorest.Response{Response: resp} 145 return 146} 147 148// Delete deletes the policy configuration at the Api. 149// Parameters: 150// resourceGroupName - the name of the resource group. 151// serviceName - the name of the API Management service. 152// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 153// revision has ;rev=n as a suffix where n is the revision number. 154// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 155// request or it should be * for unconditional update. 156func (client APIPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (result autorest.Response, err error) { 157 if tracing.IsEnabled() { 158 ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.Delete") 159 defer func() { 160 sc := -1 161 if result.Response != nil { 162 sc = result.Response.StatusCode 163 } 164 tracing.EndSpan(ctx, sc, err) 165 }() 166 } 167 if err := validation.Validate([]validation.Validation{ 168 {TargetValue: serviceName, 169 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 170 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 171 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 172 {TargetValue: apiid, 173 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 174 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 175 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 176 return result, validation.NewError("apimanagement.APIPolicyClient", "Delete", err.Error()) 177 } 178 179 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, ifMatch) 180 if err != nil { 181 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "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.APIPolicyClient", "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.APIPolicyClient", "Delete", resp, "Failure responding to request") 195 } 196 197 return 198} 199 200// DeletePreparer prepares the Delete request. 201func (client APIPolicyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (*http.Request, error) { 202 pathParameters := map[string]interface{}{ 203 "apiId": autorest.Encode("path", apiid), 204 "policyId": autorest.Encode("path", "policy"), 205 "resourceGroupName": autorest.Encode("path", resourceGroupName), 206 "serviceName": autorest.Encode("path", serviceName), 207 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 208 } 209 210 const APIVersion = "2018-06-01-preview" 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}/apis/{apiId}/policies/{policyId}", 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 APIPolicyClient) 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 APIPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 233 err = autorest.Respond( 234 resp, 235 client.ByInspecting(), 236 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 237 autorest.ByClosing()) 238 result.Response = resp 239 return 240} 241 242// Get get the policy configuration at the API level. 243// Parameters: 244// resourceGroupName - the name of the resource group. 245// serviceName - the name of the API Management service. 246// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 247// revision has ;rev=n as a suffix where n is the revision number. 248func (client APIPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result PolicyContract, err error) { 249 if tracing.IsEnabled() { 250 ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.Get") 251 defer func() { 252 sc := -1 253 if result.Response.Response != nil { 254 sc = result.Response.Response.StatusCode 255 } 256 tracing.EndSpan(ctx, sc, err) 257 }() 258 } 259 if err := validation.Validate([]validation.Validation{ 260 {TargetValue: serviceName, 261 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 262 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 263 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 264 {TargetValue: apiid, 265 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 266 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 267 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 268 return result, validation.NewError("apimanagement.APIPolicyClient", "Get", err.Error()) 269 } 270 271 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid) 272 if err != nil { 273 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", nil, "Failure preparing request") 274 return 275 } 276 277 resp, err := client.GetSender(req) 278 if err != nil { 279 result.Response = autorest.Response{Response: resp} 280 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure sending request") 281 return 282 } 283 284 result, err = client.GetResponder(resp) 285 if err != nil { 286 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure responding to request") 287 } 288 289 return 290} 291 292// GetPreparer prepares the Get request. 293func (client APIPolicyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { 294 pathParameters := map[string]interface{}{ 295 "apiId": autorest.Encode("path", apiid), 296 "policyId": autorest.Encode("path", "policy"), 297 "resourceGroupName": autorest.Encode("path", resourceGroupName), 298 "serviceName": autorest.Encode("path", serviceName), 299 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 300 } 301 302 const APIVersion = "2018-06-01-preview" 303 queryParameters := map[string]interface{}{ 304 "api-version": APIVersion, 305 } 306 307 preparer := autorest.CreatePreparer( 308 autorest.AsGet(), 309 autorest.WithBaseURL(client.BaseURI), 310 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), 311 autorest.WithQueryParameters(queryParameters)) 312 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 313} 314 315// GetSender sends the Get request. The method will close the 316// http.Response Body if it receives an error. 317func (client APIPolicyClient) GetSender(req *http.Request) (*http.Response, error) { 318 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 319} 320 321// GetResponder handles the response to the Get request. The method always 322// closes the http.Response Body. 323func (client APIPolicyClient) GetResponder(resp *http.Response) (result PolicyContract, err error) { 324 err = autorest.Respond( 325 resp, 326 client.ByInspecting(), 327 azure.WithErrorUnlessStatusCode(http.StatusOK), 328 autorest.ByUnmarshallingJSON(&result), 329 autorest.ByClosing()) 330 result.Response = autorest.Response{Response: resp} 331 return 332} 333 334// GetEntityTag gets the entity state (Etag) version of the API policy specified by its identifier. 335// Parameters: 336// resourceGroupName - the name of the resource group. 337// serviceName - the name of the API Management service. 338// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 339// revision has ;rev=n as a suffix where n is the revision number. 340func (client APIPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result autorest.Response, err error) { 341 if tracing.IsEnabled() { 342 ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.GetEntityTag") 343 defer func() { 344 sc := -1 345 if result.Response != nil { 346 sc = result.Response.StatusCode 347 } 348 tracing.EndSpan(ctx, sc, err) 349 }() 350 } 351 if err := validation.Validate([]validation.Validation{ 352 {TargetValue: serviceName, 353 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 354 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 355 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 356 {TargetValue: apiid, 357 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 358 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 359 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 360 return result, validation.NewError("apimanagement.APIPolicyClient", "GetEntityTag", err.Error()) 361 } 362 363 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid) 364 if err != nil { 365 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", nil, "Failure preparing request") 366 return 367 } 368 369 resp, err := client.GetEntityTagSender(req) 370 if err != nil { 371 result.Response = resp 372 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", resp, "Failure sending request") 373 return 374 } 375 376 result, err = client.GetEntityTagResponder(resp) 377 if err != nil { 378 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", resp, "Failure responding to request") 379 } 380 381 return 382} 383 384// GetEntityTagPreparer prepares the GetEntityTag request. 385func (client APIPolicyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { 386 pathParameters := map[string]interface{}{ 387 "apiId": autorest.Encode("path", apiid), 388 "policyId": autorest.Encode("path", "policy"), 389 "resourceGroupName": autorest.Encode("path", resourceGroupName), 390 "serviceName": autorest.Encode("path", serviceName), 391 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 392 } 393 394 const APIVersion = "2018-06-01-preview" 395 queryParameters := map[string]interface{}{ 396 "api-version": APIVersion, 397 } 398 399 preparer := autorest.CreatePreparer( 400 autorest.AsHead(), 401 autorest.WithBaseURL(client.BaseURI), 402 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), 403 autorest.WithQueryParameters(queryParameters)) 404 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 405} 406 407// GetEntityTagSender sends the GetEntityTag request. The method will close the 408// http.Response Body if it receives an error. 409func (client APIPolicyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { 410 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 411} 412 413// GetEntityTagResponder handles the response to the GetEntityTag request. The method always 414// closes the http.Response Body. 415func (client APIPolicyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { 416 err = autorest.Respond( 417 resp, 418 client.ByInspecting(), 419 azure.WithErrorUnlessStatusCode(http.StatusOK), 420 autorest.ByClosing()) 421 result.Response = resp 422 return 423} 424 425// ListByAPI get the policy configuration at the API level. 426// Parameters: 427// resourceGroupName - the name of the resource group. 428// serviceName - the name of the API Management service. 429// apiid - API revision identifier. Must be unique in the current API Management service instance. Non-current 430// revision has ;rev=n as a suffix where n is the revision number. 431func (client APIPolicyClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result PolicyCollection, err error) { 432 if tracing.IsEnabled() { 433 ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.ListByAPI") 434 defer func() { 435 sc := -1 436 if result.Response.Response != nil { 437 sc = result.Response.Response.StatusCode 438 } 439 tracing.EndSpan(ctx, sc, err) 440 }() 441 } 442 if err := validation.Validate([]validation.Validation{ 443 {TargetValue: serviceName, 444 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 445 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 446 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 447 {TargetValue: apiid, 448 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 449 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 450 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 451 return result, validation.NewError("apimanagement.APIPolicyClient", "ListByAPI", err.Error()) 452 } 453 454 req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid) 455 if err != nil { 456 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", nil, "Failure preparing request") 457 return 458 } 459 460 resp, err := client.ListByAPISender(req) 461 if err != nil { 462 result.Response = autorest.Response{Response: resp} 463 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", resp, "Failure sending request") 464 return 465 } 466 467 result, err = client.ListByAPIResponder(resp) 468 if err != nil { 469 err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", resp, "Failure responding to request") 470 } 471 472 return 473} 474 475// ListByAPIPreparer prepares the ListByAPI request. 476func (client APIPolicyClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { 477 pathParameters := map[string]interface{}{ 478 "apiId": autorest.Encode("path", apiid), 479 "resourceGroupName": autorest.Encode("path", resourceGroupName), 480 "serviceName": autorest.Encode("path", serviceName), 481 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 482 } 483 484 const APIVersion = "2018-06-01-preview" 485 queryParameters := map[string]interface{}{ 486 "api-version": APIVersion, 487 } 488 489 preparer := autorest.CreatePreparer( 490 autorest.AsGet(), 491 autorest.WithBaseURL(client.BaseURI), 492 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies", pathParameters), 493 autorest.WithQueryParameters(queryParameters)) 494 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 495} 496 497// ListByAPISender sends the ListByAPI request. The method will close the 498// http.Response Body if it receives an error. 499func (client APIPolicyClient) ListByAPISender(req *http.Request) (*http.Response, error) { 500 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 501} 502 503// ListByAPIResponder handles the response to the ListByAPI request. The method always 504// closes the http.Response Body. 505func (client APIPolicyClient) ListByAPIResponder(resp *http.Response) (result PolicyCollection, err error) { 506 err = autorest.Respond( 507 resp, 508 client.ByInspecting(), 509 azure.WithErrorUnlessStatusCode(http.StatusOK), 510 autorest.ByUnmarshallingJSON(&result), 511 autorest.ByClosing()) 512 result.Response = autorest.Response{Response: resp} 513 return 514} 515