From 38ef45465488b65431256c268b459fcf1be14a46 Mon Sep 17 00:00:00 2001 From: Phoenix He Date: Fri, 25 Oct 2019 08:48:19 +0800 Subject: [PATCH 1/2] Update swagger_to_sdk_config.json --- swagger_to_sdk_config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swagger_to_sdk_config.json b/swagger_to_sdk_config.json index afc88f9313de5..143b2e76ed7b5 100644 --- a/swagger_to_sdk_config.json +++ b/swagger_to_sdk_config.json @@ -6,7 +6,8 @@ "verbose": "", "sdkrel:azure-libraries-for-java-folder": ".", "multiapi": "", - "use": "@microsoft.azure/autorest.java@preview" + "use": "@microsoft.azure/autorest.java@preview", + "java.clear-output-folder": "" }, "version": "0.2.0", "advanced_options": { From 5bcb888f374eaaa0df9c68c88b2e95352be579d0 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Fri, 25 Oct 2019 10:06:34 +0000 Subject: [PATCH 2/2] Generated from a71df15a587ec060147aaef2dcfc12d19500fdc8 Fix json format by prettier --- .../resource-manager/v2018_03_31/pom.xml | 135 +++ .../consumption/v2018_03_31/Balance.java | 118 ++ ...alancePropertiesAdjustmentDetailsItem.java | 48 + ...ancePropertiesNewPurchasesDetailsItem.java | 48 + .../v2018_03_31/BillingFrequency.java | 44 + .../consumption/v2018_03_31/Budget.java | 249 ++++ .../v2018_03_31/BudgetTimePeriod.java | 71 ++ .../consumption/v2018_03_31/Budgets.java | 55 + .../consumption/v2018_03_31/CategoryType.java | 41 + .../consumption/v2018_03_31/CostTags.java | 37 + .../v2018_03_31/CostTagsModel.java | 47 + .../consumption/v2018_03_31/CurrentSpend.java | 48 + .../consumption/v2018_03_31/Datagrain.java | 41 + .../consumption/v2018_03_31/ErrorDetails.java | 47 + .../v2018_03_31/ErrorResponse.java | 44 + .../v2018_03_31/ErrorResponseException.java | 44 + .../consumption/v2018_03_31/Filters.java | 126 ++ .../GetBalancesByBillingAccounts.java | 27 + .../consumption/v2018_03_31/Marketplace.java | 164 +++ .../consumption/v2018_03_31/Marketplaces.java | 34 + .../MarketplacesByBillingAccounts.java | 36 + .../MarketplacesByDepartments.java | 36 + .../MarketplacesByEnrollmentAccounts.java | 36 + .../consumption/v2018_03_31/MeterDetails.java | 126 ++ .../consumption/v2018_03_31/Notification.java | 181 +++ .../consumption/v2018_03_31/Operation.java | 30 + .../v2018_03_31/OperationDisplay.java | 62 + .../consumption/v2018_03_31/Operations.java | 27 + .../consumption/v2018_03_31/OperatorType.java | 44 + .../v2018_03_31/PriceSheetProperties.java | 140 +++ .../v2018_03_31/PriceSheetResult.java | 52 + .../consumption/v2018_03_31/PriceSheets.java | 36 + .../consumption/v2018_03_31/QueryOptions.java | 44 + .../v2018_03_31/ReservationDetails.java | 83 ++ .../ReservationRecommendations.java | 19 + .../ReservationRecommendationsModel.java | 76 ++ .../v2018_03_31/ReservationSummaries.java | 88 ++ .../v2018_03_31/ReservationsDetails.java | 38 + .../v2018_03_31/ReservationsSummaries.java | 38 + .../v2018_03_31/ResourceAttributes.java | 47 + .../consumption/v2018_03_31/Tags.java | 26 + .../consumption/v2018_03_31/TagsModel.java | 47 + .../v2018_03_31/TimeGrainType.java | 44 + .../consumption/v2018_03_31/UsageDetail.java | 154 +++ .../consumption/v2018_03_31/UsageDetails.java | 34 + .../UsageDetailsByBillingAccounts.java | 36 + .../UsageDetailsByDepartments.java | 36 + .../UsageDetailsByEnrollmentAccounts.java | 36 + .../implementation/BalanceImpl.java | 127 ++ .../implementation/BalanceInner.java | 279 +++++ .../implementation/BudgetImpl.java | 182 +++ .../implementation/BudgetInner.java | 235 ++++ .../implementation/BudgetsImpl.java | 215 ++++ .../implementation/BudgetsInner.java | 1063 +++++++++++++++++ .../ConsumptionManagementClientImpl.java | 530 ++++++++ .../implementation/ConsumptionManager.java | 291 +++++ .../implementation/CostTagInner.java | 43 + .../implementation/CostTagsImpl.java | 54 + .../implementation/CostTagsInner.java | 228 ++++ .../implementation/CostTagsModelImpl.java | 52 + .../implementation/CostTagsModelInner.java | 75 ++ .../GetBalancesByBillingAccountsImpl.java | 42 + .../GetBalancesByBillingAccountsInner.java | 143 +++ .../implementation/IdParsingUtils.java | 57 + .../implementation/MarketplaceImpl.java | 170 +++ .../implementation/MarketplaceInner.java | 401 +++++++ .../MarketplacesByBillingAccountsImpl.java | 67 ++ .../MarketplacesByBillingAccountsInner.java | 785 ++++++++++++ .../MarketplacesByDepartmentsImpl.java | 67 ++ .../MarketplacesByDepartmentsInner.java | 785 ++++++++++++ .../MarketplacesByEnrollmentAccountsImpl.java | 67 ++ ...MarketplacesByEnrollmentAccountsInner.java | 785 ++++++++++++ .../implementation/MarketplacesImpl.java | 67 ++ .../implementation/MarketplacesInner.java | 765 ++++++++++++ .../implementation/OperationImpl.java | 37 + .../implementation/OperationInner.java | 59 + .../implementation/OperationsImpl.java | 49 + .../implementation/OperationsInner.java | 283 +++++ .../v2018_03_31/implementation/PageImpl.java | 75 ++ .../implementation/PriceSheetResultImpl.java | 59 + .../implementation/PriceSheetResultInner.java | 68 ++ .../implementation/PriceSheetsImpl.java | 54 + .../implementation/PriceSheetsInner.java | 382 ++++++ .../ReservationDetailsImpl.java | 89 ++ .../ReservationDetailsInner.java | 169 +++ .../ReservationRecommendationsImpl.java | 71 ++ .../ReservationRecommendationsInner.java | 393 ++++++ .../ReservationRecommendationsModelImpl.java | 93 ++ .../ReservationRecommendationsModelInner.java | 248 ++++ .../ReservationSummariesImpl.java | 94 ++ .../ReservationSummariesInner.java | 188 +++ .../ReservationsDetailsImpl.java | 67 ++ .../ReservationsDetailsInner.java | 547 +++++++++ .../ReservationsSummariesImpl.java | 68 ++ .../ReservationsSummariesInner.java | 794 ++++++++++++ .../v2018_03_31/implementation/TagInner.java | 43 + .../v2018_03_31/implementation/TagsImpl.java | 42 + .../v2018_03_31/implementation/TagsInner.java | 136 +++ .../implementation/TagsModelImpl.java | 52 + .../implementation/TagsModelInner.java | 75 ++ .../implementation/UsageDetailImpl.java | 161 +++ .../implementation/UsageDetailInner.java | 373 ++++++ .../UsageDetailsByBillingAccountsImpl.java | 67 ++ .../UsageDetailsByBillingAccountsInner.java | 823 +++++++++++++ .../UsageDetailsByDepartmentsImpl.java | 67 ++ .../UsageDetailsByDepartmentsInner.java | 823 +++++++++++++ .../UsageDetailsByEnrollmentAccountsImpl.java | 67 ++ ...UsageDetailsByEnrollmentAccountsInner.java | 823 +++++++++++++ .../implementation/UsageDetailsImpl.java | 67 ++ .../implementation/UsageDetailsInner.java | 803 +++++++++++++ .../implementation/package-info.java | 11 + .../consumption/v2018_03_31/package-info.java | 11 + 112 files changed, 19026 insertions(+) create mode 100644 consumption/resource-manager/v2018_03_31/pom.xml create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Balance.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesAdjustmentDetailsItem.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesNewPurchasesDetailsItem.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BillingFrequency.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budget.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BudgetTimePeriod.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budgets.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CategoryType.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTags.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTagsModel.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CurrentSpend.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Datagrain.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorDetails.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponse.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponseException.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Filters.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/GetBalancesByBillingAccounts.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplace.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplaces.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByBillingAccounts.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByDepartments.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByEnrollmentAccounts.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MeterDetails.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Notification.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operation.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperationDisplay.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operations.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperatorType.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetProperties.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetResult.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheets.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/QueryOptions.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationDetails.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendations.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendationsModel.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationSummaries.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsDetails.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsSummaries.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ResourceAttributes.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Tags.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TagsModel.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TimeGrainType.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetail.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetails.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByBillingAccounts.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByDepartments.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByEnrollmentAccounts.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManagementClientImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManager.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/IdParsingUtils.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PageImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsImpl.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsInner.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/package-info.java create mode 100644 consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/package-info.java diff --git a/consumption/resource-manager/v2018_03_31/pom.xml b/consumption/resource-manager/v2018_03_31/pom.xml new file mode 100644 index 0000000000000..3c34fde7162f5 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + com.microsoft.azure.consumption.v2018_03_31 + + com.microsoft.azure + azure-arm-parent + 1.1.0 + ../../../pom.management.xml + + azure-mgmt-consumption + 1.0.0-beta + jar + Microsoft Azure SDK for Consumption Management + This package contains Microsoft Consumption Management SDK. + https://github.com/Azure/azure-sdk-for-java + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + UTF-8 + + + + + microsoft + Microsoft + + + + + com.microsoft.azure + azure-client-runtime + + + com.microsoft.azure + azure-arm-client-runtime + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + test + + + com.microsoft.azure + azure-mgmt-resources + test + + + com.microsoft.azure + azure-arm-client-runtime + test-jar + test + + 1.6.5 + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + + true + true + + true + true + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search + + + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/ + ]]> +
+
+
+
+
+
diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Balance.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Balance.java new file mode 100644 index 0000000000000..118b0b53ae4d8 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Balance.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.BalanceInner; +import java.util.List; +import java.math.BigDecimal; +import java.util.Map; + +/** + * Type representing Balance. + */ +public interface Balance extends HasInner, HasManager { + /** + * @return the adjustmentDetails value. + */ + List adjustmentDetails(); + + /** + * @return the adjustments value. + */ + BigDecimal adjustments(); + + /** + * @return the azureMarketplaceServiceCharges value. + */ + BigDecimal azureMarketplaceServiceCharges(); + + /** + * @return the beginningBalance value. + */ + BigDecimal beginningBalance(); + + /** + * @return the billingFrequency value. + */ + BillingFrequency billingFrequency(); + + /** + * @return the chargesBilledSeparately value. + */ + BigDecimal chargesBilledSeparately(); + + /** + * @return the currency value. + */ + String currency(); + + /** + * @return the endingBalance value. + */ + BigDecimal endingBalance(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the newPurchases value. + */ + BigDecimal newPurchases(); + + /** + * @return the newPurchasesDetails value. + */ + List newPurchasesDetails(); + + /** + * @return the priceHidden value. + */ + Boolean priceHidden(); + + /** + * @return the serviceOverage value. + */ + BigDecimal serviceOverage(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the totalOverage value. + */ + BigDecimal totalOverage(); + + /** + * @return the totalUsage value. + */ + BigDecimal totalUsage(); + + /** + * @return the type value. + */ + String type(); + + /** + * @return the utilized value. + */ + BigDecimal utilized(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesAdjustmentDetailsItem.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesAdjustmentDetailsItem.java new file mode 100644 index 0000000000000..b28613239e6ed --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesAdjustmentDetailsItem.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.math.BigDecimal; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The BalancePropertiesAdjustmentDetailsItem model. + */ +public class BalancePropertiesAdjustmentDetailsItem { + /** + * the name of new adjustment. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * the value of new adjustment. + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal value; + + /** + * Get the name of new adjustment. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the value of new adjustment. + * + * @return the value value + */ + public BigDecimal value() { + return this.value; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesNewPurchasesDetailsItem.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesNewPurchasesDetailsItem.java new file mode 100644 index 0000000000000..33c5496bc801a --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BalancePropertiesNewPurchasesDetailsItem.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.math.BigDecimal; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The BalancePropertiesNewPurchasesDetailsItem model. + */ +public class BalancePropertiesNewPurchasesDetailsItem { + /** + * the name of new purchase. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * the value of new purchase. + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal value; + + /** + * Get the name of new purchase. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the value of new purchase. + * + * @return the value value + */ + public BigDecimal value() { + return this.value; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BillingFrequency.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BillingFrequency.java new file mode 100644 index 0000000000000..ac667a6c0c932 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BillingFrequency.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for BillingFrequency. + */ +public final class BillingFrequency extends ExpandableStringEnum { + /** Static value Month for BillingFrequency. */ + public static final BillingFrequency MONTH = fromString("Month"); + + /** Static value Quarter for BillingFrequency. */ + public static final BillingFrequency QUARTER = fromString("Quarter"); + + /** Static value Year for BillingFrequency. */ + public static final BillingFrequency YEAR = fromString("Year"); + + /** + * Creates or finds a BillingFrequency from its string representation. + * @param name a name to look for + * @return the corresponding BillingFrequency + */ + @JsonCreator + public static BillingFrequency fromString(String name) { + return fromString(name, BillingFrequency.class); + } + + /** + * @return known BillingFrequency values + */ + public static Collection values() { + return values(BillingFrequency.class); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budget.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budget.java new file mode 100644 index 0000000000000..a88bd722b71ce --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budget.java @@ -0,0 +1,249 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.BudgetInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Creatable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import java.math.BigDecimal; +import java.util.Map; + +/** + * Type representing Budget. + */ +public interface Budget extends HasInner, Indexable, Updatable, Refreshable, HasManager { + /** + * @return the amount value. + */ + BigDecimal amount(); + + /** + * @return the category value. + */ + CategoryType category(); + + /** + * @return the currentSpend value. + */ + CurrentSpend currentSpend(); + + /** + * @return the eTag value. + */ + String eTag(); + + /** + * @return the filters value. + */ + Filters filters(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the notifications value. + */ + Map notifications(); + + /** + * @return the timeGrain value. + */ + TimeGrainType timeGrain(); + + /** + * @return the timePeriod value. + */ + BudgetTimePeriod timePeriod(); + + /** + * @return the type value. + */ + String type(); + + /** + * The entirety of the Budget definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithResourceGroupName, DefinitionStages.WithAmount, DefinitionStages.WithCategory, DefinitionStages.WithTimeGrain, DefinitionStages.WithTimePeriod, DefinitionStages.WithCreate { + } + + /** + * Grouping of Budget definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Budget definition. + */ + interface Blank extends WithResourceGroupName { + } + + /** + * The stage of the budget definition allowing to specify ResourceGroupName. + */ + interface WithResourceGroupName { + /** + * Specifies resourceGroupName. + * @param resourceGroupName Azure Resource Group Name + * @return the next definition stage + */ + WithAmount withResourceGroupName(String resourceGroupName); + } + + /** + * The stage of the budget definition allowing to specify Amount. + */ + interface WithAmount { + /** + * Specifies amount. + * @param amount The total amount of cost to track with the budget + * @return the next definition stage + */ + WithCategory withAmount(BigDecimal amount); + } + + /** + * The stage of the budget definition allowing to specify Category. + */ + interface WithCategory { + /** + * Specifies category. + * @param category The category of the budget, whether the budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * @return the next definition stage + */ + WithTimeGrain withCategory(CategoryType category); + } + + /** + * The stage of the budget definition allowing to specify TimeGrain. + */ + interface WithTimeGrain { + /** + * Specifies timeGrain. + * @param timeGrain The time covered by a budget. Tracking of the amount will be reset based on the time grain. Possible values include: 'Monthly', 'Quarterly', 'Annually' + * @return the next definition stage + */ + WithTimePeriod withTimeGrain(TimeGrainType timeGrain); + } + + /** + * The stage of the budget definition allowing to specify TimePeriod. + */ + interface WithTimePeriod { + /** + * Specifies timePeriod. + * @param timePeriod Has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than three months. Past start date should be selected within the timegrain period. There are no restrictions on the end date + * @return the next definition stage + */ + WithCreate withTimePeriod(BudgetTimePeriod timePeriod); + } + + /** + * The stage of the budget definition allowing to specify ETag. + */ + interface WithETag { + /** + * Specifies eTag. + * @param eTag eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not + * @return the next definition stage + */ + WithCreate withETag(String eTag); + } + + /** + * The stage of the budget definition allowing to specify Filters. + */ + interface WithFilters { + /** + * Specifies filters. + * @param filters May be used to filter budgets by resource group, resource, or meter + * @return the next definition stage + */ + WithCreate withFilters(Filters filters); + } + + /** + * The stage of the budget definition allowing to specify Notifications. + */ + interface WithNotifications { + /** + * Specifies notifications. + * @param notifications Dictionary of notifications associated with the budget. Budget can have up to five notifications + * @return the next definition stage + */ + WithCreate withNotifications(Map notifications); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends Creatable, DefinitionStages.WithETag, DefinitionStages.WithFilters, DefinitionStages.WithNotifications { + } + } + /** + * The template for a Budget update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable, UpdateStages.WithETag, UpdateStages.WithFilters, UpdateStages.WithNotifications { + } + + /** + * Grouping of Budget update stages. + */ + interface UpdateStages { + /** + * The stage of the budget update allowing to specify ETag. + */ + interface WithETag { + /** + * Specifies eTag. + * @param eTag eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not + * @return the next update stage + */ + Update withETag(String eTag); + } + + /** + * The stage of the budget update allowing to specify Filters. + */ + interface WithFilters { + /** + * Specifies filters. + * @param filters May be used to filter budgets by resource group, resource, or meter + * @return the next update stage + */ + Update withFilters(Filters filters); + } + + /** + * The stage of the budget update allowing to specify Notifications. + */ + interface WithNotifications { + /** + * Specifies notifications. + * @param notifications Dictionary of notifications associated with the budget. Budget can have up to five notifications + * @return the next update stage + */ + Update withNotifications(Map notifications); + } + + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BudgetTimePeriod.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BudgetTimePeriod.java new file mode 100644 index 0000000000000..c1794ba85e839 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/BudgetTimePeriod.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The start and end date for a budget. + */ +public class BudgetTimePeriod { + /** + * The start date for the budget. + */ + @JsonProperty(value = "startDate", required = true) + private DateTime startDate; + + /** + * The end date for the budget. If not provided, we default this to 10 + * years from the start date. + */ + @JsonProperty(value = "endDate") + private DateTime endDate; + + /** + * Get the start date for the budget. + * + * @return the startDate value + */ + public DateTime startDate() { + return this.startDate; + } + + /** + * Set the start date for the budget. + * + * @param startDate the startDate value to set + * @return the BudgetTimePeriod object itself. + */ + public BudgetTimePeriod withStartDate(DateTime startDate) { + this.startDate = startDate; + return this; + } + + /** + * Get the end date for the budget. If not provided, we default this to 10 years from the start date. + * + * @return the endDate value + */ + public DateTime endDate() { + return this.endDate; + } + + /** + * Set the end date for the budget. If not provided, we default this to 10 years from the start date. + * + * @param endDate the endDate value to set + * @return the BudgetTimePeriod object itself. + */ + public BudgetTimePeriod withEndDate(DateTime endDate) { + this.endDate = endDate; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budgets.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budgets.java new file mode 100644 index 0000000000000..1e70022177716 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Budgets.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.collection.SupportsCreating; +import com.microsoft.azure.arm.resources.collection.SupportsDeletingByResourceGroup; +import com.microsoft.azure.arm.resources.collection.SupportsBatchDeletion; +import com.microsoft.azure.arm.resources.collection.SupportsGettingByResourceGroup; +import rx.Observable; +import com.microsoft.azure.arm.resources.collection.SupportsListingByResourceGroup; +import com.microsoft.azure.arm.collection.SupportsListing; +import rx.Completable; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.BudgetInner; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.BudgetsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing Budgets. + */ +public interface Budgets extends SupportsCreating, SupportsDeletingByResourceGroup, SupportsBatchDeletion, SupportsGettingByResourceGroup, SupportsListingByResourceGroup, SupportsListing, HasInner { + /** + * Gets the budget for a subscription by budget name. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String budgetName); + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable createOrUpdateAsync(String budgetName, BudgetInner parameters); + + /** + * The operation to delete a budget. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteAsync(String budgetName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CategoryType.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CategoryType.java new file mode 100644 index 0000000000000..785ad778fc018 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CategoryType.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for CategoryType. + */ +public final class CategoryType extends ExpandableStringEnum { + /** Static value Cost for CategoryType. */ + public static final CategoryType COST = fromString("Cost"); + + /** Static value Usage for CategoryType. */ + public static final CategoryType USAGE = fromString("Usage"); + + /** + * Creates or finds a CategoryType from its string representation. + * @param name a name to look for + * @return the corresponding CategoryType + */ + @JsonCreator + public static CategoryType fromString(String name) { + return fromString(name, CategoryType.class); + } + + /** + * @return known CategoryType values + */ + public static Collection values() { + return values(CategoryType.class); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTags.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTags.java new file mode 100644 index 0000000000000..9b1edab621d3e --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTags.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.CostTagsModelInner; + +/** + * Type representing CostTags. + */ +public interface CostTags { + /** + * Get cost tags for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String billingAccountId); + + /** + * The operation to create or update cost tags associated with a billing account. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param billingAccountId BillingAccount ID + * @param parameters Parameters supplied to the Create cost tags operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable createOrUpdateAsync(String billingAccountId, CostTagsModelInner parameters); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTagsModel.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTagsModel.java new file mode 100644 index 0000000000000..d786859c04714 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CostTagsModel.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.CostTagsModelInner; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.CostTagInner; +import java.util.List; + +/** + * Type representing CostTagsModel. + */ +public interface CostTagsModel extends HasInner, HasManager { + /** + * @return the costTags value. + */ + List costTags(); + + /** + * @return the eTag value. + */ + String eTag(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the type value. + */ + String type(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CurrentSpend.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CurrentSpend.java new file mode 100644 index 0000000000000..02d368bea3e58 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/CurrentSpend.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.math.BigDecimal; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The current amount of cost which is being tracked for a budget. + */ +public class CurrentSpend { + /** + * The total amount of cost which is being tracked by the budget. + */ + @JsonProperty(value = "amount", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal amount; + + /** + * The unit of measure for the budget amount. + */ + @JsonProperty(value = "unit", access = JsonProperty.Access.WRITE_ONLY) + private String unit; + + /** + * Get the total amount of cost which is being tracked by the budget. + * + * @return the amount value + */ + public BigDecimal amount() { + return this.amount; + } + + /** + * Get the unit of measure for the budget amount. + * + * @return the unit value + */ + public String unit() { + return this.unit; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Datagrain.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Datagrain.java new file mode 100644 index 0000000000000..a9f03fd56bf7d --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Datagrain.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for Datagrain. + */ +public final class Datagrain extends ExpandableStringEnum { + /** Static value daily for Datagrain. */ + public static final Datagrain DAILY_GRAIN = fromString("daily"); + + /** Static value monthly for Datagrain. */ + public static final Datagrain MONTHLY_GRAIN = fromString("monthly"); + + /** + * Creates or finds a Datagrain from its string representation. + * @param name a name to look for + * @return the corresponding Datagrain + */ + @JsonCreator + public static Datagrain fromString(String name) { + return fromString(name, Datagrain.class); + } + + /** + * @return known Datagrain values + */ + public static Collection values() { + return values(Datagrain.class); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorDetails.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorDetails.java new file mode 100644 index 0000000000000..349be355c71d5 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorDetails.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The details of the error. + */ +public class ErrorDetails { + /** + * Error code. + */ + @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /** + * Error message indicating why the operation failed. + */ + @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /** + * Get error code. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Get error message indicating why the operation failed. + * + * @return the message value + */ + public String message() { + return this.message; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponse.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponse.java new file mode 100644 index 0000000000000..78f031c994e89 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponse.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error response indicates that the service is not able to process the + * incoming request. The reason is provided in the error message. + */ +public class ErrorResponse { + /** + * The details of the error. + */ + @JsonProperty(value = "error") + private ErrorDetails error; + + /** + * Get the details of the error. + * + * @return the error value + */ + public ErrorDetails error() { + return this.error; + } + + /** + * Set the details of the error. + * + * @param error the error value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withError(ErrorDetails error) { + this.error = error; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponseException.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponseException.java new file mode 100644 index 0000000000000..db7d5527f688f --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ErrorResponseException.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ +public class ErrorResponseException extends RestException { + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorResponseException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public ErrorResponseException(final String message, final Response response, final ErrorResponse body) { + super(message, response, body); + } + + @Override + public ErrorResponse body() { + return (ErrorResponse) super.body(); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Filters.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Filters.java new file mode 100644 index 0000000000000..4a61b59f25051 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Filters.java @@ -0,0 +1,126 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.List; +import java.util.UUID; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * May be used to filter budgets by resource group, resource, or meter. + */ +public class Filters { + /** + * The list of filters on resource groups, allowed at subscription level + * only. + */ + @JsonProperty(value = "resourceGroups") + private List resourceGroups; + + /** + * The list of filters on resources. + */ + @JsonProperty(value = "resources") + private List resources; + + /** + * The list of filters on meters (GUID), mandatory for budgets of usage + * category. + */ + @JsonProperty(value = "meters") + private List meters; + + /** + * The dictionary of filters on tags. + */ + @JsonProperty(value = "tags") + private Map> tags; + + /** + * Get the list of filters on resource groups, allowed at subscription level only. + * + * @return the resourceGroups value + */ + public List resourceGroups() { + return this.resourceGroups; + } + + /** + * Set the list of filters on resource groups, allowed at subscription level only. + * + * @param resourceGroups the resourceGroups value to set + * @return the Filters object itself. + */ + public Filters withResourceGroups(List resourceGroups) { + this.resourceGroups = resourceGroups; + return this; + } + + /** + * Get the list of filters on resources. + * + * @return the resources value + */ + public List resources() { + return this.resources; + } + + /** + * Set the list of filters on resources. + * + * @param resources the resources value to set + * @return the Filters object itself. + */ + public Filters withResources(List resources) { + this.resources = resources; + return this; + } + + /** + * Get the list of filters on meters (GUID), mandatory for budgets of usage category. + * + * @return the meters value + */ + public List meters() { + return this.meters; + } + + /** + * Set the list of filters on meters (GUID), mandatory for budgets of usage category. + * + * @param meters the meters value to set + * @return the Filters object itself. + */ + public Filters withMeters(List meters) { + this.meters = meters; + return this; + } + + /** + * Get the dictionary of filters on tags. + * + * @return the tags value + */ + public Map> tags() { + return this.tags; + } + + /** + * Set the dictionary of filters on tags. + * + * @param tags the tags value to set + * @return the Filters object itself. + */ + public Filters withTags(Map> tags) { + this.tags = tags; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/GetBalancesByBillingAccounts.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/GetBalancesByBillingAccounts.java new file mode 100644 index 0000000000000..80b03f10a24e1 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/GetBalancesByBillingAccounts.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing GetBalancesByBillingAccounts. + */ +public interface GetBalancesByBillingAccounts { + /** + * Gets the balances for a scope by billing period and billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable byBillingPeriodAsync(String billingAccountId, String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplace.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplace.java new file mode 100644 index 0000000000000..9f53a2c30e9d4 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplace.java @@ -0,0 +1,164 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.MarketplaceInner; +import java.math.BigDecimal; +import java.util.UUID; +import java.util.Map; +import org.joda.time.DateTime; + +/** + * Type representing Marketplace. + */ +public interface Marketplace extends HasInner, HasManager { + /** + * @return the accountName value. + */ + String accountName(); + + /** + * @return the additionalProperties value. + */ + String additionalProperties(); + + /** + * @return the billingPeriodId value. + */ + String billingPeriodId(); + + /** + * @return the consumedQuantity value. + */ + BigDecimal consumedQuantity(); + + /** + * @return the consumedService value. + */ + String consumedService(); + + /** + * @return the costCenter value. + */ + String costCenter(); + + /** + * @return the currency value. + */ + String currency(); + + /** + * @return the departmentName value. + */ + String departmentName(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the instanceId value. + */ + String instanceId(); + + /** + * @return the instanceName value. + */ + String instanceName(); + + /** + * @return the isEstimated value. + */ + Boolean isEstimated(); + + /** + * @return the meterId value. + */ + UUID meterId(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the offerName value. + */ + String offerName(); + + /** + * @return the orderNumber value. + */ + String orderNumber(); + + /** + * @return the planName value. + */ + String planName(); + + /** + * @return the pretaxCost value. + */ + BigDecimal pretaxCost(); + + /** + * @return the publisherName value. + */ + String publisherName(); + + /** + * @return the resourceGroup value. + */ + String resourceGroup(); + + /** + * @return the resourceRate value. + */ + BigDecimal resourceRate(); + + /** + * @return the subscriptionGuid value. + */ + UUID subscriptionGuid(); + + /** + * @return the subscriptionName value. + */ + String subscriptionName(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the type value. + */ + String type(); + + /** + * @return the unitOfMeasure value. + */ + String unitOfMeasure(); + + /** + * @return the usageEnd value. + */ + DateTime usageEnd(); + + /** + * @return the usageStart value. + */ + DateTime usageStart(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplaces.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplaces.java new file mode 100644 index 0000000000000..724d004212968 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Marketplaces.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing Marketplaces. + */ +public interface Marketplaces { + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String billingPeriodName); + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByBillingAccounts.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByBillingAccounts.java new file mode 100644 index 0000000000000..7a926920f39dc --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByBillingAccounts.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing MarketplacesByBillingAccounts. + */ +public interface MarketplacesByBillingAccounts { + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(final String billingAccountId); + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByDepartments.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByDepartments.java new file mode 100644 index 0000000000000..8e7eff71b054b --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByDepartments.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing MarketplacesByDepartments. + */ +public interface MarketplacesByDepartments { + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(final String departmentId); + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String departmentId, final String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByEnrollmentAccounts.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByEnrollmentAccounts.java new file mode 100644 index 0000000000000..6e8dc29221a00 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MarketplacesByEnrollmentAccounts.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing MarketplacesByEnrollmentAccounts. + */ +public interface MarketplacesByEnrollmentAccounts { + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(final String enrollmentAccountId); + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MeterDetails.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MeterDetails.java new file mode 100644 index 0000000000000..83191c64dca31 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/MeterDetails.java @@ -0,0 +1,126 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.math.BigDecimal; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The properties of the meter detail. + */ +public class MeterDetails { + /** + * The name of the meter, within the given meter category. + */ + @JsonProperty(value = "meterName", access = JsonProperty.Access.WRITE_ONLY) + private String meterName; + + /** + * The category of the meter, for example, 'Cloud services', 'Networking', + * etc.. + */ + @JsonProperty(value = "meterCategory", access = JsonProperty.Access.WRITE_ONLY) + private String meterCategory; + + /** + * The subcategory of the meter, for example, 'A6 Cloud services', + * 'ExpressRoute (IXP)', etc.. + */ + @JsonProperty(value = "meterSubCategory", access = JsonProperty.Access.WRITE_ONLY) + private String meterSubCategory; + + /** + * The unit in which the meter consumption is charged, for example, + * 'Hours', 'GB', etc. + */ + @JsonProperty(value = "unit", access = JsonProperty.Access.WRITE_ONLY) + private String unit; + + /** + * The location in which the Azure service is available. + */ + @JsonProperty(value = "meterLocation", access = JsonProperty.Access.WRITE_ONLY) + private String meterLocation; + + /** + * The total included quantity associated with the offer. + */ + @JsonProperty(value = "totalIncludedQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal totalIncludedQuantity; + + /** + * The pretax listing price. + */ + @JsonProperty(value = "pretaxStandardRate", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal pretaxStandardRate; + + /** + * Get the name of the meter, within the given meter category. + * + * @return the meterName value + */ + public String meterName() { + return this.meterName; + } + + /** + * Get the category of the meter, for example, 'Cloud services', 'Networking', etc.. + * + * @return the meterCategory value + */ + public String meterCategory() { + return this.meterCategory; + } + + /** + * Get the subcategory of the meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * + * @return the meterSubCategory value + */ + public String meterSubCategory() { + return this.meterSubCategory; + } + + /** + * Get the unit in which the meter consumption is charged, for example, 'Hours', 'GB', etc. + * + * @return the unit value + */ + public String unit() { + return this.unit; + } + + /** + * Get the location in which the Azure service is available. + * + * @return the meterLocation value + */ + public String meterLocation() { + return this.meterLocation; + } + + /** + * Get the total included quantity associated with the offer. + * + * @return the totalIncludedQuantity value + */ + public BigDecimal totalIncludedQuantity() { + return this.totalIncludedQuantity; + } + + /** + * Get the pretax listing price. + * + * @return the pretaxStandardRate value + */ + public BigDecimal pretaxStandardRate() { + return this.pretaxStandardRate; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Notification.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Notification.java new file mode 100644 index 0000000000000..3a0b6d2de14ea --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Notification.java @@ -0,0 +1,181 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.math.BigDecimal; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The notification associated with a budget. + */ +public class Notification { + /** + * The notification is enabled or not. + */ + @JsonProperty(value = "enabled", required = true) + private boolean enabled; + + /** + * The comparison operator. Possible values include: 'EqualTo', + * 'GreaterThan', 'GreaterThanOrEqualTo'. + */ + @JsonProperty(value = "operator", required = true) + private OperatorType operator; + + /** + * Threshold value associated with a notification. Notification is sent + * when the cost exceeded the threshold. It is always percent and has to be + * between 0 and 1000. + */ + @JsonProperty(value = "threshold", required = true) + private BigDecimal threshold; + + /** + * Email addresses to send the budget notification to when the threshold is + * exceeded. + */ + @JsonProperty(value = "contactEmails", required = true) + private List contactEmails; + + /** + * Contact roles to send the budget notification to when the threshold is + * exceeded. + */ + @JsonProperty(value = "contactRoles") + private List contactRoles; + + /** + * Action groups to send the budget notification to when the threshold is + * exceeded. + */ + @JsonProperty(value = "contactGroups") + private List contactGroups; + + /** + * Get the notification is enabled or not. + * + * @return the enabled value + */ + public boolean enabled() { + return this.enabled; + } + + /** + * Set the notification is enabled or not. + * + * @param enabled the enabled value to set + * @return the Notification object itself. + */ + public Notification withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the comparison operator. Possible values include: 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo'. + * + * @return the operator value + */ + public OperatorType operator() { + return this.operator; + } + + /** + * Set the comparison operator. Possible values include: 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo'. + * + * @param operator the operator value to set + * @return the Notification object itself. + */ + public Notification withOperator(OperatorType operator) { + this.operator = operator; + return this; + } + + /** + * Get threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000. + * + * @return the threshold value + */ + public BigDecimal threshold() { + return this.threshold; + } + + /** + * Set threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000. + * + * @param threshold the threshold value to set + * @return the Notification object itself. + */ + public Notification withThreshold(BigDecimal threshold) { + this.threshold = threshold; + return this; + } + + /** + * Get email addresses to send the budget notification to when the threshold is exceeded. + * + * @return the contactEmails value + */ + public List contactEmails() { + return this.contactEmails; + } + + /** + * Set email addresses to send the budget notification to when the threshold is exceeded. + * + * @param contactEmails the contactEmails value to set + * @return the Notification object itself. + */ + public Notification withContactEmails(List contactEmails) { + this.contactEmails = contactEmails; + return this; + } + + /** + * Get contact roles to send the budget notification to when the threshold is exceeded. + * + * @return the contactRoles value + */ + public List contactRoles() { + return this.contactRoles; + } + + /** + * Set contact roles to send the budget notification to when the threshold is exceeded. + * + * @param contactRoles the contactRoles value to set + * @return the Notification object itself. + */ + public Notification withContactRoles(List contactRoles) { + this.contactRoles = contactRoles; + return this; + } + + /** + * Get action groups to send the budget notification to when the threshold is exceeded. + * + * @return the contactGroups value + */ + public List contactGroups() { + return this.contactGroups; + } + + /** + * Set action groups to send the budget notification to when the threshold is exceeded. + * + * @param contactGroups the contactGroups value to set + * @return the Notification object itself. + */ + public Notification withContactGroups(List contactGroups) { + this.contactGroups = contactGroups; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operation.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operation.java new file mode 100644 index 0000000000000..a8cb22ae44d35 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operation.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.OperationInner; + +/** + * Type representing Operation. + */ +public interface Operation extends HasInner, HasManager { + /** + * @return the display value. + */ + OperationDisplay display(); + + /** + * @return the name value. + */ + String name(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperationDisplay.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperationDisplay.java new file mode 100644 index 0000000000000..3da56f6d49fd0 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperationDisplay.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The object that represents the operation. + */ +public class OperationDisplay { + /** + * Service provider: Microsoft.Consumption. + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /** + * Resource on which the operation is performed: UsageDetail, etc. + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /** + * Operation type: Read, write, delete, etc. + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /** + * Get service provider: Microsoft.Consumption. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Get resource on which the operation is performed: UsageDetail, etc. + * + * @return the resource value + */ + public String resource() { + return this.resource; + } + + /** + * Get operation type: Read, write, delete, etc. + * + * @return the operation value + */ + public String operation() { + return this.operation; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operations.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operations.java new file mode 100644 index 0000000000000..2aa0f9e5e70a4 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Operations.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.OperationsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing Operations. + */ +public interface Operations extends HasInner { + /** + * Lists all of the available consumption REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperatorType.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperatorType.java new file mode 100644 index 0000000000000..462c47d73e910 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/OperatorType.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for OperatorType. + */ +public final class OperatorType extends ExpandableStringEnum { + /** Static value EqualTo for OperatorType. */ + public static final OperatorType EQUAL_TO = fromString("EqualTo"); + + /** Static value GreaterThan for OperatorType. */ + public static final OperatorType GREATER_THAN = fromString("GreaterThan"); + + /** Static value GreaterThanOrEqualTo for OperatorType. */ + public static final OperatorType GREATER_THAN_OR_EQUAL_TO = fromString("GreaterThanOrEqualTo"); + + /** + * Creates or finds a OperatorType from its string representation. + * @param name a name to look for + * @return the corresponding OperatorType + */ + @JsonCreator + public static OperatorType fromString(String name) { + return fromString(name, OperatorType.class); + } + + /** + * @return known OperatorType values + */ + public static Collection values() { + return values(OperatorType.class); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetProperties.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetProperties.java new file mode 100644 index 0000000000000..f1e2e19b761a2 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetProperties.java @@ -0,0 +1,140 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.UUID; +import java.math.BigDecimal; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The properties of the price sheet. + */ +public class PriceSheetProperties { + /** + * The id of the billing period resource that the usage belongs to. + */ + @JsonProperty(value = "billingPeriodId", access = JsonProperty.Access.WRITE_ONLY) + private String billingPeriodId; + + /** + * The meter id (GUID). + */ + @JsonProperty(value = "meterId", access = JsonProperty.Access.WRITE_ONLY) + private UUID meterId; + + /** + * The details about the meter. By default this is not populated, unless + * it's specified in $expand. + */ + @JsonProperty(value = "meterDetails", access = JsonProperty.Access.WRITE_ONLY) + private MeterDetails meterDetails; + + /** + * Unit of measure. + */ + @JsonProperty(value = "unitOfMeasure", access = JsonProperty.Access.WRITE_ONLY) + private String unitOfMeasure; + + /** + * Included quality for an offer. + */ + @JsonProperty(value = "includedQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal includedQuantity; + + /** + * Part Number. + */ + @JsonProperty(value = "partNumber", access = JsonProperty.Access.WRITE_ONLY) + private String partNumber; + + /** + * Unit Price. + */ + @JsonProperty(value = "unitPrice", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal unitPrice; + + /** + * Currency Code. + */ + @JsonProperty(value = "currencyCode", access = JsonProperty.Access.WRITE_ONLY) + private String currencyCode; + + /** + * Get the id of the billing period resource that the usage belongs to. + * + * @return the billingPeriodId value + */ + public String billingPeriodId() { + return this.billingPeriodId; + } + + /** + * Get the meter id (GUID). + * + * @return the meterId value + */ + public UUID meterId() { + return this.meterId; + } + + /** + * Get the details about the meter. By default this is not populated, unless it's specified in $expand. + * + * @return the meterDetails value + */ + public MeterDetails meterDetails() { + return this.meterDetails; + } + + /** + * Get unit of measure. + * + * @return the unitOfMeasure value + */ + public String unitOfMeasure() { + return this.unitOfMeasure; + } + + /** + * Get included quality for an offer. + * + * @return the includedQuantity value + */ + public BigDecimal includedQuantity() { + return this.includedQuantity; + } + + /** + * Get part Number. + * + * @return the partNumber value + */ + public String partNumber() { + return this.partNumber; + } + + /** + * Get unit Price. + * + * @return the unitPrice value + */ + public BigDecimal unitPrice() { + return this.unitPrice; + } + + /** + * Get currency Code. + * + * @return the currencyCode value + */ + public String currencyCode() { + return this.currencyCode; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetResult.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetResult.java new file mode 100644 index 0000000000000..64ad9425bbefb --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheetResult.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.PriceSheetResultInner; +import java.util.List; +import java.util.Map; + +/** + * Type representing PriceSheetResult. + */ +public interface PriceSheetResult extends HasInner, HasManager { + /** + * @return the id value. + */ + String id(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the nextLink value. + */ + String nextLink(); + + /** + * @return the pricesheets value. + */ + List pricesheets(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the type value. + */ + String type(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheets.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheets.java new file mode 100644 index 0000000000000..da55f26a90d29 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/PriceSheets.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.PriceSheetsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing PriceSheets. + */ +public interface PriceSheets extends HasInner { + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(); + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getByBillingPeriodAsync(String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/QueryOptions.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/QueryOptions.java new file mode 100644 index 0000000000000..908cbfd4693df --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/QueryOptions.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Additional parameters for a set of operations. + */ +public class QueryOptions { + /** + * OData apply expression to aggregate usageDetails by tags or (tags and + * properties/usageStart). + */ + @JsonProperty(value = "") + private String apply; + + /** + * Get oData apply expression to aggregate usageDetails by tags or (tags and properties/usageStart). + * + * @return the apply value + */ + public String apply() { + return this.apply; + } + + /** + * Set oData apply expression to aggregate usageDetails by tags or (tags and properties/usageStart). + * + * @param apply the apply value to set + * @return the QueryOptions object itself. + */ + public QueryOptions withApply(String apply) { + this.apply = apply; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationDetails.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationDetails.java new file mode 100644 index 0000000000000..e01cbd3edbd6f --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationDetails.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ReservationDetailsInner; +import java.math.BigDecimal; +import java.util.Map; +import org.joda.time.DateTime; + +/** + * Type representing ReservationDetails. + */ +public interface ReservationDetails extends HasInner, HasManager { + /** + * @return the id value. + */ + String id(); + + /** + * @return the instanceId value. + */ + String instanceId(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the reservationId value. + */ + String reservationId(); + + /** + * @return the reservationOrderId value. + */ + String reservationOrderId(); + + /** + * @return the reservedHours value. + */ + BigDecimal reservedHours(); + + /** + * @return the skuName value. + */ + String skuName(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the totalReservedQuantity value. + */ + BigDecimal totalReservedQuantity(); + + /** + * @return the type value. + */ + String type(); + + /** + * @return the usageDate value. + */ + DateTime usageDate(); + + /** + * @return the usedHours value. + */ + BigDecimal usedHours(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendations.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendations.java new file mode 100644 index 0000000000000..ad6cb638410a8 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendations.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.collection.SupportsListing; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ReservationRecommendationsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing ReservationRecommendations. + */ +public interface ReservationRecommendations extends SupportsListing, HasInner { +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendationsModel.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendationsModel.java new file mode 100644 index 0000000000000..0e96d4b795156 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationRecommendationsModel.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.Resource; +import com.microsoft.azure.arm.resources.models.GroupableResourceCore; +import com.microsoft.azure.arm.resources.models.HasResourceGroup; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import java.math.BigDecimal; +import org.joda.time.DateTime; +import java.util.UUID; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ReservationRecommendationsModelInner; + +/** + * Type representing ReservationRecommendationsModel. + */ +public interface ReservationRecommendationsModel extends HasInner, Resource, GroupableResourceCore, HasResourceGroup, HasManager { + /** + * @return the costWithNoReservedInstances value. + */ + BigDecimal costWithNoReservedInstances(); + + /** + * @return the firstUsageDate value. + */ + DateTime firstUsageDate(); + + /** + * @return the lookBackPeriod value. + */ + String lookBackPeriod(); + + /** + * @return the meterId value. + */ + UUID meterId(); + + /** + * @return the netSavings value. + */ + BigDecimal netSavings(); + + /** + * @return the recommendedQuantity value. + */ + BigDecimal recommendedQuantity(); + + /** + * @return the scope value. + */ + String scope(); + + /** + * @return the sku value. + */ + String sku(); + + /** + * @return the term value. + */ + String term(); + + /** + * @return the totalCostWithReservedInstances value. + */ + BigDecimal totalCostWithReservedInstances(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationSummaries.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationSummaries.java new file mode 100644 index 0000000000000..819ab31b51b45 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationSummaries.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ReservationSummariesInner; +import java.math.BigDecimal; +import java.util.Map; +import org.joda.time.DateTime; + +/** + * Type representing ReservationSummaries. + */ +public interface ReservationSummaries extends HasInner, HasManager { + /** + * @return the avgUtilizationPercentage value. + */ + BigDecimal avgUtilizationPercentage(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the maxUtilizationPercentage value. + */ + BigDecimal maxUtilizationPercentage(); + + /** + * @return the minUtilizationPercentage value. + */ + BigDecimal minUtilizationPercentage(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the reservationId value. + */ + String reservationId(); + + /** + * @return the reservationOrderId value. + */ + String reservationOrderId(); + + /** + * @return the reservedHours value. + */ + BigDecimal reservedHours(); + + /** + * @return the skuName value. + */ + String skuName(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the type value. + */ + String type(); + + /** + * @return the usageDate value. + */ + DateTime usageDate(); + + /** + * @return the usedHours value. + */ + BigDecimal usedHours(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsDetails.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsDetails.java new file mode 100644 index 0000000000000..06d13801e29e6 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsDetails.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing ReservationsDetails. + */ +public interface ReservationsDetails { + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByReservationOrderAsync(final String reservationOrderId, final String filter); + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final String filter); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsSummaries.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsSummaries.java new file mode 100644 index 0000000000000..18f3ea4244547 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ReservationsSummaries.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing ReservationsSummaries. + */ +public interface ReservationsSummaries { + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByReservationOrderAsync(final String reservationOrderId, final Datagrain grain); + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final Datagrain grain); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ResourceAttributes.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ResourceAttributes.java new file mode 100644 index 0000000000000..7fee6c3895670 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/ResourceAttributes.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Resource model definition. + */ +public class ResourceAttributes { + /** + * Resource location. + */ + @JsonProperty(value = "location", access = JsonProperty.Access.WRITE_ONLY) + private String location; + + /** + * Resource sku. + */ + @JsonProperty(value = "sku", access = JsonProperty.Access.WRITE_ONLY) + private String sku; + + /** + * Get resource location. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Get resource sku. + * + * @return the sku value + */ + public String sku() { + return this.sku; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Tags.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Tags.java new file mode 100644 index 0000000000000..093f6866d59d8 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/Tags.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing Tags. + */ +public interface Tags { + /** + * Get all available tag keys for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String billingAccountId); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TagsModel.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TagsModel.java new file mode 100644 index 0000000000000..db57877a60b08 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TagsModel.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.TagsModelInner; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.TagInner; +import java.util.List; + +/** + * Type representing TagsModel. + */ +public interface TagsModel extends HasInner, HasManager { + /** + * @return the eTag value. + */ + String eTag(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the tags value. + */ + List tags(); + + /** + * @return the type value. + */ + String type(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TimeGrainType.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TimeGrainType.java new file mode 100644 index 0000000000000..49fc6638b4682 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/TimeGrainType.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for TimeGrainType. + */ +public final class TimeGrainType extends ExpandableStringEnum { + /** Static value Monthly for TimeGrainType. */ + public static final TimeGrainType MONTHLY = fromString("Monthly"); + + /** Static value Quarterly for TimeGrainType. */ + public static final TimeGrainType QUARTERLY = fromString("Quarterly"); + + /** Static value Annually for TimeGrainType. */ + public static final TimeGrainType ANNUALLY = fromString("Annually"); + + /** + * Creates or finds a TimeGrainType from its string representation. + * @param name a name to look for + * @return the corresponding TimeGrainType + */ + @JsonCreator + public static TimeGrainType fromString(String name) { + return fromString(name, TimeGrainType.class); + } + + /** + * @return known TimeGrainType values + */ + public static Collection values() { + return values(TimeGrainType.class); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetail.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetail.java new file mode 100644 index 0000000000000..f2cf85450a905 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetail.java @@ -0,0 +1,154 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.ConsumptionManager; +import com.microsoft.azure.management.consumption.v2018_03_31.implementation.UsageDetailInner; +import java.math.BigDecimal; +import java.util.UUID; +import java.util.Map; +import org.joda.time.DateTime; + +/** + * Type representing UsageDetail. + */ +public interface UsageDetail extends HasInner, HasManager { + /** + * @return the accountName value. + */ + String accountName(); + + /** + * @return the additionalProperties value. + */ + String additionalProperties(); + + /** + * @return the billableQuantity value. + */ + BigDecimal billableQuantity(); + + /** + * @return the billingPeriodId value. + */ + String billingPeriodId(); + + /** + * @return the consumedService value. + */ + String consumedService(); + + /** + * @return the costCenter value. + */ + String costCenter(); + + /** + * @return the currency value. + */ + String currency(); + + /** + * @return the departmentName value. + */ + String departmentName(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the instanceId value. + */ + String instanceId(); + + /** + * @return the instanceLocation value. + */ + String instanceLocation(); + + /** + * @return the instanceName value. + */ + String instanceName(); + + /** + * @return the invoiceId value. + */ + String invoiceId(); + + /** + * @return the isEstimated value. + */ + Boolean isEstimated(); + + /** + * @return the meterDetails value. + */ + MeterDetails meterDetails(); + + /** + * @return the meterId value. + */ + UUID meterId(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the pretaxCost value. + */ + BigDecimal pretaxCost(); + + /** + * @return the product value. + */ + String product(); + + /** + * @return the subscriptionGuid value. + */ + UUID subscriptionGuid(); + + /** + * @return the subscriptionName value. + */ + String subscriptionName(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the type value. + */ + String type(); + + /** + * @return the usageEnd value. + */ + DateTime usageEnd(); + + /** + * @return the usageQuantity value. + */ + BigDecimal usageQuantity(); + + /** + * @return the usageStart value. + */ + DateTime usageStart(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetails.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetails.java new file mode 100644 index 0000000000000..2202eec3fd8fa --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetails.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing UsageDetails. + */ +public interface UsageDetails { + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String billingPeriodName); + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByBillingAccounts.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByBillingAccounts.java new file mode 100644 index 0000000000000..5a582016672e1 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByBillingAccounts.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing UsageDetailsByBillingAccounts. + */ +public interface UsageDetailsByBillingAccounts { + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(final String billingAccountId); + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByDepartments.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByDepartments.java new file mode 100644 index 0000000000000..3ce42151f1c08 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByDepartments.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing UsageDetailsByDepartments. + */ +public interface UsageDetailsByDepartments { + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(final String departmentId); + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String departmentId, final String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByEnrollmentAccounts.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByEnrollmentAccounts.java new file mode 100644 index 0000000000000..810b5e026760e --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/UsageDetailsByEnrollmentAccounts.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31; + +import rx.Observable; + +/** + * Type representing UsageDetailsByEnrollmentAccounts. + */ +public interface UsageDetailsByEnrollmentAccounts { + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(final String enrollmentAccountId); + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName); + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceImpl.java new file mode 100644 index 0000000000000..7033da8ec9c7b --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceImpl.java @@ -0,0 +1,127 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.Balance; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.util.List; +import com.microsoft.azure.management.consumption.v2018_03_31.BalancePropertiesAdjustmentDetailsItem; +import java.math.BigDecimal; +import com.microsoft.azure.management.consumption.v2018_03_31.BillingFrequency; +import com.microsoft.azure.management.consumption.v2018_03_31.BalancePropertiesNewPurchasesDetailsItem; +import java.util.Map; + +class BalanceImpl extends WrapperImpl implements Balance { + private final ConsumptionManager manager; + BalanceImpl(BalanceInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public List adjustmentDetails() { + return this.inner().adjustmentDetails(); + } + + @Override + public BigDecimal adjustments() { + return this.inner().adjustments(); + } + + @Override + public BigDecimal azureMarketplaceServiceCharges() { + return this.inner().azureMarketplaceServiceCharges(); + } + + @Override + public BigDecimal beginningBalance() { + return this.inner().beginningBalance(); + } + + @Override + public BillingFrequency billingFrequency() { + return this.inner().billingFrequency(); + } + + @Override + public BigDecimal chargesBilledSeparately() { + return this.inner().chargesBilledSeparately(); + } + + @Override + public String currency() { + return this.inner().currency(); + } + + @Override + public BigDecimal endingBalance() { + return this.inner().endingBalance(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public BigDecimal newPurchases() { + return this.inner().newPurchases(); + } + + @Override + public List newPurchasesDetails() { + return this.inner().newPurchasesDetails(); + } + + @Override + public Boolean priceHidden() { + return this.inner().priceHidden(); + } + + @Override + public BigDecimal serviceOverage() { + return this.inner().serviceOverage(); + } + + @Override + public Map tags() { + return this.inner().tags(); + } + + @Override + public BigDecimal totalOverage() { + return this.inner().totalOverage(); + } + + @Override + public BigDecimal totalUsage() { + return this.inner().totalUsage(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public BigDecimal utilized() { + return this.inner().utilized(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceInner.java new file mode 100644 index 0000000000000..fa1753feee560 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BalanceInner.java @@ -0,0 +1,279 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.math.BigDecimal; +import com.microsoft.azure.management.consumption.v2018_03_31.BillingFrequency; +import java.util.List; +import com.microsoft.azure.management.consumption.v2018_03_31.BalancePropertiesNewPurchasesDetailsItem; +import com.microsoft.azure.management.consumption.v2018_03_31.BalancePropertiesAdjustmentDetailsItem; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * A balance resource. + */ +@JsonFlatten +public class BalanceInner extends ProxyResource { + /** + * The ISO currency in which the meter is charged, for example, USD. + */ + @JsonProperty(value = "properties.currency", access = JsonProperty.Access.WRITE_ONLY) + private String currency; + + /** + * The beginning balance for the billing period. + */ + @JsonProperty(value = "properties.beginningBalance", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal beginningBalance; + + /** + * The ending balance for the billing period (for open periods this will be + * updated daily). + */ + @JsonProperty(value = "properties.endingBalance", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal endingBalance; + + /** + * Total new purchase amount. + */ + @JsonProperty(value = "properties.newPurchases", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal newPurchases; + + /** + * Total adjustment amount. + */ + @JsonProperty(value = "properties.adjustments", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal adjustments; + + /** + * Total Commitment usage. + */ + @JsonProperty(value = "properties.utilized", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal utilized; + + /** + * Overage for Azure services. + */ + @JsonProperty(value = "properties.serviceOverage", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal serviceOverage; + + /** + * Charges Billed separately. + */ + @JsonProperty(value = "properties.chargesBilledSeparately", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal chargesBilledSeparately; + + /** + * serviceOverage + chargesBilledSeparately. + */ + @JsonProperty(value = "properties.totalOverage", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal totalOverage; + + /** + * Azure service commitment + total Overage. + */ + @JsonProperty(value = "properties.totalUsage", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal totalUsage; + + /** + * Total charges for Azure Marketplace. + */ + @JsonProperty(value = "properties.azureMarketplaceServiceCharges", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal azureMarketplaceServiceCharges; + + /** + * The billing frequency. Possible values include: 'Month', 'Quarter', + * 'Year'. + */ + @JsonProperty(value = "properties.billingFrequency") + private BillingFrequency billingFrequency; + + /** + * Price is hidden or not. + */ + @JsonProperty(value = "properties.priceHidden", access = JsonProperty.Access.WRITE_ONLY) + private Boolean priceHidden; + + /** + * List of new purchases. + */ + @JsonProperty(value = "properties.newPurchasesDetails", access = JsonProperty.Access.WRITE_ONLY) + private List newPurchasesDetails; + + /** + * List of Adjustments (Promo credit, SIE credit etc.). + */ + @JsonProperty(value = "properties.adjustmentDetails", access = JsonProperty.Access.WRITE_ONLY) + private List adjustmentDetails; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Get the ISO currency in which the meter is charged, for example, USD. + * + * @return the currency value + */ + public String currency() { + return this.currency; + } + + /** + * Get the beginning balance for the billing period. + * + * @return the beginningBalance value + */ + public BigDecimal beginningBalance() { + return this.beginningBalance; + } + + /** + * Get the ending balance for the billing period (for open periods this will be updated daily). + * + * @return the endingBalance value + */ + public BigDecimal endingBalance() { + return this.endingBalance; + } + + /** + * Get total new purchase amount. + * + * @return the newPurchases value + */ + public BigDecimal newPurchases() { + return this.newPurchases; + } + + /** + * Get total adjustment amount. + * + * @return the adjustments value + */ + public BigDecimal adjustments() { + return this.adjustments; + } + + /** + * Get total Commitment usage. + * + * @return the utilized value + */ + public BigDecimal utilized() { + return this.utilized; + } + + /** + * Get overage for Azure services. + * + * @return the serviceOverage value + */ + public BigDecimal serviceOverage() { + return this.serviceOverage; + } + + /** + * Get charges Billed separately. + * + * @return the chargesBilledSeparately value + */ + public BigDecimal chargesBilledSeparately() { + return this.chargesBilledSeparately; + } + + /** + * Get serviceOverage + chargesBilledSeparately. + * + * @return the totalOverage value + */ + public BigDecimal totalOverage() { + return this.totalOverage; + } + + /** + * Get azure service commitment + total Overage. + * + * @return the totalUsage value + */ + public BigDecimal totalUsage() { + return this.totalUsage; + } + + /** + * Get total charges for Azure Marketplace. + * + * @return the azureMarketplaceServiceCharges value + */ + public BigDecimal azureMarketplaceServiceCharges() { + return this.azureMarketplaceServiceCharges; + } + + /** + * Get the billing frequency. Possible values include: 'Month', 'Quarter', 'Year'. + * + * @return the billingFrequency value + */ + public BillingFrequency billingFrequency() { + return this.billingFrequency; + } + + /** + * Set the billing frequency. Possible values include: 'Month', 'Quarter', 'Year'. + * + * @param billingFrequency the billingFrequency value to set + * @return the BalanceInner object itself. + */ + public BalanceInner withBillingFrequency(BillingFrequency billingFrequency) { + this.billingFrequency = billingFrequency; + return this; + } + + /** + * Get price is hidden or not. + * + * @return the priceHidden value + */ + public Boolean priceHidden() { + return this.priceHidden; + } + + /** + * Get list of new purchases. + * + * @return the newPurchasesDetails value + */ + public List newPurchasesDetails() { + return this.newPurchasesDetails; + } + + /** + * Get list of Adjustments (Promo credit, SIE credit etc.). + * + * @return the adjustmentDetails value + */ + public List adjustmentDetails() { + return this.adjustmentDetails; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetImpl.java new file mode 100644 index 0000000000000..18ef852b8fae2 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetImpl.java @@ -0,0 +1,182 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.Budget; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.CategoryType; +import java.math.BigDecimal; +import com.microsoft.azure.management.consumption.v2018_03_31.TimeGrainType; +import com.microsoft.azure.management.consumption.v2018_03_31.BudgetTimePeriod; +import com.microsoft.azure.management.consumption.v2018_03_31.Filters; +import com.microsoft.azure.management.consumption.v2018_03_31.CurrentSpend; +import java.util.Map; +import com.microsoft.azure.management.consumption.v2018_03_31.Notification; + +class BudgetImpl extends CreatableUpdatableImpl implements Budget, Budget.Definition, Budget.Update { + private String resourceGroupName; + private String budgetName; + private final ConsumptionManager manager; + + BudgetImpl(String name, ConsumptionManager manager) { + super(name, new BudgetInner()); + this.manager = manager; + // Set resource name + this.budgetName = name; + // + } + + BudgetImpl(BudgetInner inner, ConsumptionManager manager) { + super(inner.name(), inner); + this.manager = manager; + // Set resource name + this.budgetName = inner.name(); + // set resource ancestor and positional variables + this.resourceGroupName = IdParsingUtils.getValueFromIdByName(inner.id(), "resourceGroups"); + this.budgetName = IdParsingUtils.getValueFromIdByName(inner.id(), "budgets"); + // set other parameters for create and update + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable createResourceAsync() { + BudgetsInner client = this.manager().inner().budgets(); + return client.createOrUpdateByResourceGroupNameAsync(this.resourceGroupName, this.budgetName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + public Observable updateResourceAsync() { + BudgetsInner client = this.manager().inner().budgets(); + return client.createOrUpdateByResourceGroupNameAsync(this.resourceGroupName, this.budgetName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + BudgetsInner client = this.manager().inner().budgets(); + return client.getByResourceGroupAsync(this.resourceGroupName, this.budgetName); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + + @Override + public BigDecimal amount() { + return this.inner().amount(); + } + + @Override + public CategoryType category() { + return this.inner().category(); + } + + @Override + public CurrentSpend currentSpend() { + return this.inner().currentSpend(); + } + + @Override + public String eTag() { + return this.inner().eTag(); + } + + @Override + public Filters filters() { + return this.inner().filters(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public Map notifications() { + return this.inner().notifications(); + } + + @Override + public TimeGrainType timeGrain() { + return this.inner().timeGrain(); + } + + @Override + public BudgetTimePeriod timePeriod() { + return this.inner().timePeriod(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public BudgetImpl withResourceGroupName(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + @Override + public BudgetImpl withAmount(BigDecimal amount) { + this.inner().withAmount(amount); + return this; + } + + @Override + public BudgetImpl withCategory(CategoryType category) { + this.inner().withCategory(category); + return this; + } + + @Override + public BudgetImpl withTimeGrain(TimeGrainType timeGrain) { + this.inner().withTimeGrain(timeGrain); + return this; + } + + @Override + public BudgetImpl withTimePeriod(BudgetTimePeriod timePeriod) { + this.inner().withTimePeriod(timePeriod); + return this; + } + + @Override + public BudgetImpl withETag(String eTag) { + this.inner().withETag(eTag); + return this; + } + + @Override + public BudgetImpl withFilters(Filters filters) { + this.inner().withFilters(filters); + return this; + } + + @Override + public BudgetImpl withNotifications(Map notifications) { + this.inner().withNotifications(notifications); + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetInner.java new file mode 100644 index 0000000000000..e3d146176aad6 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetInner.java @@ -0,0 +1,235 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.CategoryType; +import java.math.BigDecimal; +import com.microsoft.azure.management.consumption.v2018_03_31.TimeGrainType; +import com.microsoft.azure.management.consumption.v2018_03_31.BudgetTimePeriod; +import com.microsoft.azure.management.consumption.v2018_03_31.Filters; +import com.microsoft.azure.management.consumption.v2018_03_31.CurrentSpend; +import java.util.Map; +import com.microsoft.azure.management.consumption.v2018_03_31.Notification; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * A budget resource. + */ +@JsonFlatten +public class BudgetInner extends ProxyResource { + /** + * The category of the budget, whether the budget tracks cost or usage. + * Possible values include: 'Cost', 'Usage'. + */ + @JsonProperty(value = "properties.category", required = true) + private CategoryType category; + + /** + * The total amount of cost to track with the budget. + */ + @JsonProperty(value = "properties.amount", required = true) + private BigDecimal amount; + + /** + * The time covered by a budget. Tracking of the amount will be reset based + * on the time grain. Possible values include: 'Monthly', 'Quarterly', + * 'Annually'. + */ + @JsonProperty(value = "properties.timeGrain", required = true) + private TimeGrainType timeGrain; + + /** + * Has start and end date of the budget. The start date must be first of + * the month and should be less than the end date. Budget start date must + * be on or after June 1, 2017. Future start date should not be more than + * three months. Past start date should be selected within the timegrain + * period. There are no restrictions on the end date. + */ + @JsonProperty(value = "properties.timePeriod", required = true) + private BudgetTimePeriod timePeriod; + + /** + * May be used to filter budgets by resource group, resource, or meter. + */ + @JsonProperty(value = "properties.filters") + private Filters filters; + + /** + * The current amount of cost which is being tracked for a budget. + */ + @JsonProperty(value = "properties.currentSpend", access = JsonProperty.Access.WRITE_ONLY) + private CurrentSpend currentSpend; + + /** + * Dictionary of notifications associated with the budget. Budget can have + * up to five notifications. + */ + @JsonProperty(value = "properties.notifications") + private Map notifications; + + /** + * eTag of the resource. To handle concurrent update scenario, this field + * will be used to determine whether the user is updating the latest + * version or not. + */ + @JsonProperty(value = "eTag") + private String eTag; + + /** + * Get the category of the budget, whether the budget tracks cost or usage. Possible values include: 'Cost', 'Usage'. + * + * @return the category value + */ + public CategoryType category() { + return this.category; + } + + /** + * Set the category of the budget, whether the budget tracks cost or usage. Possible values include: 'Cost', 'Usage'. + * + * @param category the category value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withCategory(CategoryType category) { + this.category = category; + return this; + } + + /** + * Get the total amount of cost to track with the budget. + * + * @return the amount value + */ + public BigDecimal amount() { + return this.amount; + } + + /** + * Set the total amount of cost to track with the budget. + * + * @param amount the amount value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withAmount(BigDecimal amount) { + this.amount = amount; + return this; + } + + /** + * Get the time covered by a budget. Tracking of the amount will be reset based on the time grain. Possible values include: 'Monthly', 'Quarterly', 'Annually'. + * + * @return the timeGrain value + */ + public TimeGrainType timeGrain() { + return this.timeGrain; + } + + /** + * Set the time covered by a budget. Tracking of the amount will be reset based on the time grain. Possible values include: 'Monthly', 'Quarterly', 'Annually'. + * + * @param timeGrain the timeGrain value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withTimeGrain(TimeGrainType timeGrain) { + this.timeGrain = timeGrain; + return this; + } + + /** + * Get has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than three months. Past start date should be selected within the timegrain period. There are no restrictions on the end date. + * + * @return the timePeriod value + */ + public BudgetTimePeriod timePeriod() { + return this.timePeriod; + } + + /** + * Set has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than three months. Past start date should be selected within the timegrain period. There are no restrictions on the end date. + * + * @param timePeriod the timePeriod value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withTimePeriod(BudgetTimePeriod timePeriod) { + this.timePeriod = timePeriod; + return this; + } + + /** + * Get may be used to filter budgets by resource group, resource, or meter. + * + * @return the filters value + */ + public Filters filters() { + return this.filters; + } + + /** + * Set may be used to filter budgets by resource group, resource, or meter. + * + * @param filters the filters value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withFilters(Filters filters) { + this.filters = filters; + return this; + } + + /** + * Get the current amount of cost which is being tracked for a budget. + * + * @return the currentSpend value + */ + public CurrentSpend currentSpend() { + return this.currentSpend; + } + + /** + * Get dictionary of notifications associated with the budget. Budget can have up to five notifications. + * + * @return the notifications value + */ + public Map notifications() { + return this.notifications; + } + + /** + * Set dictionary of notifications associated with the budget. Budget can have up to five notifications. + * + * @param notifications the notifications value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withNotifications(Map notifications) { + this.notifications = notifications; + return this; + } + + /** + * Get eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + * + * @return the eTag value + */ + public String eTag() { + return this.eTag; + } + + /** + * Set eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + * + * @param eTag the eTag value to set + * @return the BudgetInner object itself. + */ + public BudgetInner withETag(String eTag) { + this.eTag = eTag; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsImpl.java new file mode 100644 index 0000000000000..f5168f011fa24 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsImpl.java @@ -0,0 +1,215 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * jkl + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.Budgets; +import rx.Completable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import com.microsoft.azure.arm.resources.ResourceUtilsCore; +import com.microsoft.azure.arm.utils.RXMapper; +import rx.Observable; +import rx.functions.Func1; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.Page; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.Budget; +import com.microsoft.azure.arm.utils.PagedListConverter; + +class BudgetsImpl extends WrapperImpl implements Budgets { + private PagedListConverter converter; + private final ConsumptionManager manager; + + BudgetsImpl(ConsumptionManager manager) { + super(manager.inner().budgets()); + this.manager = manager; + this.converter = new PagedListConverter() { + @Override + public Observable typeConvertAsync(BudgetInner inner) { + return Observable.just((Budget) wrapModel(inner)); + } + }; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public BudgetImpl define(String name) { + return wrapModel(name); + } + + private BudgetImpl wrapModel(BudgetInner inner) { + return new BudgetImpl(inner, manager()); + } + + private BudgetImpl wrapModel(String name) { + return new BudgetImpl(name, this.manager()); + } + + @Override + public Observable getAsync(String budgetName) { + BudgetsInner client = this.inner(); + return client.getAsync(budgetName) + .map(new Func1() { + @Override + public Budget call(BudgetInner inner) { + return new BudgetImpl(inner, manager()); + } + }); + } + + @Override + public Observable createOrUpdateAsync(String budgetName, BudgetInner parameters) { + BudgetsInner client = this.inner(); + return client.createOrUpdateAsync(budgetName, parameters) + .map(new Func1() { + @Override + public Budget call(BudgetInner inner) { + return new BudgetImpl(inner, manager()); + } + }); + } + + @Override + public Completable deleteAsync(String budgetName) { + BudgetsInner client = this.inner(); + return client.deleteAsync(budgetName).toCompletable(); + } + + @Override + public PagedList list() { + BudgetsInner client = this.inner(); + return converter.convert(client.list()); + } + + @Override + public Observable listAsync() { + BudgetsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Budget call(BudgetInner inner) { + return wrapModel(inner); + } + }); + } + + @Override + public PagedList listByResourceGroup(String resourceGroupName) { + BudgetsInner client = this.inner(); + return converter.convert(client.listByResourceGroup(resourceGroupName)); + } + + @Override + public Observable listByResourceGroupAsync(String resourceGroupName) { + BudgetsInner client = this.inner(); + return client.listByResourceGroupAsync(resourceGroupName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Budget call(BudgetInner inner) { + return wrapModel(inner); + } + }); + } + + private Observable getInnerAsync(String resourceGroupName, String name) { + BudgetsInner client = this.inner(); + return client.getByResourceGroupAsync(resourceGroupName, name); + } + + @Override + public Budget getByResourceGroup(String resourceGroupName, String name) { + return getByResourceGroupAsync(resourceGroupName, name).toBlocking().last(); + } + + @Override + public Observable getByResourceGroupAsync(String resourceGroupName, String name) { + return this.getInnerAsync(resourceGroupName, name).flatMap(new Func1> () { + @Override + public Observable call(BudgetInner innerT) { + if (inner == null) { + return Observable.empty(); + } else { + return Observable.just((Budget)wrapModel(innerT)); + } + } + }); + } + + @Override + public ServiceFuture getByResourceGroupAsync(String resourceGroupName, String name, ServiceCallback callback) { + return ServiceFuture.fromBody(getByResourceGroupAsync(resourceGroupName, name), callback); + } + + @Override + public Observable deleteByIdsAsync(Collection ids) { + if (ids == null || ids.isEmpty()) { + return Observable.empty(); + } + Collection> observables = new ArrayList<>(); + for (String id : ids) { + final String resourceGroupName = ResourceUtilsCore.groupFromResourceId(id); + final String name = ResourceUtilsCore.nameFromResourceId(id); + Observable o = RXMapper.map(this.inner().deleteByResourceGroupNameAsync(resourceGroupName, name), id); + observables.add(o); + } + return Observable.mergeDelayError(observables); + } + + @Override + public Observable deleteByIdsAsync(String...ids) { + return this.deleteByIdsAsync(new ArrayList(Arrays.asList(ids))); + } + + @Override + public void deleteByIds(Collection ids) { + if (ids != null && !ids.isEmpty()) { + this.deleteByIdsAsync(ids).toBlocking().last(); + } + } + + @Override + public void deleteByIds(String...ids) { + this.deleteByIds(new ArrayList(Arrays.asList(ids))); + } + + @Override + public void deleteByResourceGroup(String resourceGroupName, String name) { + this.deleteByResourceGroupAsync(resourceGroupName, name).await(); + } + + @Override + public Completable deleteByResourceGroupAsync(String resourceGroupName, String name) { + return this.inner().deleteByResourceGroupNameAsync(resourceGroupName, name).toCompletable(); + } + + @Override + public ServiceFuture deleteByResourceGroupAsync(String resourceGroupName, String name, ServiceCallback serviceCallback) { + return ServiceFuture.fromBody(deleteByResourceGroupAsync(resourceGroupName, name), serviceCallback); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsInner.java new file mode 100644 index 0000000000000..266eab03d1b12 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/BudgetsInner.java @@ -0,0 +1,1063 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.collection.InnerSupportsGet; +import com.microsoft.azure.arm.collection.InnerSupportsListing; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Budgets. + */ +public class BudgetsInner implements InnerSupportsGet, InnerSupportsListing { + /** The Retrofit service to perform REST calls. */ + private BudgetsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of BudgetsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public BudgetsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(BudgetsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Budgets to be + * used by Retrofit to perform actually REST calls. + */ + interface BudgetsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets listByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets") + Observable> listByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets get" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets/{budgetName}") + Observable> get(@Path("subscriptionId") String subscriptionId, @Path("budgetName") String budgetName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets/{budgetName}") + Observable> createOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("budgetName") String budgetName, @Query("api-version") String apiVersion, @Body BudgetInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets/{budgetName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("subscriptionId") String subscriptionId, @Path("budgetName") String budgetName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets getByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets/{budgetName}") + Observable> getByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("budgetName") String budgetName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets createOrUpdateByResourceGroupName" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets/{budgetName}") + Observable> createOrUpdateByResourceGroupName(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("budgetName") String budgetName, @Query("api-version") String apiVersion, @Body BudgetInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets deleteByResourceGroupName" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets/{budgetName}", method = "DELETE", hasBody = true) + Observable> deleteByResourceGroupName(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("budgetName") String budgetName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Budgets listByResourceGroupNext" }) + @GET + Observable> listByResourceGroupNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists all budgets for a subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<BudgetInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all budgets for a subscription. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all budgets for a subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all budgets for a subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all budgets for a subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<BudgetInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param resourceGroupName Azure Resource Group Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<BudgetInner> object if successful. + */ + public PagedList listByResourceGroup(final String resourceGroupName) { + ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param resourceGroupName Azure Resource Group Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupSinglePageAsync(resourceGroupName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param resourceGroupName Azure Resource Group Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable> listByResourceGroupAsync(final String resourceGroupName) { + return listByResourceGroupWithServiceResponseAsync(resourceGroupName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param resourceGroupName Azure Resource Group Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { + return listByResourceGroupSinglePageAsync(resourceGroupName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + ServiceResponse> * @param resourceGroupName Azure Resource Group Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<BudgetInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupSinglePageAsync(final String resourceGroupName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByResourceGroup(this.client.subscriptionId(), resourceGroupName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Gets the budget for a subscription by budget name. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BudgetInner object if successful. + */ + public BudgetInner get(String budgetName) { + return getWithServiceResponseAsync(budgetName).toBlocking().single().body(); + } + + /** + * Gets the budget for a subscription by budget name. + * + * @param budgetName Budget Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String budgetName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(budgetName), serviceCallback); + } + + /** + * Gets the budget for a subscription by budget name. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable getAsync(String budgetName) { + return getWithServiceResponseAsync(budgetName).map(new Func1, BudgetInner>() { + @Override + public BudgetInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the budget for a subscription by budget name. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable> getWithServiceResponseAsync(String budgetName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (budgetName == null) { + throw new IllegalArgumentException("Parameter budgetName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(this.client.subscriptionId(), budgetName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BudgetInner object if successful. + */ + public BudgetInner createOrUpdate(String budgetName, BudgetInner parameters) { + return createOrUpdateWithServiceResponseAsync(budgetName, parameters).toBlocking().single().body(); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String budgetName, BudgetInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(budgetName, parameters), serviceCallback); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable createOrUpdateAsync(String budgetName, BudgetInner parameters) { + return createOrUpdateWithServiceResponseAsync(budgetName, parameters).map(new Func1, BudgetInner>() { + @Override + public BudgetInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String budgetName, BudgetInner parameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (budgetName == null) { + throw new IllegalArgumentException("Parameter budgetName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdate(this.client.subscriptionId(), budgetName, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The operation to delete a budget. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String budgetName) { + deleteWithServiceResponseAsync(budgetName).toBlocking().single().body(); + } + + /** + * The operation to delete a budget. + * + * @param budgetName Budget Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String budgetName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(budgetName), serviceCallback); + } + + /** + * The operation to delete a budget. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String budgetName) { + return deleteWithServiceResponseAsync(budgetName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The operation to delete a budget. + * + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String budgetName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (budgetName == null) { + throw new IllegalArgumentException("Parameter budgetName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(this.client.subscriptionId(), budgetName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BudgetInner object if successful. + */ + public BudgetInner getByResourceGroup(String resourceGroupName, String budgetName) { + return getByResourceGroupWithServiceResponseAsync(resourceGroupName, budgetName).toBlocking().single().body(); + } + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getByResourceGroupAsync(String resourceGroupName, String budgetName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, budgetName), serviceCallback); + } + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable getByResourceGroupAsync(String resourceGroupName, String budgetName) { + return getByResourceGroupWithServiceResponseAsync(resourceGroupName, budgetName).map(new Func1, BudgetInner>() { + @Override + public BudgetInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String budgetName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (budgetName == null) { + throw new IllegalArgumentException("Parameter budgetName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.getByResourceGroup(this.client.subscriptionId(), resourceGroupName, budgetName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByResourceGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BudgetInner object if successful. + */ + public BudgetInner createOrUpdateByResourceGroupName(String resourceGroupName, String budgetName, BudgetInner parameters) { + return createOrUpdateByResourceGroupNameWithServiceResponseAsync(resourceGroupName, budgetName, parameters).toBlocking().single().body(); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateByResourceGroupNameAsync(String resourceGroupName, String budgetName, BudgetInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateByResourceGroupNameWithServiceResponseAsync(resourceGroupName, budgetName, parameters), serviceCallback); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable createOrUpdateByResourceGroupNameAsync(String resourceGroupName, String budgetName, BudgetInner parameters) { + return createOrUpdateByResourceGroupNameWithServiceResponseAsync(resourceGroupName, budgetName, parameters).map(new Func1, BudgetInner>() { + @Override + public BudgetInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The operation to create or update a budget. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @param parameters Parameters supplied to the Create Budget operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BudgetInner object + */ + public Observable> createOrUpdateByResourceGroupNameWithServiceResponseAsync(String resourceGroupName, String budgetName, BudgetInner parameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (budgetName == null) { + throw new IllegalArgumentException("Parameter budgetName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdateByResourceGroupName(this.client.subscriptionId(), resourceGroupName, budgetName, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateByResourceGroupNameDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateByResourceGroupNameDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The operation to delete a budget. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteByResourceGroupName(String resourceGroupName, String budgetName) { + deleteByResourceGroupNameWithServiceResponseAsync(resourceGroupName, budgetName).toBlocking().single().body(); + } + + /** + * The operation to delete a budget. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteByResourceGroupNameAsync(String resourceGroupName, String budgetName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteByResourceGroupNameWithServiceResponseAsync(resourceGroupName, budgetName), serviceCallback); + } + + /** + * The operation to delete a budget. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteByResourceGroupNameAsync(String resourceGroupName, String budgetName) { + return deleteByResourceGroupNameWithServiceResponseAsync(resourceGroupName, budgetName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The operation to delete a budget. + * + * @param resourceGroupName Azure Resource Group Name. + * @param budgetName Budget Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteByResourceGroupNameWithServiceResponseAsync(String resourceGroupName, String budgetName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (budgetName == null) { + throw new IllegalArgumentException("Parameter budgetName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.deleteByResourceGroupName(this.client.subscriptionId(), resourceGroupName, budgetName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteByResourceGroupNameDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteByResourceGroupNameDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists all budgets for a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<BudgetInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all budgets for a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all budgets for a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all budgets for a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all budgets for a subscription. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<BudgetInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<BudgetInner> object if successful. + */ + public PagedList listByResourceGroupNext(final String nextPageLink) { + ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByResourceGroupNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable> listByResourceGroupNextAsync(final String nextPageLink) { + return listByResourceGroupNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<BudgetInner> object + */ + public Observable>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<BudgetInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByResourceGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManagementClientImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManagementClientImpl.java new file mode 100644 index 0000000000000..187e83db23b99 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManagementClientImpl.java @@ -0,0 +1,530 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * Initializes a new instance of the ConsumptionManagementClientImpl class. + */ +public class ConsumptionManagementClientImpl extends AzureServiceClient { + /** The Retrofit service to perform REST calls. */ + private ConsumptionManagementClientService service; + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Version of the API to be used with the client request. The current version is 2018-03-31. */ + private String apiVersion; + + /** + * Gets Version of the API to be used with the client request. The current version is 2018-03-31. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Azure Subscription ID. */ + private String subscriptionId; + + /** + * Gets Azure Subscription ID. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets Azure Subscription ID. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public ConsumptionManagementClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** The preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets The preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets The preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public ConsumptionManagementClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** The retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public ConsumptionManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public ConsumptionManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The UsageDetailsInner object to access its operations. + */ + private UsageDetailsInner usageDetails; + + /** + * Gets the UsageDetailsInner object to access its operations. + * @return the UsageDetailsInner object. + */ + public UsageDetailsInner usageDetails() { + return this.usageDetails; + } + + /** + * The UsageDetailsByBillingAccountsInner object to access its operations. + */ + private UsageDetailsByBillingAccountsInner usageDetailsByBillingAccounts; + + /** + * Gets the UsageDetailsByBillingAccountsInner object to access its operations. + * @return the UsageDetailsByBillingAccountsInner object. + */ + public UsageDetailsByBillingAccountsInner usageDetailsByBillingAccounts() { + return this.usageDetailsByBillingAccounts; + } + + /** + * The UsageDetailsByDepartmentsInner object to access its operations. + */ + private UsageDetailsByDepartmentsInner usageDetailsByDepartments; + + /** + * Gets the UsageDetailsByDepartmentsInner object to access its operations. + * @return the UsageDetailsByDepartmentsInner object. + */ + public UsageDetailsByDepartmentsInner usageDetailsByDepartments() { + return this.usageDetailsByDepartments; + } + + /** + * The UsageDetailsByEnrollmentAccountsInner object to access its operations. + */ + private UsageDetailsByEnrollmentAccountsInner usageDetailsByEnrollmentAccounts; + + /** + * Gets the UsageDetailsByEnrollmentAccountsInner object to access its operations. + * @return the UsageDetailsByEnrollmentAccountsInner object. + */ + public UsageDetailsByEnrollmentAccountsInner usageDetailsByEnrollmentAccounts() { + return this.usageDetailsByEnrollmentAccounts; + } + + /** + * The MarketplacesInner object to access its operations. + */ + private MarketplacesInner marketplaces; + + /** + * Gets the MarketplacesInner object to access its operations. + * @return the MarketplacesInner object. + */ + public MarketplacesInner marketplaces() { + return this.marketplaces; + } + + /** + * The MarketplacesByBillingAccountsInner object to access its operations. + */ + private MarketplacesByBillingAccountsInner marketplacesByBillingAccounts; + + /** + * Gets the MarketplacesByBillingAccountsInner object to access its operations. + * @return the MarketplacesByBillingAccountsInner object. + */ + public MarketplacesByBillingAccountsInner marketplacesByBillingAccounts() { + return this.marketplacesByBillingAccounts; + } + + /** + * The MarketplacesByDepartmentsInner object to access its operations. + */ + private MarketplacesByDepartmentsInner marketplacesByDepartments; + + /** + * Gets the MarketplacesByDepartmentsInner object to access its operations. + * @return the MarketplacesByDepartmentsInner object. + */ + public MarketplacesByDepartmentsInner marketplacesByDepartments() { + return this.marketplacesByDepartments; + } + + /** + * The MarketplacesByEnrollmentAccountsInner object to access its operations. + */ + private MarketplacesByEnrollmentAccountsInner marketplacesByEnrollmentAccounts; + + /** + * Gets the MarketplacesByEnrollmentAccountsInner object to access its operations. + * @return the MarketplacesByEnrollmentAccountsInner object. + */ + public MarketplacesByEnrollmentAccountsInner marketplacesByEnrollmentAccounts() { + return this.marketplacesByEnrollmentAccounts; + } + + /** + * The GetBalancesByBillingAccountsInner object to access its operations. + */ + private GetBalancesByBillingAccountsInner getBalancesByBillingAccounts; + + /** + * Gets the GetBalancesByBillingAccountsInner object to access its operations. + * @return the GetBalancesByBillingAccountsInner object. + */ + public GetBalancesByBillingAccountsInner getBalancesByBillingAccounts() { + return this.getBalancesByBillingAccounts; + } + + /** + * The ReservationsSummariesInner object to access its operations. + */ + private ReservationsSummariesInner reservationsSummaries; + + /** + * Gets the ReservationsSummariesInner object to access its operations. + * @return the ReservationsSummariesInner object. + */ + public ReservationsSummariesInner reservationsSummaries() { + return this.reservationsSummaries; + } + + /** + * The ReservationsDetailsInner object to access its operations. + */ + private ReservationsDetailsInner reservationsDetails; + + /** + * Gets the ReservationsDetailsInner object to access its operations. + * @return the ReservationsDetailsInner object. + */ + public ReservationsDetailsInner reservationsDetails() { + return this.reservationsDetails; + } + + /** + * The ReservationRecommendationsInner object to access its operations. + */ + private ReservationRecommendationsInner reservationRecommendations; + + /** + * Gets the ReservationRecommendationsInner object to access its operations. + * @return the ReservationRecommendationsInner object. + */ + public ReservationRecommendationsInner reservationRecommendations() { + return this.reservationRecommendations; + } + + /** + * The BudgetsInner object to access its operations. + */ + private BudgetsInner budgets; + + /** + * Gets the BudgetsInner object to access its operations. + * @return the BudgetsInner object. + */ + public BudgetsInner budgets() { + return this.budgets; + } + + /** + * The OperationsInner object to access its operations. + */ + private OperationsInner operations; + + /** + * Gets the OperationsInner object to access its operations. + * @return the OperationsInner object. + */ + public OperationsInner operations() { + return this.operations; + } + + /** + * The PriceSheetsInner object to access its operations. + */ + private PriceSheetsInner priceSheets; + + /** + * Gets the PriceSheetsInner object to access its operations. + * @return the PriceSheetsInner object. + */ + public PriceSheetsInner priceSheets() { + return this.priceSheets; + } + + /** + * The CostTagsInner object to access its operations. + */ + private CostTagsInner costTags; + + /** + * Gets the CostTagsInner object to access its operations. + * @return the CostTagsInner object. + */ + public CostTagsInner costTags() { + return this.costTags; + } + + /** + * The TagsInner object to access its operations. + */ + private TagsInner tags; + + /** + * Gets the TagsInner object to access its operations. + * @return the TagsInner object. + */ + public TagsInner tags() { + return this.tags; + } + + /** + * Initializes an instance of ConsumptionManagementClient client. + * + * @param credentials the management credentials for Azure + */ + public ConsumptionManagementClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of ConsumptionManagementClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public ConsumptionManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of ConsumptionManagementClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public ConsumptionManagementClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2018-03-31"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.usageDetails = new UsageDetailsInner(restClient().retrofit(), this); + this.usageDetailsByBillingAccounts = new UsageDetailsByBillingAccountsInner(restClient().retrofit(), this); + this.usageDetailsByDepartments = new UsageDetailsByDepartmentsInner(restClient().retrofit(), this); + this.usageDetailsByEnrollmentAccounts = new UsageDetailsByEnrollmentAccountsInner(restClient().retrofit(), this); + this.marketplaces = new MarketplacesInner(restClient().retrofit(), this); + this.marketplacesByBillingAccounts = new MarketplacesByBillingAccountsInner(restClient().retrofit(), this); + this.marketplacesByDepartments = new MarketplacesByDepartmentsInner(restClient().retrofit(), this); + this.marketplacesByEnrollmentAccounts = new MarketplacesByEnrollmentAccountsInner(restClient().retrofit(), this); + this.getBalancesByBillingAccounts = new GetBalancesByBillingAccountsInner(restClient().retrofit(), this); + this.reservationsSummaries = new ReservationsSummariesInner(restClient().retrofit(), this); + this.reservationsDetails = new ReservationsDetailsInner(restClient().retrofit(), this); + this.reservationRecommendations = new ReservationRecommendationsInner(restClient().retrofit(), this); + this.budgets = new BudgetsInner(restClient().retrofit(), this); + this.operations = new OperationsInner(restClient().retrofit(), this); + this.priceSheets = new PriceSheetsInner(restClient().retrofit(), this); + this.costTags = new CostTagsInner(restClient().retrofit(), this); + this.tags = new TagsInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + initializeService(); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s, auto-generated)", super.userAgent(), "ConsumptionManagementClient", "2018-03-31"); + } + + private void initializeService() { + service = restClient().retrofit().create(ConsumptionManagementClientService.class); + } + + /** + * The interface defining all the services for ConsumptionManagementClient to be + * used by Retrofit to perform actually REST calls. + */ + interface ConsumptionManagementClientService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ConsumptionManagementClient getBalancesByBillingAccount" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances") + Observable> getBalancesByBillingAccount(@Path("billingAccountId") String billingAccountId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets the balances for a scope by billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BalanceInner object if successful. + */ + public BalanceInner getBalancesByBillingAccount(String billingAccountId) { + return getBalancesByBillingAccountWithServiceResponseAsync(billingAccountId).toBlocking().single().body(); + } + + /** + * Gets the balances for a scope by billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getBalancesByBillingAccountAsync(String billingAccountId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getBalancesByBillingAccountWithServiceResponseAsync(billingAccountId), serviceCallback); + } + + /** + * Gets the balances for a scope by billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BalanceInner object + */ + public Observable getBalancesByBillingAccountAsync(String billingAccountId) { + return getBalancesByBillingAccountWithServiceResponseAsync(billingAccountId).map(new Func1, BalanceInner>() { + @Override + public BalanceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the balances for a scope by billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BalanceInner object + */ + public Observable> getBalancesByBillingAccountWithServiceResponseAsync(String billingAccountId) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + return service.getBalancesByBillingAccount(billingAccountId, this.apiVersion(), this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getBalancesByBillingAccountDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getBalancesByBillingAccountDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManager.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManager.java new file mode 100644 index 0000000000000..98bb7adcf4326 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ConsumptionManager.java @@ -0,0 +1,291 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.AzureResponseBuilder; +import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.apigeneration.Beta; +import com.microsoft.azure.management.apigeneration.Beta.SinceVersion; +import com.microsoft.azure.arm.resources.AzureConfigurable; +import com.microsoft.azure.serializer.AzureJacksonAdapter; +import com.microsoft.rest.RestClient; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetails; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByBillingAccounts; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByDepartments; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByEnrollmentAccounts; +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplaces; +import com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByBillingAccounts; +import com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByDepartments; +import com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByEnrollmentAccounts; +import com.microsoft.azure.management.consumption.v2018_03_31.GetBalancesByBillingAccounts; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationsSummaries; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationsDetails; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationRecommendations; +import com.microsoft.azure.management.consumption.v2018_03_31.Budgets; +import com.microsoft.azure.management.consumption.v2018_03_31.Operations; +import com.microsoft.azure.management.consumption.v2018_03_31.PriceSheets; +import com.microsoft.azure.management.consumption.v2018_03_31.CostTags; +import com.microsoft.azure.management.consumption.v2018_03_31.Tags; +import com.microsoft.azure.arm.resources.implementation.AzureConfigurableCoreImpl; +import com.microsoft.azure.arm.resources.implementation.ManagerCore; + +/** + * Entry point to Azure Consumption resource management. + */ +public final class ConsumptionManager extends ManagerCore { + private UsageDetails usageDetails; + private UsageDetailsByBillingAccounts usageDetailsByBillingAccounts; + private UsageDetailsByDepartments usageDetailsByDepartments; + private UsageDetailsByEnrollmentAccounts usageDetailsByEnrollmentAccounts; + private Marketplaces marketplaces; + private MarketplacesByBillingAccounts marketplacesByBillingAccounts; + private MarketplacesByDepartments marketplacesByDepartments; + private MarketplacesByEnrollmentAccounts marketplacesByEnrollmentAccounts; + private GetBalancesByBillingAccounts getBalancesByBillingAccounts; + private ReservationsSummaries reservationsSummaries; + private ReservationsDetails reservationsDetails; + private ReservationRecommendations reservationRecommendations; + private Budgets budgets; + private Operations operations; + private PriceSheets priceSheets; + private CostTags costTags; + private Tags tags; + /** + * Get a Configurable instance that can be used to create ConsumptionManager with optional configuration. + * + * @return the instance allowing configurations + */ + public static Configurable configure() { + return new ConsumptionManager.ConfigurableImpl(); + } + /** + * Creates an instance of ConsumptionManager that exposes Consumption resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the ConsumptionManager + */ + public static ConsumptionManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new ConsumptionManager(new RestClient.Builder() + .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) + .withCredentials(credentials) + .withSerializerAdapter(new AzureJacksonAdapter()) + .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) + .build(), subscriptionId); + } + /** + * Creates an instance of ConsumptionManager that exposes Consumption resource management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription UUID + * @return the ConsumptionManager + */ + public static ConsumptionManager authenticate(RestClient restClient, String subscriptionId) { + return new ConsumptionManager(restClient, subscriptionId); + } + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of ConsumptionManager that exposes Consumption management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the interface exposing Consumption management API entry points that work across subscriptions + */ + ConsumptionManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * @return Entry point to manage UsageDetails. + */ + public UsageDetails usageDetails() { + if (this.usageDetails == null) { + this.usageDetails = new UsageDetailsImpl(this); + } + return this.usageDetails; + } + + /** + * @return Entry point to manage UsageDetailsByBillingAccounts. + */ + public UsageDetailsByBillingAccounts usageDetailsByBillingAccounts() { + if (this.usageDetailsByBillingAccounts == null) { + this.usageDetailsByBillingAccounts = new UsageDetailsByBillingAccountsImpl(this); + } + return this.usageDetailsByBillingAccounts; + } + + /** + * @return Entry point to manage UsageDetailsByDepartments. + */ + public UsageDetailsByDepartments usageDetailsByDepartments() { + if (this.usageDetailsByDepartments == null) { + this.usageDetailsByDepartments = new UsageDetailsByDepartmentsImpl(this); + } + return this.usageDetailsByDepartments; + } + + /** + * @return Entry point to manage UsageDetailsByEnrollmentAccounts. + */ + public UsageDetailsByEnrollmentAccounts usageDetailsByEnrollmentAccounts() { + if (this.usageDetailsByEnrollmentAccounts == null) { + this.usageDetailsByEnrollmentAccounts = new UsageDetailsByEnrollmentAccountsImpl(this); + } + return this.usageDetailsByEnrollmentAccounts; + } + + /** + * @return Entry point to manage Marketplaces. + */ + public Marketplaces marketplaces() { + if (this.marketplaces == null) { + this.marketplaces = new MarketplacesImpl(this); + } + return this.marketplaces; + } + + /** + * @return Entry point to manage MarketplacesByBillingAccounts. + */ + public MarketplacesByBillingAccounts marketplacesByBillingAccounts() { + if (this.marketplacesByBillingAccounts == null) { + this.marketplacesByBillingAccounts = new MarketplacesByBillingAccountsImpl(this); + } + return this.marketplacesByBillingAccounts; + } + + /** + * @return Entry point to manage MarketplacesByDepartments. + */ + public MarketplacesByDepartments marketplacesByDepartments() { + if (this.marketplacesByDepartments == null) { + this.marketplacesByDepartments = new MarketplacesByDepartmentsImpl(this); + } + return this.marketplacesByDepartments; + } + + /** + * @return Entry point to manage MarketplacesByEnrollmentAccounts. + */ + public MarketplacesByEnrollmentAccounts marketplacesByEnrollmentAccounts() { + if (this.marketplacesByEnrollmentAccounts == null) { + this.marketplacesByEnrollmentAccounts = new MarketplacesByEnrollmentAccountsImpl(this); + } + return this.marketplacesByEnrollmentAccounts; + } + + /** + * @return Entry point to manage GetBalancesByBillingAccounts. + */ + public GetBalancesByBillingAccounts getBalancesByBillingAccounts() { + if (this.getBalancesByBillingAccounts == null) { + this.getBalancesByBillingAccounts = new GetBalancesByBillingAccountsImpl(this); + } + return this.getBalancesByBillingAccounts; + } + + /** + * @return Entry point to manage ReservationsSummaries. + */ + public ReservationsSummaries reservationsSummaries() { + if (this.reservationsSummaries == null) { + this.reservationsSummaries = new ReservationsSummariesImpl(this); + } + return this.reservationsSummaries; + } + + /** + * @return Entry point to manage ReservationsDetails. + */ + public ReservationsDetails reservationsDetails() { + if (this.reservationsDetails == null) { + this.reservationsDetails = new ReservationsDetailsImpl(this); + } + return this.reservationsDetails; + } + + /** + * @return Entry point to manage ReservationRecommendations. + */ + public ReservationRecommendations reservationRecommendations() { + if (this.reservationRecommendations == null) { + this.reservationRecommendations = new ReservationRecommendationsImpl(this); + } + return this.reservationRecommendations; + } + + /** + * @return Entry point to manage Budgets. + */ + public Budgets budgets() { + if (this.budgets == null) { + this.budgets = new BudgetsImpl(this); + } + return this.budgets; + } + + /** + * @return Entry point to manage Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(this); + } + return this.operations; + } + + /** + * @return Entry point to manage PriceSheets. + */ + public PriceSheets priceSheets() { + if (this.priceSheets == null) { + this.priceSheets = new PriceSheetsImpl(this); + } + return this.priceSheets; + } + + /** + * @return Entry point to manage CostTags. + */ + public CostTags costTags() { + if (this.costTags == null) { + this.costTags = new CostTagsImpl(this); + } + return this.costTags; + } + + /** + * @return Entry point to manage Tags. + */ + public Tags tags() { + if (this.tags == null) { + this.tags = new TagsImpl(this); + } + return this.tags; + } + + /** + * The implementation for Configurable interface. + */ + private static final class ConfigurableImpl extends AzureConfigurableCoreImpl implements Configurable { + public ConsumptionManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return ConsumptionManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + private ConsumptionManager(RestClient restClient, String subscriptionId) { + super( + restClient, + subscriptionId, + new ConsumptionManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagInner.java new file mode 100644 index 0000000000000..52e54aef33a48 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagInner.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The cost tag. + */ +public class CostTagInner { + /** + * Cost tag key. + */ + @JsonProperty(value = "key") + private String key; + + /** + * Get cost tag key. + * + * @return the key value + */ + public String key() { + return this.key; + } + + /** + * Set cost tag key. + * + * @param key the key value to set + * @return the CostTagInner object itself. + */ + public CostTagInner withKey(String key) { + this.key = key; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsImpl.java new file mode 100644 index 0000000000000..e8ec4fbc10a12 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsImpl.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.CostTags; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.CostTagsModel; + +class CostTagsImpl extends WrapperImpl implements CostTags { + private final ConsumptionManager manager; + + CostTagsImpl(ConsumptionManager manager) { + super(manager.inner().costTags()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable getAsync(String billingAccountId) { + CostTagsInner client = this.inner(); + return client.getAsync(billingAccountId) + .map(new Func1() { + @Override + public CostTagsModel call(CostTagsModelInner inner) { + return new CostTagsModelImpl(inner, manager()); + } + }); + } + + @Override + public Observable createOrUpdateAsync(String billingAccountId, CostTagsModelInner parameters) { + CostTagsInner client = this.inner(); + return client.createOrUpdateAsync(billingAccountId, parameters) + .map(new Func1() { + @Override + public CostTagsModel call(CostTagsModelInner inner) { + return new CostTagsModelImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsInner.java new file mode 100644 index 0000000000000..4aae1deaaa04e --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsInner.java @@ -0,0 +1,228 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in CostTags. + */ +public class CostTagsInner { + /** The Retrofit service to perform REST calls. */ + private CostTagsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of CostTagsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public CostTagsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(CostTagsService.class); + this.client = client; + } + + /** + * The interface defining all the services for CostTags to be + * used by Retrofit to perform actually REST calls. + */ + interface CostTagsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.CostTags get" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags") + Observable> get(@Path("billingAccountId") String billingAccountId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.CostTags createOrUpdate" }) + @PUT("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags") + Observable> createOrUpdate(@Path("billingAccountId") String billingAccountId, @Query("api-version") String apiVersion, @Body CostTagsModelInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get cost tags for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the CostTagsModelInner object if successful. + */ + public CostTagsModelInner get(String billingAccountId) { + return getWithServiceResponseAsync(billingAccountId).toBlocking().single().body(); + } + + /** + * Get cost tags for a billing account. + * + * @param billingAccountId BillingAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String billingAccountId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(billingAccountId), serviceCallback); + } + + /** + * Get cost tags for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the CostTagsModelInner object + */ + public Observable getAsync(String billingAccountId) { + return getWithServiceResponseAsync(billingAccountId).map(new Func1, CostTagsModelInner>() { + @Override + public CostTagsModelInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get cost tags for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the CostTagsModelInner object + */ + public Observable> getWithServiceResponseAsync(String billingAccountId) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(billingAccountId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The operation to create or update cost tags associated with a billing account. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param billingAccountId BillingAccount ID + * @param parameters Parameters supplied to the Create cost tags operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the CostTagsModelInner object if successful. + */ + public CostTagsModelInner createOrUpdate(String billingAccountId, CostTagsModelInner parameters) { + return createOrUpdateWithServiceResponseAsync(billingAccountId, parameters).toBlocking().single().body(); + } + + /** + * The operation to create or update cost tags associated with a billing account. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param billingAccountId BillingAccount ID + * @param parameters Parameters supplied to the Create cost tags operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String billingAccountId, CostTagsModelInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(billingAccountId, parameters), serviceCallback); + } + + /** + * The operation to create or update cost tags associated with a billing account. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param billingAccountId BillingAccount ID + * @param parameters Parameters supplied to the Create cost tags operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the CostTagsModelInner object + */ + public Observable createOrUpdateAsync(String billingAccountId, CostTagsModelInner parameters) { + return createOrUpdateWithServiceResponseAsync(billingAccountId, parameters).map(new Func1, CostTagsModelInner>() { + @Override + public CostTagsModelInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The operation to create or update cost tags associated with a billing account. Update operation requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. + * + * @param billingAccountId BillingAccount ID + * @param parameters Parameters supplied to the Create cost tags operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the CostTagsModelInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String billingAccountId, CostTagsModelInner parameters) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdate(billingAccountId, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelImpl.java new file mode 100644 index 0000000000000..1f9b2a0d3812e --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelImpl.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.CostTagsModel; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.util.List; + +class CostTagsModelImpl extends WrapperImpl implements CostTagsModel { + private final ConsumptionManager manager; + CostTagsModelImpl(CostTagsModelInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public List costTags() { + return this.inner().costTags(); + } + + @Override + public String eTag() { + return this.inner().eTag(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String type() { + return this.inner().type(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelInner.java new file mode 100644 index 0000000000000..3b3de1cf15ccc --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/CostTagsModelInner.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * A cost tag resource. + */ +@JsonFlatten +public class CostTagsModelInner extends ProxyResource { + /** + * Cost tags. + */ + @JsonProperty(value = "properties.costTags") + private List costTags; + + /** + * eTag of the resource. To handle concurrent update scenario, this field + * will be used to determine whether the user is updating the latest + * version or not. + */ + @JsonProperty(value = "eTag") + private String eTag; + + /** + * Get cost tags. + * + * @return the costTags value + */ + public List costTags() { + return this.costTags; + } + + /** + * Set cost tags. + * + * @param costTags the costTags value to set + * @return the CostTagsModelInner object itself. + */ + public CostTagsModelInner withCostTags(List costTags) { + this.costTags = costTags; + return this; + } + + /** + * Get eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + * + * @return the eTag value + */ + public String eTag() { + return this.eTag; + } + + /** + * Set eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + * + * @param eTag the eTag value to set + * @return the CostTagsModelInner object itself. + */ + public CostTagsModelInner withETag(String eTag) { + this.eTag = eTag; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsImpl.java new file mode 100644 index 0000000000000..cca7c37090def --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsImpl.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.GetBalancesByBillingAccounts; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.Balance; + +class GetBalancesByBillingAccountsImpl extends WrapperImpl implements GetBalancesByBillingAccounts { + private final ConsumptionManager manager; + + GetBalancesByBillingAccountsImpl(ConsumptionManager manager) { + super(manager.inner().getBalancesByBillingAccounts()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable byBillingPeriodAsync(String billingAccountId, String billingPeriodName) { + GetBalancesByBillingAccountsInner client = this.inner(); + return client.byBillingPeriodAsync(billingAccountId, billingPeriodName) + .map(new Func1() { + @Override + public Balance call(BalanceInner inner) { + return new BalanceImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsInner.java new file mode 100644 index 0000000000000..ed2056ea3d2bd --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/GetBalancesByBillingAccountsInner.java @@ -0,0 +1,143 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in GetBalancesByBillingAccounts. + */ +public class GetBalancesByBillingAccountsInner { + /** The Retrofit service to perform REST calls. */ + private GetBalancesByBillingAccountsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of GetBalancesByBillingAccountsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public GetBalancesByBillingAccountsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(GetBalancesByBillingAccountsService.class); + this.client = client; + } + + /** + * The interface defining all the services for GetBalancesByBillingAccounts to be + * used by Retrofit to perform actually REST calls. + */ + interface GetBalancesByBillingAccountsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.GetBalancesByBillingAccounts byBillingPeriod" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances") + Observable> byBillingPeriod(@Path("billingAccountId") String billingAccountId, @Path("billingPeriodName") String billingPeriodName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BalanceInner object if successful. + */ + public BalanceInner byBillingPeriod(String billingAccountId, String billingPeriodName) { + return byBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName).toBlocking().single().body(); + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture byBillingPeriodAsync(String billingAccountId, String billingPeriodName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(byBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName), serviceCallback); + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BalanceInner object + */ + public Observable byBillingPeriodAsync(String billingAccountId, String billingPeriodName) { + return byBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName).map(new Func1, BalanceInner>() { + @Override + public BalanceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. Balances are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BalanceInner object + */ + public Observable> byBillingPeriodWithServiceResponseAsync(String billingAccountId, String billingPeriodName) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.byBillingPeriod(billingAccountId, billingPeriodName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = byBillingPeriodDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse byBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/IdParsingUtils.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/IdParsingUtils.java new file mode 100644 index 0000000000000..b4f14548926b1 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/IdParsingUtils.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; +import java.util.Arrays; +import java.util.Iterator; + +class IdParsingUtils { + public static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterable iterable = Arrays.asList(id.split("/")); + Iterator itr = iterable.iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && part.trim() != "") { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + public static String getValueFromIdByPosition(String id, int pos) { + if (id == null) { + return null; + } + Iterable iterable = Arrays.asList(id.split("/")); + Iterator itr = iterable.iterator(); + int index = 0; + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && part.trim() != "") { + if (index == pos) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + index++; + } + return null; + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceImpl.java new file mode 100644 index 0000000000000..7665e62b5093a --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceImpl.java @@ -0,0 +1,170 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplace; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.math.BigDecimal; +import java.util.UUID; +import java.util.Map; +import org.joda.time.DateTime; + +class MarketplaceImpl extends WrapperImpl implements Marketplace { + private final ConsumptionManager manager; + MarketplaceImpl(MarketplaceInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public String accountName() { + return this.inner().accountName(); + } + + @Override + public String additionalProperties() { + return this.inner().additionalProperties(); + } + + @Override + public String billingPeriodId() { + return this.inner().billingPeriodId(); + } + + @Override + public BigDecimal consumedQuantity() { + return this.inner().consumedQuantity(); + } + + @Override + public String consumedService() { + return this.inner().consumedService(); + } + + @Override + public String costCenter() { + return this.inner().costCenter(); + } + + @Override + public String currency() { + return this.inner().currency(); + } + + @Override + public String departmentName() { + return this.inner().departmentName(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String instanceId() { + return this.inner().instanceId(); + } + + @Override + public String instanceName() { + return this.inner().instanceName(); + } + + @Override + public Boolean isEstimated() { + return this.inner().isEstimated(); + } + + @Override + public UUID meterId() { + return this.inner().meterId(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String offerName() { + return this.inner().offerName(); + } + + @Override + public String orderNumber() { + return this.inner().orderNumber(); + } + + @Override + public String planName() { + return this.inner().planName(); + } + + @Override + public BigDecimal pretaxCost() { + return this.inner().pretaxCost(); + } + + @Override + public String publisherName() { + return this.inner().publisherName(); + } + + @Override + public String resourceGroup() { + return this.inner().resourceGroup(); + } + + @Override + public BigDecimal resourceRate() { + return this.inner().resourceRate(); + } + + @Override + public UUID subscriptionGuid() { + return this.inner().subscriptionGuid(); + } + + @Override + public String subscriptionName() { + return this.inner().subscriptionName(); + } + + @Override + public Map tags() { + return this.inner().tags(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public String unitOfMeasure() { + return this.inner().unitOfMeasure(); + } + + @Override + public DateTime usageEnd() { + return this.inner().usageEnd(); + } + + @Override + public DateTime usageStart() { + return this.inner().usageStart(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceInner.java new file mode 100644 index 0000000000000..4e2bb680c34aa --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplaceInner.java @@ -0,0 +1,401 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import org.joda.time.DateTime; +import java.math.BigDecimal; +import java.util.UUID; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * An marketplace resource. + */ +@JsonFlatten +public class MarketplaceInner extends ProxyResource { + /** + * The id of the billing period resource that the usage belongs to. + */ + @JsonProperty(value = "properties.billingPeriodId", access = JsonProperty.Access.WRITE_ONLY) + private String billingPeriodId; + + /** + * The start of the date time range covered by the usage detail. + */ + @JsonProperty(value = "properties.usageStart", access = JsonProperty.Access.WRITE_ONLY) + private DateTime usageStart; + + /** + * The end of the date time range covered by the usage detail. + */ + @JsonProperty(value = "properties.usageEnd", access = JsonProperty.Access.WRITE_ONLY) + private DateTime usageEnd; + + /** + * The marketplace resource rate. + */ + @JsonProperty(value = "properties.resourceRate", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal resourceRate; + + /** + * The type of offer. + */ + @JsonProperty(value = "properties.offerName", access = JsonProperty.Access.WRITE_ONLY) + private String offerName; + + /** + * The name of resource group. + */ + @JsonProperty(value = "properties.resourceGroup", access = JsonProperty.Access.WRITE_ONLY) + private String resourceGroup; + + /** + * The order number. + */ + @JsonProperty(value = "properties.orderNumber", access = JsonProperty.Access.WRITE_ONLY) + private String orderNumber; + + /** + * The name of the resource instance that the usage is about. + */ + @JsonProperty(value = "properties.instanceName", access = JsonProperty.Access.WRITE_ONLY) + private String instanceName; + + /** + * The uri of the resource instance that the usage is about. + */ + @JsonProperty(value = "properties.instanceId", access = JsonProperty.Access.WRITE_ONLY) + private String instanceId; + + /** + * The ISO currency in which the meter is charged, for example, USD. + */ + @JsonProperty(value = "properties.currency", access = JsonProperty.Access.WRITE_ONLY) + private String currency; + + /** + * The quantity of usage. + */ + @JsonProperty(value = "properties.consumedQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal consumedQuantity; + + /** + * The unit of measure. + */ + @JsonProperty(value = "properties.unitOfMeasure", access = JsonProperty.Access.WRITE_ONLY) + private String unitOfMeasure; + + /** + * The amount of cost before tax. + */ + @JsonProperty(value = "properties.pretaxCost", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal pretaxCost; + + /** + * The estimated usage is subject to change. + */ + @JsonProperty(value = "properties.isEstimated", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isEstimated; + + /** + * The meter id (GUID). + */ + @JsonProperty(value = "properties.meterId", access = JsonProperty.Access.WRITE_ONLY) + private UUID meterId; + + /** + * Subscription guid. + */ + @JsonProperty(value = "properties.subscriptionGuid", access = JsonProperty.Access.WRITE_ONLY) + private UUID subscriptionGuid; + + /** + * Subscription name. + */ + @JsonProperty(value = "properties.subscriptionName", access = JsonProperty.Access.WRITE_ONLY) + private String subscriptionName; + + /** + * Account name. + */ + @JsonProperty(value = "properties.accountName", access = JsonProperty.Access.WRITE_ONLY) + private String accountName; + + /** + * Department name. + */ + @JsonProperty(value = "properties.departmentName", access = JsonProperty.Access.WRITE_ONLY) + private String departmentName; + + /** + * Consumed service name. + */ + @JsonProperty(value = "properties.consumedService", access = JsonProperty.Access.WRITE_ONLY) + private String consumedService; + + /** + * The cost center of this department if it is a department and a + * costcenter exists. + */ + @JsonProperty(value = "properties.costCenter", access = JsonProperty.Access.WRITE_ONLY) + private String costCenter; + + /** + * Additional details of this usage item. By default this is not populated, + * unless it's specified in $expand. + */ + @JsonProperty(value = "properties.additionalProperties", access = JsonProperty.Access.WRITE_ONLY) + private String additionalProperties; + + /** + * The name of publisher. + */ + @JsonProperty(value = "properties.publisherName", access = JsonProperty.Access.WRITE_ONLY) + private String publisherName; + + /** + * The name of plan. + */ + @JsonProperty(value = "properties.planName", access = JsonProperty.Access.WRITE_ONLY) + private String planName; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Get the id of the billing period resource that the usage belongs to. + * + * @return the billingPeriodId value + */ + public String billingPeriodId() { + return this.billingPeriodId; + } + + /** + * Get the start of the date time range covered by the usage detail. + * + * @return the usageStart value + */ + public DateTime usageStart() { + return this.usageStart; + } + + /** + * Get the end of the date time range covered by the usage detail. + * + * @return the usageEnd value + */ + public DateTime usageEnd() { + return this.usageEnd; + } + + /** + * Get the marketplace resource rate. + * + * @return the resourceRate value + */ + public BigDecimal resourceRate() { + return this.resourceRate; + } + + /** + * Get the type of offer. + * + * @return the offerName value + */ + public String offerName() { + return this.offerName; + } + + /** + * Get the name of resource group. + * + * @return the resourceGroup value + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * Get the order number. + * + * @return the orderNumber value + */ + public String orderNumber() { + return this.orderNumber; + } + + /** + * Get the name of the resource instance that the usage is about. + * + * @return the instanceName value + */ + public String instanceName() { + return this.instanceName; + } + + /** + * Get the uri of the resource instance that the usage is about. + * + * @return the instanceId value + */ + public String instanceId() { + return this.instanceId; + } + + /** + * Get the ISO currency in which the meter is charged, for example, USD. + * + * @return the currency value + */ + public String currency() { + return this.currency; + } + + /** + * Get the quantity of usage. + * + * @return the consumedQuantity value + */ + public BigDecimal consumedQuantity() { + return this.consumedQuantity; + } + + /** + * Get the unit of measure. + * + * @return the unitOfMeasure value + */ + public String unitOfMeasure() { + return this.unitOfMeasure; + } + + /** + * Get the amount of cost before tax. + * + * @return the pretaxCost value + */ + public BigDecimal pretaxCost() { + return this.pretaxCost; + } + + /** + * Get the estimated usage is subject to change. + * + * @return the isEstimated value + */ + public Boolean isEstimated() { + return this.isEstimated; + } + + /** + * Get the meter id (GUID). + * + * @return the meterId value + */ + public UUID meterId() { + return this.meterId; + } + + /** + * Get subscription guid. + * + * @return the subscriptionGuid value + */ + public UUID subscriptionGuid() { + return this.subscriptionGuid; + } + + /** + * Get subscription name. + * + * @return the subscriptionName value + */ + public String subscriptionName() { + return this.subscriptionName; + } + + /** + * Get account name. + * + * @return the accountName value + */ + public String accountName() { + return this.accountName; + } + + /** + * Get department name. + * + * @return the departmentName value + */ + public String departmentName() { + return this.departmentName; + } + + /** + * Get consumed service name. + * + * @return the consumedService value + */ + public String consumedService() { + return this.consumedService; + } + + /** + * Get the cost center of this department if it is a department and a costcenter exists. + * + * @return the costCenter value + */ + public String costCenter() { + return this.costCenter; + } + + /** + * Get additional details of this usage item. By default this is not populated, unless it's specified in $expand. + * + * @return the additionalProperties value + */ + public String additionalProperties() { + return this.additionalProperties; + } + + /** + * Get the name of publisher. + * + * @return the publisherName value + */ + public String publisherName() { + return this.publisherName; + } + + /** + * Get the name of plan. + * + * @return the planName value + */ + public String planName() { + return this.planName; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsImpl.java new file mode 100644 index 0000000000000..8c7fe429c8d7a --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByBillingAccounts; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplace; + +class MarketplacesByBillingAccountsImpl extends WrapperImpl implements MarketplacesByBillingAccounts { + private final ConsumptionManager manager; + + MarketplacesByBillingAccountsImpl(ConsumptionManager manager) { + super(manager.inner().marketplacesByBillingAccounts()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync(final String billingAccountId) { + MarketplacesByBillingAccountsInner client = this.inner(); + return client.listAsync(billingAccountId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName) { + MarketplacesByBillingAccountsInner client = this.inner(); + return client.listByBillingPeriodAsync(billingAccountId, billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsInner.java new file mode 100644 index 0000000000000..c0631429fac2d --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByBillingAccountsInner.java @@ -0,0 +1,785 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in MarketplacesByBillingAccounts. + */ +public class MarketplacesByBillingAccountsInner { + /** The Retrofit service to perform REST calls. */ + private MarketplacesByBillingAccountsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of MarketplacesByBillingAccountsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MarketplacesByBillingAccountsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(MarketplacesByBillingAccountsService.class); + this.client = client; + } + + /** + * The interface defining all the services for MarketplacesByBillingAccounts to be + * used by Retrofit to perform actually REST calls. + */ + interface MarketplacesByBillingAccountsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByBillingAccounts list" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/marketplaces") + Observable> list(@Path("billingAccountId") String billingAccountId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByBillingAccounts listByBillingPeriod" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces") + Observable> listByBillingPeriod(@Path("billingAccountId") String billingAccountId, @Path("billingPeriodName") String billingPeriodName, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByBillingAccounts listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByBillingAccounts listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String billingAccountId) { + ServiceResponse> response = listSinglePageAsync(billingAccountId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String billingAccountId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(billingAccountId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String billingAccountId) { + return listWithServiceResponseAsync(billingAccountId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String billingAccountId) { + return listSinglePageAsync(billingAccountId) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String billingAccountId) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.list(billingAccountId, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String billingAccountId, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listSinglePageAsync(billingAccountId, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String billingAccountId, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(billingAccountId, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String billingAccountId, final String filter, final Integer top, final String skiptoken) { + return listWithServiceResponseAsync(billingAccountId, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String billingAccountId, final String filter, final Integer top, final String skiptoken) { + return listSinglePageAsync(billingAccountId, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param billingAccountId BillingAccount ID + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String billingAccountId, final String filter, final Integer top, final String skiptoken) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(billingAccountId, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingAccountId, final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingAccountId, final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingAccountId, final String billingPeriodName) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.listByBillingPeriod(billingAccountId, billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param billingAccountId BillingAccount ID + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByBillingPeriod(billingAccountId, billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsImpl.java new file mode 100644 index 0000000000000..61bdeb7da963e --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByDepartments; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplace; + +class MarketplacesByDepartmentsImpl extends WrapperImpl implements MarketplacesByDepartments { + private final ConsumptionManager manager; + + MarketplacesByDepartmentsImpl(ConsumptionManager manager) { + super(manager.inner().marketplacesByDepartments()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync(final String departmentId) { + MarketplacesByDepartmentsInner client = this.inner(); + return client.listAsync(departmentId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByBillingPeriodAsync(final String departmentId, final String billingPeriodName) { + MarketplacesByDepartmentsInner client = this.inner(); + return client.listByBillingPeriodAsync(departmentId, billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsInner.java new file mode 100644 index 0000000000000..3b9c8d95161aa --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByDepartmentsInner.java @@ -0,0 +1,785 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in MarketplacesByDepartments. + */ +public class MarketplacesByDepartmentsInner { + /** The Retrofit service to perform REST calls. */ + private MarketplacesByDepartmentsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of MarketplacesByDepartmentsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MarketplacesByDepartmentsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(MarketplacesByDepartmentsService.class); + this.client = client; + } + + /** + * The interface defining all the services for MarketplacesByDepartments to be + * used by Retrofit to perform actually REST calls. + */ + interface MarketplacesByDepartmentsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByDepartments list" }) + @GET("providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/marketplaces") + Observable> list(@Path("departmentId") String departmentId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByDepartments listByBillingPeriod" }) + @GET("providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces") + Observable> listByBillingPeriod(@Path("departmentId") String departmentId, @Path("billingPeriodName") String billingPeriodName, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByDepartments listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByDepartments listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String departmentId) { + ServiceResponse> response = listSinglePageAsync(departmentId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String departmentId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(departmentId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String departmentId) { + return listWithServiceResponseAsync(departmentId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String departmentId) { + return listSinglePageAsync(departmentId) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String departmentId) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.list(departmentId, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String departmentId, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listSinglePageAsync(departmentId, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String departmentId, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(departmentId, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String departmentId, final String filter, final Integer top, final String skiptoken) { + return listWithServiceResponseAsync(departmentId, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String departmentId, final String filter, final Integer top, final String skiptoken) { + return listSinglePageAsync(departmentId, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param departmentId Department ID + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String departmentId, final String filter, final Integer top, final String skiptoken) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(departmentId, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String departmentId, final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(departmentId, billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String departmentId, final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String departmentId, final String billingPeriodName) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.listByBillingPeriod(departmentId, billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String departmentId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodWithServiceResponseAsync(departmentId, billingPeriodName, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String departmentId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param departmentId Department ID + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String departmentId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByBillingPeriod(departmentId, billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsImpl.java new file mode 100644 index 0000000000000..74efbb0602d9f --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByEnrollmentAccounts; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplace; + +class MarketplacesByEnrollmentAccountsImpl extends WrapperImpl implements MarketplacesByEnrollmentAccounts { + private final ConsumptionManager manager; + + MarketplacesByEnrollmentAccountsImpl(ConsumptionManager manager) { + super(manager.inner().marketplacesByEnrollmentAccounts()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync(final String enrollmentAccountId) { + MarketplacesByEnrollmentAccountsInner client = this.inner(); + return client.listAsync(enrollmentAccountId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName) { + MarketplacesByEnrollmentAccountsInner client = this.inner(); + return client.listByBillingPeriodAsync(enrollmentAccountId, billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsInner.java new file mode 100644 index 0000000000000..42a07763f19a0 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesByEnrollmentAccountsInner.java @@ -0,0 +1,785 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in MarketplacesByEnrollmentAccounts. + */ +public class MarketplacesByEnrollmentAccountsInner { + /** The Retrofit service to perform REST calls. */ + private MarketplacesByEnrollmentAccountsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of MarketplacesByEnrollmentAccountsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MarketplacesByEnrollmentAccountsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(MarketplacesByEnrollmentAccountsService.class); + this.client = client; + } + + /** + * The interface defining all the services for MarketplacesByEnrollmentAccounts to be + * used by Retrofit to perform actually REST calls. + */ + interface MarketplacesByEnrollmentAccountsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByEnrollmentAccounts list" }) + @GET("providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/marketplaces") + Observable> list(@Path("enrollmentAccountId") String enrollmentAccountId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByEnrollmentAccounts listByBillingPeriod" }) + @GET("providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces") + Observable> listByBillingPeriod(@Path("enrollmentAccountId") String enrollmentAccountId, @Path("billingPeriodName") String billingPeriodName, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByEnrollmentAccounts listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.MarketplacesByEnrollmentAccounts listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String enrollmentAccountId) { + ServiceResponse> response = listSinglePageAsync(enrollmentAccountId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String enrollmentAccountId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(enrollmentAccountId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String enrollmentAccountId) { + return listWithServiceResponseAsync(enrollmentAccountId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String enrollmentAccountId) { + return listSinglePageAsync(enrollmentAccountId) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String enrollmentAccountId) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.list(enrollmentAccountId, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String enrollmentAccountId, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listSinglePageAsync(enrollmentAccountId, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String enrollmentAccountId, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(enrollmentAccountId, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String enrollmentAccountId, final String filter, final Integer top, final String skiptoken) { + return listWithServiceResponseAsync(enrollmentAccountId, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String enrollmentAccountId, final String filter, final Integer top, final String skiptoken) { + return listSinglePageAsync(enrollmentAccountId, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param enrollmentAccountId EnrollmentAccount ID + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String enrollmentAccountId, final String filter, final Integer top, final String skiptoken) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(enrollmentAccountId, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String enrollmentAccountId, final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(enrollmentAccountId, billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String enrollmentAccountId, final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String enrollmentAccountId, final String billingPeriodName) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.listByBillingPeriod(enrollmentAccountId, billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String enrollmentAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodWithServiceResponseAsync(enrollmentAccountId, billingPeriodName, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String enrollmentAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param enrollmentAccountId EnrollmentAccount ID + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String enrollmentAccountId, final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByBillingPeriod(enrollmentAccountId, billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesImpl.java new file mode 100644 index 0000000000000..9a47b47a90add --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplaces; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.Marketplace; + +class MarketplacesImpl extends WrapperImpl implements Marketplaces { + private final ConsumptionManager manager; + + MarketplacesImpl(ConsumptionManager manager) { + super(manager.inner().marketplaces()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listByBillingPeriodAsync(final String billingPeriodName) { + MarketplacesInner client = this.inner(); + return client.listByBillingPeriodAsync(billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + + @Override + public Observable listAsync() { + MarketplacesInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Marketplace call(MarketplaceInner inner) { + return new MarketplaceImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesInner.java new file mode 100644 index 0000000000000..ee68e53c1c363 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/MarketplacesInner.java @@ -0,0 +1,765 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Marketplaces. + */ +public class MarketplacesInner { + /** The Retrofit service to perform REST calls. */ + private MarketplacesService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of MarketplacesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MarketplacesInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(MarketplacesService.class); + this.client = client; + } + + /** + * The interface defining all the services for Marketplaces to be + * used by Retrofit to perform actually REST calls. + */ + interface MarketplacesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Marketplaces list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/marketplaces") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Marketplaces listByBillingPeriod" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces") + Observable> listByBillingPeriod(@Path("subscriptionId") String subscriptionId, @Path("billingPeriodName") String billingPeriodName, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skiptoken") String skiptoken, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Marketplaces listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Marketplaces listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.list(this.client.subscriptionId(), filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList list(final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listSinglePageAsync(filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listAsync(final String filter, final Integer top, final String skiptoken) { + return listWithServiceResponseAsync(filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listWithServiceResponseAsync(final String filter, final Integer top, final String skiptoken) { + return listSinglePageAsync(filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String filter, final Integer top, final String skiptoken) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingPeriodName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return service.listByBillingPeriod(this.client.subscriptionId(), billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingPeriodName, filter, top, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingPeriodName, final String filter, final Integer top, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingPeriodName, filter, top, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodWithServiceResponseAsync(billingPeriodName, filter, top, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param top May be used to limit the number of results to the most recent N marketplaces. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + return listByBillingPeriodSinglePageAsync(billingPeriodName, filter, top, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param filter May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N marketplaces. + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingPeriodName, final String filter, final Integer top, final String skiptoken) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByBillingPeriod(this.client.subscriptionId(), billingPeriodName, filter, top, skiptoken, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<MarketplaceInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MarketplaceInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MarketplaceInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationImpl.java new file mode 100644 index 0000000000000..b728e132de3d9 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationImpl.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.Operation; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.OperationDisplay; + +class OperationImpl extends WrapperImpl implements Operation { + private final ConsumptionManager manager; + OperationImpl(OperationInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public OperationDisplay display() { + return this.inner().display(); + } + + @Override + public String name() { + return this.inner().name(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationInner.java new file mode 100644 index 0000000000000..cb62d41155928 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationInner.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A Consumption REST API operation. + */ +public class OperationInner { + /** + * Operation name: {provider}/{resource}/{operation}. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The object that represents the operation. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /** + * Get operation name: {provider}/{resource}/{operation}. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the object that represents the operation. + * + * @return the display value + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the object that represents the operation. + * + * @param display the display value to set + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..54deec6215a2f --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsImpl.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.Operations; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.Operation; + +class OperationsImpl extends WrapperImpl implements Operations { + private final ConsumptionManager manager; + + OperationsImpl(ConsumptionManager manager) { + super(manager.inner().operations()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync() { + OperationsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public Operation call(OperationInner inner) { + return new OperationImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsInner.java new file mode 100644 index 0000000000000..70c5730fff2af --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/OperationsInner.java @@ -0,0 +1,283 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Operations. + */ +public class OperationsInner { + /** The Retrofit service to perform REST calls. */ + private OperationsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of OperationsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public OperationsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(OperationsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Operations to be + * used by Retrofit to perform actually REST calls. + */ + interface OperationsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Operations list" }) + @GET("providers/Microsoft.Consumption/operations") + Observable> list(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Operations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists all of the available consumption REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<OperationInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<OperationInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all of the available consumption REST API operations. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PageImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PageImpl.java new file mode 100644 index 0000000000000..4958a79d9f27f --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PageImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("nextLink") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String nextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List items() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultImpl.java new file mode 100644 index 0000000000000..c6a777b406c45 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultImpl.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.PriceSheetResult; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.util.List; +import com.microsoft.azure.management.consumption.v2018_03_31.PriceSheetProperties; +import java.util.Map; + +class PriceSheetResultImpl extends WrapperImpl implements PriceSheetResult { + private final ConsumptionManager manager; + PriceSheetResultImpl(PriceSheetResultInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String nextLink() { + return this.inner().nextLink(); + } + + @Override + public List pricesheets() { + return this.inner().pricesheets(); + } + + @Override + public Map tags() { + return this.inner().tags(); + } + + @Override + public String type() { + return this.inner().type(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultInner.java new file mode 100644 index 0000000000000..a0db2acc34f74 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetResultInner.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.util.List; +import com.microsoft.azure.management.consumption.v2018_03_31.PriceSheetProperties; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * An pricesheet resource. + */ +@JsonFlatten +public class PriceSheetResultInner extends ProxyResource { + /** + * Price sheet. + */ + @JsonProperty(value = "properties.pricesheets", access = JsonProperty.Access.WRITE_ONLY) + private List pricesheets; + + /** + * The link (url) to the next page of results. + */ + @JsonProperty(value = "properties.nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Get price sheet. + * + * @return the pricesheets value + */ + public List pricesheets() { + return this.pricesheets; + } + + /** + * Get the link (url) to the next page of results. + * + * @return the nextLink value + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsImpl.java new file mode 100644 index 0000000000000..85ec0f9470327 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsImpl.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.PriceSheets; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.PriceSheetResult; + +class PriceSheetsImpl extends WrapperImpl implements PriceSheets { + private final ConsumptionManager manager; + + PriceSheetsImpl(ConsumptionManager manager) { + super(manager.inner().priceSheets()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable getAsync() { + PriceSheetsInner client = this.inner(); + return client.getAsync() + .map(new Func1() { + @Override + public PriceSheetResult call(PriceSheetResultInner inner) { + return new PriceSheetResultImpl(inner, manager()); + } + }); + } + + @Override + public Observable getByBillingPeriodAsync(String billingPeriodName) { + PriceSheetsInner client = this.inner(); + return client.getByBillingPeriodAsync(billingPeriodName) + .map(new Func1() { + @Override + public PriceSheetResult call(PriceSheetResultInner inner) { + return new PriceSheetResultImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsInner.java new file mode 100644 index 0000000000000..6a02b4d64fdb6 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/PriceSheetsInner.java @@ -0,0 +1,382 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in PriceSheets. + */ +public class PriceSheetsInner { + /** The Retrofit service to perform REST calls. */ + private PriceSheetsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of PriceSheetsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PriceSheetsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(PriceSheetsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PriceSheets to be + * used by Retrofit to perform actually REST calls. + */ + interface PriceSheetsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.PriceSheets get" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default") + Observable> get(@Path("subscriptionId") String subscriptionId, @Query("$expand") String expand, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.PriceSheets getByBillingPeriod" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default") + Observable> getByBillingPeriod(@Path("subscriptionId") String subscriptionId, @Path("billingPeriodName") String billingPeriodName, @Query("$expand") String expand, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PriceSheetResultInner object if successful. + */ + public PriceSheetResultInner get() { + return getWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(), serviceCallback); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable getAsync() { + return getWithServiceResponseAsync().map(new Func1, PriceSheetResultInner>() { + @Override + public PriceSheetResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable> getWithServiceResponseAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String skiptoken = null; + final Integer top = null; + return service.get(this.client.subscriptionId(), expand, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PriceSheetResultInner object if successful. + */ + public PriceSheetResultInner get(String expand, String skiptoken, Integer top) { + return getWithServiceResponseAsync(expand, skiptoken, top).toBlocking().single().body(); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String expand, String skiptoken, Integer top, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(expand, skiptoken, top), serviceCallback); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable getAsync(String expand, String skiptoken, Integer top) { + return getWithServiceResponseAsync(expand, skiptoken, top).map(new Func1, PriceSheetResultInner>() { + @Override + public PriceSheetResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable> getWithServiceResponseAsync(String expand, String skiptoken, Integer top) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(this.client.subscriptionId(), expand, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PriceSheetResultInner object if successful. + */ + public PriceSheetResultInner getByBillingPeriod(String billingPeriodName) { + return getByBillingPeriodWithServiceResponseAsync(billingPeriodName).toBlocking().single().body(); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getByBillingPeriodAsync(String billingPeriodName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getByBillingPeriodWithServiceResponseAsync(billingPeriodName), serviceCallback); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable getByBillingPeriodAsync(String billingPeriodName) { + return getByBillingPeriodWithServiceResponseAsync(billingPeriodName).map(new Func1, PriceSheetResultInner>() { + @Override + public PriceSheetResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable> getByBillingPeriodWithServiceResponseAsync(String billingPeriodName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String skiptoken = null; + final Integer top = null; + return service.getByBillingPeriod(this.client.subscriptionId(), billingPeriodName, expand, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByBillingPeriodDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PriceSheetResultInner object if successful. + */ + public PriceSheetResultInner getByBillingPeriod(String billingPeriodName, String expand, String skiptoken, Integer top) { + return getByBillingPeriodWithServiceResponseAsync(billingPeriodName, expand, skiptoken, top).toBlocking().single().body(); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getByBillingPeriodAsync(String billingPeriodName, String expand, String skiptoken, Integer top, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getByBillingPeriodWithServiceResponseAsync(billingPeriodName, expand, skiptoken, top), serviceCallback); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable getByBillingPeriodAsync(String billingPeriodName, String expand, String skiptoken, Integer top) { + return getByBillingPeriodWithServiceResponseAsync(billingPeriodName, expand, skiptoken, top).map(new Func1, PriceSheetResultInner>() { + @Override + public PriceSheetResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the top N results. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PriceSheetResultInner object + */ + public Observable> getByBillingPeriodWithServiceResponseAsync(String billingPeriodName, String expand, String skiptoken, Integer top) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.getByBillingPeriod(this.client.subscriptionId(), billingPeriodName, expand, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByBillingPeriodDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsImpl.java new file mode 100644 index 0000000000000..b163aa88483e5 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsImpl.java @@ -0,0 +1,89 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationDetails; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.math.BigDecimal; +import java.util.Map; +import org.joda.time.DateTime; + +class ReservationDetailsImpl extends WrapperImpl implements ReservationDetails { + private final ConsumptionManager manager; + ReservationDetailsImpl(ReservationDetailsInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String instanceId() { + return this.inner().instanceId(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String reservationId() { + return this.inner().reservationId(); + } + + @Override + public String reservationOrderId() { + return this.inner().reservationOrderId(); + } + + @Override + public BigDecimal reservedHours() { + return this.inner().reservedHours(); + } + + @Override + public String skuName() { + return this.inner().skuName(); + } + + @Override + public Map tags() { + return this.inner().tags(); + } + + @Override + public BigDecimal totalReservedQuantity() { + return this.inner().totalReservedQuantity(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public DateTime usageDate() { + return this.inner().usageDate(); + } + + @Override + public BigDecimal usedHours() { + return this.inner().usedHours(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsInner.java new file mode 100644 index 0000000000000..942c6602303bd --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationDetailsInner.java @@ -0,0 +1,169 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.math.BigDecimal; +import org.joda.time.DateTime; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * reservation details resource. + */ +@JsonFlatten +public class ReservationDetailsInner extends ProxyResource { + /** + * The reservation order ID is the identifier for a reservation purchase. + * Each reservation order ID represents a single purchase transaction. A + * reservation order contains reservations. The reservation order specifies + * the VM size and region for the reservations. + */ + @JsonProperty(value = "properties.reservationOrderId", access = JsonProperty.Access.WRITE_ONLY) + private String reservationOrderId; + + /** + * The reservation ID is the identifier of a reservation within a + * reservation order. Each reservation is the grouping for applying the + * benefit scope and also specifies the number of instances to which the + * reservation benefit can be applied to. + */ + @JsonProperty(value = "properties.reservationId", access = JsonProperty.Access.WRITE_ONLY) + private String reservationId; + + /** + * This is the ARM Sku name. It can be used to join with the serviceType + * field in additional info in usage records. + */ + @JsonProperty(value = "properties.skuName", access = JsonProperty.Access.WRITE_ONLY) + private String skuName; + + /** + * This is the total hours reserved for the day. E.g. if reservation for 1 + * instance was made on 1 PM, this will be 11 hours for that day and 24 + * hours from subsequent days. + */ + @JsonProperty(value = "properties.reservedHours", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal reservedHours; + + /** + * The date on which consumption occurred. + */ + @JsonProperty(value = "properties.usageDate", access = JsonProperty.Access.WRITE_ONLY) + private DateTime usageDate; + + /** + * This is the total hours used by the instance. + */ + @JsonProperty(value = "properties.usedHours", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal usedHours; + + /** + * This identifier is the name of the resource or the fully qualified + * Resource ID. + */ + @JsonProperty(value = "properties.instanceId", access = JsonProperty.Access.WRITE_ONLY) + private String instanceId; + + /** + * This is the total count of instances that are reserved for the + * reservationId. + */ + @JsonProperty(value = "properties.totalReservedQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal totalReservedQuantity; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Get the reservation order ID is the identifier for a reservation purchase. Each reservation order ID represents a single purchase transaction. A reservation order contains reservations. The reservation order specifies the VM size and region for the reservations. + * + * @return the reservationOrderId value + */ + public String reservationOrderId() { + return this.reservationOrderId; + } + + /** + * Get the reservation ID is the identifier of a reservation within a reservation order. Each reservation is the grouping for applying the benefit scope and also specifies the number of instances to which the reservation benefit can be applied to. + * + * @return the reservationId value + */ + public String reservationId() { + return this.reservationId; + } + + /** + * Get this is the ARM Sku name. It can be used to join with the serviceType field in additional info in usage records. + * + * @return the skuName value + */ + public String skuName() { + return this.skuName; + } + + /** + * Get this is the total hours reserved for the day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 hours for that day and 24 hours from subsequent days. + * + * @return the reservedHours value + */ + public BigDecimal reservedHours() { + return this.reservedHours; + } + + /** + * Get the date on which consumption occurred. + * + * @return the usageDate value + */ + public DateTime usageDate() { + return this.usageDate; + } + + /** + * Get this is the total hours used by the instance. + * + * @return the usedHours value + */ + public BigDecimal usedHours() { + return this.usedHours; + } + + /** + * Get this identifier is the name of the resource or the fully qualified Resource ID. + * + * @return the instanceId value + */ + public String instanceId() { + return this.instanceId; + } + + /** + * Get this is the total count of instances that are reserved for the reservationId. + * + * @return the totalReservedQuantity value + */ + public BigDecimal totalReservedQuantity() { + return this.totalReservedQuantity; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsImpl.java new file mode 100644 index 0000000000000..5fc7257cc06a0 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsImpl.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * def + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.resources.collection.implementation.GroupableResourcesCoreImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationRecommendations; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationRecommendationsModel; +import rx.Observable; +import rx.Completable; +import rx.functions.Func1; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.Page; + +class ReservationRecommendationsImpl extends GroupableResourcesCoreImpl implements ReservationRecommendations { + protected ReservationRecommendationsImpl(ConsumptionManager manager) { + super(manager.inner().reservationRecommendations(), manager); + } + + @Override + protected Observable getInnerAsync(String resourceGroupName, String name) { + return null; // NOP Retrieve by resource group not supported + } + + @Override + protected Completable deleteInnerAsync(String resourceGroupName, String name) { + ReservationRecommendationsInner client = this.inner(); + return Completable.error(new Throwable("Delete by RG not supported for this resource")); // NOP Delete by RG not supported + } + + @Override + public PagedList list() { + ReservationRecommendationsInner client = this.inner(); + return this.wrapList(client.list()); + } + + @Override + public Observable listAsync() { + ReservationRecommendationsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public ReservationRecommendationsModel call(ReservationRecommendationsModelInner inner) { + return wrapModel(inner); + } + }); + } + + @Override + protected ReservationRecommendationsModelImpl wrapModel(ReservationRecommendationsModelInner inner) { + return new ReservationRecommendationsModelImpl(inner.name(), inner, manager()); + } + + @Override + protected ReservationRecommendationsModelImpl wrapModel(String name) { + return null; // Model is not creatable + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsInner.java new file mode 100644 index 0000000000000..09c93c828c207 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsInner.java @@ -0,0 +1,393 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ReservationRecommendations. + */ +public class ReservationRecommendationsInner { + /** The Retrofit service to perform REST calls. */ + private ReservationRecommendationsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of ReservationRecommendationsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ReservationRecommendationsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(ReservationRecommendationsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ReservationRecommendations to be + * used by Retrofit to perform actually REST calls. + */ + interface ReservationRecommendationsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationRecommendations list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reservationRecommendations") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationRecommendations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationRecommendationsModelInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationRecommendationsModelInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationRecommendationsModelInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationRecommendationsModelInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + return service.list(this.client.subscriptionId(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param filter May be used to filter reservationRecommendations by properties/scope and properties/lookBackPeriod. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationRecommendationsModelInner> object if successful. + */ + public PagedList list(final String filter) { + ServiceResponse> response = listSinglePageAsync(filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param filter May be used to filter reservationRecommendations by properties/scope and properties/lookBackPeriod. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param filter May be used to filter reservationRecommendations by properties/scope and properties/lookBackPeriod. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationRecommendationsModelInner> object + */ + public Observable> listAsync(final String filter) { + return listWithServiceResponseAsync(filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param filter May be used to filter reservationRecommendations by properties/scope and properties/lookBackPeriod. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationRecommendationsModelInner> object + */ + public Observable>> listWithServiceResponseAsync(final String filter) { + return listSinglePageAsync(filter) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + ServiceResponse> * @param filter May be used to filter reservationRecommendations by properties/scope and properties/lookBackPeriod. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationRecommendationsModelInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String filter) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationRecommendationsModelInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationRecommendationsModelInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationRecommendationsModelInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * List of recommendations for purchasing reserved instances. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationRecommendationsModelInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelImpl.java new file mode 100644 index 0000000000000..9698ab48a85eb --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelImpl.java @@ -0,0 +1,93 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.resources.models.implementation.GroupableResourceCoreImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationRecommendationsModel; +import rx.Observable; +import java.math.BigDecimal; +import org.joda.time.DateTime; +import java.util.UUID; + +class ReservationRecommendationsModelImpl extends GroupableResourceCoreImpl implements ReservationRecommendationsModel { + ReservationRecommendationsModelImpl(String name, ReservationRecommendationsModelInner inner, ConsumptionManager manager) { + super(name, inner, manager); + } + + @Override + public Observable createResourceAsync() { + ReservationRecommendationsInner client = this.manager().inner().reservationRecommendations(); + return null; // NOP createResourceAsync implementation as create is not supported + } + + @Override + public Observable updateResourceAsync() { + ReservationRecommendationsInner client = this.manager().inner().reservationRecommendations(); + return null; // NOP updateResourceAsync implementation as update is not supported + } + + @Override + protected Observable getInnerAsync() { + ReservationRecommendationsInner client = this.manager().inner().reservationRecommendations(); + return null; // NOP getInnerAsync implementation as get is not supported + } + + + + @Override + public BigDecimal costWithNoReservedInstances() { + return this.inner().costWithNoReservedInstances(); + } + + @Override + public DateTime firstUsageDate() { + return this.inner().firstUsageDate(); + } + + @Override + public String lookBackPeriod() { + return this.inner().lookBackPeriod(); + } + + @Override + public UUID meterId() { + return this.inner().meterId(); + } + + @Override + public BigDecimal netSavings() { + return this.inner().netSavings(); + } + + @Override + public BigDecimal recommendedQuantity() { + return this.inner().recommendedQuantity(); + } + + @Override + public String scope() { + return this.inner().scope(); + } + + @Override + public String sku() { + return this.inner().sku(); + } + + @Override + public String term() { + return this.inner().term(); + } + + @Override + public BigDecimal totalCostWithReservedInstances() { + return this.inner().totalCostWithReservedInstances(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelInner.java new file mode 100644 index 0000000000000..61be627a8a139 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationRecommendationsModelInner.java @@ -0,0 +1,248 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.util.Map; +import java.util.UUID; +import java.math.BigDecimal; +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * Reservation recommendations resource. + */ +@JsonFlatten +public class ReservationRecommendationsModelInner { + /** + * Resource Id. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Resource name. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * Resource type. + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Resource location. + */ + @JsonProperty(value = "location", access = JsonProperty.Access.WRITE_ONLY) + private String location; + + /** + * Resource sku. + */ + @JsonProperty(value = "sku", access = JsonProperty.Access.WRITE_ONLY) + private String sku; + + /** + * The number of days of usage to look back for recommendations. + */ + @JsonProperty(value = "properties.lookBackPeriod", access = JsonProperty.Access.WRITE_ONLY) + private String lookBackPeriod; + + /** + * The meter id (GUID). + */ + @JsonProperty(value = "properties.meterId", access = JsonProperty.Access.WRITE_ONLY) + private UUID meterId; + + /** + * RI recommendations in one or three year terms. + */ + @JsonProperty(value = "properties.term", access = JsonProperty.Access.WRITE_ONLY) + private String term; + + /** + * The total amount of cost without reserved instances. + */ + @JsonProperty(value = "properties.costWithNoReservedInstances", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal costWithNoReservedInstances; + + /** + * Recommended quality for reserved instances. + */ + @JsonProperty(value = "properties.recommendedQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal recommendedQuantity; + + /** + * The total amount of cost with reserved instances. + */ + @JsonProperty(value = "properties.totalCostWithReservedInstances", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal totalCostWithReservedInstances; + + /** + * Total estimated savings with reserved instances. + */ + @JsonProperty(value = "properties.netSavings", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal netSavings; + + /** + * The usage date for looking back. + */ + @JsonProperty(value = "properties.firstUsageDate", access = JsonProperty.Access.WRITE_ONLY) + private DateTime firstUsageDate; + + /** + * Shared or single recommendation. + */ + @JsonProperty(value = "properties.scope", access = JsonProperty.Access.WRITE_ONLY) + private String scope; + + /** + * Get resource Id. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get resource name. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get resource type. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Get resource location. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Get resource sku. + * + * @return the sku value + */ + public String sku() { + return this.sku; + } + + /** + * Get the number of days of usage to look back for recommendations. + * + * @return the lookBackPeriod value + */ + public String lookBackPeriod() { + return this.lookBackPeriod; + } + + /** + * Get the meter id (GUID). + * + * @return the meterId value + */ + public UUID meterId() { + return this.meterId; + } + + /** + * Get rI recommendations in one or three year terms. + * + * @return the term value + */ + public String term() { + return this.term; + } + + /** + * Get the total amount of cost without reserved instances. + * + * @return the costWithNoReservedInstances value + */ + public BigDecimal costWithNoReservedInstances() { + return this.costWithNoReservedInstances; + } + + /** + * Get recommended quality for reserved instances. + * + * @return the recommendedQuantity value + */ + public BigDecimal recommendedQuantity() { + return this.recommendedQuantity; + } + + /** + * Get the total amount of cost with reserved instances. + * + * @return the totalCostWithReservedInstances value + */ + public BigDecimal totalCostWithReservedInstances() { + return this.totalCostWithReservedInstances; + } + + /** + * Get total estimated savings with reserved instances. + * + * @return the netSavings value + */ + public BigDecimal netSavings() { + return this.netSavings; + } + + /** + * Get the usage date for looking back. + * + * @return the firstUsageDate value + */ + public DateTime firstUsageDate() { + return this.firstUsageDate; + } + + /** + * Get shared or single recommendation. + * + * @return the scope value + */ + public String scope() { + return this.scope; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesImpl.java new file mode 100644 index 0000000000000..a499e864467c0 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesImpl.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationSummaries; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.math.BigDecimal; +import java.util.Map; +import org.joda.time.DateTime; + +class ReservationSummariesImpl extends WrapperImpl implements ReservationSummaries { + private final ConsumptionManager manager; + ReservationSummariesImpl(ReservationSummariesInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public BigDecimal avgUtilizationPercentage() { + return this.inner().avgUtilizationPercentage(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public BigDecimal maxUtilizationPercentage() { + return this.inner().maxUtilizationPercentage(); + } + + @Override + public BigDecimal minUtilizationPercentage() { + return this.inner().minUtilizationPercentage(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String reservationId() { + return this.inner().reservationId(); + } + + @Override + public String reservationOrderId() { + return this.inner().reservationOrderId(); + } + + @Override + public BigDecimal reservedHours() { + return this.inner().reservedHours(); + } + + @Override + public String skuName() { + return this.inner().skuName(); + } + + @Override + public Map tags() { + return this.inner().tags(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public DateTime usageDate() { + return this.inner().usageDate(); + } + + @Override + public BigDecimal usedHours() { + return this.inner().usedHours(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesInner.java new file mode 100644 index 0000000000000..f33ccfa5e8e10 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationSummariesInner.java @@ -0,0 +1,188 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.math.BigDecimal; +import org.joda.time.DateTime; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * reservation summaries resource. + */ +@JsonFlatten +public class ReservationSummariesInner extends ProxyResource { + /** + * The reservation order ID is the identifier for a reservation purchase. + * Each reservation order ID represents a single purchase transaction. A + * reservation order contains reservations. The reservation order specifies + * the VM size and region for the reservations. + */ + @JsonProperty(value = "properties.reservationOrderId", access = JsonProperty.Access.WRITE_ONLY) + private String reservationOrderId; + + /** + * The reservation ID is the identifier of a reservation within a + * reservation order. Each reservation is the grouping for applying the + * benefit scope and also specifies the number of instances to which the + * reservation benefit can be applied to. + */ + @JsonProperty(value = "properties.reservationId", access = JsonProperty.Access.WRITE_ONLY) + private String reservationId; + + /** + * This is the ARM Sku name. It can be used to join with the serviceType + * field in additional info in usage records. + */ + @JsonProperty(value = "properties.skuName", access = JsonProperty.Access.WRITE_ONLY) + private String skuName; + + /** + * This is the total hours reserved. E.g. if reservation for 1 instance was + * made on 1 PM, this will be 11 hours for that day and 24 hours from + * subsequent days. + */ + @JsonProperty(value = "properties.reservedHours", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal reservedHours; + + /** + * Data corresponding to the utilization record. If the grain of data is + * monthly, it will be first day of month. + */ + @JsonProperty(value = "properties.usageDate", access = JsonProperty.Access.WRITE_ONLY) + private DateTime usageDate; + + /** + * Total used hours by the reservation. + */ + @JsonProperty(value = "properties.usedHours", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal usedHours; + + /** + * This is the minimum hourly utilization in the usage time (day or month). + * E.g. if usage record corresponds to 12/10/2017 and on that for hour 4 + * and 5, utilization was 10%, this field will return 10% for that day. + */ + @JsonProperty(value = "properties.minUtilizationPercentage", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal minUtilizationPercentage; + + /** + * This is average utilization for the entire time range. (day or month + * depending on the grain). + */ + @JsonProperty(value = "properties.avgUtilizationPercentage", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal avgUtilizationPercentage; + + /** + * This is the maximum hourly utilization in the usage time (day or month). + * E.g. if usage record corresponds to 12/10/2017 and on that for hour 4 + * and 5, utilization was 100%, this field will return 100% for that day. + */ + @JsonProperty(value = "properties.maxUtilizationPercentage", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal maxUtilizationPercentage; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Get the reservation order ID is the identifier for a reservation purchase. Each reservation order ID represents a single purchase transaction. A reservation order contains reservations. The reservation order specifies the VM size and region for the reservations. + * + * @return the reservationOrderId value + */ + public String reservationOrderId() { + return this.reservationOrderId; + } + + /** + * Get the reservation ID is the identifier of a reservation within a reservation order. Each reservation is the grouping for applying the benefit scope and also specifies the number of instances to which the reservation benefit can be applied to. + * + * @return the reservationId value + */ + public String reservationId() { + return this.reservationId; + } + + /** + * Get this is the ARM Sku name. It can be used to join with the serviceType field in additional info in usage records. + * + * @return the skuName value + */ + public String skuName() { + return this.skuName; + } + + /** + * Get this is the total hours reserved. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 hours for that day and 24 hours from subsequent days. + * + * @return the reservedHours value + */ + public BigDecimal reservedHours() { + return this.reservedHours; + } + + /** + * Get data corresponding to the utilization record. If the grain of data is monthly, it will be first day of month. + * + * @return the usageDate value + */ + public DateTime usageDate() { + return this.usageDate; + } + + /** + * Get total used hours by the reservation. + * + * @return the usedHours value + */ + public BigDecimal usedHours() { + return this.usedHours; + } + + /** + * Get this is the minimum hourly utilization in the usage time (day or month). E.g. if usage record corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 10%, this field will return 10% for that day. + * + * @return the minUtilizationPercentage value + */ + public BigDecimal minUtilizationPercentage() { + return this.minUtilizationPercentage; + } + + /** + * Get this is average utilization for the entire time range. (day or month depending on the grain). + * + * @return the avgUtilizationPercentage value + */ + public BigDecimal avgUtilizationPercentage() { + return this.avgUtilizationPercentage; + } + + /** + * Get this is the maximum hourly utilization in the usage time (day or month). E.g. if usage record corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 100%, this field will return 100% for that day. + * + * @return the maxUtilizationPercentage value + */ + public BigDecimal maxUtilizationPercentage() { + return this.maxUtilizationPercentage; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsImpl.java new file mode 100644 index 0000000000000..33cb54b377e35 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationsDetails; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationDetails; + +class ReservationsDetailsImpl extends WrapperImpl implements ReservationsDetails { + private final ConsumptionManager manager; + + ReservationsDetailsImpl(ConsumptionManager manager) { + super(manager.inner().reservationsDetails()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listByReservationOrderAsync(final String reservationOrderId, final String filter) { + ReservationsDetailsInner client = this.inner(); + return client.listByReservationOrderAsync(reservationOrderId, filter) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public ReservationDetails call(ReservationDetailsInner inner) { + return new ReservationDetailsImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final String filter) { + ReservationsDetailsInner client = this.inner(); + return client.listByReservationOrderAndReservationAsync(reservationOrderId, reservationId, filter) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public ReservationDetails call(ReservationDetailsInner inner) { + return new ReservationDetailsImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsInner.java new file mode 100644 index 0000000000000..1591d1527ede9 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsDetailsInner.java @@ -0,0 +1,547 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ReservationsDetails. + */ +public class ReservationsDetailsInner { + /** The Retrofit service to perform REST calls. */ + private ReservationsDetailsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of ReservationsDetailsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ReservationsDetailsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(ReservationsDetailsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ReservationsDetails to be + * used by Retrofit to perform actually REST calls. + */ + interface ReservationsDetailsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsDetails listByReservationOrder" }) + @GET("providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails") + Observable> listByReservationOrder(@Path("reservationOrderId") String reservationOrderId, @Query("$filter") String filter, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsDetails listByReservationOrderAndReservation" }) + @GET("providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails") + Observable> listByReservationOrderAndReservation(@Path("reservationOrderId") String reservationOrderId, @Path("reservationId") String reservationId, @Query("$filter") String filter, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsDetails listByReservationOrderNext" }) + @GET + Observable> listByReservationOrderNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsDetails listByReservationOrderAndReservationNext" }) + @GET + Observable> listByReservationOrderAndReservationNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationDetailsInner> object if successful. + */ + public PagedList listByReservationOrder(final String reservationOrderId, final String filter) { + ServiceResponse> response = listByReservationOrderSinglePageAsync(reservationOrderId, filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAsync(final String reservationOrderId, final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderSinglePageAsync(reservationOrderId, filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable> listByReservationOrderAsync(final String reservationOrderId, final String filter) { + return listByReservationOrderWithServiceResponseAsync(reservationOrderId, filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable>> listByReservationOrderWithServiceResponseAsync(final String reservationOrderId, final String filter) { + return listByReservationOrderSinglePageAsync(reservationOrderId, filter) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + ServiceResponse> * @param reservationOrderId Order Id of the reservation + ServiceResponse> * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationDetailsInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderSinglePageAsync(final String reservationOrderId, final String filter) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (filter == null) { + throw new IllegalArgumentException("Parameter filter is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByReservationOrder(reservationOrderId, filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationDetailsInner> object if successful. + */ + public PagedList listByReservationOrderAndReservation(final String reservationOrderId, final String reservationId, final String filter) { + ServiceResponse> response = listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable> listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final String filter) { + return listByReservationOrderAndReservationWithServiceResponseAsync(reservationOrderId, reservationId, filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable>> listByReservationOrderAndReservationWithServiceResponseAsync(final String reservationOrderId, final String reservationId, final String filter) { + return listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, filter) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + ServiceResponse> * @param reservationOrderId Order Id of the reservation + ServiceResponse> * @param reservationId Id of the reservation + ServiceResponse> * @param filter Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationDetailsInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderAndReservationSinglePageAsync(final String reservationOrderId, final String reservationId, final String filter) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId is required and cannot be null."); + } + if (filter == null) { + throw new IllegalArgumentException("Parameter filter is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByReservationOrderAndReservation(reservationOrderId, reservationId, filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderAndReservationDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderAndReservationDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationDetailsInner> object if successful. + */ + public PagedList listByReservationOrderNext(final String nextPageLink) { + ServiceResponse> response = listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable> listByReservationOrderNextAsync(final String nextPageLink) { + return listByReservationOrderNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable>> listByReservationOrderNextWithServiceResponseAsync(final String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationDetailsInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByReservationOrderNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationDetailsInner> object if successful. + */ + public PagedList listByReservationOrderAndReservationNext(final String nextPageLink) { + ServiceResponse> response = listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAndReservationNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable> listByReservationOrderAndReservationNextAsync(final String nextPageLink) { + return listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationDetailsInner> object + */ + public Observable>> listByReservationOrderAndReservationNextWithServiceResponseAsync(final String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations details for provided date range. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationDetailsInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderAndReservationNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByReservationOrderAndReservationNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderAndReservationNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderAndReservationNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesImpl.java new file mode 100644 index 0000000000000..ea010232a0460 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesImpl.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationsSummaries; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.ReservationSummaries; +import com.microsoft.azure.management.consumption.v2018_03_31.Datagrain; + +class ReservationsSummariesImpl extends WrapperImpl implements ReservationsSummaries { + private final ConsumptionManager manager; + + ReservationsSummariesImpl(ConsumptionManager manager) { + super(manager.inner().reservationsSummaries()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listByReservationOrderAsync(final String reservationOrderId, final Datagrain grain) { + ReservationsSummariesInner client = this.inner(); + return client.listByReservationOrderAsync(reservationOrderId, grain) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public ReservationSummaries call(ReservationSummariesInner inner) { + return new ReservationSummariesImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final Datagrain grain) { + ReservationsSummariesInner client = this.inner(); + return client.listByReservationOrderAndReservationAsync(reservationOrderId, reservationId, grain) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public ReservationSummaries call(ReservationSummariesInner inner) { + return new ReservationSummariesImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesInner.java new file mode 100644 index 0000000000000..d51d609f51215 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/ReservationsSummariesInner.java @@ -0,0 +1,794 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.Datagrain; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ReservationsSummaries. + */ +public class ReservationsSummariesInner { + /** The Retrofit service to perform REST calls. */ + private ReservationsSummariesService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of ReservationsSummariesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ReservationsSummariesInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(ReservationsSummariesService.class); + this.client = client; + } + + /** + * The interface defining all the services for ReservationsSummaries to be + * used by Retrofit to perform actually REST calls. + */ + interface ReservationsSummariesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsSummaries listByReservationOrder" }) + @GET("providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries") + Observable> listByReservationOrder(@Path("reservationOrderId") String reservationOrderId, @Query("grain") Datagrain grain, @Query("$filter") String filter, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsSummaries listByReservationOrderAndReservation" }) + @GET("providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries") + Observable> listByReservationOrderAndReservation(@Path("reservationOrderId") String reservationOrderId, @Path("reservationId") String reservationId, @Query("grain") Datagrain grain, @Query("$filter") String filter, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsSummaries listByReservationOrderNext" }) + @GET + Observable> listByReservationOrderNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.ReservationsSummaries listByReservationOrderAndReservationNext" }) + @GET + Observable> listByReservationOrderAndReservationNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationSummariesInner> object if successful. + */ + public PagedList listByReservationOrder(final String reservationOrderId, final Datagrain grain) { + ServiceResponse> response = listByReservationOrderSinglePageAsync(reservationOrderId, grain).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAsync(final String reservationOrderId, final Datagrain grain, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderSinglePageAsync(reservationOrderId, grain), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable> listByReservationOrderAsync(final String reservationOrderId, final Datagrain grain) { + return listByReservationOrderWithServiceResponseAsync(reservationOrderId, grain) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable>> listByReservationOrderWithServiceResponseAsync(final String reservationOrderId, final Datagrain grain) { + return listByReservationOrderSinglePageAsync(reservationOrderId, grain) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationSummariesInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderSinglePageAsync(final String reservationOrderId, final Datagrain grain) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (grain == null) { + throw new IllegalArgumentException("Parameter grain is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + return service.listByReservationOrder(reservationOrderId, grain, filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationSummariesInner> object if successful. + */ + public PagedList listByReservationOrder(final String reservationOrderId, final Datagrain grain, final String filter) { + ServiceResponse> response = listByReservationOrderSinglePageAsync(reservationOrderId, grain, filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAsync(final String reservationOrderId, final Datagrain grain, final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderSinglePageAsync(reservationOrderId, grain, filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable> listByReservationOrderAsync(final String reservationOrderId, final Datagrain grain, final String filter) { + return listByReservationOrderWithServiceResponseAsync(reservationOrderId, grain, filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable>> listByReservationOrderWithServiceResponseAsync(final String reservationOrderId, final Datagrain grain, final String filter) { + return listByReservationOrderSinglePageAsync(reservationOrderId, grain, filter) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + ServiceResponse> * @param reservationOrderId Order Id of the reservation + ServiceResponse> * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + ServiceResponse> * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationSummariesInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderSinglePageAsync(final String reservationOrderId, final Datagrain grain, final String filter) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (grain == null) { + throw new IllegalArgumentException("Parameter grain is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByReservationOrder(reservationOrderId, grain, filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationSummariesInner> object if successful. + */ + public PagedList listByReservationOrderAndReservation(final String reservationOrderId, final String reservationId, final Datagrain grain) { + ServiceResponse> response = listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, grain).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final Datagrain grain, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, grain), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable> listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final Datagrain grain) { + return listByReservationOrderAndReservationWithServiceResponseAsync(reservationOrderId, reservationId, grain) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable>> listByReservationOrderAndReservationWithServiceResponseAsync(final String reservationOrderId, final String reservationId, final Datagrain grain) { + return listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, grain) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationSummariesInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderAndReservationSinglePageAsync(final String reservationOrderId, final String reservationId, final Datagrain grain) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId is required and cannot be null."); + } + if (grain == null) { + throw new IllegalArgumentException("Parameter grain is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + return service.listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderAndReservationDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationSummariesInner> object if successful. + */ + public PagedList listByReservationOrderAndReservation(final String reservationOrderId, final String reservationId, final Datagrain grain, final String filter) { + ServiceResponse> response = listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, grain, filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final Datagrain grain, final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, grain, filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable> listByReservationOrderAndReservationAsync(final String reservationOrderId, final String reservationId, final Datagrain grain, final String filter) { + return listByReservationOrderAndReservationWithServiceResponseAsync(reservationOrderId, reservationId, grain, filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the reservation + * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable>> listByReservationOrderAndReservationWithServiceResponseAsync(final String reservationOrderId, final String reservationId, final Datagrain grain, final String filter) { + return listByReservationOrderAndReservationSinglePageAsync(reservationOrderId, reservationId, grain, filter) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + ServiceResponse> * @param reservationOrderId Order Id of the reservation + ServiceResponse> * @param reservationId Id of the reservation + ServiceResponse> * @param grain Can be daily or monthly. Possible values include: 'DailyGrain', 'MonthlyGrain' + ServiceResponse> * @param filter Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationSummariesInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderAndReservationSinglePageAsync(final String reservationOrderId, final String reservationId, final Datagrain grain, final String filter) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId is required and cannot be null."); + } + if (grain == null) { + throw new IllegalArgumentException("Parameter grain is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderAndReservationDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderAndReservationDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationSummariesInner> object if successful. + */ + public PagedList listByReservationOrderNext(final String nextPageLink) { + ServiceResponse> response = listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable> listByReservationOrderNextAsync(final String nextPageLink) { + return listByReservationOrderNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable>> listByReservationOrderNextWithServiceResponseAsync(final String nextPageLink) { + return listByReservationOrderNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationSummariesInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByReservationOrderNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ReservationSummariesInner> object if successful. + */ + public PagedList listByReservationOrderAndReservationNext(final String nextPageLink) { + ServiceResponse> response = listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByReservationOrderAndReservationNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable> listByReservationOrderAndReservationNextAsync(final String nextPageLink) { + return listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationSummariesInner> object + */ + public Observable>> listByReservationOrderAndReservationNextWithServiceResponseAsync(final String nextPageLink) { + return listByReservationOrderAndReservationNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByReservationOrderAndReservationNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationSummariesInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByReservationOrderAndReservationNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByReservationOrderAndReservationNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByReservationOrderAndReservationNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByReservationOrderAndReservationNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagInner.java new file mode 100644 index 0000000000000..3cc039d489d45 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagInner.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The tag resource. + */ +public class TagInner { + /** + * Tag key. + */ + @JsonProperty(value = "key") + private String key; + + /** + * Get tag key. + * + * @return the key value + */ + public String key() { + return this.key; + } + + /** + * Set tag key. + * + * @param key the key value to set + * @return the TagInner object itself. + */ + public TagInner withKey(String key) { + this.key = key; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsImpl.java new file mode 100644 index 0000000000000..ef1454727be1f --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsImpl.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.Tags; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.management.consumption.v2018_03_31.TagsModel; + +class TagsImpl extends WrapperImpl implements Tags { + private final ConsumptionManager manager; + + TagsImpl(ConsumptionManager manager) { + super(manager.inner().tags()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable getAsync(String billingAccountId) { + TagsInner client = this.inner(); + return client.getAsync(billingAccountId) + .map(new Func1() { + @Override + public TagsModel call(TagsModelInner inner) { + return new TagsModelImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsInner.java new file mode 100644 index 0000000000000..aa4e16efaca0d --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsInner.java @@ -0,0 +1,136 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Tags. + */ +public class TagsInner { + /** The Retrofit service to perform REST calls. */ + private TagsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of TagsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public TagsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(TagsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Tags to be + * used by Retrofit to perform actually REST calls. + */ + interface TagsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.Tags get" }) + @GET("providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/tags") + Observable> get(@Path("billingAccountId") String billingAccountId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get all available tag keys for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TagsModelInner object if successful. + */ + public TagsModelInner get(String billingAccountId) { + return getWithServiceResponseAsync(billingAccountId).toBlocking().single().body(); + } + + /** + * Get all available tag keys for a billing account. + * + * @param billingAccountId BillingAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String billingAccountId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(billingAccountId), serviceCallback); + } + + /** + * Get all available tag keys for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TagsModelInner object + */ + public Observable getAsync(String billingAccountId) { + return getWithServiceResponseAsync(billingAccountId).map(new Func1, TagsModelInner>() { + @Override + public TagsModelInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get all available tag keys for a billing account. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TagsModelInner object + */ + public Observable> getWithServiceResponseAsync(String billingAccountId) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(billingAccountId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelImpl.java new file mode 100644 index 0000000000000..514fbd112f714 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelImpl.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.TagsModel; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.util.List; + +class TagsModelImpl extends WrapperImpl implements TagsModel { + private final ConsumptionManager manager; + TagsModelImpl(TagsModelInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public String eTag() { + return this.inner().eTag(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public List tags() { + return this.inner().tags(); + } + + @Override + public String type() { + return this.inner().type(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelInner.java new file mode 100644 index 0000000000000..25909989046be --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/TagsModelInner.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * A resource listing all tags. + */ +@JsonFlatten +public class TagsModelInner extends ProxyResource { + /** + * A list of Tag. + */ + @JsonProperty(value = "properties.tags") + private List tags; + + /** + * eTag of the resource. To handle concurrent update scenario, this field + * will be used to determine whether the user is updating the latest + * version or not. + */ + @JsonProperty(value = "eTag") + private String eTag; + + /** + * Get a list of Tag. + * + * @return the tags value + */ + public List tags() { + return this.tags; + } + + /** + * Set a list of Tag. + * + * @param tags the tags value to set + * @return the TagsModelInner object itself. + */ + public TagsModelInner withTags(List tags) { + this.tags = tags; + return this; + } + + /** + * Get eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + * + * @return the eTag value + */ + public String eTag() { + return this.eTag; + } + + /** + * Set eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + * + * @param eTag the eTag value to set + * @return the TagsModelInner object itself. + */ + public TagsModelInner withETag(String eTag) { + this.eTag = eTag; + return this; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailImpl.java new file mode 100644 index 0000000000000..3fe2ad7bf26e7 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailImpl.java @@ -0,0 +1,161 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetail; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import java.math.BigDecimal; +import com.microsoft.azure.management.consumption.v2018_03_31.MeterDetails; +import java.util.UUID; +import java.util.Map; +import org.joda.time.DateTime; + +class UsageDetailImpl extends WrapperImpl implements UsageDetail { + private final ConsumptionManager manager; + UsageDetailImpl(UsageDetailInner inner, ConsumptionManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public String accountName() { + return this.inner().accountName(); + } + + @Override + public String additionalProperties() { + return this.inner().additionalProperties(); + } + + @Override + public BigDecimal billableQuantity() { + return this.inner().billableQuantity(); + } + + @Override + public String billingPeriodId() { + return this.inner().billingPeriodId(); + } + + @Override + public String consumedService() { + return this.inner().consumedService(); + } + + @Override + public String costCenter() { + return this.inner().costCenter(); + } + + @Override + public String currency() { + return this.inner().currency(); + } + + @Override + public String departmentName() { + return this.inner().departmentName(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String instanceId() { + return this.inner().instanceId(); + } + + @Override + public String instanceLocation() { + return this.inner().instanceLocation(); + } + + @Override + public String instanceName() { + return this.inner().instanceName(); + } + + @Override + public String invoiceId() { + return this.inner().invoiceId(); + } + + @Override + public Boolean isEstimated() { + return this.inner().isEstimated(); + } + + @Override + public MeterDetails meterDetails() { + return this.inner().meterDetails(); + } + + @Override + public UUID meterId() { + return this.inner().meterId(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public BigDecimal pretaxCost() { + return this.inner().pretaxCost(); + } + + @Override + public String product() { + return this.inner().product(); + } + + @Override + public UUID subscriptionGuid() { + return this.inner().subscriptionGuid(); + } + + @Override + public String subscriptionName() { + return this.inner().subscriptionName(); + } + + @Override + public Map tags() { + return this.inner().tags(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public DateTime usageEnd() { + return this.inner().usageEnd(); + } + + @Override + public BigDecimal usageQuantity() { + return this.inner().usageQuantity(); + } + + @Override + public DateTime usageStart() { + return this.inner().usageStart(); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailInner.java new file mode 100644 index 0000000000000..d412e00b92fe5 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailInner.java @@ -0,0 +1,373 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import org.joda.time.DateTime; +import java.math.BigDecimal; +import java.util.UUID; +import com.microsoft.azure.management.consumption.v2018_03_31.MeterDetails; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * An usage detail resource. + */ +@JsonFlatten +public class UsageDetailInner extends ProxyResource { + /** + * The id of the billing period resource that the usage belongs to. + */ + @JsonProperty(value = "properties.billingPeriodId", access = JsonProperty.Access.WRITE_ONLY) + private String billingPeriodId; + + /** + * The id of the invoice resource that the usage belongs to. + */ + @JsonProperty(value = "properties.invoiceId", access = JsonProperty.Access.WRITE_ONLY) + private String invoiceId; + + /** + * The start of the date time range covered by the usage detail. + */ + @JsonProperty(value = "properties.usageStart", access = JsonProperty.Access.WRITE_ONLY) + private DateTime usageStart; + + /** + * The end of the date time range covered by the usage detail. + */ + @JsonProperty(value = "properties.usageEnd", access = JsonProperty.Access.WRITE_ONLY) + private DateTime usageEnd; + + /** + * The name of the resource instance that the usage is about. + */ + @JsonProperty(value = "properties.instanceName", access = JsonProperty.Access.WRITE_ONLY) + private String instanceName; + + /** + * The uri of the resource instance that the usage is about. + */ + @JsonProperty(value = "properties.instanceId", access = JsonProperty.Access.WRITE_ONLY) + private String instanceId; + + /** + * The location of the resource instance that the usage is about. + */ + @JsonProperty(value = "properties.instanceLocation", access = JsonProperty.Access.WRITE_ONLY) + private String instanceLocation; + + /** + * The ISO currency in which the meter is charged, for example, USD. + */ + @JsonProperty(value = "properties.currency", access = JsonProperty.Access.WRITE_ONLY) + private String currency; + + /** + * The quantity of usage. + */ + @JsonProperty(value = "properties.usageQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal usageQuantity; + + /** + * The billable usage quantity. + */ + @JsonProperty(value = "properties.billableQuantity", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal billableQuantity; + + /** + * The amount of cost before tax. + */ + @JsonProperty(value = "properties.pretaxCost", access = JsonProperty.Access.WRITE_ONLY) + private BigDecimal pretaxCost; + + /** + * The estimated usage is subject to change. + */ + @JsonProperty(value = "properties.isEstimated", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isEstimated; + + /** + * The meter id (GUID). + */ + @JsonProperty(value = "properties.meterId", access = JsonProperty.Access.WRITE_ONLY) + private UUID meterId; + + /** + * The details about the meter. By default this is not populated, unless + * it's specified in $expand. + */ + @JsonProperty(value = "properties.meterDetails", access = JsonProperty.Access.WRITE_ONLY) + private MeterDetails meterDetails; + + /** + * Subscription guid. + */ + @JsonProperty(value = "properties.subscriptionGuid", access = JsonProperty.Access.WRITE_ONLY) + private UUID subscriptionGuid; + + /** + * Subscription name. + */ + @JsonProperty(value = "properties.subscriptionName", access = JsonProperty.Access.WRITE_ONLY) + private String subscriptionName; + + /** + * Account name. + */ + @JsonProperty(value = "properties.accountName", access = JsonProperty.Access.WRITE_ONLY) + private String accountName; + + /** + * Department name. + */ + @JsonProperty(value = "properties.departmentName", access = JsonProperty.Access.WRITE_ONLY) + private String departmentName; + + /** + * Product name. + */ + @JsonProperty(value = "properties.product", access = JsonProperty.Access.WRITE_ONLY) + private String product; + + /** + * Consumed service name. + */ + @JsonProperty(value = "properties.consumedService", access = JsonProperty.Access.WRITE_ONLY) + private String consumedService; + + /** + * The cost center of this department if it is a department and a + * costcenter exists. + */ + @JsonProperty(value = "properties.costCenter", access = JsonProperty.Access.WRITE_ONLY) + private String costCenter; + + /** + * Additional details of this usage item. By default this is not populated, + * unless it's specified in $expand. + */ + @JsonProperty(value = "properties.additionalProperties", access = JsonProperty.Access.WRITE_ONLY) + private String additionalProperties; + + /** + * Resource tags. + */ + @JsonProperty(value = "tags", access = JsonProperty.Access.WRITE_ONLY) + private Map tags; + + /** + * Get the id of the billing period resource that the usage belongs to. + * + * @return the billingPeriodId value + */ + public String billingPeriodId() { + return this.billingPeriodId; + } + + /** + * Get the id of the invoice resource that the usage belongs to. + * + * @return the invoiceId value + */ + public String invoiceId() { + return this.invoiceId; + } + + /** + * Get the start of the date time range covered by the usage detail. + * + * @return the usageStart value + */ + public DateTime usageStart() { + return this.usageStart; + } + + /** + * Get the end of the date time range covered by the usage detail. + * + * @return the usageEnd value + */ + public DateTime usageEnd() { + return this.usageEnd; + } + + /** + * Get the name of the resource instance that the usage is about. + * + * @return the instanceName value + */ + public String instanceName() { + return this.instanceName; + } + + /** + * Get the uri of the resource instance that the usage is about. + * + * @return the instanceId value + */ + public String instanceId() { + return this.instanceId; + } + + /** + * Get the location of the resource instance that the usage is about. + * + * @return the instanceLocation value + */ + public String instanceLocation() { + return this.instanceLocation; + } + + /** + * Get the ISO currency in which the meter is charged, for example, USD. + * + * @return the currency value + */ + public String currency() { + return this.currency; + } + + /** + * Get the quantity of usage. + * + * @return the usageQuantity value + */ + public BigDecimal usageQuantity() { + return this.usageQuantity; + } + + /** + * Get the billable usage quantity. + * + * @return the billableQuantity value + */ + public BigDecimal billableQuantity() { + return this.billableQuantity; + } + + /** + * Get the amount of cost before tax. + * + * @return the pretaxCost value + */ + public BigDecimal pretaxCost() { + return this.pretaxCost; + } + + /** + * Get the estimated usage is subject to change. + * + * @return the isEstimated value + */ + public Boolean isEstimated() { + return this.isEstimated; + } + + /** + * Get the meter id (GUID). + * + * @return the meterId value + */ + public UUID meterId() { + return this.meterId; + } + + /** + * Get the details about the meter. By default this is not populated, unless it's specified in $expand. + * + * @return the meterDetails value + */ + public MeterDetails meterDetails() { + return this.meterDetails; + } + + /** + * Get subscription guid. + * + * @return the subscriptionGuid value + */ + public UUID subscriptionGuid() { + return this.subscriptionGuid; + } + + /** + * Get subscription name. + * + * @return the subscriptionName value + */ + public String subscriptionName() { + return this.subscriptionName; + } + + /** + * Get account name. + * + * @return the accountName value + */ + public String accountName() { + return this.accountName; + } + + /** + * Get department name. + * + * @return the departmentName value + */ + public String departmentName() { + return this.departmentName; + } + + /** + * Get product name. + * + * @return the product value + */ + public String product() { + return this.product; + } + + /** + * Get consumed service name. + * + * @return the consumedService value + */ + public String consumedService() { + return this.consumedService; + } + + /** + * Get the cost center of this department if it is a department and a costcenter exists. + * + * @return the costCenter value + */ + public String costCenter() { + return this.costCenter; + } + + /** + * Get additional details of this usage item. By default this is not populated, unless it's specified in $expand. + * + * @return the additionalProperties value + */ + public String additionalProperties() { + return this.additionalProperties; + } + + /** + * Get resource tags. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsImpl.java new file mode 100644 index 0000000000000..fd1dce8ff5a72 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByBillingAccounts; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetail; + +class UsageDetailsByBillingAccountsImpl extends WrapperImpl implements UsageDetailsByBillingAccounts { + private final ConsumptionManager manager; + + UsageDetailsByBillingAccountsImpl(ConsumptionManager manager) { + super(manager.inner().usageDetailsByBillingAccounts()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync(final String billingAccountId) { + UsageDetailsByBillingAccountsInner client = this.inner(); + return client.listAsync(billingAccountId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName) { + UsageDetailsByBillingAccountsInner client = this.inner(); + return client.listByBillingPeriodAsync(billingAccountId, billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsInner.java new file mode 100644 index 0000000000000..58b43d1e7e81c --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByBillingAccountsInner.java @@ -0,0 +1,823 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.management.consumption.v2018_03_31.QueryOptions; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in UsageDetailsByBillingAccounts. + */ +public class UsageDetailsByBillingAccountsInner { + /** The Retrofit service to perform REST calls. */ + private UsageDetailsByBillingAccountsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of UsageDetailsByBillingAccountsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public UsageDetailsByBillingAccountsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(UsageDetailsByBillingAccountsService.class); + this.client = client; + } + + /** + * The interface defining all the services for UsageDetailsByBillingAccounts to be + * used by Retrofit to perform actually REST calls. + */ + interface UsageDetailsByBillingAccountsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByBillingAccounts list" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/usageDetails") + Observable> list(@Path("billingAccountId") String billingAccountId, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByBillingAccounts listByBillingPeriod" }) + @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails") + Observable> listByBillingPeriod(@Path("billingAccountId") String billingAccountId, @Path("billingPeriodName") String billingPeriodName, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByBillingAccounts listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByBillingAccounts listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String billingAccountId) { + ServiceResponse> response = listSinglePageAsync(billingAccountId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String billingAccountId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(billingAccountId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String billingAccountId) { + return listWithServiceResponseAsync(billingAccountId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String billingAccountId) { + return listSinglePageAsync(billingAccountId) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String billingAccountId) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.list(billingAccountId, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String billingAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listSinglePageAsync(billingAccountId, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String billingAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(billingAccountId, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String billingAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listWithServiceResponseAsync(billingAccountId, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String billingAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listSinglePageAsync(billingAccountId, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param billingAccountId BillingAccount ID + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String billingAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.list(billingAccountId, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingAccountId, final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingAccountId, final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingAccountId, final String billingPeriodName) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.listByBillingPeriod(billingAccountId, billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodWithServiceResponseAsync(billingAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingAccountId BillingAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodSinglePageAsync(billingAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param billingAccountId BillingAccount ID + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (billingAccountId == null) { + throw new IllegalArgumentException("Parameter billingAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.listByBillingPeriod(billingAccountId, billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsImpl.java new file mode 100644 index 0000000000000..85497c1e13aa6 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByDepartments; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetail; + +class UsageDetailsByDepartmentsImpl extends WrapperImpl implements UsageDetailsByDepartments { + private final ConsumptionManager manager; + + UsageDetailsByDepartmentsImpl(ConsumptionManager manager) { + super(manager.inner().usageDetailsByDepartments()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync(final String departmentId) { + UsageDetailsByDepartmentsInner client = this.inner(); + return client.listAsync(departmentId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByBillingPeriodAsync(final String departmentId, final String billingPeriodName) { + UsageDetailsByDepartmentsInner client = this.inner(); + return client.listByBillingPeriodAsync(departmentId, billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsInner.java new file mode 100644 index 0000000000000..e9be4c07cd7a9 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByDepartmentsInner.java @@ -0,0 +1,823 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.management.consumption.v2018_03_31.QueryOptions; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in UsageDetailsByDepartments. + */ +public class UsageDetailsByDepartmentsInner { + /** The Retrofit service to perform REST calls. */ + private UsageDetailsByDepartmentsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of UsageDetailsByDepartmentsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public UsageDetailsByDepartmentsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(UsageDetailsByDepartmentsService.class); + this.client = client; + } + + /** + * The interface defining all the services for UsageDetailsByDepartments to be + * used by Retrofit to perform actually REST calls. + */ + interface UsageDetailsByDepartmentsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByDepartments list" }) + @GET("providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/usageDetails") + Observable> list(@Path("departmentId") String departmentId, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByDepartments listByBillingPeriod" }) + @GET("providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails") + Observable> listByBillingPeriod(@Path("departmentId") String departmentId, @Path("billingPeriodName") String billingPeriodName, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByDepartments listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByDepartments listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String departmentId) { + ServiceResponse> response = listSinglePageAsync(departmentId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String departmentId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(departmentId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String departmentId) { + return listWithServiceResponseAsync(departmentId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String departmentId) { + return listSinglePageAsync(departmentId) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String departmentId) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.list(departmentId, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String departmentId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listSinglePageAsync(departmentId, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String departmentId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(departmentId, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String departmentId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listWithServiceResponseAsync(departmentId, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String departmentId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listSinglePageAsync(departmentId, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param departmentId Department ID + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String departmentId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.list(departmentId, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String departmentId, final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(departmentId, billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String departmentId, final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String departmentId, final String billingPeriodName) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.listByBillingPeriod(departmentId, billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String departmentId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String departmentId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodWithServiceResponseAsync(departmentId, billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param departmentId Department ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String departmentId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodSinglePageAsync(departmentId, billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param departmentId Department ID + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String departmentId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (departmentId == null) { + throw new IllegalArgumentException("Parameter departmentId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.listByBillingPeriod(departmentId, billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsImpl.java new file mode 100644 index 0000000000000..9f60325d4fc3c --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByEnrollmentAccounts; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetail; + +class UsageDetailsByEnrollmentAccountsImpl extends WrapperImpl implements UsageDetailsByEnrollmentAccounts { + private final ConsumptionManager manager; + + UsageDetailsByEnrollmentAccountsImpl(ConsumptionManager manager) { + super(manager.inner().usageDetailsByEnrollmentAccounts()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listAsync(final String enrollmentAccountId) { + UsageDetailsByEnrollmentAccountsInner client = this.inner(); + return client.listAsync(enrollmentAccountId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName) { + UsageDetailsByEnrollmentAccountsInner client = this.inner(); + return client.listByBillingPeriodAsync(enrollmentAccountId, billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsInner.java new file mode 100644 index 0000000000000..fede22e5e3dbf --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsByEnrollmentAccountsInner.java @@ -0,0 +1,823 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.management.consumption.v2018_03_31.QueryOptions; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in UsageDetailsByEnrollmentAccounts. + */ +public class UsageDetailsByEnrollmentAccountsInner { + /** The Retrofit service to perform REST calls. */ + private UsageDetailsByEnrollmentAccountsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of UsageDetailsByEnrollmentAccountsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public UsageDetailsByEnrollmentAccountsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(UsageDetailsByEnrollmentAccountsService.class); + this.client = client; + } + + /** + * The interface defining all the services for UsageDetailsByEnrollmentAccounts to be + * used by Retrofit to perform actually REST calls. + */ + interface UsageDetailsByEnrollmentAccountsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByEnrollmentAccounts list" }) + @GET("providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/usageDetails") + Observable> list(@Path("enrollmentAccountId") String enrollmentAccountId, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByEnrollmentAccounts listByBillingPeriod" }) + @GET("providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails") + Observable> listByBillingPeriod(@Path("enrollmentAccountId") String enrollmentAccountId, @Path("billingPeriodName") String billingPeriodName, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByEnrollmentAccounts listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetailsByEnrollmentAccounts listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String enrollmentAccountId) { + ServiceResponse> response = listSinglePageAsync(enrollmentAccountId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String enrollmentAccountId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(enrollmentAccountId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String enrollmentAccountId) { + return listWithServiceResponseAsync(enrollmentAccountId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String enrollmentAccountId) { + return listSinglePageAsync(enrollmentAccountId) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String enrollmentAccountId) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.list(enrollmentAccountId, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String enrollmentAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listSinglePageAsync(enrollmentAccountId, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String enrollmentAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(enrollmentAccountId, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String enrollmentAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listWithServiceResponseAsync(enrollmentAccountId, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String enrollmentAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listSinglePageAsync(enrollmentAccountId, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param enrollmentAccountId EnrollmentAccount ID + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String enrollmentAccountId, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.list(enrollmentAccountId, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String enrollmentAccountId, final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(enrollmentAccountId, billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String enrollmentAccountId, final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String enrollmentAccountId, final String billingPeriodName) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.listByBillingPeriod(enrollmentAccountId, billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String enrollmentAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String enrollmentAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodWithServiceResponseAsync(enrollmentAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param enrollmentAccountId EnrollmentAccount ID + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String enrollmentAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodSinglePageAsync(enrollmentAccountId, billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param enrollmentAccountId EnrollmentAccount ID + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String enrollmentAccountId, final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (enrollmentAccountId == null) { + throw new IllegalArgumentException("Parameter enrollmentAccountId is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.listByBillingPeriod(enrollmentAccountId, billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsImpl.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsImpl.java new file mode 100644 index 0000000000000..f1fe64a7fe6c9 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsImpl.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetails; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.consumption.v2018_03_31.UsageDetail; + +class UsageDetailsImpl extends WrapperImpl implements UsageDetails { + private final ConsumptionManager manager; + + UsageDetailsImpl(ConsumptionManager manager) { + super(manager.inner().usageDetails()); + this.manager = manager; + } + + public ConsumptionManager manager() { + return this.manager; + } + + @Override + public Observable listByBillingPeriodAsync(final String billingPeriodName) { + UsageDetailsInner client = this.inner(); + return client.listByBillingPeriodAsync(billingPeriodName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + + @Override + public Observable listAsync() { + UsageDetailsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public UsageDetail call(UsageDetailInner inner) { + return new UsageDetailImpl(inner, manager()); + } + }); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsInner.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsInner.java new file mode 100644 index 0000000000000..77a3c73b9183e --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/UsageDetailsInner.java @@ -0,0 +1,803 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.consumption.v2018_03_31.ErrorResponseException; +import com.microsoft.azure.management.consumption.v2018_03_31.QueryOptions; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in UsageDetails. + */ +public class UsageDetailsInner { + /** The Retrofit service to perform REST calls. */ + private UsageDetailsService service; + /** The service client containing this operation class. */ + private ConsumptionManagementClientImpl client; + + /** + * Initializes an instance of UsageDetailsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public UsageDetailsInner(Retrofit retrofit, ConsumptionManagementClientImpl client) { + this.service = retrofit.create(UsageDetailsService.class); + this.client = client; + } + + /** + * The interface defining all the services for UsageDetails to be + * used by Retrofit to perform actually REST calls. + */ + interface UsageDetailsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetails list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Consumption/usageDetails") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetails listByBillingPeriod" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails") + Observable> listByBillingPeriod(@Path("subscriptionId") String subscriptionId, @Path("billingPeriodName") String billingPeriodName, @Query("$expand") String expand, @Query("$filter") String filter, @Query("$skiptoken") String skiptoken, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$apply") String apply, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetails listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.consumption.v2018_03_31.UsageDetails listByBillingPeriodNext" }) + @GET + Observable> listByBillingPeriodNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.list(this.client.subscriptionId(), expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList list(final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listSinglePageAsync(expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listAsync(final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listWithServiceResponseAsync(expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listWithServiceResponseAsync(final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listSinglePageAsync(expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName, properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.list(this.client.subscriptionId(), expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingPeriodName) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingPeriodName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingPeriodName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingPeriodName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingPeriodName) { + return listByBillingPeriodWithServiceResponseAsync(billingPeriodName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingPeriodName) { + return listByBillingPeriodSinglePageAsync(billingPeriodName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingPeriodName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final String filter = null; + final String skiptoken = null; + final Integer top = null; + final QueryOptions queryOptions = null; + String apply = null; + return service.listByBillingPeriod(this.client.subscriptionId(), billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriod(final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + ServiceResponse> response = listByBillingPeriodSinglePageAsync(billingPeriodName, expand, filter, skiptoken, top, queryOptions).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodAsync(final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodSinglePageAsync(billingPeriodName, expand, filter, skiptoken, top, queryOptions), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodAsync(final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodWithServiceResponseAsync(billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param billingPeriodName Billing Period Name. + * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + * @param top May be used to limit the number of results to the most recent N usageDetails. + * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodWithServiceResponseAsync(final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + return listByBillingPeriodSinglePageAsync(billingPeriodName, expand, filter, skiptoken, top, queryOptions) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param billingPeriodName Billing Period Name. + ServiceResponse> * @param expand May be used to expand the properties/additionalProperties or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details. + ServiceResponse> * @param filter May be used to filter usageDetails by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). + ServiceResponse> * @param skiptoken Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + ServiceResponse> * @param top May be used to limit the number of results to the most recent N usageDetails. + ServiceResponse> * @param queryOptions Additional parameters for the operation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodSinglePageAsync(final String billingPeriodName, final String expand, final String filter, final String skiptoken, final Integer top, final QueryOptions queryOptions) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (billingPeriodName == null) { + throw new IllegalArgumentException("Parameter billingPeriodName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(queryOptions); + String apply = null; + if (queryOptions != null) { + apply = queryOptions.apply(); + } + return service.listByBillingPeriod(this.client.subscriptionId(), billingPeriodName, expand, filter, skiptoken, top, this.client.apiVersion(), this.client.acceptLanguage(), apply, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<UsageDetailInner> object if successful. + */ + public PagedList listByBillingPeriodNext(final String nextPageLink) { + ServiceResponse> response = listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByBillingPeriodNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByBillingPeriodNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable> listByBillingPeriodNextAsync(final String nextPageLink) { + return listByBillingPeriodNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<UsageDetailInner> object + */ + public Observable>> listByBillingPeriodNextWithServiceResponseAsync(final String nextPageLink) { + return listByBillingPeriodNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByBillingPeriodNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are available via this API only for May 1, 2014 or later. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<UsageDetailInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByBillingPeriodNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByBillingPeriodNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByBillingPeriodNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByBillingPeriodNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/package-info.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/package-info.java new file mode 100644 index 0000000000000..c6cb15aeddae7 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for ConsumptionManagementClient. + * Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions. + */ +package com.microsoft.azure.management.consumption.v2018_03_31.implementation; diff --git a/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/package-info.java b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/package-info.java new file mode 100644 index 0000000000000..c5800acde7654 --- /dev/null +++ b/consumption/resource-manager/v2018_03_31/src/main/java/com/microsoft/azure/management/consumption/v2018_03_31/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for ConsumptionManagementClient. + * Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions. + */ +package com.microsoft.azure.management.consumption.v2018_03_31;