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/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// ReportsClient is the apiManagement Client 19type ReportsClient struct { 20 BaseClient 21} 22 23// NewReportsClient creates an instance of the ReportsClient client. 24func NewReportsClient(subscriptionID string) ReportsClient { 25 return NewReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewReportsClientWithBaseURI creates an instance of the ReportsClient client using a custom endpoint. Use this when 29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewReportsClientWithBaseURI(baseURI string, subscriptionID string) ReportsClient { 31 return ReportsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// ListByAPI lists report records by API. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// serviceName - the name of the API Management service. 38// filter - the filter to apply on the operation. 39// top - number of records to return. 40// skip - number of records to skip. 41func (client ReportsClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 42 if tracing.IsEnabled() { 43 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByAPI") 44 defer func() { 45 sc := -1 46 if result.rc.Response.Response != nil { 47 sc = result.rc.Response.Response.StatusCode 48 } 49 tracing.EndSpan(ctx, sc, err) 50 }() 51 } 52 if err := validation.Validate([]validation.Validation{ 53 {TargetValue: serviceName, 54 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 55 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 56 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 57 {TargetValue: top, 58 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 59 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 60 {TargetValue: skip, 61 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 62 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 63 return result, validation.NewError("apimanagement.ReportsClient", "ListByAPI", err.Error()) 64 } 65 66 result.fn = client.listByAPINextResults 67 req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", nil, "Failure preparing request") 70 return 71 } 72 73 resp, err := client.ListByAPISender(req) 74 if err != nil { 75 result.rc.Response = autorest.Response{Response: resp} 76 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", resp, "Failure sending request") 77 return 78 } 79 80 result.rc, err = client.ListByAPIResponder(resp) 81 if err != nil { 82 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", resp, "Failure responding to request") 83 return 84 } 85 if result.rc.hasNextLink() && result.rc.IsEmpty() { 86 err = result.NextWithContext(ctx) 87 return 88 } 89 90 return 91} 92 93// ListByAPIPreparer prepares the ListByAPI request. 94func (client ReportsClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 95 pathParameters := map[string]interface{}{ 96 "resourceGroupName": autorest.Encode("path", resourceGroupName), 97 "serviceName": autorest.Encode("path", serviceName), 98 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 99 } 100 101 const APIVersion = "2018-06-01-preview" 102 queryParameters := map[string]interface{}{ 103 "$filter": autorest.Encode("query", filter), 104 "api-version": APIVersion, 105 } 106 if top != nil { 107 queryParameters["$top"] = autorest.Encode("query", *top) 108 } 109 if skip != nil { 110 queryParameters["$skip"] = autorest.Encode("query", *skip) 111 } 112 113 preparer := autorest.CreatePreparer( 114 autorest.AsGet(), 115 autorest.WithBaseURL(client.BaseURI), 116 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi", pathParameters), 117 autorest.WithQueryParameters(queryParameters)) 118 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 119} 120 121// ListByAPISender sends the ListByAPI request. The method will close the 122// http.Response Body if it receives an error. 123func (client ReportsClient) ListByAPISender(req *http.Request) (*http.Response, error) { 124 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 125} 126 127// ListByAPIResponder handles the response to the ListByAPI request. The method always 128// closes the http.Response Body. 129func (client ReportsClient) ListByAPIResponder(resp *http.Response) (result ReportCollection, err error) { 130 err = autorest.Respond( 131 resp, 132 azure.WithErrorUnlessStatusCode(http.StatusOK), 133 autorest.ByUnmarshallingJSON(&result), 134 autorest.ByClosing()) 135 result.Response = autorest.Response{Response: resp} 136 return 137} 138 139// listByAPINextResults retrieves the next set of results, if any. 140func (client ReportsClient) listByAPINextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 141 req, err := lastResults.reportCollectionPreparer(ctx) 142 if err != nil { 143 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", nil, "Failure preparing next results request") 144 } 145 if req == nil { 146 return 147 } 148 resp, err := client.ListByAPISender(req) 149 if err != nil { 150 result.Response = autorest.Response{Response: resp} 151 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", resp, "Failure sending next results request") 152 } 153 result, err = client.ListByAPIResponder(resp) 154 if err != nil { 155 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", resp, "Failure responding to next results request") 156 } 157 return 158} 159 160// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required. 161func (client ReportsClient) ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 162 if tracing.IsEnabled() { 163 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByAPI") 164 defer func() { 165 sc := -1 166 if result.Response().Response.Response != nil { 167 sc = result.page.Response().Response.Response.StatusCode 168 } 169 tracing.EndSpan(ctx, sc, err) 170 }() 171 } 172 result.page, err = client.ListByAPI(ctx, resourceGroupName, serviceName, filter, top, skip) 173 return 174} 175 176// ListByGeo lists report records by geography. 177// Parameters: 178// resourceGroupName - the name of the resource group. 179// serviceName - the name of the API Management service. 180// filter - the filter to apply on the operation. 181// top - number of records to return. 182// skip - number of records to skip. 183func (client ReportsClient) ListByGeo(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 184 if tracing.IsEnabled() { 185 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByGeo") 186 defer func() { 187 sc := -1 188 if result.rc.Response.Response != nil { 189 sc = result.rc.Response.Response.StatusCode 190 } 191 tracing.EndSpan(ctx, sc, err) 192 }() 193 } 194 if err := validation.Validate([]validation.Validation{ 195 {TargetValue: serviceName, 196 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 197 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 198 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 199 {TargetValue: top, 200 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 201 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 202 {TargetValue: skip, 203 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 204 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 205 return result, validation.NewError("apimanagement.ReportsClient", "ListByGeo", err.Error()) 206 } 207 208 result.fn = client.listByGeoNextResults 209 req, err := client.ListByGeoPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 210 if err != nil { 211 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", nil, "Failure preparing request") 212 return 213 } 214 215 resp, err := client.ListByGeoSender(req) 216 if err != nil { 217 result.rc.Response = autorest.Response{Response: resp} 218 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", resp, "Failure sending request") 219 return 220 } 221 222 result.rc, err = client.ListByGeoResponder(resp) 223 if err != nil { 224 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", resp, "Failure responding to request") 225 return 226 } 227 if result.rc.hasNextLink() && result.rc.IsEmpty() { 228 err = result.NextWithContext(ctx) 229 return 230 } 231 232 return 233} 234 235// ListByGeoPreparer prepares the ListByGeo request. 236func (client ReportsClient) ListByGeoPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 237 pathParameters := map[string]interface{}{ 238 "resourceGroupName": autorest.Encode("path", resourceGroupName), 239 "serviceName": autorest.Encode("path", serviceName), 240 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 241 } 242 243 const APIVersion = "2018-06-01-preview" 244 queryParameters := map[string]interface{}{ 245 "api-version": APIVersion, 246 } 247 if len(filter) > 0 { 248 queryParameters["$filter"] = autorest.Encode("query", filter) 249 } 250 if top != nil { 251 queryParameters["$top"] = autorest.Encode("query", *top) 252 } 253 if skip != nil { 254 queryParameters["$skip"] = autorest.Encode("query", *skip) 255 } 256 257 preparer := autorest.CreatePreparer( 258 autorest.AsGet(), 259 autorest.WithBaseURL(client.BaseURI), 260 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo", pathParameters), 261 autorest.WithQueryParameters(queryParameters)) 262 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 263} 264 265// ListByGeoSender sends the ListByGeo request. The method will close the 266// http.Response Body if it receives an error. 267func (client ReportsClient) ListByGeoSender(req *http.Request) (*http.Response, error) { 268 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 269} 270 271// ListByGeoResponder handles the response to the ListByGeo request. The method always 272// closes the http.Response Body. 273func (client ReportsClient) ListByGeoResponder(resp *http.Response) (result ReportCollection, err error) { 274 err = autorest.Respond( 275 resp, 276 azure.WithErrorUnlessStatusCode(http.StatusOK), 277 autorest.ByUnmarshallingJSON(&result), 278 autorest.ByClosing()) 279 result.Response = autorest.Response{Response: resp} 280 return 281} 282 283// listByGeoNextResults retrieves the next set of results, if any. 284func (client ReportsClient) listByGeoNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 285 req, err := lastResults.reportCollectionPreparer(ctx) 286 if err != nil { 287 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", nil, "Failure preparing next results request") 288 } 289 if req == nil { 290 return 291 } 292 resp, err := client.ListByGeoSender(req) 293 if err != nil { 294 result.Response = autorest.Response{Response: resp} 295 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", resp, "Failure sending next results request") 296 } 297 result, err = client.ListByGeoResponder(resp) 298 if err != nil { 299 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", resp, "Failure responding to next results request") 300 } 301 return 302} 303 304// ListByGeoComplete enumerates all values, automatically crossing page boundaries as required. 305func (client ReportsClient) ListByGeoComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 306 if tracing.IsEnabled() { 307 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByGeo") 308 defer func() { 309 sc := -1 310 if result.Response().Response.Response != nil { 311 sc = result.page.Response().Response.Response.StatusCode 312 } 313 tracing.EndSpan(ctx, sc, err) 314 }() 315 } 316 result.page, err = client.ListByGeo(ctx, resourceGroupName, serviceName, filter, top, skip) 317 return 318} 319 320// ListByOperation lists report records by API Operations. 321// Parameters: 322// resourceGroupName - the name of the resource group. 323// serviceName - the name of the API Management service. 324// filter - the filter to apply on the operation. 325// top - number of records to return. 326// skip - number of records to skip. 327func (client ReportsClient) ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 328 if tracing.IsEnabled() { 329 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByOperation") 330 defer func() { 331 sc := -1 332 if result.rc.Response.Response != nil { 333 sc = result.rc.Response.Response.StatusCode 334 } 335 tracing.EndSpan(ctx, sc, err) 336 }() 337 } 338 if err := validation.Validate([]validation.Validation{ 339 {TargetValue: serviceName, 340 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 341 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 342 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 343 {TargetValue: top, 344 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 345 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 346 {TargetValue: skip, 347 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 348 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 349 return result, validation.NewError("apimanagement.ReportsClient", "ListByOperation", err.Error()) 350 } 351 352 result.fn = client.listByOperationNextResults 353 req, err := client.ListByOperationPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 354 if err != nil { 355 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", nil, "Failure preparing request") 356 return 357 } 358 359 resp, err := client.ListByOperationSender(req) 360 if err != nil { 361 result.rc.Response = autorest.Response{Response: resp} 362 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", resp, "Failure sending request") 363 return 364 } 365 366 result.rc, err = client.ListByOperationResponder(resp) 367 if err != nil { 368 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", resp, "Failure responding to request") 369 return 370 } 371 if result.rc.hasNextLink() && result.rc.IsEmpty() { 372 err = result.NextWithContext(ctx) 373 return 374 } 375 376 return 377} 378 379// ListByOperationPreparer prepares the ListByOperation request. 380func (client ReportsClient) ListByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 381 pathParameters := map[string]interface{}{ 382 "resourceGroupName": autorest.Encode("path", resourceGroupName), 383 "serviceName": autorest.Encode("path", serviceName), 384 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 385 } 386 387 const APIVersion = "2018-06-01-preview" 388 queryParameters := map[string]interface{}{ 389 "$filter": autorest.Encode("query", filter), 390 "api-version": APIVersion, 391 } 392 if top != nil { 393 queryParameters["$top"] = autorest.Encode("query", *top) 394 } 395 if skip != nil { 396 queryParameters["$skip"] = autorest.Encode("query", *skip) 397 } 398 399 preparer := autorest.CreatePreparer( 400 autorest.AsGet(), 401 autorest.WithBaseURL(client.BaseURI), 402 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation", pathParameters), 403 autorest.WithQueryParameters(queryParameters)) 404 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 405} 406 407// ListByOperationSender sends the ListByOperation request. The method will close the 408// http.Response Body if it receives an error. 409func (client ReportsClient) ListByOperationSender(req *http.Request) (*http.Response, error) { 410 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 411} 412 413// ListByOperationResponder handles the response to the ListByOperation request. The method always 414// closes the http.Response Body. 415func (client ReportsClient) ListByOperationResponder(resp *http.Response) (result ReportCollection, err error) { 416 err = autorest.Respond( 417 resp, 418 azure.WithErrorUnlessStatusCode(http.StatusOK), 419 autorest.ByUnmarshallingJSON(&result), 420 autorest.ByClosing()) 421 result.Response = autorest.Response{Response: resp} 422 return 423} 424 425// listByOperationNextResults retrieves the next set of results, if any. 426func (client ReportsClient) listByOperationNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 427 req, err := lastResults.reportCollectionPreparer(ctx) 428 if err != nil { 429 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", nil, "Failure preparing next results request") 430 } 431 if req == nil { 432 return 433 } 434 resp, err := client.ListByOperationSender(req) 435 if err != nil { 436 result.Response = autorest.Response{Response: resp} 437 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", resp, "Failure sending next results request") 438 } 439 result, err = client.ListByOperationResponder(resp) 440 if err != nil { 441 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", resp, "Failure responding to next results request") 442 } 443 return 444} 445 446// ListByOperationComplete enumerates all values, automatically crossing page boundaries as required. 447func (client ReportsClient) ListByOperationComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 448 if tracing.IsEnabled() { 449 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByOperation") 450 defer func() { 451 sc := -1 452 if result.Response().Response.Response != nil { 453 sc = result.page.Response().Response.Response.StatusCode 454 } 455 tracing.EndSpan(ctx, sc, err) 456 }() 457 } 458 result.page, err = client.ListByOperation(ctx, resourceGroupName, serviceName, filter, top, skip) 459 return 460} 461 462// ListByProduct lists report records by Product. 463// Parameters: 464// resourceGroupName - the name of the resource group. 465// serviceName - the name of the API Management service. 466// filter - the filter to apply on the operation. 467// top - number of records to return. 468// skip - number of records to skip. 469func (client ReportsClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 470 if tracing.IsEnabled() { 471 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByProduct") 472 defer func() { 473 sc := -1 474 if result.rc.Response.Response != nil { 475 sc = result.rc.Response.Response.StatusCode 476 } 477 tracing.EndSpan(ctx, sc, err) 478 }() 479 } 480 if err := validation.Validate([]validation.Validation{ 481 {TargetValue: serviceName, 482 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 483 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 484 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 485 {TargetValue: top, 486 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 487 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 488 {TargetValue: skip, 489 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 490 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 491 return result, validation.NewError("apimanagement.ReportsClient", "ListByProduct", err.Error()) 492 } 493 494 result.fn = client.listByProductNextResults 495 req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 496 if err != nil { 497 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", nil, "Failure preparing request") 498 return 499 } 500 501 resp, err := client.ListByProductSender(req) 502 if err != nil { 503 result.rc.Response = autorest.Response{Response: resp} 504 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", resp, "Failure sending request") 505 return 506 } 507 508 result.rc, err = client.ListByProductResponder(resp) 509 if err != nil { 510 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", resp, "Failure responding to request") 511 return 512 } 513 if result.rc.hasNextLink() && result.rc.IsEmpty() { 514 err = result.NextWithContext(ctx) 515 return 516 } 517 518 return 519} 520 521// ListByProductPreparer prepares the ListByProduct request. 522func (client ReportsClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 523 pathParameters := map[string]interface{}{ 524 "resourceGroupName": autorest.Encode("path", resourceGroupName), 525 "serviceName": autorest.Encode("path", serviceName), 526 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 527 } 528 529 const APIVersion = "2018-06-01-preview" 530 queryParameters := map[string]interface{}{ 531 "$filter": autorest.Encode("query", filter), 532 "api-version": APIVersion, 533 } 534 if top != nil { 535 queryParameters["$top"] = autorest.Encode("query", *top) 536 } 537 if skip != nil { 538 queryParameters["$skip"] = autorest.Encode("query", *skip) 539 } 540 541 preparer := autorest.CreatePreparer( 542 autorest.AsGet(), 543 autorest.WithBaseURL(client.BaseURI), 544 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct", pathParameters), 545 autorest.WithQueryParameters(queryParameters)) 546 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 547} 548 549// ListByProductSender sends the ListByProduct request. The method will close the 550// http.Response Body if it receives an error. 551func (client ReportsClient) ListByProductSender(req *http.Request) (*http.Response, error) { 552 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 553} 554 555// ListByProductResponder handles the response to the ListByProduct request. The method always 556// closes the http.Response Body. 557func (client ReportsClient) ListByProductResponder(resp *http.Response) (result ReportCollection, err error) { 558 err = autorest.Respond( 559 resp, 560 azure.WithErrorUnlessStatusCode(http.StatusOK), 561 autorest.ByUnmarshallingJSON(&result), 562 autorest.ByClosing()) 563 result.Response = autorest.Response{Response: resp} 564 return 565} 566 567// listByProductNextResults retrieves the next set of results, if any. 568func (client ReportsClient) listByProductNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 569 req, err := lastResults.reportCollectionPreparer(ctx) 570 if err != nil { 571 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", nil, "Failure preparing next results request") 572 } 573 if req == nil { 574 return 575 } 576 resp, err := client.ListByProductSender(req) 577 if err != nil { 578 result.Response = autorest.Response{Response: resp} 579 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", resp, "Failure sending next results request") 580 } 581 result, err = client.ListByProductResponder(resp) 582 if err != nil { 583 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", resp, "Failure responding to next results request") 584 } 585 return 586} 587 588// ListByProductComplete enumerates all values, automatically crossing page boundaries as required. 589func (client ReportsClient) ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 590 if tracing.IsEnabled() { 591 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByProduct") 592 defer func() { 593 sc := -1 594 if result.Response().Response.Response != nil { 595 sc = result.page.Response().Response.Response.StatusCode 596 } 597 tracing.EndSpan(ctx, sc, err) 598 }() 599 } 600 result.page, err = client.ListByProduct(ctx, resourceGroupName, serviceName, filter, top, skip) 601 return 602} 603 604// ListByRequest lists report records by Request. 605// Parameters: 606// resourceGroupName - the name of the resource group. 607// serviceName - the name of the API Management service. 608// filter - the filter to apply on the operation. 609// top - number of records to return. 610// skip - number of records to skip. 611func (client ReportsClient) ListByRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result RequestReportCollection, err error) { 612 if tracing.IsEnabled() { 613 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByRequest") 614 defer func() { 615 sc := -1 616 if result.Response.Response != nil { 617 sc = result.Response.Response.StatusCode 618 } 619 tracing.EndSpan(ctx, sc, err) 620 }() 621 } 622 if err := validation.Validate([]validation.Validation{ 623 {TargetValue: serviceName, 624 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 625 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 626 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 627 {TargetValue: top, 628 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 629 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 630 {TargetValue: skip, 631 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 632 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 633 return result, validation.NewError("apimanagement.ReportsClient", "ListByRequest", err.Error()) 634 } 635 636 req, err := client.ListByRequestPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 637 if err != nil { 638 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", nil, "Failure preparing request") 639 return 640 } 641 642 resp, err := client.ListByRequestSender(req) 643 if err != nil { 644 result.Response = autorest.Response{Response: resp} 645 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", resp, "Failure sending request") 646 return 647 } 648 649 result, err = client.ListByRequestResponder(resp) 650 if err != nil { 651 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", resp, "Failure responding to request") 652 return 653 } 654 655 return 656} 657 658// ListByRequestPreparer prepares the ListByRequest request. 659func (client ReportsClient) ListByRequestPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 660 pathParameters := map[string]interface{}{ 661 "resourceGroupName": autorest.Encode("path", resourceGroupName), 662 "serviceName": autorest.Encode("path", serviceName), 663 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 664 } 665 666 const APIVersion = "2018-06-01-preview" 667 queryParameters := map[string]interface{}{ 668 "$filter": autorest.Encode("query", filter), 669 "api-version": APIVersion, 670 } 671 if top != nil { 672 queryParameters["$top"] = autorest.Encode("query", *top) 673 } 674 if skip != nil { 675 queryParameters["$skip"] = autorest.Encode("query", *skip) 676 } 677 678 preparer := autorest.CreatePreparer( 679 autorest.AsGet(), 680 autorest.WithBaseURL(client.BaseURI), 681 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest", pathParameters), 682 autorest.WithQueryParameters(queryParameters)) 683 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 684} 685 686// ListByRequestSender sends the ListByRequest request. The method will close the 687// http.Response Body if it receives an error. 688func (client ReportsClient) ListByRequestSender(req *http.Request) (*http.Response, error) { 689 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 690} 691 692// ListByRequestResponder handles the response to the ListByRequest request. The method always 693// closes the http.Response Body. 694func (client ReportsClient) ListByRequestResponder(resp *http.Response) (result RequestReportCollection, err error) { 695 err = autorest.Respond( 696 resp, 697 azure.WithErrorUnlessStatusCode(http.StatusOK), 698 autorest.ByUnmarshallingJSON(&result), 699 autorest.ByClosing()) 700 result.Response = autorest.Response{Response: resp} 701 return 702} 703 704// ListBySubscription lists report records by subscription. 705// Parameters: 706// resourceGroupName - the name of the resource group. 707// serviceName - the name of the API Management service. 708// filter - the filter to apply on the operation. 709// top - number of records to return. 710// skip - number of records to skip. 711func (client ReportsClient) ListBySubscription(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 712 if tracing.IsEnabled() { 713 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListBySubscription") 714 defer func() { 715 sc := -1 716 if result.rc.Response.Response != nil { 717 sc = result.rc.Response.Response.StatusCode 718 } 719 tracing.EndSpan(ctx, sc, err) 720 }() 721 } 722 if err := validation.Validate([]validation.Validation{ 723 {TargetValue: serviceName, 724 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 725 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 726 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 727 {TargetValue: top, 728 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 729 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 730 {TargetValue: skip, 731 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 732 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 733 return result, validation.NewError("apimanagement.ReportsClient", "ListBySubscription", err.Error()) 734 } 735 736 result.fn = client.listBySubscriptionNextResults 737 req, err := client.ListBySubscriptionPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 738 if err != nil { 739 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", nil, "Failure preparing request") 740 return 741 } 742 743 resp, err := client.ListBySubscriptionSender(req) 744 if err != nil { 745 result.rc.Response = autorest.Response{Response: resp} 746 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", resp, "Failure sending request") 747 return 748 } 749 750 result.rc, err = client.ListBySubscriptionResponder(resp) 751 if err != nil { 752 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", resp, "Failure responding to request") 753 return 754 } 755 if result.rc.hasNextLink() && result.rc.IsEmpty() { 756 err = result.NextWithContext(ctx) 757 return 758 } 759 760 return 761} 762 763// ListBySubscriptionPreparer prepares the ListBySubscription request. 764func (client ReportsClient) ListBySubscriptionPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 765 pathParameters := map[string]interface{}{ 766 "resourceGroupName": autorest.Encode("path", resourceGroupName), 767 "serviceName": autorest.Encode("path", serviceName), 768 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 769 } 770 771 const APIVersion = "2018-06-01-preview" 772 queryParameters := map[string]interface{}{ 773 "api-version": APIVersion, 774 } 775 if len(filter) > 0 { 776 queryParameters["$filter"] = autorest.Encode("query", filter) 777 } 778 if top != nil { 779 queryParameters["$top"] = autorest.Encode("query", *top) 780 } 781 if skip != nil { 782 queryParameters["$skip"] = autorest.Encode("query", *skip) 783 } 784 785 preparer := autorest.CreatePreparer( 786 autorest.AsGet(), 787 autorest.WithBaseURL(client.BaseURI), 788 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription", pathParameters), 789 autorest.WithQueryParameters(queryParameters)) 790 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 791} 792 793// ListBySubscriptionSender sends the ListBySubscription request. The method will close the 794// http.Response Body if it receives an error. 795func (client ReportsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { 796 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 797} 798 799// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always 800// closes the http.Response Body. 801func (client ReportsClient) ListBySubscriptionResponder(resp *http.Response) (result ReportCollection, err error) { 802 err = autorest.Respond( 803 resp, 804 azure.WithErrorUnlessStatusCode(http.StatusOK), 805 autorest.ByUnmarshallingJSON(&result), 806 autorest.ByClosing()) 807 result.Response = autorest.Response{Response: resp} 808 return 809} 810 811// listBySubscriptionNextResults retrieves the next set of results, if any. 812func (client ReportsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 813 req, err := lastResults.reportCollectionPreparer(ctx) 814 if err != nil { 815 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") 816 } 817 if req == nil { 818 return 819 } 820 resp, err := client.ListBySubscriptionSender(req) 821 if err != nil { 822 result.Response = autorest.Response{Response: resp} 823 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") 824 } 825 result, err = client.ListBySubscriptionResponder(resp) 826 if err != nil { 827 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") 828 } 829 return 830} 831 832// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. 833func (client ReportsClient) ListBySubscriptionComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 834 if tracing.IsEnabled() { 835 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListBySubscription") 836 defer func() { 837 sc := -1 838 if result.Response().Response.Response != nil { 839 sc = result.page.Response().Response.Response.StatusCode 840 } 841 tracing.EndSpan(ctx, sc, err) 842 }() 843 } 844 result.page, err = client.ListBySubscription(ctx, resourceGroupName, serviceName, filter, top, skip) 845 return 846} 847 848// ListByTime lists report records by Time. 849// Parameters: 850// resourceGroupName - the name of the resource group. 851// serviceName - the name of the API Management service. 852// interval - by time interval. Interval must be multiple of 15 minutes and may not be zero. The value should 853// be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert 854// TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)) 855// filter - the filter to apply on the operation. 856// top - number of records to return. 857// skip - number of records to skip. 858func (client ReportsClient) ListByTime(ctx context.Context, resourceGroupName string, serviceName string, interval string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 859 if tracing.IsEnabled() { 860 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByTime") 861 defer func() { 862 sc := -1 863 if result.rc.Response.Response != nil { 864 sc = result.rc.Response.Response.StatusCode 865 } 866 tracing.EndSpan(ctx, sc, err) 867 }() 868 } 869 if err := validation.Validate([]validation.Validation{ 870 {TargetValue: serviceName, 871 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 872 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 873 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 874 {TargetValue: top, 875 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 876 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 877 {TargetValue: skip, 878 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 879 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 880 return result, validation.NewError("apimanagement.ReportsClient", "ListByTime", err.Error()) 881 } 882 883 result.fn = client.listByTimeNextResults 884 req, err := client.ListByTimePreparer(ctx, resourceGroupName, serviceName, interval, filter, top, skip) 885 if err != nil { 886 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", nil, "Failure preparing request") 887 return 888 } 889 890 resp, err := client.ListByTimeSender(req) 891 if err != nil { 892 result.rc.Response = autorest.Response{Response: resp} 893 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", resp, "Failure sending request") 894 return 895 } 896 897 result.rc, err = client.ListByTimeResponder(resp) 898 if err != nil { 899 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", resp, "Failure responding to request") 900 return 901 } 902 if result.rc.hasNextLink() && result.rc.IsEmpty() { 903 err = result.NextWithContext(ctx) 904 return 905 } 906 907 return 908} 909 910// ListByTimePreparer prepares the ListByTime request. 911func (client ReportsClient) ListByTimePreparer(ctx context.Context, resourceGroupName string, serviceName string, interval string, filter string, top *int32, skip *int32) (*http.Request, error) { 912 pathParameters := map[string]interface{}{ 913 "resourceGroupName": autorest.Encode("path", resourceGroupName), 914 "serviceName": autorest.Encode("path", serviceName), 915 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 916 } 917 918 const APIVersion = "2018-06-01-preview" 919 queryParameters := map[string]interface{}{ 920 "api-version": APIVersion, 921 "interval": autorest.Encode("query", interval), 922 } 923 if len(filter) > 0 { 924 queryParameters["$filter"] = autorest.Encode("query", filter) 925 } 926 if top != nil { 927 queryParameters["$top"] = autorest.Encode("query", *top) 928 } 929 if skip != nil { 930 queryParameters["$skip"] = autorest.Encode("query", *skip) 931 } 932 933 preparer := autorest.CreatePreparer( 934 autorest.AsGet(), 935 autorest.WithBaseURL(client.BaseURI), 936 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime", pathParameters), 937 autorest.WithQueryParameters(queryParameters)) 938 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 939} 940 941// ListByTimeSender sends the ListByTime request. The method will close the 942// http.Response Body if it receives an error. 943func (client ReportsClient) ListByTimeSender(req *http.Request) (*http.Response, error) { 944 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 945} 946 947// ListByTimeResponder handles the response to the ListByTime request. The method always 948// closes the http.Response Body. 949func (client ReportsClient) ListByTimeResponder(resp *http.Response) (result ReportCollection, err error) { 950 err = autorest.Respond( 951 resp, 952 azure.WithErrorUnlessStatusCode(http.StatusOK), 953 autorest.ByUnmarshallingJSON(&result), 954 autorest.ByClosing()) 955 result.Response = autorest.Response{Response: resp} 956 return 957} 958 959// listByTimeNextResults retrieves the next set of results, if any. 960func (client ReportsClient) listByTimeNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 961 req, err := lastResults.reportCollectionPreparer(ctx) 962 if err != nil { 963 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", nil, "Failure preparing next results request") 964 } 965 if req == nil { 966 return 967 } 968 resp, err := client.ListByTimeSender(req) 969 if err != nil { 970 result.Response = autorest.Response{Response: resp} 971 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", resp, "Failure sending next results request") 972 } 973 result, err = client.ListByTimeResponder(resp) 974 if err != nil { 975 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", resp, "Failure responding to next results request") 976 } 977 return 978} 979 980// ListByTimeComplete enumerates all values, automatically crossing page boundaries as required. 981func (client ReportsClient) ListByTimeComplete(ctx context.Context, resourceGroupName string, serviceName string, interval string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 982 if tracing.IsEnabled() { 983 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByTime") 984 defer func() { 985 sc := -1 986 if result.Response().Response.Response != nil { 987 sc = result.page.Response().Response.Response.StatusCode 988 } 989 tracing.EndSpan(ctx, sc, err) 990 }() 991 } 992 result.page, err = client.ListByTime(ctx, resourceGroupName, serviceName, interval, filter, top, skip) 993 return 994} 995 996// ListByUser lists report records by User. 997// Parameters: 998// resourceGroupName - the name of the resource group. 999// serviceName - the name of the API Management service. 1000// filter - the filter to apply on the operation. 1001// top - number of records to return. 1002// skip - number of records to skip. 1003func (client ReportsClient) ListByUser(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { 1004 if tracing.IsEnabled() { 1005 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByUser") 1006 defer func() { 1007 sc := -1 1008 if result.rc.Response.Response != nil { 1009 sc = result.rc.Response.Response.StatusCode 1010 } 1011 tracing.EndSpan(ctx, sc, err) 1012 }() 1013 } 1014 if err := validation.Validate([]validation.Validation{ 1015 {TargetValue: serviceName, 1016 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1017 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1018 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 1019 {TargetValue: top, 1020 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1021 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 1022 {TargetValue: skip, 1023 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 1024 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1025 return result, validation.NewError("apimanagement.ReportsClient", "ListByUser", err.Error()) 1026 } 1027 1028 result.fn = client.listByUserNextResults 1029 req, err := client.ListByUserPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 1030 if err != nil { 1031 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", nil, "Failure preparing request") 1032 return 1033 } 1034 1035 resp, err := client.ListByUserSender(req) 1036 if err != nil { 1037 result.rc.Response = autorest.Response{Response: resp} 1038 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", resp, "Failure sending request") 1039 return 1040 } 1041 1042 result.rc, err = client.ListByUserResponder(resp) 1043 if err != nil { 1044 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", resp, "Failure responding to request") 1045 return 1046 } 1047 if result.rc.hasNextLink() && result.rc.IsEmpty() { 1048 err = result.NextWithContext(ctx) 1049 return 1050 } 1051 1052 return 1053} 1054 1055// ListByUserPreparer prepares the ListByUser request. 1056func (client ReportsClient) ListByUserPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 1057 pathParameters := map[string]interface{}{ 1058 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1059 "serviceName": autorest.Encode("path", serviceName), 1060 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1061 } 1062 1063 const APIVersion = "2018-06-01-preview" 1064 queryParameters := map[string]interface{}{ 1065 "$filter": autorest.Encode("query", filter), 1066 "api-version": APIVersion, 1067 } 1068 if top != nil { 1069 queryParameters["$top"] = autorest.Encode("query", *top) 1070 } 1071 if skip != nil { 1072 queryParameters["$skip"] = autorest.Encode("query", *skip) 1073 } 1074 1075 preparer := autorest.CreatePreparer( 1076 autorest.AsGet(), 1077 autorest.WithBaseURL(client.BaseURI), 1078 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser", pathParameters), 1079 autorest.WithQueryParameters(queryParameters)) 1080 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1081} 1082 1083// ListByUserSender sends the ListByUser request. The method will close the 1084// http.Response Body if it receives an error. 1085func (client ReportsClient) ListByUserSender(req *http.Request) (*http.Response, error) { 1086 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1087} 1088 1089// ListByUserResponder handles the response to the ListByUser request. The method always 1090// closes the http.Response Body. 1091func (client ReportsClient) ListByUserResponder(resp *http.Response) (result ReportCollection, err error) { 1092 err = autorest.Respond( 1093 resp, 1094 azure.WithErrorUnlessStatusCode(http.StatusOK), 1095 autorest.ByUnmarshallingJSON(&result), 1096 autorest.ByClosing()) 1097 result.Response = autorest.Response{Response: resp} 1098 return 1099} 1100 1101// listByUserNextResults retrieves the next set of results, if any. 1102func (client ReportsClient) listByUserNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { 1103 req, err := lastResults.reportCollectionPreparer(ctx) 1104 if err != nil { 1105 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", nil, "Failure preparing next results request") 1106 } 1107 if req == nil { 1108 return 1109 } 1110 resp, err := client.ListByUserSender(req) 1111 if err != nil { 1112 result.Response = autorest.Response{Response: resp} 1113 return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", resp, "Failure sending next results request") 1114 } 1115 result, err = client.ListByUserResponder(resp) 1116 if err != nil { 1117 err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", resp, "Failure responding to next results request") 1118 } 1119 return 1120} 1121 1122// ListByUserComplete enumerates all values, automatically crossing page boundaries as required. 1123func (client ReportsClient) ListByUserComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { 1124 if tracing.IsEnabled() { 1125 ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByUser") 1126 defer func() { 1127 sc := -1 1128 if result.Response().Response.Response != nil { 1129 sc = result.page.Response().Response.Response.StatusCode 1130 } 1131 tracing.EndSpan(ctx, sc, err) 1132 }() 1133 } 1134 result.page, err = client.ListByUser(ctx, resourceGroupName, serviceName, filter, top, skip) 1135 return 1136} 1137