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