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