From 148961f77bf137f17f06050f7fd1cb174fb6ee9c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 15 Apr 2025 15:43:42 +0000 Subject: [PATCH] CodeGen from PR 33803 in Azure/azure-rest-api-specs Merge b5ce9c5928b2db407ce5dac2f9c49e65b5b7c488 into cb5ef7fc4cb443bd5f6b21d02cbce41051beb6ae --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../azure-resourcemanager-carbon/CHANGELOG.md | 8 + .../azure-resourcemanager-carbon/README.md | 102 +++ .../azure-resourcemanager-carbon/SAMPLE.md | 587 ++++++++++++++++++ .../azure-resourcemanager-carbon/pom.xml | 63 ++ .../resourcemanager/carbon/CarbonManager.java | 297 +++++++++ .../CarbonOptimizationManagementClient.java | 55 ++ .../carbon/fluent/CarbonServicesClient.java | 67 ++ .../carbon/fluent/OperationsClient.java | 40 ++ ...onEmissionDataAvailableDateRangeInner.java | 137 ++++ .../CarbonEmissionDataListResultInner.java | 175 ++++++ .../carbon/fluent/models/OperationInner.java | 172 +++++ .../carbon/fluent/models/package-info.java | 9 + .../carbon/fluent/package-info.java | 9 + ...bonEmissionDataAvailableDateRangeImpl.java | 36 ++ .../CarbonEmissionDataListResultImpl.java | 54 ++ ...onOptimizationManagementClientBuilder.java | 122 ++++ ...arbonOptimizationManagementClientImpl.java | 288 +++++++++ .../CarbonServicesClientImpl.java | 267 ++++++++ .../implementation/CarbonServicesImpl.java | 82 +++ .../carbon/implementation/OperationImpl.java | 50 ++ .../implementation/OperationsClientImpl.java | 235 +++++++ .../carbon/implementation/OperationsImpl.java | 44 ++ .../implementation/ResourceManagerUtils.java | 195 ++++++ .../carbon/implementation/package-info.java | 9 + .../carbon/models/AccessDecisionEnum.java | 51 ++ .../carbon/models/ActionType.java | 46 ++ .../carbon/models/CarbonEmissionData.java | 259 ++++++++ .../CarbonEmissionDataAvailableDateRange.java | 33 + .../models/CarbonEmissionDataListResult.java | 42 ++ .../models/CarbonEmissionItemDetailData.java | 209 +++++++ .../CarbonEmissionMonthlySummaryData.java | 206 ++++++ .../CarbonEmissionOverallSummaryData.java | 137 ++++ ...rbonEmissionTopItemMonthlySummaryData.java | 246 ++++++++ .../CarbonEmissionTopItemsSummaryData.java | 215 +++++++ .../carbon/models/CarbonServices.java | 58 ++ .../carbon/models/CategoryTypeEnum.java | 67 ++ .../carbon/models/DateRange.java | 138 ++++ .../carbon/models/EmissionScopeEnum.java | 57 ++ .../carbon/models/ItemDetailsQueryFilter.java | 349 +++++++++++ .../MonthlySummaryReportQueryFilter.java | 191 ++++++ .../carbon/models/Operation.java | 58 ++ .../carbon/models/OperationDisplay.java | 136 ++++ .../carbon/models/OperationListResult.java | 104 ++++ .../carbon/models/Operations.java | 35 ++ .../carbon/models/OrderByColumnEnum.java | 73 +++ .../resourcemanager/carbon/models/Origin.java | 57 ++ .../OverallSummaryReportQueryFilter.java | 191 ++++++ .../carbon/models/QueryFilter.java | 345 ++++++++++ .../carbon/models/ReportTypeEnum.java | 68 ++ .../ResourceCarbonEmissionItemDetailData.java | 366 +++++++++++ ...rbonEmissionTopItemMonthlySummaryData.java | 346 +++++++++++ ...urceCarbonEmissionTopItemsSummaryData.java | 315 ++++++++++ ...urceGroupCarbonEmissionItemDetailData.java | 277 +++++++++ ...rbonEmissionTopItemMonthlySummaryData.java | 316 ++++++++++ ...roupCarbonEmissionTopItemsSummaryData.java | 278 +++++++++ .../carbon/models/ResponseDataTypeEnum.java | 101 +++ .../carbon/models/SortDirectionEnum.java | 51 ++ .../models/SubscriptionAccessDecision.java | 163 +++++ ...pItemsMonthlySummaryReportQueryFilter.java | 256 ++++++++ .../TopItemsSummaryReportQueryFilter.java | 258 ++++++++ .../carbon/models/package-info.java | 9 + .../resourcemanager/carbon/package-info.java | 9 + .../src/main/java/module-info.java | 15 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + .../azure-resourcemanager-carbon.properties | 1 + ...EmissionDataAvailableDateRangeSamples.java | 25 + ...viceQueryCarbonEmissionReportsSamples.java | 531 ++++++++++++++++ .../generated/OperationsListSamples.java | 23 + sdk/carbon/ci.yml | 46 ++ sdk/carbon/pom.xml | 15 + 73 files changed, 9879 insertions(+) create mode 100644 sdk/carbon/azure-resourcemanager-carbon/CHANGELOG.md create mode 100644 sdk/carbon/azure-resourcemanager-carbon/README.md create mode 100644 sdk/carbon/azure-resourcemanager-carbon/SAMPLE.md create mode 100644 sdk/carbon/azure-resourcemanager-carbon/pom.xml create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/CarbonManager.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonOptimizationManagementClient.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonServicesClient.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/OperationsClient.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataListResultInner.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/OperationInner.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/package-info.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/package-info.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataAvailableDateRangeImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataListResultImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientBuilder.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesClientImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsClientImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsImpl.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/ResourceManagerUtils.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/package-info.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/AccessDecisionEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ActionType.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataAvailableDateRange.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataListResult.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionItemDetailData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionMonthlySummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionOverallSummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemMonthlySummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemsSummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonServices.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CategoryTypeEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/DateRange.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/EmissionScopeEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ItemDetailsQueryFilter.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/MonthlySummaryReportQueryFilter.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operation.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationDisplay.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationListResult.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operations.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OrderByColumnEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Origin.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OverallSummaryReportQueryFilter.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/QueryFilter.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ReportTypeEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionItemDetailData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemsSummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionItemDetailData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResponseDataTypeEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SortDirectionEnum.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SubscriptionAccessDecision.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsMonthlySummaryReportQueryFilter.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsSummaryReportQueryFilter.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/package-info.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/package-info.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/java/module-info.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/proxy-config.json create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/reflect-config.json create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/main/resources/azure-resourcemanager-carbon.properties create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java create mode 100644 sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/OperationsListSamples.java create mode 100644 sdk/carbon/ci.yml create mode 100644 sdk/carbon/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 92dbd2e57617..b75159e21507 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -473,6 +473,7 @@ com.azure.resourcemanager:azure-resourcemanager-databasewatcher;1.0.0-beta.1;1.0 com.azure.resourcemanager:azure-resourcemanager-durabletask;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-arizeaiobservabilityeval;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-weightsandbiases;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-carbon;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 com.azure.v2:azure-client-sdk-parent;2.0.0-beta.1;2.0.0-beta.1 diff --git a/pom.xml b/pom.xml index ff71d092c5bb..b7b8a7f03cdf 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ sdk/billingbenefits sdk/boms sdk/botservice + sdk/carbon sdk/changeanalysis sdk/chaos sdk/clientcore diff --git a/sdk/carbon/azure-resourcemanager-carbon/CHANGELOG.md b/sdk/carbon/azure-resourcemanager-carbon/CHANGELOG.md new file mode 100644 index 000000000000..485e990eca30 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2025-04-15) + +- Azure Resource Manager Carbon client library for Java. This package contains Microsoft Azure SDK for Carbon Management SDK. Carbon Optimization Client. Package tag package-2025-04-01-beta. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +### Features Added + +- Initial release for the azure-resourcemanager-carbon Java SDK. diff --git a/sdk/carbon/azure-resourcemanager-carbon/README.md b/sdk/carbon/azure-resourcemanager-carbon/README.md new file mode 100644 index 000000000000..49721afe747c --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Carbon client library for Java + +Azure Resource Manager Carbon client library for Java. + +This package contains Microsoft Azure SDK for Carbon Management SDK. Carbon Optimization Client. Package tag package-2025-04-01-beta. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-carbon;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-carbon + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +CarbonManager manager = CarbonManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change the `AzureCloud.AZURE_PUBLIC_CLOUD` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/carbon/azure-resourcemanager-carbon/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/carbon/azure-resourcemanager-carbon/SAMPLE.md b/sdk/carbon/azure-resourcemanager-carbon/SAMPLE.md new file mode 100644 index 000000000000..e8c1cae636e7 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/SAMPLE.md @@ -0,0 +1,587 @@ +# Code snippets and samples + + +## CarbonService + +- [QueryCarbonEmissionDataAvailableDateRange](#carbonservice_querycarbonemissiondataavailabledaterange) +- [QueryCarbonEmissionReports](#carbonservice_querycarbonemissionreports) + +## Operations + +- [List](#operations_list) +### CarbonService_QueryCarbonEmissionDataAvailableDateRange + +```java +/** + * Samples for CarbonService QueryCarbonEmissionDataAvailableDateRange. + */ +public final class CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples { + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * carbonEmissionsDataAvailableDateRange.json + */ + /** + * Sample code: CarbonService_QueryCarbonEmissionDataAvailableDateRange. + * + * @param manager Entry point to CarbonManager. + */ + public static void + carbonServiceQueryCarbonEmissionDataAvailableDateRange(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionDataAvailableDateRangeWithResponse(com.azure.core.util.Context.NONE); + } +} +``` + +### CarbonService_QueryCarbonEmissionReports + +```java +import com.azure.resourcemanager.carbon.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbon.models.DateRange; +import com.azure.resourcemanager.carbon.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbon.models.ItemDetailsQueryFilter; +import com.azure.resourcemanager.carbon.models.MonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbon.models.OrderByColumnEnum; +import com.azure.resourcemanager.carbon.models.OverallSummaryReportQueryFilter; +import com.azure.resourcemanager.carbon.models.SortDirectionEnum; +import com.azure.resourcemanager.carbon.models.TopItemsMonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbon.models.TopItemsSummaryReportQueryFilter; +import java.time.LocalDate; +import java.util.Arrays; + +/** + * Samples for CarbonService QueryCarbonEmissionReports. + */ +public final class CarbonServiceQueryCarbonEmissionReportsSamples { + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceTypeItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceTypeReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionTopNResourceReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsMonthlySummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Monthly Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionMonthlySummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new MonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withResourceGroupUrlList( + Arrays.asList("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-name")) + .withResourceTypeList( + Arrays.asList("microsoft.storage/storageaccounts", "microsoft.databricks/workspaces")) + .withLocationList(Arrays.asList("east us", "west us")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsSubscriptionItemDetailsReportReport.json + */ + /** + * Sample code: QueryCarbonEmission Subscriptions item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionSubscriptionsItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.SUBSCRIPTION) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceGroupItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceGroup item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionResourceGroupItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsOverallSummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionOverallSummaryReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new OverallSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2023-06-01")).withEnd(LocalDate.parse("2023-06-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNSubscriptionItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNSubscriptionsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.SUBSCRIPTION) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceGroupItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceGroupReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionResourceItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNSubscriptionItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNSubscriptionsMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.SUBSCRIPTION) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNLocationItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionTopNLocationsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.LOCATION) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceItemDetailsReportWithPaginationToken.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report with pagination token. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionResourceItemDetailsReportWithPaginationToken( + com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100) + .withSkipToken("fakeTokenPlaceholder"), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsLocationItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission Location item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionLocationItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.LOCATION) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsMonthlySummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Monthly Summary Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionOverallMonthlySummaryReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new MonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsOverallSummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionOverallSummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new OverallSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2023-06-01")).withEnd(LocalDate.parse("2023-06-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withResourceGroupUrlList( + Arrays.asList("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-name")) + .withResourceTypeList( + Arrays.asList("microsoft.storage/storageaccounts", "microsoft.databricks/workspaces")) + .withLocationList(Arrays.asList("east us", "west us")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNLocationItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNLocationsMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.LOCATION) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceTypeItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceTypeMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceTypeItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceType item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionResourceTypeItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceGroupItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceGroupMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withTopItems(2), com.azure.core.util.Context.NONE); + } +} +``` + +### Operations_List + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: + * specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/listOperations.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to CarbonManager. + */ + public static void operationsList(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/carbon/azure-resourcemanager-carbon/pom.xml b/sdk/carbon/azure-resourcemanager-carbon/pom.xml new file mode 100644 index 000000000000..65014a4ac555 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-carbon + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Carbon Management + This package contains Microsoft Azure SDK for Carbon Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Carbon Optimization Client. Package tag package-2025-04-01-beta. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + false + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-management + 1.17.0 + + + diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/CarbonManager.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/CarbonManager.java new file mode 100644 index 000000000000..754fdfb66046 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/CarbonManager.java @@ -0,0 +1,297 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.carbon.fluent.CarbonOptimizationManagementClient; +import com.azure.resourcemanager.carbon.implementation.CarbonOptimizationManagementClientBuilder; +import com.azure.resourcemanager.carbon.implementation.CarbonServicesImpl; +import com.azure.resourcemanager.carbon.implementation.OperationsImpl; +import com.azure.resourcemanager.carbon.models.CarbonServices; +import com.azure.resourcemanager.carbon.models.Operations; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to CarbonManager. + * Carbon Optimization Client. + */ +public final class CarbonManager { + private CarbonServices carbonServices; + + private Operations operations; + + private final CarbonOptimizationManagementClient clientObject; + + private CarbonManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new CarbonOptimizationManagementClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Carbon service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Carbon service API instance. + */ + public static CarbonManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Carbon service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Carbon service API instance. + */ + public static CarbonManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new CarbonManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create CarbonManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new CarbonManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-carbon.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Carbon service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Carbon service API instance. + */ + public CarbonManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.carbon") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new CarbonManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of CarbonServices. + * + * @return Resource collection API of CarbonServices. + */ + public CarbonServices carbonServices() { + if (this.carbonServices == null) { + this.carbonServices = new CarbonServicesImpl(clientObject.getCarbonServices(), this); + } + return carbonServices; + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets wrapped service client CarbonOptimizationManagementClient providing direct access to the underlying + * auto-generated API implementation, based on Azure REST API. + * + * @return Wrapped service client CarbonOptimizationManagementClient. + */ + public CarbonOptimizationManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonOptimizationManagementClient.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonOptimizationManagementClient.java new file mode 100644 index 000000000000..084b8a7884d6 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonOptimizationManagementClient.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for CarbonOptimizationManagementClient class. + */ +public interface CarbonOptimizationManagementClient { + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the CarbonServicesClient object to access its operations. + * + * @return the CarbonServicesClient object. + */ + CarbonServicesClient getCarbonServices(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonServicesClient.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonServicesClient.java new file mode 100644 index 000000000000..ad831fea21f8 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/CarbonServicesClient.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataListResultInner; +import com.azure.resourcemanager.carbon.models.QueryFilter; + +/** + * An instance of this class provides access to all the operations defined in CarbonServicesClient. + */ +public interface CarbonServicesClient { + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response queryCarbonEmissionReportsWithResponse(QueryFilter queryParameters, + Context context); + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CarbonEmissionDataListResultInner queryCarbonEmissionReports(QueryFilter queryParameters); + + /** + * API for query carbon emission data available date range. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response + queryCarbonEmissionDataAvailableDateRangeWithResponse(Context context); + + /** + * API for query carbon emission data available date range. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CarbonEmissionDataAvailableDateRangeInner queryCarbonEmissionDataAvailableDateRange(); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/OperationsClient.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/OperationsClient.java new file mode 100644 index 000000000000..6aec3a9d84f7 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.carbon.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java new file mode 100644 index 000000000000..9037fd8a5693 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for available date range of carbon emission data. + */ +@Fluent +public final class CarbonEmissionDataAvailableDateRangeInner + implements JsonSerializable { + /* + * Start date parameter, format is yyyy-MM-dd + */ + private String startDate; + + /* + * End date parameter, format is yyyy-MM-dd + */ + private String endDate; + + /** + * Creates an instance of CarbonEmissionDataAvailableDateRangeInner class. + */ + public CarbonEmissionDataAvailableDateRangeInner() { + } + + /** + * Get the startDate property: Start date parameter, format is yyyy-MM-dd. + * + * @return the startDate value. + */ + public String startDate() { + return this.startDate; + } + + /** + * Set the startDate property: Start date parameter, format is yyyy-MM-dd. + * + * @param startDate the startDate value to set. + * @return the CarbonEmissionDataAvailableDateRangeInner object itself. + */ + public CarbonEmissionDataAvailableDateRangeInner withStartDate(String startDate) { + this.startDate = startDate; + return this; + } + + /** + * Get the endDate property: End date parameter, format is yyyy-MM-dd. + * + * @return the endDate value. + */ + public String endDate() { + return this.endDate; + } + + /** + * Set the endDate property: End date parameter, format is yyyy-MM-dd. + * + * @param endDate the endDate value to set. + * @return the CarbonEmissionDataAvailableDateRangeInner object itself. + */ + public CarbonEmissionDataAvailableDateRangeInner withEndDate(String endDate) { + this.endDate = endDate; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (startDate() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property startDate in model CarbonEmissionDataAvailableDateRangeInner")); + } + if (endDate() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property endDate in model CarbonEmissionDataAvailableDateRangeInner")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionDataAvailableDateRangeInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("startDate", this.startDate); + jsonWriter.writeStringField("endDate", this.endDate); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionDataAvailableDateRangeInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionDataAvailableDateRangeInner if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionDataAvailableDateRangeInner. + */ + public static CarbonEmissionDataAvailableDateRangeInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionDataAvailableDateRangeInner deserializedCarbonEmissionDataAvailableDateRangeInner + = new CarbonEmissionDataAvailableDateRangeInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("startDate".equals(fieldName)) { + deserializedCarbonEmissionDataAvailableDateRangeInner.startDate = reader.getString(); + } else if ("endDate".equals(fieldName)) { + deserializedCarbonEmissionDataAvailableDateRangeInner.endDate = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionDataAvailableDateRangeInner; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataListResultInner.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataListResultInner.java new file mode 100644 index 000000000000..738658da3f66 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/CarbonEmissionDataListResultInner.java @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbon.models.CarbonEmissionData; +import com.azure.resourcemanager.carbon.models.SubscriptionAccessDecision; +import java.io.IOException; +import java.util.List; + +/** + * List of carbon emission results. + */ +@Fluent +public final class CarbonEmissionDataListResultInner implements JsonSerializable { + /* + * The CarbonEmissionData items on this page + */ + private List value; + + /* + * The pagination token to fetch next page data, it's null or empty if it doesn't have next page data + */ + private String skipToken; + + /* + * The access decision list for each input subscription + */ + private List subscriptionAccessDecisionList; + + /** + * Creates an instance of CarbonEmissionDataListResultInner class. + */ + public CarbonEmissionDataListResultInner() { + } + + /** + * Get the value property: The CarbonEmissionData items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The CarbonEmissionData items on this page. + * + * @param value the value value to set. + * @return the CarbonEmissionDataListResultInner object itself. + */ + public CarbonEmissionDataListResultInner withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the skipToken property: The pagination token to fetch next page data, it's null or empty if it doesn't have + * next page data. + * + * @return the skipToken value. + */ + public String skipToken() { + return this.skipToken; + } + + /** + * Set the skipToken property: The pagination token to fetch next page data, it's null or empty if it doesn't have + * next page data. + * + * @param skipToken the skipToken value to set. + * @return the CarbonEmissionDataListResultInner object itself. + */ + public CarbonEmissionDataListResultInner withSkipToken(String skipToken) { + this.skipToken = skipToken; + return this; + } + + /** + * Get the subscriptionAccessDecisionList property: The access decision list for each input subscription. + * + * @return the subscriptionAccessDecisionList value. + */ + public List subscriptionAccessDecisionList() { + return this.subscriptionAccessDecisionList; + } + + /** + * Set the subscriptionAccessDecisionList property: The access decision list for each input subscription. + * + * @param subscriptionAccessDecisionList the subscriptionAccessDecisionList value to set. + * @return the CarbonEmissionDataListResultInner object itself. + */ + public CarbonEmissionDataListResultInner + withSubscriptionAccessDecisionList(List subscriptionAccessDecisionList) { + this.subscriptionAccessDecisionList = subscriptionAccessDecisionList; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model CarbonEmissionDataListResultInner")); + } else { + value().forEach(e -> e.validate()); + } + if (subscriptionAccessDecisionList() != null) { + subscriptionAccessDecisionList().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionDataListResultInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("skipToken", this.skipToken); + jsonWriter.writeArrayField("subscriptionAccessDecisionList", this.subscriptionAccessDecisionList, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionDataListResultInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionDataListResultInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionDataListResultInner. + */ + public static CarbonEmissionDataListResultInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionDataListResultInner deserializedCarbonEmissionDataListResultInner + = new CarbonEmissionDataListResultInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> CarbonEmissionData.fromJson(reader1)); + deserializedCarbonEmissionDataListResultInner.value = value; + } else if ("skipToken".equals(fieldName)) { + deserializedCarbonEmissionDataListResultInner.skipToken = reader.getString(); + } else if ("subscriptionAccessDecisionList".equals(fieldName)) { + List subscriptionAccessDecisionList + = reader.readArray(reader1 -> SubscriptionAccessDecision.fromJson(reader1)); + deserializedCarbonEmissionDataListResultInner.subscriptionAccessDecisionList + = subscriptionAccessDecisionList; + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionDataListResultInner; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/OperationInner.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/OperationInner.java new file mode 100644 index 000000000000..f6c2ba8a0487 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/OperationInner.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbon.models.ActionType; +import com.azure.resourcemanager.carbon.models.OperationDisplay; +import com.azure.resourcemanager.carbon.models.Origin; +import java.io.IOException; + +/** + * REST API Operation + * + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Fluent +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for + * ARM/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + public OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Localized display information for this particular operation. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("display", this.display); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/package-info.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/package-info.java new file mode 100644 index 000000000000..7bb0c99ca627 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the inner data models for CarbonOptimizationManagementClient. + * Carbon Optimization Client. + */ +package com.azure.resourcemanager.carbon.fluent.models; diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/package-info.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/package-info.java new file mode 100644 index 000000000000..1b35d1a60d96 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the service clients for CarbonOptimizationManagementClient. + * Carbon Optimization Client. + */ +package com.azure.resourcemanager.carbon.fluent; diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataAvailableDateRangeImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataAvailableDateRangeImpl.java new file mode 100644 index 000000000000..da7abd796e3c --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataAvailableDateRangeImpl.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbon.models.CarbonEmissionDataAvailableDateRange; + +public final class CarbonEmissionDataAvailableDateRangeImpl implements CarbonEmissionDataAvailableDateRange { + private CarbonEmissionDataAvailableDateRangeInner innerObject; + + private final com.azure.resourcemanager.carbon.CarbonManager serviceManager; + + CarbonEmissionDataAvailableDateRangeImpl(CarbonEmissionDataAvailableDateRangeInner innerObject, + com.azure.resourcemanager.carbon.CarbonManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String startDate() { + return this.innerModel().startDate(); + } + + public String endDate() { + return this.innerModel().endDate(); + } + + public CarbonEmissionDataAvailableDateRangeInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.carbon.CarbonManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataListResultImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataListResultImpl.java new file mode 100644 index 000000000000..fc1f477e6902 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonEmissionDataListResultImpl.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataListResultInner; +import com.azure.resourcemanager.carbon.models.CarbonEmissionData; +import com.azure.resourcemanager.carbon.models.CarbonEmissionDataListResult; +import com.azure.resourcemanager.carbon.models.SubscriptionAccessDecision; +import java.util.Collections; +import java.util.List; + +public final class CarbonEmissionDataListResultImpl implements CarbonEmissionDataListResult { + private CarbonEmissionDataListResultInner innerObject; + + private final com.azure.resourcemanager.carbon.CarbonManager serviceManager; + + CarbonEmissionDataListResultImpl(CarbonEmissionDataListResultInner innerObject, + com.azure.resourcemanager.carbon.CarbonManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public List value() { + List inner = this.innerModel().value(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public String skipToken() { + return this.innerModel().skipToken(); + } + + public List subscriptionAccessDecisionList() { + List inner = this.innerModel().subscriptionAccessDecisionList(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public CarbonEmissionDataListResultInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.carbon.CarbonManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientBuilder.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientBuilder.java new file mode 100644 index 000000000000..da6b4c68f0e2 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the CarbonOptimizationManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { CarbonOptimizationManagementClientImpl.class }) +public final class CarbonOptimizationManagementClientBuilder { + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the CarbonOptimizationManagementClientBuilder. + */ + public CarbonOptimizationManagementClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the CarbonOptimizationManagementClientBuilder. + */ + public CarbonOptimizationManagementClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the CarbonOptimizationManagementClientBuilder. + */ + public CarbonOptimizationManagementClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the CarbonOptimizationManagementClientBuilder. + */ + public CarbonOptimizationManagementClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the CarbonOptimizationManagementClientBuilder. + */ + public CarbonOptimizationManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of CarbonOptimizationManagementClientImpl with the provided parameters. + * + * @return an instance of CarbonOptimizationManagementClientImpl. + */ + public CarbonOptimizationManagementClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + CarbonOptimizationManagementClientImpl client = new CarbonOptimizationManagementClientImpl(localPipeline, + localSerializerAdapter, localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientImpl.java new file mode 100644 index 000000000000..4b314f5059d6 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonOptimizationManagementClientImpl.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.carbon.fluent.CarbonOptimizationManagementClient; +import com.azure.resourcemanager.carbon.fluent.CarbonServicesClient; +import com.azure.resourcemanager.carbon.fluent.OperationsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the CarbonOptimizationManagementClientImpl type. + */ +@ServiceClient(builder = CarbonOptimizationManagementClientBuilder.class) +public final class CarbonOptimizationManagementClientImpl implements CarbonOptimizationManagementClient { + /** + * server parameter. + */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Api Version. + */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The CarbonServicesClient object to access its operations. + */ + private final CarbonServicesClient carbonServices; + + /** + * Gets the CarbonServicesClient object to access its operations. + * + * @return the CarbonServicesClient object. + */ + public CarbonServicesClient getCarbonServices() { + return this.carbonServices; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * Initializes an instance of CarbonOptimizationManagementClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint server parameter. + */ + CarbonOptimizationManagementClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2025-04-01"; + this.carbonServices = new CarbonServicesClientImpl(this); + this.operations = new OperationsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonOptimizationManagementClientImpl.class); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesClientImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesClientImpl.java new file mode 100644 index 000000000000..cce087fc352c --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesClientImpl.java @@ -0,0 +1,267 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.carbon.fluent.CarbonServicesClient; +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataListResultInner; +import com.azure.resourcemanager.carbon.models.QueryFilter; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in CarbonServicesClient. + */ +public final class CarbonServicesClientImpl implements CarbonServicesClient { + /** + * The proxy service used to perform REST calls. + */ + private final CarbonServicesService service; + + /** + * The service client containing this operation class. + */ + private final CarbonOptimizationManagementClientImpl client; + + /** + * Initializes an instance of CarbonServicesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CarbonServicesClientImpl(CarbonOptimizationManagementClientImpl client) { + this.service + = RestProxy.create(CarbonServicesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CarbonOptimizationManagementClientCarbonServices to be used by the + * proxy service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "CarbonOptimizationMa") + public interface CarbonServicesService { + @Headers({ "Content-Type: application/json" }) + @Post("/providers/Microsoft.Carbon/carbonEmissionReports") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> queryCarbonEmissionReports( + @HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") QueryFilter queryParameters, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/providers/Microsoft.Carbon/queryCarbonEmissionDataAvailableDateRange") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> queryCarbonEmissionDataAvailableDateRange( + @HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + queryCarbonEmissionReportsWithResponseAsync(QueryFilter queryParameters) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (queryParameters == null) { + return Mono + .error(new IllegalArgumentException("Parameter queryParameters is required and cannot be null.")); + } else { + queryParameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.queryCarbonEmissionReports(this.client.getEndpoint(), + this.client.getApiVersion(), queryParameters, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + queryCarbonEmissionReportsWithResponseAsync(QueryFilter queryParameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (queryParameters == null) { + return Mono + .error(new IllegalArgumentException("Parameter queryParameters is required and cannot be null.")); + } else { + queryParameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.queryCarbonEmissionReports(this.client.getEndpoint(), this.client.getApiVersion(), + queryParameters, accept, context); + } + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono queryCarbonEmissionReportsAsync(QueryFilter queryParameters) { + return queryCarbonEmissionReportsWithResponseAsync(queryParameters) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response + queryCarbonEmissionReportsWithResponse(QueryFilter queryParameters, Context context) { + return queryCarbonEmissionReportsWithResponseAsync(queryParameters, context).block(); + } + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CarbonEmissionDataListResultInner queryCarbonEmissionReports(QueryFilter queryParameters) { + return queryCarbonEmissionReportsWithResponse(queryParameters, Context.NONE).getValue(); + } + + /** + * API for query carbon emission data available date range. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + queryCarbonEmissionDataAvailableDateRangeWithResponseAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.queryCarbonEmissionDataAvailableDateRange(this.client.getEndpoint(), + this.client.getApiVersion(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * API for query carbon emission data available date range. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + queryCarbonEmissionDataAvailableDateRangeWithResponseAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.queryCarbonEmissionDataAvailableDateRange(this.client.getEndpoint(), this.client.getApiVersion(), + accept, context); + } + + /** + * API for query carbon emission data available date range. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono queryCarbonEmissionDataAvailableDateRangeAsync() { + return queryCarbonEmissionDataAvailableDateRangeWithResponseAsync() + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * API for query carbon emission data available date range. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response + queryCarbonEmissionDataAvailableDateRangeWithResponse(Context context) { + return queryCarbonEmissionDataAvailableDateRangeWithResponseAsync(context).block(); + } + + /** + * API for query carbon emission data available date range. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CarbonEmissionDataAvailableDateRangeInner queryCarbonEmissionDataAvailableDateRange() { + return queryCarbonEmissionDataAvailableDateRangeWithResponse(Context.NONE).getValue(); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesImpl.java new file mode 100644 index 000000000000..80c9f97e362d --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/CarbonServicesImpl.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.carbon.fluent.CarbonServicesClient; +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataListResultInner; +import com.azure.resourcemanager.carbon.models.CarbonEmissionDataAvailableDateRange; +import com.azure.resourcemanager.carbon.models.CarbonEmissionDataListResult; +import com.azure.resourcemanager.carbon.models.CarbonServices; +import com.azure.resourcemanager.carbon.models.QueryFilter; + +public final class CarbonServicesImpl implements CarbonServices { + private static final ClientLogger LOGGER = new ClientLogger(CarbonServicesImpl.class); + + private final CarbonServicesClient innerClient; + + private final com.azure.resourcemanager.carbon.CarbonManager serviceManager; + + public CarbonServicesImpl(CarbonServicesClient innerClient, + com.azure.resourcemanager.carbon.CarbonManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response queryCarbonEmissionReportsWithResponse(QueryFilter queryParameters, + Context context) { + Response inner + = this.serviceClient().queryCarbonEmissionReportsWithResponse(queryParameters, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new CarbonEmissionDataListResultImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public CarbonEmissionDataListResult queryCarbonEmissionReports(QueryFilter queryParameters) { + CarbonEmissionDataListResultInner inner = this.serviceClient().queryCarbonEmissionReports(queryParameters); + if (inner != null) { + return new CarbonEmissionDataListResultImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response + queryCarbonEmissionDataAvailableDateRangeWithResponse(Context context) { + Response inner + = this.serviceClient().queryCarbonEmissionDataAvailableDateRangeWithResponse(context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new CarbonEmissionDataAvailableDateRangeImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public CarbonEmissionDataAvailableDateRange queryCarbonEmissionDataAvailableDateRange() { + CarbonEmissionDataAvailableDateRangeInner inner + = this.serviceClient().queryCarbonEmissionDataAvailableDateRange(); + if (inner != null) { + return new CarbonEmissionDataAvailableDateRangeImpl(inner, this.manager()); + } else { + return null; + } + } + + private CarbonServicesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.carbon.CarbonManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationImpl.java new file mode 100644 index 000000000000..0536a99fad41 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.resourcemanager.carbon.fluent.models.OperationInner; +import com.azure.resourcemanager.carbon.models.ActionType; +import com.azure.resourcemanager.carbon.models.Operation; +import com.azure.resourcemanager.carbon.models.OperationDisplay; +import com.azure.resourcemanager.carbon.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.carbon.CarbonManager serviceManager; + + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.carbon.CarbonManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.carbon.CarbonManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsClientImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..d3ea6677d745 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.carbon.fluent.OperationsClient; +import com.azure.resourcemanager.carbon.fluent.models.OperationInner; +import com.azure.resourcemanager.carbon.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final CarbonOptimizationManagementClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(CarbonOptimizationManagementClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CarbonOptimizationManagementClientOperations to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "CarbonOptimizationMa") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Carbon/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsImpl.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsImpl.java new file mode 100644 index 000000000000..edfac87b7628 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/OperationsImpl.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.carbon.fluent.OperationsClient; +import com.azure.resourcemanager.carbon.fluent.models.OperationInner; +import com.azure.resourcemanager.carbon.models.Operation; +import com.azure.resourcemanager.carbon.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.carbon.CarbonManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, com.azure.resourcemanager.carbon.CarbonManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.carbon.CarbonManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/ResourceManagerUtils.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..f82e0c9e9cca --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/package-info.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/package-info.java new file mode 100644 index 000000000000..85045b602efd --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the implementations for CarbonOptimizationManagementClient. + * Carbon Optimization Client. + */ +package com.azure.resourcemanager.carbon.implementation; diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/AccessDecisionEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/AccessDecisionEnum.java new file mode 100644 index 000000000000..6d7ec2858dad --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/AccessDecisionEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum for Access Decision. + */ +public final class AccessDecisionEnum extends ExpandableStringEnum { + /** + * Static value Allowed for AccessDecisionEnum. + */ + public static final AccessDecisionEnum ALLOWED = fromString("Allowed"); + + /** + * Static value Denied for AccessDecisionEnum. + */ + public static final AccessDecisionEnum DENIED = fromString("Denied"); + + /** + * Creates a new instance of AccessDecisionEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public AccessDecisionEnum() { + } + + /** + * Creates or finds a AccessDecisionEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding AccessDecisionEnum. + */ + public static AccessDecisionEnum fromString(String name) { + return fromString(name, AccessDecisionEnum.class); + } + + /** + * Gets known AccessDecisionEnum values. + * + * @return known AccessDecisionEnum values. + */ + public static Collection values() { + return values(AccessDecisionEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ActionType.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ActionType.java new file mode 100644 index 000000000000..36dead8ca3f4 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ActionType.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Static value Internal for ActionType. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionData.java new file mode 100644 index 000000000000..6ac7ea2b7774 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionData.java @@ -0,0 +1,259 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The basic response for different query report, all query report result will have these information. + */ +@Fluent +public class CarbonEmissionData implements JsonSerializable { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.fromString("CarbonEmissionData"); + + /* + * Total carbon emissions for the specified query parameters, measured in kgCO2E. This value represents total + * emissions over the specified date range (e.g., March-June). + */ + private double latestMonthEmissions; + + /* + * Total carbon emissions for the previous month’s date range, which is the same period as the specified date range + * but shifted left by one month (e.g., if the specified range is March - June, the previous month’s range will be + * Feb - May). The value is measured in kgCO2E. + */ + private double previousMonthEmissions; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /** + * Creates an instance of CarbonEmissionData class. + */ + public CarbonEmissionData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the latestMonthEmissions property: Total carbon emissions for the specified query parameters, measured in + * kgCO2E. This value represents total emissions over the specified date range (e.g., March-June). + * + * @return the latestMonthEmissions value. + */ + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * Set the latestMonthEmissions property: Total carbon emissions for the specified query parameters, measured in + * kgCO2E. This value represents total emissions over the specified date range (e.g., March-June). + * + * @param latestMonthEmissions the latestMonthEmissions value to set. + * @return the CarbonEmissionData object itself. + */ + public CarbonEmissionData withLatestMonthEmissions(double latestMonthEmissions) { + this.latestMonthEmissions = latestMonthEmissions; + return this; + } + + /** + * Get the previousMonthEmissions property: Total carbon emissions for the previous month’s date range, which is the + * same period as the specified date range but shifted left by one month (e.g., if the specified range is March - + * June, the previous month’s range will be Feb - May). The value is measured in kgCO2E. + * + * @return the previousMonthEmissions value. + */ + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * Set the previousMonthEmissions property: Total carbon emissions for the previous month’s date range, which is the + * same period as the specified date range but shifted left by one month (e.g., if the specified range is March - + * June, the previous month’s range will be Feb - May). The value is measured in kgCO2E. + * + * @param previousMonthEmissions the previousMonthEmissions value to set. + * @return the CarbonEmissionData object itself. + */ + public CarbonEmissionData withPreviousMonthEmissions(double previousMonthEmissions) { + this.previousMonthEmissions = previousMonthEmissions; + return this; + } + + /** + * Get the monthOverMonthEmissionsChangeRatio property: The percentage change in carbon emissions between the + * current and previous DateRange. This is calculated as: (latestMonthEmissions - previousMonthEmissions) / + * previousMonthEmissions. + * + * @return the monthOverMonthEmissionsChangeRatio value. + */ + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * Set the monthOverMonthEmissionsChangeRatio property: The percentage change in carbon emissions between the + * current and previous DateRange. This is calculated as: (latestMonthEmissions - previousMonthEmissions) / + * previousMonthEmissions. + * + * @param monthOverMonthEmissionsChangeRatio the monthOverMonthEmissionsChangeRatio value to set. + * @return the CarbonEmissionData object itself. + */ + public CarbonEmissionData withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + this.monthOverMonthEmissionsChangeRatio = monthOverMonthEmissionsChangeRatio; + return this; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * Set the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @param monthlyEmissionsChangeValue the monthlyEmissionsChangeValue value to set. + * @return the CarbonEmissionData object itself. + */ + public CarbonEmissionData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + this.monthlyEmissionsChangeValue = monthlyEmissionsChangeValue; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", this.latestMonthEmissions); + jsonWriter.writeDoubleField("previousMonthEmissions", this.previousMonthEmissions); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", this.monthOverMonthEmissionsChangeRatio); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", this.monthlyEmissionsChangeValue); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionData if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionData. + */ + public static CarbonEmissionData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("dataType".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("ItemDetailsData".equals(discriminatorValue)) { + return CarbonEmissionItemDetailData.fromJson(readerToUse.reset()); + } else if ("MonthlySummaryData".equals(discriminatorValue)) { + return CarbonEmissionMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("OverallSummaryData".equals(discriminatorValue)) { + return CarbonEmissionOverallSummaryData.fromJson(readerToUse.reset()); + } else if ("TopItemsMonthlySummaryData".equals(discriminatorValue)) { + return CarbonEmissionTopItemMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("TopItemsSummaryData".equals(discriminatorValue)) { + return CarbonEmissionTopItemsSummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceItemDetailsData".equals(discriminatorValue)) { + return ResourceCarbonEmissionItemDetailData.fromJson(readerToUse.reset()); + } else if ("ResourceTopItemsMonthlySummaryData".equals(discriminatorValue)) { + return ResourceCarbonEmissionTopItemMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceTopItemsSummaryData".equals(discriminatorValue)) { + return ResourceCarbonEmissionTopItemsSummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceGroupItemDetailsData".equals(discriminatorValue)) { + return ResourceGroupCarbonEmissionItemDetailData.fromJson(readerToUse.reset()); + } else if ("ResourceGroupTopItemsMonthlySummaryData".equals(discriminatorValue)) { + return ResourceGroupCarbonEmissionTopItemMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceGroupTopItemsSummaryData".equals(discriminatorValue)) { + return ResourceGroupCarbonEmissionTopItemsSummaryData.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static CarbonEmissionData fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionData deserializedCarbonEmissionData = new CarbonEmissionData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionData.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionData.previousMonthEmissions = reader.getDouble(); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionData.dataType = ResponseDataTypeEnum.fromString(reader.getString()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionData.monthlyEmissionsChangeValue + = reader.getNullable(JsonReader::getDouble); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataAvailableDateRange.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataAvailableDateRange.java new file mode 100644 index 000000000000..c7409895644e --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataAvailableDateRange.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataAvailableDateRangeInner; + +/** + * An immutable client-side representation of CarbonEmissionDataAvailableDateRange. + */ +public interface CarbonEmissionDataAvailableDateRange { + /** + * Gets the startDate property: Start date parameter, format is yyyy-MM-dd. + * + * @return the startDate value. + */ + String startDate(); + + /** + * Gets the endDate property: End date parameter, format is yyyy-MM-dd. + * + * @return the endDate value. + */ + String endDate(); + + /** + * Gets the inner com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataAvailableDateRangeInner object. + * + * @return the inner object. + */ + CarbonEmissionDataAvailableDateRangeInner innerModel(); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataListResult.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataListResult.java new file mode 100644 index 000000000000..2b75ca8c5eee --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionDataListResult.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataListResultInner; +import java.util.List; + +/** + * An immutable client-side representation of CarbonEmissionDataListResult. + */ +public interface CarbonEmissionDataListResult { + /** + * Gets the value property: The CarbonEmissionData items on this page. + * + * @return the value value. + */ + List value(); + + /** + * Gets the skipToken property: The pagination token to fetch next page data, it's null or empty if it doesn't have + * next page data. + * + * @return the skipToken value. + */ + String skipToken(); + + /** + * Gets the subscriptionAccessDecisionList property: The access decision list for each input subscription. + * + * @return the subscriptionAccessDecisionList value. + */ + List subscriptionAccessDecisionList(); + + /** + * Gets the inner com.azure.resourcemanager.carbon.fluent.models.CarbonEmissionDataListResultInner object. + * + * @return the inner object. + */ + CarbonEmissionDataListResultInner innerModel(); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionItemDetailData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionItemDetailData.java new file mode 100644 index 000000000000..1a614f5b2839 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionItemDetailData.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for detailed carbon emissions. + */ +@Fluent +public final class CarbonEmissionItemDetailData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.ITEM_DETAILS_DATA; + + /* + * Item name, it can be resource name, resource type name, location, resource group name or subscriptionId. It + * depends on category type. + */ + private String itemName; + + /* + * Item category, see supported type value defined in CategoryTypeEnum + */ + private CategoryTypeEnum categoryType; + + /** + * Creates an instance of CarbonEmissionItemDetailData class. + */ + public CarbonEmissionItemDetailData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: Item name, it can be resource name, resource type name, location, resource group name + * or subscriptionId. It depends on category type. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: Item name, it can be resource name, resource type name, location, resource group name + * or subscriptionId. It depends on category type. + * + * @param itemName the itemName value to set. + * @return the CarbonEmissionItemDetailData object itself. + */ + public CarbonEmissionItemDetailData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: Item category, see supported type value defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Item category, see supported type value defined in CategoryTypeEnum. + * + * @param categoryType the categoryType value to set. + * @return the CarbonEmissionItemDetailData object itself. + */ + public CarbonEmissionItemDetailData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionItemDetailData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionItemDetailData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionItemDetailData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionItemDetailData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model CarbonEmissionItemDetailData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model CarbonEmissionItemDetailData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionItemDetailData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionItemDetailData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionItemDetailData if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionItemDetailData. + */ + public static CarbonEmissionItemDetailData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionItemDetailData deserializedCarbonEmissionItemDetailData = new CarbonEmissionItemDetailData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionItemDetailData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionMonthlySummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionMonthlySummaryData.java new file mode 100644 index 000000000000..ca99dffbae38 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionMonthlySummaryData.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Monthly Carbon Emissions Summary. + */ +@Fluent +public final class CarbonEmissionMonthlySummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.MONTHLY_SUMMARY_DATA; + + /* + * The date, representing the month, for which the emissions data is reported, formatted as yyyy-MM-dd (e.g., + * 2024-03-01) + */ + private String date; + + /* + * Carbon intensity for the specified month, typically in units of kgCO2E per unit of normalized usage + */ + private double carbonIntensity; + + /** + * Creates an instance of CarbonEmissionMonthlySummaryData class. + */ + public CarbonEmissionMonthlySummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the date property: The date, representing the month, for which the emissions data is reported, formatted as + * yyyy-MM-dd (e.g., 2024-03-01). + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Set the date property: The date, representing the month, for which the emissions data is reported, formatted as + * yyyy-MM-dd (e.g., 2024-03-01). + * + * @param date the date value to set. + * @return the CarbonEmissionMonthlySummaryData object itself. + */ + public CarbonEmissionMonthlySummaryData withDate(String date) { + this.date = date; + return this; + } + + /** + * Get the carbonIntensity property: Carbon intensity for the specified month, typically in units of kgCO2E per unit + * of normalized usage. + * + * @return the carbonIntensity value. + */ + public double carbonIntensity() { + return this.carbonIntensity; + } + + /** + * Set the carbonIntensity property: Carbon intensity for the specified month, typically in units of kgCO2E per unit + * of normalized usage. + * + * @param carbonIntensity the carbonIntensity value to set. + * @return the CarbonEmissionMonthlySummaryData object itself. + */ + public CarbonEmissionMonthlySummaryData withCarbonIntensity(double carbonIntensity) { + this.carbonIntensity = carbonIntensity; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionMonthlySummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionMonthlySummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionMonthlySummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionMonthlySummaryData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (date() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property date in model CarbonEmissionMonthlySummaryData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionMonthlySummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("date", this.date); + jsonWriter.writeDoubleField("carbonIntensity", this.carbonIntensity); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionMonthlySummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionMonthlySummaryData if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionMonthlySummaryData. + */ + public static CarbonEmissionMonthlySummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionMonthlySummaryData deserializedCarbonEmissionMonthlySummaryData + = new CarbonEmissionMonthlySummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("date".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.date = reader.getString(); + } else if ("carbonIntensity".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.carbonIntensity = reader.getDouble(); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionMonthlySummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionOverallSummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionOverallSummaryData.java new file mode 100644 index 000000000000..4f4232755246 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionOverallSummaryData.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Overall Carbon Emissions Summary. + */ +@Fluent +public final class CarbonEmissionOverallSummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.OVERALL_SUMMARY_DATA; + + /** + * Creates an instance of CarbonEmissionOverallSummaryData class. + */ + public CarbonEmissionOverallSummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionOverallSummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionOverallSummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionOverallSummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionOverallSummaryData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionOverallSummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionOverallSummaryData if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionOverallSummaryData. + */ + public static CarbonEmissionOverallSummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionOverallSummaryData deserializedCarbonEmissionOverallSummaryData + = new CarbonEmissionOverallSummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionOverallSummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemMonthlySummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemMonthlySummaryData.java new file mode 100644 index 000000000000..f2a0c75186f2 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemMonthlySummaryData.java @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Top Items Carbon Emissions by Month. + */ +@Fluent +public final class CarbonEmissionTopItemMonthlySummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.TOP_ITEMS_MONTHLY_SUMMARY_DATA; + + /* + * Item name, it can be resource name, resource type name, location, resource group name or subscriptionId. It + * depends on category type. + */ + private String itemName; + + /* + * Item category, see supported type value defined in CategoryTypeEnum + */ + private CategoryTypeEnum categoryType; + + /* + * The date, representing the month, for which the emissions data is reported, formatted as yyyy-MM-dd (e.g., + * 2024-03-01) + */ + private String date; + + /** + * Creates an instance of CarbonEmissionTopItemMonthlySummaryData class. + */ + public CarbonEmissionTopItemMonthlySummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: Item name, it can be resource name, resource type name, location, resource group name + * or subscriptionId. It depends on category type. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: Item name, it can be resource name, resource type name, location, resource group name + * or subscriptionId. It depends on category type. + * + * @param itemName the itemName value to set. + * @return the CarbonEmissionTopItemMonthlySummaryData object itself. + */ + public CarbonEmissionTopItemMonthlySummaryData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: Item category, see supported type value defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Item category, see supported type value defined in CategoryTypeEnum. + * + * @param categoryType the categoryType value to set. + * @return the CarbonEmissionTopItemMonthlySummaryData object itself. + */ + public CarbonEmissionTopItemMonthlySummaryData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the date property: The date, representing the month, for which the emissions data is reported, formatted as + * yyyy-MM-dd (e.g., 2024-03-01). + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Set the date property: The date, representing the month, for which the emissions data is reported, formatted as + * yyyy-MM-dd (e.g., 2024-03-01). + * + * @param date the date value to set. + * @return the CarbonEmissionTopItemMonthlySummaryData object itself. + */ + public CarbonEmissionTopItemMonthlySummaryData withDate(String date) { + this.date = date; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemMonthlySummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemMonthlySummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemMonthlySummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemMonthlySummaryData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model CarbonEmissionTopItemMonthlySummaryData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model CarbonEmissionTopItemMonthlySummaryData")); + } + if (date() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property date in model CarbonEmissionTopItemMonthlySummaryData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionTopItemMonthlySummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("date", this.date); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionTopItemMonthlySummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionTopItemMonthlySummaryData if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionTopItemMonthlySummaryData. + */ + public static CarbonEmissionTopItemMonthlySummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionTopItemMonthlySummaryData deserializedCarbonEmissionTopItemMonthlySummaryData + = new CarbonEmissionTopItemMonthlySummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("date".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.date = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionTopItemMonthlySummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemsSummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemsSummaryData.java new file mode 100644 index 000000000000..2bca66219b2b --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonEmissionTopItemsSummaryData.java @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Top Items by Category Type. + */ +@Fluent +public final class CarbonEmissionTopItemsSummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.TOP_ITEMS_SUMMARY_DATA; + + /* + * The identifier of the item being reported on, which could refer to the resource name, resource type name, + * location, resource group name, or subscription ID, depending on the specified category type. + */ + private String itemName; + + /* + * The category type of the item. This defines which dimension the emissions are aggregated by, and the supported + * values are defined in CategoryTypeEnum (e.g., Subscription, ResourceGroup, Resource, etc.). + */ + private CategoryTypeEnum categoryType; + + /** + * Creates an instance of CarbonEmissionTopItemsSummaryData class. + */ + public CarbonEmissionTopItemsSummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: The identifier of the item being reported on, which could refer to the resource name, + * resource type name, location, resource group name, or subscription ID, depending on the specified category type. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: The identifier of the item being reported on, which could refer to the resource name, + * resource type name, location, resource group name, or subscription ID, depending on the specified category type. + * + * @param itemName the itemName value to set. + * @return the CarbonEmissionTopItemsSummaryData object itself. + */ + public CarbonEmissionTopItemsSummaryData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: The category type of the item. This defines which dimension the emissions are + * aggregated by, and the supported values are defined in CategoryTypeEnum (e.g., Subscription, ResourceGroup, + * Resource, etc.). + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: The category type of the item. This defines which dimension the emissions are + * aggregated by, and the supported values are defined in CategoryTypeEnum (e.g., Subscription, ResourceGroup, + * Resource, etc.). + * + * @param categoryType the categoryType value to set. + * @return the CarbonEmissionTopItemsSummaryData object itself. + */ + public CarbonEmissionTopItemsSummaryData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemsSummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemsSummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemsSummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CarbonEmissionTopItemsSummaryData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model CarbonEmissionTopItemsSummaryData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model CarbonEmissionTopItemsSummaryData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionTopItemsSummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CarbonEmissionTopItemsSummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionTopItemsSummaryData if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CarbonEmissionTopItemsSummaryData. + */ + public static CarbonEmissionTopItemsSummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionTopItemsSummaryData deserializedCarbonEmissionTopItemsSummaryData + = new CarbonEmissionTopItemsSummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionTopItemsSummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonServices.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonServices.java new file mode 100644 index 000000000000..400c0e28f2d1 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CarbonServices.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of CarbonServices. + */ +public interface CarbonServices { + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results along with {@link Response}. + */ + Response queryCarbonEmissionReportsWithResponse(QueryFilter queryParameters, + Context context); + + /** + * API for Carbon Emissions Reports. + * + * @param queryParameters Query parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of carbon emission results. + */ + CarbonEmissionDataListResult queryCarbonEmissionReports(QueryFilter queryParameters); + + /** + * API for query carbon emission data available date range. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data along with {@link Response}. + */ + Response + queryCarbonEmissionDataAvailableDateRangeWithResponse(Context context); + + /** + * API for query carbon emission data available date range. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for available date range of carbon emission data. + */ + CarbonEmissionDataAvailableDateRange queryCarbonEmissionDataAvailableDateRange(); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CategoryTypeEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CategoryTypeEnum.java new file mode 100644 index 000000000000..30c650fb388b --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/CategoryTypeEnum.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Supported category types to be used with QueryParameter. Each type represents a different level of emissions data + * aggregation. + */ +public final class CategoryTypeEnum extends ExpandableStringEnum { + /** + * Static value Subscription for CategoryTypeEnum. + */ + public static final CategoryTypeEnum SUBSCRIPTION = fromString("Subscription"); + + /** + * Static value ResourceGroup for CategoryTypeEnum. + */ + public static final CategoryTypeEnum RESOURCE_GROUP = fromString("ResourceGroup"); + + /** + * Static value Location for CategoryTypeEnum. + */ + public static final CategoryTypeEnum LOCATION = fromString("Location"); + + /** + * Static value Resource for CategoryTypeEnum. + */ + public static final CategoryTypeEnum RESOURCE = fromString("Resource"); + + /** + * Static value ResourceType for CategoryTypeEnum. + */ + public static final CategoryTypeEnum RESOURCE_TYPE = fromString("ResourceType"); + + /** + * Creates a new instance of CategoryTypeEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public CategoryTypeEnum() { + } + + /** + * Creates or finds a CategoryTypeEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding CategoryTypeEnum. + */ + public static CategoryTypeEnum fromString(String name) { + return fromString(name, CategoryTypeEnum.class); + } + + /** + * Gets known CategoryTypeEnum values. + * + * @return known CategoryTypeEnum values. + */ + public static Collection values() { + return values(CategoryTypeEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/DateRange.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/DateRange.java new file mode 100644 index 000000000000..d867bcefec5e --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/DateRange.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.LocalDate; +import java.util.Objects; + +/** + * Date range to be used with QueryParameter, it should be within 12 months between start and end date. In certain + * cases, start and end dates must be the same date. + */ +@Fluent +public final class DateRange implements JsonSerializable { + /* + * Start date parameter in yyyy-MM-01 format. Only the first day of each month is accepted. + */ + private LocalDate start; + + /* + * End date parameter in yyyy-MM-01 format. Only the first day of each month is accepted. + */ + private LocalDate end; + + /** + * Creates an instance of DateRange class. + */ + public DateRange() { + } + + /** + * Get the start property: Start date parameter in yyyy-MM-01 format. Only the first day of each month is accepted. + * + * @return the start value. + */ + public LocalDate start() { + return this.start; + } + + /** + * Set the start property: Start date parameter in yyyy-MM-01 format. Only the first day of each month is accepted. + * + * @param start the start value to set. + * @return the DateRange object itself. + */ + public DateRange withStart(LocalDate start) { + this.start = start; + return this; + } + + /** + * Get the end property: End date parameter in yyyy-MM-01 format. Only the first day of each month is accepted. + * + * @return the end value. + */ + public LocalDate end() { + return this.end; + } + + /** + * Set the end property: End date parameter in yyyy-MM-01 format. Only the first day of each month is accepted. + * + * @param end the end value to set. + * @return the DateRange object itself. + */ + public DateRange withEnd(LocalDate end) { + this.end = end; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (start() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property start in model DateRange")); + } + if (end() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property end in model DateRange")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DateRange.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("start", Objects.toString(this.start, null)); + jsonWriter.writeStringField("end", Objects.toString(this.end, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DateRange from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DateRange if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DateRange. + */ + public static DateRange fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DateRange deserializedDateRange = new DateRange(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + deserializedDateRange.start + = reader.getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString())); + } else if ("end".equals(fieldName)) { + deserializedDateRange.end + = reader.getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDateRange; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/EmissionScopeEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/EmissionScopeEnum.java new file mode 100644 index 000000000000..5b13ad4f5a69 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/EmissionScopeEnum.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Supported carbon emission scopes to be used with QueryParameter, as defined by the GHG Protocol. At least one scope + * must be specified. The output will return a total of all specified scopes. + */ +public final class EmissionScopeEnum extends ExpandableStringEnum { + /** + * Static value Scope1 for EmissionScopeEnum. + */ + public static final EmissionScopeEnum SCOPE1 = fromString("Scope1"); + + /** + * Static value Scope2 for EmissionScopeEnum. + */ + public static final EmissionScopeEnum SCOPE2 = fromString("Scope2"); + + /** + * Static value Scope3 for EmissionScopeEnum. + */ + public static final EmissionScopeEnum SCOPE3 = fromString("Scope3"); + + /** + * Creates a new instance of EmissionScopeEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EmissionScopeEnum() { + } + + /** + * Creates or finds a EmissionScopeEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding EmissionScopeEnum. + */ + public static EmissionScopeEnum fromString(String name) { + return fromString(name, EmissionScopeEnum.class); + } + + /** + * Gets known EmissionScopeEnum values. + * + * @return known EmissionScopeEnum values. + */ + public static Collection values() { + return values(EmissionScopeEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ItemDetailsQueryFilter.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ItemDetailsQueryFilter.java new file mode 100644 index 000000000000..c7d10b9bd4be --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ItemDetailsQueryFilter.java @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Query Parameters for ItemDetailsReport. + */ +@Fluent +public final class ItemDetailsQueryFilter extends QueryFilter { + /* + * The ReportType requested for carbon emissions data. Required. Specifies how data is aggregated and displayed in + * the output, as explained in the ReportTypeEnum. + */ + private ReportTypeEnum reportType = ReportTypeEnum.ITEM_DETAILS_REPORT; + + /* + * Specifies the category type for detailed emissions data, such as Resource, ResourceGroup, ResourceType, Location, + * or Subscription. See supported types in CategoryTypeEnum. + */ + private CategoryTypeEnum categoryType; + + /* + * The column name to order the results by. See supported values in OrderByColumnEnum. + */ + private OrderByColumnEnum orderBy; + + /* + * Direction for sorting results. See supported values in SortDirectionEnum. + */ + private SortDirectionEnum sortDirection; + + /* + * Number of items to return in one request, max value is 5000. + */ + private int pageSize; + + /* + * Pagination token for fetching the next page of data. This token is nullable and will be returned in the previous + * response if additional data pages are available. + */ + private String skipToken; + + /** + * Creates an instance of ItemDetailsQueryFilter class. + */ + public ItemDetailsQueryFilter() { + } + + /** + * Get the reportType property: The ReportType requested for carbon emissions data. Required. Specifies how data is + * aggregated and displayed in the output, as explained in the ReportTypeEnum. + * + * @return the reportType value. + */ + @Override + public ReportTypeEnum reportType() { + return this.reportType; + } + + /** + * Get the categoryType property: Specifies the category type for detailed emissions data, such as Resource, + * ResourceGroup, ResourceType, Location, or Subscription. See supported types in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Specifies the category type for detailed emissions data, such as Resource, + * ResourceGroup, ResourceType, Location, or Subscription. See supported types in CategoryTypeEnum. + * + * @param categoryType the categoryType value to set. + * @return the ItemDetailsQueryFilter object itself. + */ + public ItemDetailsQueryFilter withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the orderBy property: The column name to order the results by. See supported values in OrderByColumnEnum. + * + * @return the orderBy value. + */ + public OrderByColumnEnum orderBy() { + return this.orderBy; + } + + /** + * Set the orderBy property: The column name to order the results by. See supported values in OrderByColumnEnum. + * + * @param orderBy the orderBy value to set. + * @return the ItemDetailsQueryFilter object itself. + */ + public ItemDetailsQueryFilter withOrderBy(OrderByColumnEnum orderBy) { + this.orderBy = orderBy; + return this; + } + + /** + * Get the sortDirection property: Direction for sorting results. See supported values in SortDirectionEnum. + * + * @return the sortDirection value. + */ + public SortDirectionEnum sortDirection() { + return this.sortDirection; + } + + /** + * Set the sortDirection property: Direction for sorting results. See supported values in SortDirectionEnum. + * + * @param sortDirection the sortDirection value to set. + * @return the ItemDetailsQueryFilter object itself. + */ + public ItemDetailsQueryFilter withSortDirection(SortDirectionEnum sortDirection) { + this.sortDirection = sortDirection; + return this; + } + + /** + * Get the pageSize property: Number of items to return in one request, max value is 5000. + * + * @return the pageSize value. + */ + public int pageSize() { + return this.pageSize; + } + + /** + * Set the pageSize property: Number of items to return in one request, max value is 5000. + * + * @param pageSize the pageSize value to set. + * @return the ItemDetailsQueryFilter object itself. + */ + public ItemDetailsQueryFilter withPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Get the skipToken property: Pagination token for fetching the next page of data. This token is nullable and will + * be returned in the previous response if additional data pages are available. + * + * @return the skipToken value. + */ + public String skipToken() { + return this.skipToken; + } + + /** + * Set the skipToken property: Pagination token for fetching the next page of data. This token is nullable and will + * be returned in the previous response if additional data pages are available. + * + * @param skipToken the skipToken value to set. + * @return the ItemDetailsQueryFilter object itself. + */ + public ItemDetailsQueryFilter withSkipToken(String skipToken) { + this.skipToken = skipToken; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ItemDetailsQueryFilter withDateRange(DateRange dateRange) { + super.withDateRange(dateRange); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ItemDetailsQueryFilter withSubscriptionList(List subscriptionList) { + super.withSubscriptionList(subscriptionList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ItemDetailsQueryFilter withResourceGroupUrlList(List resourceGroupUrlList) { + super.withResourceGroupUrlList(resourceGroupUrlList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ItemDetailsQueryFilter withResourceTypeList(List resourceTypeList) { + super.withResourceTypeList(resourceTypeList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ItemDetailsQueryFilter withLocationList(List locationList) { + super.withLocationList(locationList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ItemDetailsQueryFilter withCarbonScopeList(List carbonScopeList) { + super.withCarbonScopeList(carbonScopeList); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ItemDetailsQueryFilter")); + } + if (orderBy() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property orderBy in model ItemDetailsQueryFilter")); + } + if (sortDirection() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property sortDirection in model ItemDetailsQueryFilter")); + } + if (dateRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dateRange in model ItemDetailsQueryFilter")); + } else { + dateRange().validate(); + } + if (subscriptionList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionList in model ItemDetailsQueryFilter")); + } + if (carbonScopeList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property carbonScopeList in model ItemDetailsQueryFilter")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ItemDetailsQueryFilter.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dateRange", dateRange()); + jsonWriter.writeArrayField("subscriptionList", subscriptionList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("carbonScopeList", carbonScopeList(), + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("resourceGroupUrlList", resourceGroupUrlList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("resourceTypeList", resourceTypeList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("locationList", locationList(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("orderBy", this.orderBy == null ? null : this.orderBy.toString()); + jsonWriter.writeStringField("sortDirection", this.sortDirection == null ? null : this.sortDirection.toString()); + jsonWriter.writeIntField("pageSize", this.pageSize); + jsonWriter.writeStringField("reportType", this.reportType == null ? null : this.reportType.toString()); + jsonWriter.writeStringField("skipToken", this.skipToken); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ItemDetailsQueryFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ItemDetailsQueryFilter if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ItemDetailsQueryFilter. + */ + public static ItemDetailsQueryFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ItemDetailsQueryFilter deserializedItemDetailsQueryFilter = new ItemDetailsQueryFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateRange".equals(fieldName)) { + deserializedItemDetailsQueryFilter.withDateRange(DateRange.fromJson(reader)); + } else if ("subscriptionList".equals(fieldName)) { + List subscriptionList = reader.readArray(reader1 -> reader1.getString()); + deserializedItemDetailsQueryFilter.withSubscriptionList(subscriptionList); + } else if ("carbonScopeList".equals(fieldName)) { + List carbonScopeList + = reader.readArray(reader1 -> EmissionScopeEnum.fromString(reader1.getString())); + deserializedItemDetailsQueryFilter.withCarbonScopeList(carbonScopeList); + } else if ("resourceGroupUrlList".equals(fieldName)) { + List resourceGroupUrlList = reader.readArray(reader1 -> reader1.getString()); + deserializedItemDetailsQueryFilter.withResourceGroupUrlList(resourceGroupUrlList); + } else if ("resourceTypeList".equals(fieldName)) { + List resourceTypeList = reader.readArray(reader1 -> reader1.getString()); + deserializedItemDetailsQueryFilter.withResourceTypeList(resourceTypeList); + } else if ("locationList".equals(fieldName)) { + List locationList = reader.readArray(reader1 -> reader1.getString()); + deserializedItemDetailsQueryFilter.withLocationList(locationList); + } else if ("categoryType".equals(fieldName)) { + deserializedItemDetailsQueryFilter.categoryType = CategoryTypeEnum.fromString(reader.getString()); + } else if ("orderBy".equals(fieldName)) { + deserializedItemDetailsQueryFilter.orderBy = OrderByColumnEnum.fromString(reader.getString()); + } else if ("sortDirection".equals(fieldName)) { + deserializedItemDetailsQueryFilter.sortDirection = SortDirectionEnum.fromString(reader.getString()); + } else if ("pageSize".equals(fieldName)) { + deserializedItemDetailsQueryFilter.pageSize = reader.getInt(); + } else if ("reportType".equals(fieldName)) { + deserializedItemDetailsQueryFilter.reportType = ReportTypeEnum.fromString(reader.getString()); + } else if ("skipToken".equals(fieldName)) { + deserializedItemDetailsQueryFilter.skipToken = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedItemDetailsQueryFilter; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/MonthlySummaryReportQueryFilter.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/MonthlySummaryReportQueryFilter.java new file mode 100644 index 000000000000..5041fe74dc0b --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/MonthlySummaryReportQueryFilter.java @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Query filter parameter to configure MonthlySummaryReport queries. + */ +@Fluent +public final class MonthlySummaryReportQueryFilter extends QueryFilter { + /* + * The ReportType requested for carbon emissions data. Required. Specifies how data is aggregated and displayed in + * the output, as explained in the ReportTypeEnum. + */ + private ReportTypeEnum reportType = ReportTypeEnum.MONTHLY_SUMMARY_REPORT; + + /** + * Creates an instance of MonthlySummaryReportQueryFilter class. + */ + public MonthlySummaryReportQueryFilter() { + } + + /** + * Get the reportType property: The ReportType requested for carbon emissions data. Required. Specifies how data is + * aggregated and displayed in the output, as explained in the ReportTypeEnum. + * + * @return the reportType value. + */ + @Override + public ReportTypeEnum reportType() { + return this.reportType; + } + + /** + * {@inheritDoc} + */ + @Override + public MonthlySummaryReportQueryFilter withDateRange(DateRange dateRange) { + super.withDateRange(dateRange); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public MonthlySummaryReportQueryFilter withSubscriptionList(List subscriptionList) { + super.withSubscriptionList(subscriptionList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public MonthlySummaryReportQueryFilter withResourceGroupUrlList(List resourceGroupUrlList) { + super.withResourceGroupUrlList(resourceGroupUrlList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public MonthlySummaryReportQueryFilter withResourceTypeList(List resourceTypeList) { + super.withResourceTypeList(resourceTypeList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public MonthlySummaryReportQueryFilter withLocationList(List locationList) { + super.withLocationList(locationList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public MonthlySummaryReportQueryFilter withCarbonScopeList(List carbonScopeList) { + super.withCarbonScopeList(carbonScopeList); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (dateRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dateRange in model MonthlySummaryReportQueryFilter")); + } else { + dateRange().validate(); + } + if (subscriptionList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionList in model MonthlySummaryReportQueryFilter")); + } + if (carbonScopeList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property carbonScopeList in model MonthlySummaryReportQueryFilter")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(MonthlySummaryReportQueryFilter.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dateRange", dateRange()); + jsonWriter.writeArrayField("subscriptionList", subscriptionList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("carbonScopeList", carbonScopeList(), + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("resourceGroupUrlList", resourceGroupUrlList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("resourceTypeList", resourceTypeList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("locationList", locationList(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("reportType", this.reportType == null ? null : this.reportType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MonthlySummaryReportQueryFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MonthlySummaryReportQueryFilter if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MonthlySummaryReportQueryFilter. + */ + public static MonthlySummaryReportQueryFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MonthlySummaryReportQueryFilter deserializedMonthlySummaryReportQueryFilter + = new MonthlySummaryReportQueryFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateRange".equals(fieldName)) { + deserializedMonthlySummaryReportQueryFilter.withDateRange(DateRange.fromJson(reader)); + } else if ("subscriptionList".equals(fieldName)) { + List subscriptionList = reader.readArray(reader1 -> reader1.getString()); + deserializedMonthlySummaryReportQueryFilter.withSubscriptionList(subscriptionList); + } else if ("carbonScopeList".equals(fieldName)) { + List carbonScopeList + = reader.readArray(reader1 -> EmissionScopeEnum.fromString(reader1.getString())); + deserializedMonthlySummaryReportQueryFilter.withCarbonScopeList(carbonScopeList); + } else if ("resourceGroupUrlList".equals(fieldName)) { + List resourceGroupUrlList = reader.readArray(reader1 -> reader1.getString()); + deserializedMonthlySummaryReportQueryFilter.withResourceGroupUrlList(resourceGroupUrlList); + } else if ("resourceTypeList".equals(fieldName)) { + List resourceTypeList = reader.readArray(reader1 -> reader1.getString()); + deserializedMonthlySummaryReportQueryFilter.withResourceTypeList(resourceTypeList); + } else if ("locationList".equals(fieldName)) { + List locationList = reader.readArray(reader1 -> reader1.getString()); + deserializedMonthlySummaryReportQueryFilter.withLocationList(locationList); + } else if ("reportType".equals(fieldName)) { + deserializedMonthlySummaryReportQueryFilter.reportType + = ReportTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedMonthlySummaryReportQueryFilter; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operation.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operation.java new file mode 100644 index 000000000000..eabee5eb4c99 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.resourcemanager.carbon.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.carbon.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationDisplay.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationDisplay.java new file mode 100644 index 000000000000..7f3f998daa13 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationDisplay.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Localized display information for this particular operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + public OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationListResult.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationListResult.java new file mode 100644 index 000000000000..49d935cb69e6 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OperationListResult.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbon.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * List of operations supported by the resource provider + */ + private List value; + + /* + * URL to get the next set of operation list results (if there are any). + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + public OperationListResult() { + } + + /** + * Get the value property: List of operations supported by the resource provider. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: URL to get the next set of operation list results (if there are any). + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operations.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operations.java new file mode 100644 index 000000000000..98b87cc0b453 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OrderByColumnEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OrderByColumnEnum.java new file mode 100644 index 000000000000..c6baf19dae78 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OrderByColumnEnum.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Sorting is supported for columns in ItemDetailsReport. This object includes the column names that sorting is allowed + * for. Select one of these supported values. + */ +public final class OrderByColumnEnum extends ExpandableStringEnum { + /** + * Static value ItemName for OrderByColumnEnum. + */ + public static final OrderByColumnEnum ITEM_NAME = fromString("ItemName"); + + /** + * Static value LatestMonthEmissions for OrderByColumnEnum. + */ + public static final OrderByColumnEnum LATEST_MONTH_EMISSIONS = fromString("LatestMonthEmissions"); + + /** + * Static value PreviousMonthEmissions for OrderByColumnEnum. + */ + public static final OrderByColumnEnum PREVIOUS_MONTH_EMISSIONS = fromString("PreviousMonthEmissions"); + + /** + * Static value MonthOverMonthEmissionsChangeRatio for OrderByColumnEnum. + */ + public static final OrderByColumnEnum MONTH_OVER_MONTH_EMISSIONS_CHANGE_RATIO + = fromString("MonthOverMonthEmissionsChangeRatio"); + + /** + * Static value MonthlyEmissionsChangeValue for OrderByColumnEnum. + */ + public static final OrderByColumnEnum MONTHLY_EMISSIONS_CHANGE_VALUE = fromString("MonthlyEmissionsChangeValue"); + + /** + * Static value ResourceGroup for OrderByColumnEnum. + */ + public static final OrderByColumnEnum RESOURCE_GROUP = fromString("ResourceGroup"); + + /** + * Creates a new instance of OrderByColumnEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public OrderByColumnEnum() { + } + + /** + * Creates or finds a OrderByColumnEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding OrderByColumnEnum. + */ + public static OrderByColumnEnum fromString(String name) { + return fromString(name, OrderByColumnEnum.class); + } + + /** + * Gets known OrderByColumnEnum values. + * + * @return known OrderByColumnEnum values. + */ + public static Collection values() { + return values(OrderByColumnEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Origin.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Origin.java new file mode 100644 index 000000000000..313ab1ab039b --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Static value user for Origin. + */ + public static final Origin USER = fromString("user"); + + /** + * Static value system for Origin. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Static value user,system for Origin. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OverallSummaryReportQueryFilter.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OverallSummaryReportQueryFilter.java new file mode 100644 index 000000000000..b1f67fcd8fe8 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/OverallSummaryReportQueryFilter.java @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Query filter parameter to configure OverallSummaryReport queries. + */ +@Fluent +public final class OverallSummaryReportQueryFilter extends QueryFilter { + /* + * The ReportType requested for carbon emissions data. Required. Specifies how data is aggregated and displayed in + * the output, as explained in the ReportTypeEnum. + */ + private ReportTypeEnum reportType = ReportTypeEnum.OVERALL_SUMMARY_REPORT; + + /** + * Creates an instance of OverallSummaryReportQueryFilter class. + */ + public OverallSummaryReportQueryFilter() { + } + + /** + * Get the reportType property: The ReportType requested for carbon emissions data. Required. Specifies how data is + * aggregated and displayed in the output, as explained in the ReportTypeEnum. + * + * @return the reportType value. + */ + @Override + public ReportTypeEnum reportType() { + return this.reportType; + } + + /** + * {@inheritDoc} + */ + @Override + public OverallSummaryReportQueryFilter withDateRange(DateRange dateRange) { + super.withDateRange(dateRange); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public OverallSummaryReportQueryFilter withSubscriptionList(List subscriptionList) { + super.withSubscriptionList(subscriptionList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public OverallSummaryReportQueryFilter withResourceGroupUrlList(List resourceGroupUrlList) { + super.withResourceGroupUrlList(resourceGroupUrlList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public OverallSummaryReportQueryFilter withResourceTypeList(List resourceTypeList) { + super.withResourceTypeList(resourceTypeList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public OverallSummaryReportQueryFilter withLocationList(List locationList) { + super.withLocationList(locationList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public OverallSummaryReportQueryFilter withCarbonScopeList(List carbonScopeList) { + super.withCarbonScopeList(carbonScopeList); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (dateRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dateRange in model OverallSummaryReportQueryFilter")); + } else { + dateRange().validate(); + } + if (subscriptionList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionList in model OverallSummaryReportQueryFilter")); + } + if (carbonScopeList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property carbonScopeList in model OverallSummaryReportQueryFilter")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OverallSummaryReportQueryFilter.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dateRange", dateRange()); + jsonWriter.writeArrayField("subscriptionList", subscriptionList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("carbonScopeList", carbonScopeList(), + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("resourceGroupUrlList", resourceGroupUrlList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("resourceTypeList", resourceTypeList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("locationList", locationList(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("reportType", this.reportType == null ? null : this.reportType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OverallSummaryReportQueryFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OverallSummaryReportQueryFilter if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OverallSummaryReportQueryFilter. + */ + public static OverallSummaryReportQueryFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OverallSummaryReportQueryFilter deserializedOverallSummaryReportQueryFilter + = new OverallSummaryReportQueryFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateRange".equals(fieldName)) { + deserializedOverallSummaryReportQueryFilter.withDateRange(DateRange.fromJson(reader)); + } else if ("subscriptionList".equals(fieldName)) { + List subscriptionList = reader.readArray(reader1 -> reader1.getString()); + deserializedOverallSummaryReportQueryFilter.withSubscriptionList(subscriptionList); + } else if ("carbonScopeList".equals(fieldName)) { + List carbonScopeList + = reader.readArray(reader1 -> EmissionScopeEnum.fromString(reader1.getString())); + deserializedOverallSummaryReportQueryFilter.withCarbonScopeList(carbonScopeList); + } else if ("resourceGroupUrlList".equals(fieldName)) { + List resourceGroupUrlList = reader.readArray(reader1 -> reader1.getString()); + deserializedOverallSummaryReportQueryFilter.withResourceGroupUrlList(resourceGroupUrlList); + } else if ("resourceTypeList".equals(fieldName)) { + List resourceTypeList = reader.readArray(reader1 -> reader1.getString()); + deserializedOverallSummaryReportQueryFilter.withResourceTypeList(resourceTypeList); + } else if ("locationList".equals(fieldName)) { + List locationList = reader.readArray(reader1 -> reader1.getString()); + deserializedOverallSummaryReportQueryFilter.withLocationList(locationList); + } else if ("reportType".equals(fieldName)) { + deserializedOverallSummaryReportQueryFilter.reportType + = ReportTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOverallSummaryReportQueryFilter; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/QueryFilter.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/QueryFilter.java new file mode 100644 index 000000000000..5edd544a9bb3 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/QueryFilter.java @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Shared query filter parameter to configure carbon emissions data queries for all different report type defined in + * ReportTypeEnum. + */ +@Fluent +public class QueryFilter implements JsonSerializable { + /* + * The ReportType requested for carbon emissions data. Required. Specifies how data is aggregated and displayed in + * the output, as explained in the ReportTypeEnum. + */ + private ReportTypeEnum reportType = ReportTypeEnum.fromString("QueryFilter"); + + /* + * The start and end dates for carbon emissions data. Required. For ItemDetailsReport and TopItemsSummaryReport, + * only one month of data is supported at a time, so start and end dates should be equal within DateRange (e.g., + * start: 2024-06-01 and end: 2024-06-01). + */ + private DateRange dateRange; + + /* + * List of subscription IDs for which carbon emissions data is requested. Required. Each subscription ID should be + * in lowercase format. The max length of list is 100. + */ + private List subscriptionList; + + /* + * List of resource group URLs for carbon emissions data. Optional. Each URL must follow the format + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}', and should be in all lowercase. + */ + private List resourceGroupUrlList; + + /* + * List of resource types for carbon emissions data. Optional. Each resource type should be specified in lowercase, + * following the format 'microsoft.{service}/{resourceType}', e.g., 'microsoft.storage/storageaccounts'. + */ + private List resourceTypeList; + + /* + * List of locations(Azure Region Display Name) for carbon emissions data, with each location specified in lowercase + * (e.g., 'east us'). Optional. You can use the command 'az account list-locations -o table' to find Azure Region + * Display Names. + */ + private List locationList; + + /* + * List of carbon emission scopes. Required. Accepts one or more values from EmissionScopeEnum (e.g., Scope1, + * Scope2, Scope3) in list form. The output will include the total emissions for the specified scopes. + */ + private List carbonScopeList; + + /** + * Creates an instance of QueryFilter class. + */ + public QueryFilter() { + } + + /** + * Get the reportType property: The ReportType requested for carbon emissions data. Required. Specifies how data is + * aggregated and displayed in the output, as explained in the ReportTypeEnum. + * + * @return the reportType value. + */ + public ReportTypeEnum reportType() { + return this.reportType; + } + + /** + * Get the dateRange property: The start and end dates for carbon emissions data. Required. For ItemDetailsReport + * and TopItemsSummaryReport, only one month of data is supported at a time, so start and end dates should be equal + * within DateRange (e.g., start: 2024-06-01 and end: 2024-06-01). + * + * @return the dateRange value. + */ + public DateRange dateRange() { + return this.dateRange; + } + + /** + * Set the dateRange property: The start and end dates for carbon emissions data. Required. For ItemDetailsReport + * and TopItemsSummaryReport, only one month of data is supported at a time, so start and end dates should be equal + * within DateRange (e.g., start: 2024-06-01 and end: 2024-06-01). + * + * @param dateRange the dateRange value to set. + * @return the QueryFilter object itself. + */ + public QueryFilter withDateRange(DateRange dateRange) { + this.dateRange = dateRange; + return this; + } + + /** + * Get the subscriptionList property: List of subscription IDs for which carbon emissions data is requested. + * Required. Each subscription ID should be in lowercase format. The max length of list is 100. + * + * @return the subscriptionList value. + */ + public List subscriptionList() { + return this.subscriptionList; + } + + /** + * Set the subscriptionList property: List of subscription IDs for which carbon emissions data is requested. + * Required. Each subscription ID should be in lowercase format. The max length of list is 100. + * + * @param subscriptionList the subscriptionList value to set. + * @return the QueryFilter object itself. + */ + public QueryFilter withSubscriptionList(List subscriptionList) { + this.subscriptionList = subscriptionList; + return this; + } + + /** + * Get the resourceGroupUrlList property: List of resource group URLs for carbon emissions data. Optional. Each URL + * must follow the format '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}', and should be in all + * lowercase. + * + * @return the resourceGroupUrlList value. + */ + public List resourceGroupUrlList() { + return this.resourceGroupUrlList; + } + + /** + * Set the resourceGroupUrlList property: List of resource group URLs for carbon emissions data. Optional. Each URL + * must follow the format '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}', and should be in all + * lowercase. + * + * @param resourceGroupUrlList the resourceGroupUrlList value to set. + * @return the QueryFilter object itself. + */ + public QueryFilter withResourceGroupUrlList(List resourceGroupUrlList) { + this.resourceGroupUrlList = resourceGroupUrlList; + return this; + } + + /** + * Get the resourceTypeList property: List of resource types for carbon emissions data. Optional. Each resource type + * should be specified in lowercase, following the format 'microsoft.{service}/{resourceType}', e.g., + * 'microsoft.storage/storageaccounts'. + * + * @return the resourceTypeList value. + */ + public List resourceTypeList() { + return this.resourceTypeList; + } + + /** + * Set the resourceTypeList property: List of resource types for carbon emissions data. Optional. Each resource type + * should be specified in lowercase, following the format 'microsoft.{service}/{resourceType}', e.g., + * 'microsoft.storage/storageaccounts'. + * + * @param resourceTypeList the resourceTypeList value to set. + * @return the QueryFilter object itself. + */ + public QueryFilter withResourceTypeList(List resourceTypeList) { + this.resourceTypeList = resourceTypeList; + return this; + } + + /** + * Get the locationList property: List of locations(Azure Region Display Name) for carbon emissions data, with each + * location specified in lowercase (e.g., 'east us'). Optional. You can use the command 'az account list-locations + * -o table' to find Azure Region Display Names. + * + * @return the locationList value. + */ + public List locationList() { + return this.locationList; + } + + /** + * Set the locationList property: List of locations(Azure Region Display Name) for carbon emissions data, with each + * location specified in lowercase (e.g., 'east us'). Optional. You can use the command 'az account list-locations + * -o table' to find Azure Region Display Names. + * + * @param locationList the locationList value to set. + * @return the QueryFilter object itself. + */ + public QueryFilter withLocationList(List locationList) { + this.locationList = locationList; + return this; + } + + /** + * Get the carbonScopeList property: List of carbon emission scopes. Required. Accepts one or more values from + * EmissionScopeEnum (e.g., Scope1, Scope2, Scope3) in list form. The output will include the total emissions for + * the specified scopes. + * + * @return the carbonScopeList value. + */ + public List carbonScopeList() { + return this.carbonScopeList; + } + + /** + * Set the carbonScopeList property: List of carbon emission scopes. Required. Accepts one or more values from + * EmissionScopeEnum (e.g., Scope1, Scope2, Scope3) in list form. The output will include the total emissions for + * the specified scopes. + * + * @param carbonScopeList the carbonScopeList value to set. + * @return the QueryFilter object itself. + */ + public QueryFilter withCarbonScopeList(List carbonScopeList) { + this.carbonScopeList = carbonScopeList; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (dateRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property dateRange in model QueryFilter")); + } else { + dateRange().validate(); + } + if (subscriptionList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property subscriptionList in model QueryFilter")); + } + if (carbonScopeList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property carbonScopeList in model QueryFilter")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(QueryFilter.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dateRange", this.dateRange); + jsonWriter.writeArrayField("subscriptionList", this.subscriptionList, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("carbonScopeList", this.carbonScopeList, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeStringField("reportType", this.reportType == null ? null : this.reportType.toString()); + jsonWriter.writeArrayField("resourceGroupUrlList", this.resourceGroupUrlList, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("resourceTypeList", this.resourceTypeList, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("locationList", this.locationList, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QueryFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QueryFilter if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the QueryFilter. + */ + public static QueryFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("reportType".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("ItemDetailsReport".equals(discriminatorValue)) { + return ItemDetailsQueryFilter.fromJson(readerToUse.reset()); + } else if ("MonthlySummaryReport".equals(discriminatorValue)) { + return MonthlySummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("OverallSummaryReport".equals(discriminatorValue)) { + return OverallSummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("TopItemsMonthlySummaryReport".equals(discriminatorValue)) { + return TopItemsMonthlySummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("TopItemsSummaryReport".equals(discriminatorValue)) { + return TopItemsSummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static QueryFilter fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + QueryFilter deserializedQueryFilter = new QueryFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateRange".equals(fieldName)) { + deserializedQueryFilter.dateRange = DateRange.fromJson(reader); + } else if ("subscriptionList".equals(fieldName)) { + List subscriptionList = reader.readArray(reader1 -> reader1.getString()); + deserializedQueryFilter.subscriptionList = subscriptionList; + } else if ("carbonScopeList".equals(fieldName)) { + List carbonScopeList + = reader.readArray(reader1 -> EmissionScopeEnum.fromString(reader1.getString())); + deserializedQueryFilter.carbonScopeList = carbonScopeList; + } else if ("reportType".equals(fieldName)) { + deserializedQueryFilter.reportType = ReportTypeEnum.fromString(reader.getString()); + } else if ("resourceGroupUrlList".equals(fieldName)) { + List resourceGroupUrlList = reader.readArray(reader1 -> reader1.getString()); + deserializedQueryFilter.resourceGroupUrlList = resourceGroupUrlList; + } else if ("resourceTypeList".equals(fieldName)) { + List resourceTypeList = reader.readArray(reader1 -> reader1.getString()); + deserializedQueryFilter.resourceTypeList = resourceTypeList; + } else if ("locationList".equals(fieldName)) { + List locationList = reader.readArray(reader1 -> reader1.getString()); + deserializedQueryFilter.locationList = locationList; + } else { + reader.skipChildren(); + } + } + + return deserializedQueryFilter; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ReportTypeEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ReportTypeEnum.java new file mode 100644 index 000000000000..7765fbf4cdb7 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ReportTypeEnum.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum for Report Type, specifying different report formats for carbon emissions data. Each report type returns + * different aggregations of carbon emissions across various categories, date range, emissions scope, and other + * parameters. + */ +public final class ReportTypeEnum extends ExpandableStringEnum { + /** + * Static value OverallSummaryReport for ReportTypeEnum. + */ + public static final ReportTypeEnum OVERALL_SUMMARY_REPORT = fromString("OverallSummaryReport"); + + /** + * Static value MonthlySummaryReport for ReportTypeEnum. + */ + public static final ReportTypeEnum MONTHLY_SUMMARY_REPORT = fromString("MonthlySummaryReport"); + + /** + * Static value TopItemsSummaryReport for ReportTypeEnum. + */ + public static final ReportTypeEnum TOP_ITEMS_SUMMARY_REPORT = fromString("TopItemsSummaryReport"); + + /** + * Static value TopItemsMonthlySummaryReport for ReportTypeEnum. + */ + public static final ReportTypeEnum TOP_ITEMS_MONTHLY_SUMMARY_REPORT = fromString("TopItemsMonthlySummaryReport"); + + /** + * Static value ItemDetailsReport for ReportTypeEnum. + */ + public static final ReportTypeEnum ITEM_DETAILS_REPORT = fromString("ItemDetailsReport"); + + /** + * Creates a new instance of ReportTypeEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ReportTypeEnum() { + } + + /** + * Creates or finds a ReportTypeEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding ReportTypeEnum. + */ + public static ReportTypeEnum fromString(String name) { + return fromString(name, ReportTypeEnum.class); + } + + /** + * Gets known ReportTypeEnum values. + * + * @return known ReportTypeEnum values. + */ + public static Collection values() { + return values(ReportTypeEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionItemDetailData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionItemDetailData.java new file mode 100644 index 000000000000..56db5463b2a3 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionItemDetailData.java @@ -0,0 +1,366 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Resource detailed carbon emissions. + */ +@Fluent +public final class ResourceCarbonEmissionItemDetailData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.RESOURCE_ITEM_DETAILS_DATA; + + /* + * It's resource name. + */ + private String itemName; + + /* + * Resource Item category, see supported value defined in CategoryTypeEnum + */ + private CategoryTypeEnum categoryType; + + /* + * Subscription Id + */ + private String subscriptionId; + + /* + * Resource Group + */ + private String resourceGroup; + + /* + * The fully qualified resource ID for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{ + * resourceType}/{resourceName} + */ + private String resourceId; + + /* + * Resource Location (e.g., 'east us'). + */ + private String location; + + /* + * The type of resource, for example: microsoft.storage/storageaccounts + */ + private String resourceType; + + /** + * Creates an instance of ResourceCarbonEmissionItemDetailData class. + */ + public ResourceCarbonEmissionItemDetailData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: It's resource name. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: It's resource name. + * + * @param itemName the itemName value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: Resource Item category, see supported value defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Resource Item category, see supported value defined in CategoryTypeEnum. + * + * @param categoryType the categoryType value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Subscription Id. + * + * @param subscriptionId the subscriptionId value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the resourceGroup property: Resource Group. + * + * @return the resourceGroup value. + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * Set the resourceGroup property: Resource Group. + * + * @param resourceGroup the resourceGroup value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withResourceGroup(String resourceGroup) { + this.resourceGroup = resourceGroup; + return this; + } + + /** + * Get the resourceId property: The fully qualified resource ID for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: The fully qualified resource ID for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + * + * @param resourceId the resourceId value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the location property: Resource Location (e.g., 'east us'). + * + * @return the location value. + */ + public String location() { + return this.location; + } + + /** + * Set the location property: Resource Location (e.g., 'east us'). + * + * @param location the location value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the resourceType property: The type of resource, for example: microsoft.storage/storageaccounts. + * + * @return the resourceType value. + */ + public String resourceType() { + return this.resourceType; + } + + /** + * Set the resourceType property: The type of resource, for example: microsoft.storage/storageaccounts. + * + * @param resourceType the resourceType value to set. + * @return the ResourceCarbonEmissionItemDetailData object itself. + */ + public ResourceCarbonEmissionItemDetailData withResourceType(String resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionItemDetailData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionItemDetailData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionItemDetailData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionItemDetailData withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model ResourceCarbonEmissionItemDetailData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ResourceCarbonEmissionItemDetailData")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model ResourceCarbonEmissionItemDetailData")); + } + if (resourceGroup() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGroup in model ResourceCarbonEmissionItemDetailData")); + } + if (resourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceId in model ResourceCarbonEmissionItemDetailData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceCarbonEmissionItemDetailData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("resourceGroup", this.resourceGroup); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + jsonWriter.writeStringField("location", this.location); + jsonWriter.writeStringField("resourceType", this.resourceType); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceCarbonEmissionItemDetailData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceCarbonEmissionItemDetailData if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceCarbonEmissionItemDetailData. + */ + public static ResourceCarbonEmissionItemDetailData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceCarbonEmissionItemDetailData deserializedResourceCarbonEmissionItemDetailData + = new ResourceCarbonEmissionItemDetailData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("subscriptionId".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.subscriptionId = reader.getString(); + } else if ("resourceGroup".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.resourceGroup = reader.getString(); + } else if ("resourceId".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.resourceId = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else if ("location".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.location = reader.getString(); + } else if ("resourceType".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.resourceType = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceCarbonEmissionItemDetailData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java new file mode 100644 index 000000000000..7842dda06805 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for top items carbon emissions by month for resource. + */ +@Fluent +public final class ResourceCarbonEmissionTopItemMonthlySummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.RESOURCE_TOP_ITEMS_MONTHLY_SUMMARY_DATA; + + /* + * The resource name of resource for Resource Category + */ + private String itemName; + + /* + * Resource Item category + */ + private CategoryTypeEnum categoryType; + + /* + * Monthly date string, format is yyyy-MM-dd + */ + private String date; + + /* + * Subscription Id + */ + private String subscriptionId; + + /* + * Resource Group + */ + private String resourceGroup; + + /* + * The fully qualified resource ID for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{ + * resourceType}/{resourceName} + */ + private String resourceId; + + /** + * Creates an instance of ResourceCarbonEmissionTopItemMonthlySummaryData class. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: The resource name of resource for Resource Category. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: The resource name of resource for Resource Category. + * + * @param itemName the itemName value to set. + * @return the ResourceCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: Resource Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Resource Item category. + * + * @param categoryType the categoryType value to set. + * @return the ResourceCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the date property: Monthly date string, format is yyyy-MM-dd. + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Set the date property: Monthly date string, format is yyyy-MM-dd. + * + * @param date the date value to set. + * @return the ResourceCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData withDate(String date) { + this.date = date; + return this; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Subscription Id. + * + * @param subscriptionId the subscriptionId value to set. + * @return the ResourceCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the resourceGroup property: Resource Group. + * + * @return the resourceGroup value. + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * Set the resourceGroup property: Resource Group. + * + * @param resourceGroup the resourceGroup value to set. + * @return the ResourceCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData withResourceGroup(String resourceGroup) { + this.resourceGroup = resourceGroup; + return this; + } + + /** + * Get the resourceId property: The fully qualified resource ID for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: The fully qualified resource ID for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + * + * @param resourceId the resourceId value to set. + * @return the ResourceCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceCarbonEmissionTopItemMonthlySummaryData withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemMonthlySummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemMonthlySummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemMonthlySummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemMonthlySummaryData + withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model ResourceCarbonEmissionTopItemMonthlySummaryData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ResourceCarbonEmissionTopItemMonthlySummaryData")); + } + if (date() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property date in model ResourceCarbonEmissionTopItemMonthlySummaryData")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model ResourceCarbonEmissionTopItemMonthlySummaryData")); + } + if (resourceGroup() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGroup in model ResourceCarbonEmissionTopItemMonthlySummaryData")); + } + if (resourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceId in model ResourceCarbonEmissionTopItemMonthlySummaryData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceCarbonEmissionTopItemMonthlySummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("date", this.date); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("resourceGroup", this.resourceGroup); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceCarbonEmissionTopItemMonthlySummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceCarbonEmissionTopItemMonthlySummaryData if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceCarbonEmissionTopItemMonthlySummaryData. + */ + public static ResourceCarbonEmissionTopItemMonthlySummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceCarbonEmissionTopItemMonthlySummaryData deserializedResourceCarbonEmissionTopItemMonthlySummaryData + = new ResourceCarbonEmissionTopItemMonthlySummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData + .withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData + .withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("date".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.date = reader.getString(); + } else if ("subscriptionId".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.subscriptionId = reader.getString(); + } else if ("resourceGroup".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.resourceGroup = reader.getString(); + } else if ("resourceId".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.resourceId = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceCarbonEmissionTopItemMonthlySummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemsSummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemsSummaryData.java new file mode 100644 index 000000000000..4622e0399038 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceCarbonEmissionTopItemsSummaryData.java @@ -0,0 +1,315 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Top Items For Resource Category. + */ +@Fluent +public final class ResourceCarbonEmissionTopItemsSummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.RESOURCE_TOP_ITEMS_SUMMARY_DATA; + + /* + * The resource name of the resource for the Resource Category. + */ + private String itemName; + + /* + * The category type of the item. This defines which dimension the emissions are aggregated by, and the supported + * values are defined in CategoryTypeEnum (e.g., Subscription, ResourceGroup, Resource, etc.). + */ + private CategoryTypeEnum categoryType; + + /* + * Subscription Id + */ + private String subscriptionId; + + /* + * Resource group name + */ + private String resourceGroup; + + /* + * Resource Id, The URI of the resource for the Resource Category. This identifies the resource being reported. + */ + private String resourceId; + + /** + * Creates an instance of ResourceCarbonEmissionTopItemsSummaryData class. + */ + public ResourceCarbonEmissionTopItemsSummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: The resource name of the resource for the Resource Category. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: The resource name of the resource for the Resource Category. + * + * @param itemName the itemName value to set. + * @return the ResourceCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceCarbonEmissionTopItemsSummaryData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: The category type of the item. This defines which dimension the emissions are + * aggregated by, and the supported values are defined in CategoryTypeEnum (e.g., Subscription, ResourceGroup, + * Resource, etc.). + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: The category type of the item. This defines which dimension the emissions are + * aggregated by, and the supported values are defined in CategoryTypeEnum (e.g., Subscription, ResourceGroup, + * Resource, etc.). + * + * @param categoryType the categoryType value to set. + * @return the ResourceCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceCarbonEmissionTopItemsSummaryData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Subscription Id. + * + * @param subscriptionId the subscriptionId value to set. + * @return the ResourceCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceCarbonEmissionTopItemsSummaryData withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the resourceGroup property: Resource group name. + * + * @return the resourceGroup value. + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * Set the resourceGroup property: Resource group name. + * + * @param resourceGroup the resourceGroup value to set. + * @return the ResourceCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceCarbonEmissionTopItemsSummaryData withResourceGroup(String resourceGroup) { + this.resourceGroup = resourceGroup; + return this; + } + + /** + * Get the resourceId property: Resource Id, The URI of the resource for the Resource Category. This identifies the + * resource being reported. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: Resource Id, The URI of the resource for the Resource Category. This identifies the + * resource being reported. + * + * @param resourceId the resourceId value to set. + * @return the ResourceCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceCarbonEmissionTopItemsSummaryData withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemsSummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemsSummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemsSummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceCarbonEmissionTopItemsSummaryData + withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model ResourceCarbonEmissionTopItemsSummaryData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ResourceCarbonEmissionTopItemsSummaryData")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model ResourceCarbonEmissionTopItemsSummaryData")); + } + if (resourceGroup() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGroup in model ResourceCarbonEmissionTopItemsSummaryData")); + } + if (resourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceId in model ResourceCarbonEmissionTopItemsSummaryData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceCarbonEmissionTopItemsSummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("resourceGroup", this.resourceGroup); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceCarbonEmissionTopItemsSummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceCarbonEmissionTopItemsSummaryData if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceCarbonEmissionTopItemsSummaryData. + */ + public static ResourceCarbonEmissionTopItemsSummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceCarbonEmissionTopItemsSummaryData deserializedResourceCarbonEmissionTopItemsSummaryData + = new ResourceCarbonEmissionTopItemsSummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData + .withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("subscriptionId".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.subscriptionId = reader.getString(); + } else if ("resourceGroup".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.resourceGroup = reader.getString(); + } else if ("resourceId".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.resourceId = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceCarbonEmissionTopItemsSummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionItemDetailData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionItemDetailData.java new file mode 100644 index 000000000000..d8347c31db68 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionItemDetailData.java @@ -0,0 +1,277 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Resource Group detailed carbon emissions. + */ +@Fluent +public final class ResourceGroupCarbonEmissionItemDetailData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.RESOURCE_GROUP_ITEM_DETAILS_DATA; + + /* + * It's resource group name + */ + private String itemName; + + /* + * ResourceGroup Item category + */ + private CategoryTypeEnum categoryType; + + /* + * Subscription Id + */ + private String subscriptionId; + + /* + * Resource Group url, value format is '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}' + */ + private String resourceGroupUrl; + + /** + * Creates an instance of ResourceGroupCarbonEmissionItemDetailData class. + */ + public ResourceGroupCarbonEmissionItemDetailData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: It's resource group name. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: It's resource group name. + * + * @param itemName the itemName value to set. + * @return the ResourceGroupCarbonEmissionItemDetailData object itself. + */ + public ResourceGroupCarbonEmissionItemDetailData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: ResourceGroup Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: ResourceGroup Item category. + * + * @param categoryType the categoryType value to set. + * @return the ResourceGroupCarbonEmissionItemDetailData object itself. + */ + public ResourceGroupCarbonEmissionItemDetailData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Subscription Id. + * + * @param subscriptionId the subscriptionId value to set. + * @return the ResourceGroupCarbonEmissionItemDetailData object itself. + */ + public ResourceGroupCarbonEmissionItemDetailData withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the resourceGroupUrl property: Resource Group url, value format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @return the resourceGroupUrl value. + */ + public String resourceGroupUrl() { + return this.resourceGroupUrl; + } + + /** + * Set the resourceGroupUrl property: Resource Group url, value format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @param resourceGroupUrl the resourceGroupUrl value to set. + * @return the ResourceGroupCarbonEmissionItemDetailData object itself. + */ + public ResourceGroupCarbonEmissionItemDetailData withResourceGroupUrl(String resourceGroupUrl) { + this.resourceGroupUrl = resourceGroupUrl; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionItemDetailData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionItemDetailData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionItemDetailData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionItemDetailData + withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model ResourceGroupCarbonEmissionItemDetailData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ResourceGroupCarbonEmissionItemDetailData")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model ResourceGroupCarbonEmissionItemDetailData")); + } + if (resourceGroupUrl() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGroupUrl in model ResourceGroupCarbonEmissionItemDetailData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceGroupCarbonEmissionItemDetailData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("resourceGroupUrl", this.resourceGroupUrl); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceGroupCarbonEmissionItemDetailData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceGroupCarbonEmissionItemDetailData if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceGroupCarbonEmissionItemDetailData. + */ + public static ResourceGroupCarbonEmissionItemDetailData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceGroupCarbonEmissionItemDetailData deserializedResourceGroupCarbonEmissionItemDetailData + = new ResourceGroupCarbonEmissionItemDetailData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData + .withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("subscriptionId".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.subscriptionId = reader.getString(); + } else if ("resourceGroupUrl".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.resourceGroupUrl = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceGroupCarbonEmissionItemDetailData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java new file mode 100644 index 000000000000..df96fc285bdc --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java @@ -0,0 +1,316 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for top items carbon emissions by month for resource group. + */ +@Fluent +public final class ResourceGroupCarbonEmissionTopItemMonthlySummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.RESOURCE_GROUP_TOP_ITEMS_MONTHLY_SUMMARY_DATA; + + /* + * It's resource group name for ResourceGroup category + */ + private String itemName; + + /* + * ResourceGroup Item category + */ + private CategoryTypeEnum categoryType; + + /* + * Monthly date string, format is yyyy-MM-dd + */ + private String date; + + /* + * Subscription Id + */ + private String subscriptionId; + + /* + * Resource Group url, the format is '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}' + */ + private String resourceGroupUrl; + + /** + * Creates an instance of ResourceGroupCarbonEmissionTopItemMonthlySummaryData class. + */ + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: It's resource group name for ResourceGroup category. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: It's resource group name for ResourceGroup category. + * + * @param itemName the itemName value to set. + * @return the ResourceGroupCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: ResourceGroup Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: ResourceGroup Item category. + * + * @param categoryType the categoryType value to set. + * @return the ResourceGroupCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the date property: Monthly date string, format is yyyy-MM-dd. + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Set the date property: Monthly date string, format is yyyy-MM-dd. + * + * @param date the date value to set. + * @return the ResourceGroupCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData withDate(String date) { + this.date = date; + return this; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Subscription Id. + * + * @param subscriptionId the subscriptionId value to set. + * @return the ResourceGroupCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the resourceGroupUrl property: Resource Group url, the format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @return the resourceGroupUrl value. + */ + public String resourceGroupUrl() { + return this.resourceGroupUrl; + } + + /** + * Set the resourceGroupUrl property: Resource Group url, the format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @param resourceGroupUrl the resourceGroupUrl value to set. + * @return the ResourceGroupCarbonEmissionTopItemMonthlySummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData withResourceGroupUrl(String resourceGroupUrl) { + this.resourceGroupUrl = resourceGroupUrl; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData + withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemMonthlySummaryData + withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model ResourceGroupCarbonEmissionTopItemMonthlySummaryData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ResourceGroupCarbonEmissionTopItemMonthlySummaryData")); + } + if (date() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property date in model ResourceGroupCarbonEmissionTopItemMonthlySummaryData")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model ResourceGroupCarbonEmissionTopItemMonthlySummaryData")); + } + if (resourceGroupUrl() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGroupUrl in model ResourceGroupCarbonEmissionTopItemMonthlySummaryData")); + } + } + + private static final ClientLogger LOGGER + = new ClientLogger(ResourceGroupCarbonEmissionTopItemMonthlySummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("date", this.date); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("resourceGroupUrl", this.resourceGroupUrl); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceGroupCarbonEmissionTopItemMonthlySummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceGroupCarbonEmissionTopItemMonthlySummaryData if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceGroupCarbonEmissionTopItemMonthlySummaryData. + */ + public static ResourceGroupCarbonEmissionTopItemMonthlySummaryData fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + ResourceGroupCarbonEmissionTopItemMonthlySummaryData deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData + = new ResourceGroupCarbonEmissionTopItemMonthlySummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData + .withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData + .withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("date".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.date = reader.getString(); + } else if ("subscriptionId".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.subscriptionId + = reader.getString(); + } else if ("resourceGroupUrl".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.resourceGroupUrl + = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java new file mode 100644 index 000000000000..1a6fab1aa29d --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java @@ -0,0 +1,278 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response for Top Items For ResourceGroup. + */ +@Fluent +public final class ResourceGroupCarbonEmissionTopItemsSummaryData extends CarbonEmissionData { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.RESOURCE_GROUP_TOP_ITEMS_SUMMARY_DATA; + + /* + * The resourceGroup name of the resource for ResourceGroup Category + */ + private String itemName; + + /* + * ResourceGroup Item category + */ + private CategoryTypeEnum categoryType; + + /* + * Subscription Id + */ + private String subscriptionId; + + /* + * Resource Group url, value format is '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}' + */ + private String resourceGroupUrl; + + /** + * Creates an instance of ResourceGroupCarbonEmissionTopItemsSummaryData class. + */ + public ResourceGroupCarbonEmissionTopItemsSummaryData() { + } + + /** + * Get the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + @Override + public ResponseDataTypeEnum dataType() { + return this.dataType; + } + + /** + * Get the itemName property: The resourceGroup name of the resource for ResourceGroup Category. + * + * @return the itemName value. + */ + public String itemName() { + return this.itemName; + } + + /** + * Set the itemName property: The resourceGroup name of the resource for ResourceGroup Category. + * + * @param itemName the itemName value to set. + * @return the ResourceGroupCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemsSummaryData withItemName(String itemName) { + this.itemName = itemName; + return this; + } + + /** + * Get the categoryType property: ResourceGroup Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: ResourceGroup Item category. + * + * @param categoryType the categoryType value to set. + * @return the ResourceGroupCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemsSummaryData withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Subscription Id. + * + * @param subscriptionId the subscriptionId value to set. + * @return the ResourceGroupCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemsSummaryData withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the resourceGroupUrl property: Resource Group url, value format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @return the resourceGroupUrl value. + */ + public String resourceGroupUrl() { + return this.resourceGroupUrl; + } + + /** + * Set the resourceGroupUrl property: Resource Group url, value format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @param resourceGroupUrl the resourceGroupUrl value to set. + * @return the ResourceGroupCarbonEmissionTopItemsSummaryData object itself. + */ + public ResourceGroupCarbonEmissionTopItemsSummaryData withResourceGroupUrl(String resourceGroupUrl) { + this.resourceGroupUrl = resourceGroupUrl; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemsSummaryData withLatestMonthEmissions(double latestMonthEmissions) { + super.withLatestMonthEmissions(latestMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemsSummaryData withPreviousMonthEmissions(double previousMonthEmissions) { + super.withPreviousMonthEmissions(previousMonthEmissions); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemsSummaryData + withMonthOverMonthEmissionsChangeRatio(Double monthOverMonthEmissionsChangeRatio) { + super.withMonthOverMonthEmissionsChangeRatio(monthOverMonthEmissionsChangeRatio); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceGroupCarbonEmissionTopItemsSummaryData + withMonthlyEmissionsChangeValue(Double monthlyEmissionsChangeValue) { + super.withMonthlyEmissionsChangeValue(monthlyEmissionsChangeValue); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (itemName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property itemName in model ResourceGroupCarbonEmissionTopItemsSummaryData")); + } + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model ResourceGroupCarbonEmissionTopItemsSummaryData")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model ResourceGroupCarbonEmissionTopItemsSummaryData")); + } + if (resourceGroupUrl() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGroupUrl in model ResourceGroupCarbonEmissionTopItemsSummaryData")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceGroupCarbonEmissionTopItemsSummaryData.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("latestMonthEmissions", latestMonthEmissions()); + jsonWriter.writeDoubleField("previousMonthEmissions", previousMonthEmissions()); + jsonWriter.writeNumberField("monthOverMonthEmissionsChangeRatio", monthOverMonthEmissionsChangeRatio()); + jsonWriter.writeNumberField("monthlyEmissionsChangeValue", monthlyEmissionsChangeValue()); + jsonWriter.writeStringField("itemName", this.itemName); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("resourceGroupUrl", this.resourceGroupUrl); + jsonWriter.writeStringField("dataType", this.dataType == null ? null : this.dataType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceGroupCarbonEmissionTopItemsSummaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceGroupCarbonEmissionTopItemsSummaryData if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceGroupCarbonEmissionTopItemsSummaryData. + */ + public static ResourceGroupCarbonEmissionTopItemsSummaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceGroupCarbonEmissionTopItemsSummaryData deserializedResourceGroupCarbonEmissionTopItemsSummaryData + = new ResourceGroupCarbonEmissionTopItemsSummaryData(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData + .withLatestMonthEmissions(reader.getDouble()); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData + .withPreviousMonthEmissions(reader.getDouble()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData + .withMonthOverMonthEmissionsChangeRatio(reader.getNullable(JsonReader::getDouble)); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData + .withMonthlyEmissionsChangeValue(reader.getNullable(JsonReader::getDouble)); + } else if ("itemName".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.itemName = reader.getString(); + } else if ("categoryType".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("subscriptionId".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.subscriptionId = reader.getString(); + } else if ("resourceGroupUrl".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.resourceGroupUrl = reader.getString(); + } else if ("dataType".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceGroupCarbonEmissionTopItemsSummaryData; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResponseDataTypeEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResponseDataTypeEnum.java new file mode 100644 index 000000000000..27fc83b98cc1 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/ResponseDataTypeEnum.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The response data type of Carbon emission data. + */ +public final class ResponseDataTypeEnum extends ExpandableStringEnum { + /** + * Static value OverallSummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum OVERALL_SUMMARY_DATA = fromString("OverallSummaryData"); + + /** + * Static value MonthlySummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum MONTHLY_SUMMARY_DATA = fromString("MonthlySummaryData"); + + /** + * Static value TopItemsSummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum TOP_ITEMS_SUMMARY_DATA = fromString("TopItemsSummaryData"); + + /** + * Static value ResourceTopItemsSummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum RESOURCE_TOP_ITEMS_SUMMARY_DATA + = fromString("ResourceTopItemsSummaryData"); + + /** + * Static value ResourceGroupTopItemsSummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum RESOURCE_GROUP_TOP_ITEMS_SUMMARY_DATA + = fromString("ResourceGroupTopItemsSummaryData"); + + /** + * Static value TopItemsMonthlySummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum TOP_ITEMS_MONTHLY_SUMMARY_DATA = fromString("TopItemsMonthlySummaryData"); + + /** + * Static value ResourceTopItemsMonthlySummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum RESOURCE_TOP_ITEMS_MONTHLY_SUMMARY_DATA + = fromString("ResourceTopItemsMonthlySummaryData"); + + /** + * Static value ResourceGroupTopItemsMonthlySummaryData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum RESOURCE_GROUP_TOP_ITEMS_MONTHLY_SUMMARY_DATA + = fromString("ResourceGroupTopItemsMonthlySummaryData"); + + /** + * Static value ItemDetailsData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum ITEM_DETAILS_DATA = fromString("ItemDetailsData"); + + /** + * Static value ResourceItemDetailsData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum RESOURCE_ITEM_DETAILS_DATA = fromString("ResourceItemDetailsData"); + + /** + * Static value ResourceGroupItemDetailsData for ResponseDataTypeEnum. + */ + public static final ResponseDataTypeEnum RESOURCE_GROUP_ITEM_DETAILS_DATA + = fromString("ResourceGroupItemDetailsData"); + + /** + * Creates a new instance of ResponseDataTypeEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResponseDataTypeEnum() { + } + + /** + * Creates or finds a ResponseDataTypeEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResponseDataTypeEnum. + */ + public static ResponseDataTypeEnum fromString(String name) { + return fromString(name, ResponseDataTypeEnum.class); + } + + /** + * Gets known ResponseDataTypeEnum values. + * + * @return known ResponseDataTypeEnum values. + */ + public static Collection values() { + return values(ResponseDataTypeEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SortDirectionEnum.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SortDirectionEnum.java new file mode 100644 index 000000000000..2a435248283c --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SortDirectionEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Sorting is supported for columns in ItemDetailsReport. This object define sorting direction. + */ +public final class SortDirectionEnum extends ExpandableStringEnum { + /** + * Static value Desc for SortDirectionEnum. + */ + public static final SortDirectionEnum DESC = fromString("Desc"); + + /** + * Static value Asc for SortDirectionEnum. + */ + public static final SortDirectionEnum ASC = fromString("Asc"); + + /** + * Creates a new instance of SortDirectionEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SortDirectionEnum() { + } + + /** + * Creates or finds a SortDirectionEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding SortDirectionEnum. + */ + public static SortDirectionEnum fromString(String name) { + return fromString(name, SortDirectionEnum.class); + } + + /** + * Gets known SortDirectionEnum values. + * + * @return known SortDirectionEnum values. + */ + public static Collection values() { + return values(SortDirectionEnum.class); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SubscriptionAccessDecision.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SubscriptionAccessDecision.java new file mode 100644 index 000000000000..243ffa6c0420 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/SubscriptionAccessDecision.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Access Decision for each Subscription. + */ +@Fluent +public final class SubscriptionAccessDecision implements JsonSerializable { + /* + * Id of Subscription + */ + private String subscriptionId; + + /* + * Access decision to subscription + */ + private AccessDecisionEnum decision; + + /* + * The reason why access request got denied + */ + private String denialReason; + + /** + * Creates an instance of SubscriptionAccessDecision class. + */ + public SubscriptionAccessDecision() { + } + + /** + * Get the subscriptionId property: Id of Subscription. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: Id of Subscription. + * + * @param subscriptionId the subscriptionId value to set. + * @return the SubscriptionAccessDecision object itself. + */ + public SubscriptionAccessDecision withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the decision property: Access decision to subscription. + * + * @return the decision value. + */ + public AccessDecisionEnum decision() { + return this.decision; + } + + /** + * Set the decision property: Access decision to subscription. + * + * @param decision the decision value to set. + * @return the SubscriptionAccessDecision object itself. + */ + public SubscriptionAccessDecision withDecision(AccessDecisionEnum decision) { + this.decision = decision; + return this; + } + + /** + * Get the denialReason property: The reason why access request got denied. + * + * @return the denialReason value. + */ + public String denialReason() { + return this.denialReason; + } + + /** + * Set the denialReason property: The reason why access request got denied. + * + * @param denialReason the denialReason value to set. + * @return the SubscriptionAccessDecision object itself. + */ + public SubscriptionAccessDecision withDenialReason(String denialReason) { + this.denialReason = denialReason; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (subscriptionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionId in model SubscriptionAccessDecision")); + } + if (decision() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property decision in model SubscriptionAccessDecision")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SubscriptionAccessDecision.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeStringField("decision", this.decision == null ? null : this.decision.toString()); + jsonWriter.writeStringField("denialReason", this.denialReason); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubscriptionAccessDecision from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubscriptionAccessDecision if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SubscriptionAccessDecision. + */ + public static SubscriptionAccessDecision fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SubscriptionAccessDecision deserializedSubscriptionAccessDecision = new SubscriptionAccessDecision(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("subscriptionId".equals(fieldName)) { + deserializedSubscriptionAccessDecision.subscriptionId = reader.getString(); + } else if ("decision".equals(fieldName)) { + deserializedSubscriptionAccessDecision.decision = AccessDecisionEnum.fromString(reader.getString()); + } else if ("denialReason".equals(fieldName)) { + deserializedSubscriptionAccessDecision.denialReason = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSubscriptionAccessDecision; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsMonthlySummaryReportQueryFilter.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsMonthlySummaryReportQueryFilter.java new file mode 100644 index 000000000000..1b91d8584589 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsMonthlySummaryReportQueryFilter.java @@ -0,0 +1,256 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Query filter parameter to configure TopItemsMonthlySummaryReport queries. + */ +@Fluent +public final class TopItemsMonthlySummaryReportQueryFilter extends QueryFilter { + /* + * The ReportType requested for carbon emissions data. Required. Specifies how data is aggregated and displayed in + * the output, as explained in the ReportTypeEnum. + */ + private ReportTypeEnum reportType = ReportTypeEnum.TOP_ITEMS_MONTHLY_SUMMARY_REPORT; + + /* + * Specifies the category type to retrieve top-emitting items, aggregated by month. See supported types in + * CategoryTypeEnum. + */ + private CategoryTypeEnum categoryType; + + /* + * The number of top items to return, based on emissions. Must be between 1 and 10. + */ + private int topItems; + + /** + * Creates an instance of TopItemsMonthlySummaryReportQueryFilter class. + */ + public TopItemsMonthlySummaryReportQueryFilter() { + } + + /** + * Get the reportType property: The ReportType requested for carbon emissions data. Required. Specifies how data is + * aggregated and displayed in the output, as explained in the ReportTypeEnum. + * + * @return the reportType value. + */ + @Override + public ReportTypeEnum reportType() { + return this.reportType; + } + + /** + * Get the categoryType property: Specifies the category type to retrieve top-emitting items, aggregated by month. + * See supported types in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Specifies the category type to retrieve top-emitting items, aggregated by month. + * See supported types in CategoryTypeEnum. + * + * @param categoryType the categoryType value to set. + * @return the TopItemsMonthlySummaryReportQueryFilter object itself. + */ + public TopItemsMonthlySummaryReportQueryFilter withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the topItems property: The number of top items to return, based on emissions. Must be between 1 and 10. + * + * @return the topItems value. + */ + public int topItems() { + return this.topItems; + } + + /** + * Set the topItems property: The number of top items to return, based on emissions. Must be between 1 and 10. + * + * @param topItems the topItems value to set. + * @return the TopItemsMonthlySummaryReportQueryFilter object itself. + */ + public TopItemsMonthlySummaryReportQueryFilter withTopItems(int topItems) { + this.topItems = topItems; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsMonthlySummaryReportQueryFilter withDateRange(DateRange dateRange) { + super.withDateRange(dateRange); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsMonthlySummaryReportQueryFilter withSubscriptionList(List subscriptionList) { + super.withSubscriptionList(subscriptionList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsMonthlySummaryReportQueryFilter withResourceGroupUrlList(List resourceGroupUrlList) { + super.withResourceGroupUrlList(resourceGroupUrlList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsMonthlySummaryReportQueryFilter withResourceTypeList(List resourceTypeList) { + super.withResourceTypeList(resourceTypeList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsMonthlySummaryReportQueryFilter withLocationList(List locationList) { + super.withLocationList(locationList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsMonthlySummaryReportQueryFilter withCarbonScopeList(List carbonScopeList) { + super.withCarbonScopeList(carbonScopeList); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model TopItemsMonthlySummaryReportQueryFilter")); + } + if (dateRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dateRange in model TopItemsMonthlySummaryReportQueryFilter")); + } else { + dateRange().validate(); + } + if (subscriptionList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionList in model TopItemsMonthlySummaryReportQueryFilter")); + } + if (carbonScopeList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property carbonScopeList in model TopItemsMonthlySummaryReportQueryFilter")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopItemsMonthlySummaryReportQueryFilter.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dateRange", dateRange()); + jsonWriter.writeArrayField("subscriptionList", subscriptionList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("carbonScopeList", carbonScopeList(), + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("resourceGroupUrlList", resourceGroupUrlList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("resourceTypeList", resourceTypeList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("locationList", locationList(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeIntField("topItems", this.topItems); + jsonWriter.writeStringField("reportType", this.reportType == null ? null : this.reportType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopItemsMonthlySummaryReportQueryFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopItemsMonthlySummaryReportQueryFilter if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TopItemsMonthlySummaryReportQueryFilter. + */ + public static TopItemsMonthlySummaryReportQueryFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopItemsMonthlySummaryReportQueryFilter deserializedTopItemsMonthlySummaryReportQueryFilter + = new TopItemsMonthlySummaryReportQueryFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateRange".equals(fieldName)) { + deserializedTopItemsMonthlySummaryReportQueryFilter.withDateRange(DateRange.fromJson(reader)); + } else if ("subscriptionList".equals(fieldName)) { + List subscriptionList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsMonthlySummaryReportQueryFilter.withSubscriptionList(subscriptionList); + } else if ("carbonScopeList".equals(fieldName)) { + List carbonScopeList + = reader.readArray(reader1 -> EmissionScopeEnum.fromString(reader1.getString())); + deserializedTopItemsMonthlySummaryReportQueryFilter.withCarbonScopeList(carbonScopeList); + } else if ("resourceGroupUrlList".equals(fieldName)) { + List resourceGroupUrlList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsMonthlySummaryReportQueryFilter.withResourceGroupUrlList(resourceGroupUrlList); + } else if ("resourceTypeList".equals(fieldName)) { + List resourceTypeList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsMonthlySummaryReportQueryFilter.withResourceTypeList(resourceTypeList); + } else if ("locationList".equals(fieldName)) { + List locationList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsMonthlySummaryReportQueryFilter.withLocationList(locationList); + } else if ("categoryType".equals(fieldName)) { + deserializedTopItemsMonthlySummaryReportQueryFilter.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("topItems".equals(fieldName)) { + deserializedTopItemsMonthlySummaryReportQueryFilter.topItems = reader.getInt(); + } else if ("reportType".equals(fieldName)) { + deserializedTopItemsMonthlySummaryReportQueryFilter.reportType + = ReportTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedTopItemsMonthlySummaryReportQueryFilter; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsSummaryReportQueryFilter.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsSummaryReportQueryFilter.java new file mode 100644 index 000000000000..df3973bf6a35 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/TopItemsSummaryReportQueryFilter.java @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Query filter parameter to configure TopItemsSummaryReport queries. + */ +@Fluent +public final class TopItemsSummaryReportQueryFilter extends QueryFilter { + /* + * The ReportType requested for carbon emissions data. Required. Specifies how data is aggregated and displayed in + * the output, as explained in the ReportTypeEnum. + */ + private ReportTypeEnum reportType = ReportTypeEnum.TOP_ITEMS_SUMMARY_REPORT; + + /* + * Specifies the category type for which to retrieve top-emitting items. See supported values defined in + * CategoryTypeEnum. + */ + private CategoryTypeEnum categoryType; + + /* + * The number of top items to return, based on emissions. This value must be between 1 and 10. + */ + private int topItems; + + /** + * Creates an instance of TopItemsSummaryReportQueryFilter class. + */ + public TopItemsSummaryReportQueryFilter() { + } + + /** + * Get the reportType property: The ReportType requested for carbon emissions data. Required. Specifies how data is + * aggregated and displayed in the output, as explained in the ReportTypeEnum. + * + * @return the reportType value. + */ + @Override + public ReportTypeEnum reportType() { + return this.reportType; + } + + /** + * Get the categoryType property: Specifies the category type for which to retrieve top-emitting items. See + * supported values defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Set the categoryType property: Specifies the category type for which to retrieve top-emitting items. See + * supported values defined in CategoryTypeEnum. + * + * @param categoryType the categoryType value to set. + * @return the TopItemsSummaryReportQueryFilter object itself. + */ + public TopItemsSummaryReportQueryFilter withCategoryType(CategoryTypeEnum categoryType) { + this.categoryType = categoryType; + return this; + } + + /** + * Get the topItems property: The number of top items to return, based on emissions. This value must be between 1 + * and 10. + * + * @return the topItems value. + */ + public int topItems() { + return this.topItems; + } + + /** + * Set the topItems property: The number of top items to return, based on emissions. This value must be between 1 + * and 10. + * + * @param topItems the topItems value to set. + * @return the TopItemsSummaryReportQueryFilter object itself. + */ + public TopItemsSummaryReportQueryFilter withTopItems(int topItems) { + this.topItems = topItems; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsSummaryReportQueryFilter withDateRange(DateRange dateRange) { + super.withDateRange(dateRange); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsSummaryReportQueryFilter withSubscriptionList(List subscriptionList) { + super.withSubscriptionList(subscriptionList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsSummaryReportQueryFilter withResourceGroupUrlList(List resourceGroupUrlList) { + super.withResourceGroupUrlList(resourceGroupUrlList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsSummaryReportQueryFilter withResourceTypeList(List resourceTypeList) { + super.withResourceTypeList(resourceTypeList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsSummaryReportQueryFilter withLocationList(List locationList) { + super.withLocationList(locationList); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopItemsSummaryReportQueryFilter withCarbonScopeList(List carbonScopeList) { + super.withCarbonScopeList(carbonScopeList); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (categoryType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property categoryType in model TopItemsSummaryReportQueryFilter")); + } + if (dateRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dateRange in model TopItemsSummaryReportQueryFilter")); + } else { + dateRange().validate(); + } + if (subscriptionList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property subscriptionList in model TopItemsSummaryReportQueryFilter")); + } + if (carbonScopeList() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property carbonScopeList in model TopItemsSummaryReportQueryFilter")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopItemsSummaryReportQueryFilter.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dateRange", dateRange()); + jsonWriter.writeArrayField("subscriptionList", subscriptionList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("carbonScopeList", carbonScopeList(), + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("resourceGroupUrlList", resourceGroupUrlList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("resourceTypeList", resourceTypeList(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("locationList", locationList(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("categoryType", this.categoryType == null ? null : this.categoryType.toString()); + jsonWriter.writeIntField("topItems", this.topItems); + jsonWriter.writeStringField("reportType", this.reportType == null ? null : this.reportType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopItemsSummaryReportQueryFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopItemsSummaryReportQueryFilter if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TopItemsSummaryReportQueryFilter. + */ + public static TopItemsSummaryReportQueryFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopItemsSummaryReportQueryFilter deserializedTopItemsSummaryReportQueryFilter + = new TopItemsSummaryReportQueryFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateRange".equals(fieldName)) { + deserializedTopItemsSummaryReportQueryFilter.withDateRange(DateRange.fromJson(reader)); + } else if ("subscriptionList".equals(fieldName)) { + List subscriptionList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsSummaryReportQueryFilter.withSubscriptionList(subscriptionList); + } else if ("carbonScopeList".equals(fieldName)) { + List carbonScopeList + = reader.readArray(reader1 -> EmissionScopeEnum.fromString(reader1.getString())); + deserializedTopItemsSummaryReportQueryFilter.withCarbonScopeList(carbonScopeList); + } else if ("resourceGroupUrlList".equals(fieldName)) { + List resourceGroupUrlList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsSummaryReportQueryFilter.withResourceGroupUrlList(resourceGroupUrlList); + } else if ("resourceTypeList".equals(fieldName)) { + List resourceTypeList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsSummaryReportQueryFilter.withResourceTypeList(resourceTypeList); + } else if ("locationList".equals(fieldName)) { + List locationList = reader.readArray(reader1 -> reader1.getString()); + deserializedTopItemsSummaryReportQueryFilter.withLocationList(locationList); + } else if ("categoryType".equals(fieldName)) { + deserializedTopItemsSummaryReportQueryFilter.categoryType + = CategoryTypeEnum.fromString(reader.getString()); + } else if ("topItems".equals(fieldName)) { + deserializedTopItemsSummaryReportQueryFilter.topItems = reader.getInt(); + } else if ("reportType".equals(fieldName)) { + deserializedTopItemsSummaryReportQueryFilter.reportType + = ReportTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedTopItemsSummaryReportQueryFilter; + }); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/package-info.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/package-info.java new file mode 100644 index 000000000000..95af8dec79c3 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the data models for CarbonOptimizationManagementClient. + * Carbon Optimization Client. + */ +package com.azure.resourcemanager.carbon.models; diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/package-info.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/package-info.java new file mode 100644 index 000000000000..cd0191890cef --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/com/azure/resourcemanager/carbon/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the classes for CarbonOptimizationManagementClient. + * Carbon Optimization Client. + */ +package com.azure.resourcemanager.carbon; diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/java/module-info.java b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/module-info.java new file mode 100644 index 000000000000..897aa9308aa1 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/java/module-info.java @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.carbon { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.carbon; + exports com.azure.resourcemanager.carbon.fluent; + exports com.azure.resourcemanager.carbon.fluent.models; + exports com.azure.resourcemanager.carbon.models; + + opens com.azure.resourcemanager.carbon.fluent.models to com.azure.core; + opens com.azure.resourcemanager.carbon.models to com.azure.core; +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/proxy-config.json b/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/proxy-config.json new file mode 100644 index 000000000000..14692ab97ace --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.carbon.implementation.CarbonServicesClientImpl$CarbonServicesService"],["com.azure.resourcemanager.carbon.implementation.OperationsClientImpl$OperationsService"]] \ No newline at end of file diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/reflect-config.json b/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbon/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/azure-resourcemanager-carbon.properties b/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/azure-resourcemanager-carbon.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/main/resources/azure-resourcemanager-carbon.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java b/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java new file mode 100644 index 000000000000..90b1f9a151dd --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.generated; + +/** + * Samples for CarbonService QueryCarbonEmissionDataAvailableDateRange. + */ +public final class CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples { + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * carbonEmissionsDataAvailableDateRange.json + */ + /** + * Sample code: CarbonService_QueryCarbonEmissionDataAvailableDateRange. + * + * @param manager Entry point to CarbonManager. + */ + public static void + carbonServiceQueryCarbonEmissionDataAvailableDateRange(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionDataAvailableDateRangeWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java b/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java new file mode 100644 index 000000000000..1668142557ec --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java @@ -0,0 +1,531 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.generated; + +import com.azure.resourcemanager.carbon.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbon.models.DateRange; +import com.azure.resourcemanager.carbon.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbon.models.ItemDetailsQueryFilter; +import com.azure.resourcemanager.carbon.models.MonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbon.models.OrderByColumnEnum; +import com.azure.resourcemanager.carbon.models.OverallSummaryReportQueryFilter; +import com.azure.resourcemanager.carbon.models.SortDirectionEnum; +import com.azure.resourcemanager.carbon.models.TopItemsMonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbon.models.TopItemsSummaryReportQueryFilter; +import java.time.LocalDate; +import java.util.Arrays; + +/** + * Samples for CarbonService QueryCarbonEmissionReports. + */ +public final class CarbonServiceQueryCarbonEmissionReportsSamples { + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceTypeItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceTypeReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionTopNResourceReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsMonthlySummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Monthly Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionMonthlySummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new MonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withResourceGroupUrlList( + Arrays.asList("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-name")) + .withResourceTypeList( + Arrays.asList("microsoft.storage/storageaccounts", "microsoft.databricks/workspaces")) + .withLocationList(Arrays.asList("east us", "west us")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsSubscriptionItemDetailsReportReport.json + */ + /** + * Sample code: QueryCarbonEmission Subscriptions item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionSubscriptionsItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.SUBSCRIPTION) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceGroupItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceGroup item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionResourceGroupItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsOverallSummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionOverallSummaryReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new OverallSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2023-06-01")).withEnd(LocalDate.parse("2023-06-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNSubscriptionItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNSubscriptionsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.SUBSCRIPTION) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceGroupItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceGroupReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionResourceItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNSubscriptionItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNSubscriptionsMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.SUBSCRIPTION) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNLocationItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionTopNLocationsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.LOCATION) + .withTopItems(5), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceItemDetailsReportWithPaginationToken.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report with pagination token. + * + * @param manager Entry point to CarbonManager. + */ + public static void queryCarbonEmissionResourceItemDetailsReportWithPaginationToken( + com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100) + .withSkipToken("fakeTokenPlaceholder"), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsLocationItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission Location item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionLocationItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.LOCATION) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsMonthlySummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Monthly Summary Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionOverallMonthlySummaryReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new MonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsOverallSummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionOverallSummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse( + new OverallSummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2023-06-01")).withEnd(LocalDate.parse("2023-06-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000")) + .withResourceGroupUrlList( + Arrays.asList("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-name")) + .withResourceTypeList( + Arrays.asList("microsoft.storage/storageaccounts", "microsoft.databricks/workspaces")) + .withLocationList(Arrays.asList("east us", "west us")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNLocationItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNLocationsMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.LOCATION) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceTypeItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceTypeMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withTopItems(2), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsResourceTypeItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceType item details Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionResourceTypeItemDetailsReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new ItemDetailsQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-05-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withOrderBy(OrderByColumnEnum.LATEST_MONTH_EMISSIONS) + .withSortDirection(SortDirectionEnum.DESC) + .withPageSize(100), com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/ + * queryCarbonEmissionsTopNResourceGroupItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup monthly Report. + * + * @param manager Entry point to CarbonManager. + */ + public static void + queryCarbonEmissionTopNResourceGroupMonthlyReport(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.carbonServices() + .queryCarbonEmissionReportsWithResponse(new TopItemsMonthlySummaryReportQueryFilter() + .withDateRange( + new DateRange().withStart(LocalDate.parse("2024-03-01")).withEnd(LocalDate.parse("2024-05-01"))) + .withSubscriptionList(Arrays.asList("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000001,", "00000000-0000-0000-0000-000000000002", + "00000000-0000-0000-0000-000000000003", "00000000-0000-0000-0000-000000000004", + "00000000-0000-0000-0000-000000000005", "00000000-0000-0000-0000-000000000006", + "00000000-0000-0000-0000-000000000007", "00000000-0000-0000-0000-000000000008")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE3)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withTopItems(2), com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/OperationsListSamples.java b/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/OperationsListSamples.java new file mode 100644 index 000000000000..e2636ffefe65 --- /dev/null +++ b/sdk/carbon/azure-resourcemanager-carbon/src/samples/java/com/azure/resourcemanager/carbon/generated/OperationsListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.carbon.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: + * specification/carbon/resource-manager/Microsoft.Carbon/stable/2025-04-01/examples/listOperations.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to CarbonManager. + */ + public static void operationsList(com.azure.resourcemanager.carbon.CarbonManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/carbon/ci.yml b/sdk/carbon/ci.yml new file mode 100644 index 000000000000..691fbaf7e630 --- /dev/null +++ b/sdk/carbon/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/carbon/ci.yml + - sdk/carbon/azure-resourcemanager-carbon/ + exclude: + - sdk/carbon/pom.xml + - sdk/carbon/azure-resourcemanager-carbon/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/carbon/ci.yml + - sdk/carbon/azure-resourcemanager-carbon/ + exclude: + - sdk/carbon/pom.xml + - sdk/carbon/azure-resourcemanager-carbon/pom.xml + +parameters: + - name: release_azureresourcemanagercarbon + displayName: azure-resourcemanager-carbon + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: carbon + Artifacts: + - name: azure-resourcemanager-carbon + groupId: com.azure.resourcemanager + safeName: azureresourcemanagercarbon + releaseInBatch: ${{ parameters.release_azureresourcemanagercarbon }} diff --git a/sdk/carbon/pom.xml b/sdk/carbon/pom.xml new file mode 100644 index 000000000000..0b474005577f --- /dev/null +++ b/sdk/carbon/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-carbon-service + pom + 1.0.0 + + + azure-resourcemanager-carbon + +