diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 92dbd2e57617..2ae9df283abd 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-carbonoptimization;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..a0c6cbfce1c0 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ sdk/billingbenefits sdk/boms sdk/botservice + sdk/carbonoptimization sdk/changeanalysis sdk/chaos sdk/clientcore diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/CHANGELOG.md b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/CHANGELOG.md new file mode 100644 index 000000000000..c566af0dcc36 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2025-04-16) + +- Azure Resource Manager carbonoptimization client library for Java. This package contains Microsoft Azure SDK for carbonoptimization Management SDK. Carbon Report Resource Provider query API. 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-carbonoptimization Java SDK. diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/README.md b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/README.md new file mode 100644 index 000000000000..0b2ff6c71960 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager carbonoptimization client library for Java + +Azure Resource Manager carbonoptimization client library for Java. + +This package contains Microsoft Azure SDK for carbonoptimization Management SDK. Carbon Report Resource Provider query API. 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-carbonoptimization;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-carbonoptimization + 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(); +CarbonoptimizationManager manager = CarbonoptimizationManager + .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/carbonoptimization/azure-resourcemanager-carbonoptimization/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/carbonoptimization/azure-resourcemanager-carbonoptimization/SAMPLE.md b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/SAMPLE.md new file mode 100644 index 000000000000..affedb5a1e62 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/SAMPLE.md @@ -0,0 +1,568 @@ +# 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: 2025-04-01/carbonEmissionsDataAvailableDateRange.json + */ + /** + * Sample code: CarbonService_QueryCarbonEmissionDataAvailableDateRange. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void carbonServiceQueryCarbonEmissionDataAvailableDateRange( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionDataAvailableDateRangeWithResponse(com.azure.core.util.Context.NONE); + } +} +``` + +### CarbonService_QueryCarbonEmissionReports + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2025-04-01/listOperations.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void operationsList(com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Operations_List + +```java +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ItemDetailsQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.MonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.OrderByColumnEnum; +import com.azure.resourcemanager.carbonoptimization.models.OverallSummaryReportQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.SortDirectionEnum; +import com.azure.resourcemanager.carbonoptimization.models.TopItemsMonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.TopItemsSummaryReportQueryFilter; +import java.time.LocalDate; +import java.util.Arrays; + +/** + * Samples for CarbonService QueryCarbonEmissionReports. + */ +public final class CarbonServiceQueryCarbonEmissionReportsSamples { + /* + * x-ms-original-file: 2025-04-01/queryCarbonEmissionsTopNResourceTypeItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceTypeReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsMonthlySummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Monthly Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void + queryCarbonEmissionMonthlySummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsSubscriptionItemDetailsReportReport.json + */ + /** + * Sample code: QueryCarbonEmission Subscriptions item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionSubscriptionsItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceGroupItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceGroup item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceGroupItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsOverallSummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionOverallSummaryReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsTopNSubscriptionItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNSubscriptionsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceGroupItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceGroupReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNSubscriptionItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNSubscriptionsMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNLocationItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNLocationsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceItemDetailsReportWithPaginationToken.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report with pagination token. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceItemDetailsReportWithPaginationToken( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsLocationItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission Location item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionLocationItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsMonthlySummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Monthly Summary Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionOverallMonthlySummaryReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsOverallSummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void + queryCarbonEmissionOverallSummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsTopNLocationItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNLocationsMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceTypeItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceTypeMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceTypeItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceType item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceTypeItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceGroupItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceGroupMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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/carbonoptimization/azure-resourcemanager-carbonoptimization/pom.xml b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/pom.xml new file mode 100644 index 000000000000..91afca7f7a12 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-carbonoptimization + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for carbonoptimization Management + This package contains Microsoft Azure SDK for carbonoptimization Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Carbon Report Resource Provider query API. + 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 + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-management + 1.17.0 + + + com.azure + azure-core-test + 1.27.0-beta.8 + test + + + com.azure + azure-identity + 1.15.4 + test + + + diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/CarbonoptimizationManager.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/CarbonoptimizationManager.java new file mode 100644 index 000000000000..9ef39367b1fd --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/CarbonoptimizationManager.java @@ -0,0 +1,297 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization; + +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.carbonoptimization.fluent.CarbonClient; +import com.azure.resourcemanager.carbonoptimization.implementation.CarbonClientBuilder; +import com.azure.resourcemanager.carbonoptimization.implementation.CarbonServicesImpl; +import com.azure.resourcemanager.carbonoptimization.implementation.OperationsImpl; +import com.azure.resourcemanager.carbonoptimization.models.CarbonServices; +import com.azure.resourcemanager.carbonoptimization.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 CarbonoptimizationManager. + * Carbon Report Resource Provider query API. + */ +public final class CarbonoptimizationManager { + private Operations operations; + + private CarbonServices carbonServices; + + private final CarbonClient clientObject; + + private CarbonoptimizationManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new CarbonClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of carbonoptimization service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the carbonoptimization service API instance. + */ + public static CarbonoptimizationManager 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 carbonoptimization service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the carbonoptimization service API instance. + */ + public static CarbonoptimizationManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new CarbonoptimizationManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create CarbonoptimizationManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new CarbonoptimizationManager.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-carbonoptimization.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 carbonoptimization service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the carbonoptimization service API instance. + */ + public CarbonoptimizationManager 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.carbonoptimization") + .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 CarbonoptimizationManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * 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 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 wrapped service client CarbonClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client CarbonClient. + */ + public CarbonClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/CarbonClient.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/CarbonClient.java new file mode 100644 index 000000000000..78f30c130090 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/CarbonClient.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for CarbonClient class. + */ +public interface CarbonClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @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 OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the CarbonServicesClient object to access its operations. + * + * @return the CarbonServicesClient object. + */ + CarbonServicesClient getCarbonServices(); +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/CarbonServicesClient.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/CarbonServicesClient.java new file mode 100644 index 000000000000..a9bc21276ba8 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/CarbonServicesClient.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import com.azure.resourcemanager.carbonoptimization.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. + * @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 as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters); + + /** + * 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 as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters, Context context); + + /** + * 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/OperationsClient.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/OperationsClient.java new file mode 100644 index 000000000000..1011264eab36 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java new file mode 100644 index 000000000000..a1f879c014c6 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/CarbonEmissionDataAvailableDateRangeInner.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.fluent.models; + +import com.azure.core.annotation.Immutable; +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. + */ +@Immutable +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. + */ + private CarbonEmissionDataAvailableDateRangeInner() { + } + + /** + * Get the startDate property: Start date parameter, format is yyyy-MM-dd. + * + * @return the startDate value. + */ + public String startDate() { + return this.startDate; + } + + /** + * Get the endDate property: End date parameter, format is yyyy-MM-dd. + * + * @return the endDate value. + */ + public String endDate() { + return this.endDate; + } + + /** + * 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/CarbonEmissionDataInner.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/CarbonEmissionDataInner.java new file mode 100644 index 000000000000..a28272d54204 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/CarbonEmissionDataInner.java @@ -0,0 +1,271 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.fluent.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.carbonoptimization.models.CarbonEmissionItemDetailData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionMonthlySummaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionOverallSummaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionTopItemMonthlySummaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionTopItemsSummaryData; +import com.azure.resourcemanager.carbonoptimization.models.ResourceCarbonEmissionItemDetailData; +import com.azure.resourcemanager.carbonoptimization.models.ResourceCarbonEmissionTopItemMonthlySummaryData; +import com.azure.resourcemanager.carbonoptimization.models.ResourceCarbonEmissionTopItemsSummaryData; +import com.azure.resourcemanager.carbonoptimization.models.ResourceGroupCarbonEmissionItemDetailData; +import com.azure.resourcemanager.carbonoptimization.models.ResourceGroupCarbonEmissionTopItemMonthlySummaryData; +import com.azure.resourcemanager.carbonoptimization.models.ResourceGroupCarbonEmissionTopItemsSummaryData; +import com.azure.resourcemanager.carbonoptimization.models.ResponseDataTypeEnum; +import java.io.IOException; + +/** + * The basic response for different query report, all query report result will have these information. + */ +@Immutable +public class CarbonEmissionDataInner 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 CarbonEmissionDataInner class. + */ + protected CarbonEmissionDataInner() { + } + + /** + * 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 CarbonEmissionDataInner object itself. + */ + CarbonEmissionDataInner 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 CarbonEmissionDataInner object itself. + */ + CarbonEmissionDataInner 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 CarbonEmissionDataInner object itself. + */ + CarbonEmissionDataInner 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 CarbonEmissionDataInner object itself. + */ + CarbonEmissionDataInner 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 CarbonEmissionDataInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionDataInner 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 CarbonEmissionDataInner. + */ + public static CarbonEmissionDataInner 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 ("OverallSummaryData".equals(discriminatorValue)) { + return CarbonEmissionOverallSummaryData.fromJson(readerToUse.reset()); + } else if ("MonthlySummaryData".equals(discriminatorValue)) { + return CarbonEmissionMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("TopItemsSummaryData".equals(discriminatorValue)) { + return CarbonEmissionTopItemsSummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceTopItemsSummaryData".equals(discriminatorValue)) { + return ResourceCarbonEmissionTopItemsSummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceGroupTopItemsSummaryData".equals(discriminatorValue)) { + return ResourceGroupCarbonEmissionTopItemsSummaryData.fromJson(readerToUse.reset()); + } else if ("TopItemsMonthlySummaryData".equals(discriminatorValue)) { + return CarbonEmissionTopItemMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceTopItemsMonthlySummaryData".equals(discriminatorValue)) { + return ResourceCarbonEmissionTopItemMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("ResourceGroupTopItemsMonthlySummaryData".equals(discriminatorValue)) { + return ResourceGroupCarbonEmissionTopItemMonthlySummaryData.fromJson(readerToUse.reset()); + } else if ("ItemDetailsData".equals(discriminatorValue)) { + return CarbonEmissionItemDetailData.fromJson(readerToUse.reset()); + } else if ("ResourceItemDetailsData".equals(discriminatorValue)) { + return ResourceCarbonEmissionItemDetailData.fromJson(readerToUse.reset()); + } else if ("ResourceGroupItemDetailsData".equals(discriminatorValue)) { + return ResourceGroupCarbonEmissionItemDetailData.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static CarbonEmissionDataInner fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionDataInner deserializedCarbonEmissionDataInner = new CarbonEmissionDataInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("latestMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionDataInner.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionDataInner.previousMonthEmissions = reader.getDouble(); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionDataInner.dataType = ResponseDataTypeEnum.fromString(reader.getString()); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionDataInner.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionDataInner.monthlyEmissionsChangeValue + = reader.getNullable(JsonReader::getDouble); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionDataInner; + }); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/OperationInner.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/OperationInner.java new file mode 100644 index 000000000000..b5c1130db012 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/OperationInner.java @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.fluent.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.carbonoptimization.models.ActionType; +import com.azure.resourcemanager.carbonoptimization.models.OperationDisplay; +import com.azure.resourcemanager.carbonoptimization.models.Origin; +import java.io.IOException; + +/** + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +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 Azure + * Resource Manager/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; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private 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 Azure Resource Manager/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; + } + + /** + * 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: Extensible 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/package-info.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/models/package-info.java new file mode 100644 index 000000000000..3f7041504cc2 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/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) TypeSpec Code Generator. + +/** + * Package containing the inner data models for Carbonoptimization. + * Carbon Report Resource Provider query API. + */ +package com.azure.resourcemanager.carbonoptimization.fluent.models; diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/package-info.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/fluent/package-info.java new file mode 100644 index 000000000000..4f27b5752377 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/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) TypeSpec Code Generator. + +/** + * Package containing the service clients for Carbonoptimization. + * Carbon Report Resource Provider query API. + */ +package com.azure.resourcemanager.carbonoptimization.fluent; diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonClientBuilder.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonClientBuilder.java new file mode 100644 index 000000000000..4cb4bcb64de6 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 CarbonClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { CarbonClientImpl.class }) +public final class CarbonClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the CarbonClientBuilder. + */ + public CarbonClientBuilder 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 CarbonClientBuilder. + */ + public CarbonClientBuilder 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 CarbonClientBuilder. + */ + public CarbonClientBuilder 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 CarbonClientBuilder. + */ + public CarbonClientBuilder 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 CarbonClientBuilder. + */ + public CarbonClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of CarbonClientImpl with the provided parameters. + * + * @return an instance of CarbonClientImpl. + */ + public CarbonClientImpl 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(); + CarbonClientImpl client = new CarbonClientImpl(localPipeline, localSerializerAdapter, localDefaultPollInterval, + localEnvironment, localEndpoint); + return client; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonClientImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonClientImpl.java new file mode 100644 index 000000000000..9a90c31bbd94 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonClientImpl.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.fluent.CarbonClient; +import com.azure.resourcemanager.carbonoptimization.fluent.CarbonServicesClient; +import com.azure.resourcemanager.carbonoptimization.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 CarbonClientImpl type. + */ +@ServiceClient(builder = CarbonClientBuilder.class) +public final class CarbonClientImpl implements CarbonClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @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 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; + } + + /** + * 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; + } + + /** + * Initializes an instance of CarbonClient 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 Service host. + */ + CarbonClientImpl(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.operations = new OperationsClientImpl(this); + this.carbonServices = new CarbonServicesClientImpl(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(CarbonClientImpl.class); +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonEmissionDataAvailableDateRangeImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonEmissionDataAvailableDateRangeImpl.java new file mode 100644 index 000000000000..8bd47eedd7dc --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonEmissionDataAvailableDateRangeImpl.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.implementation; + +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionDataAvailableDateRange; + +public final class CarbonEmissionDataAvailableDateRangeImpl implements CarbonEmissionDataAvailableDateRange { + private CarbonEmissionDataAvailableDateRangeInner innerObject; + + private final com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager serviceManager; + + CarbonEmissionDataAvailableDateRangeImpl(CarbonEmissionDataAvailableDateRangeInner innerObject, + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager 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.carbonoptimization.CarbonoptimizationManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonEmissionDataImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonEmissionDataImpl.java new file mode 100644 index 000000000000..9dbeca43a700 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonEmissionDataImpl.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.implementation; + +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionData; +import com.azure.resourcemanager.carbonoptimization.models.ResponseDataTypeEnum; + +public final class CarbonEmissionDataImpl implements CarbonEmissionData { + private CarbonEmissionDataInner innerObject; + + private final com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager serviceManager; + + CarbonEmissionDataImpl(CarbonEmissionDataInner innerObject, + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public ResponseDataTypeEnum dataType() { + return this.innerModel().dataType(); + } + + public double latestMonthEmissions() { + return this.innerModel().latestMonthEmissions(); + } + + public double previousMonthEmissions() { + return this.innerModel().previousMonthEmissions(); + } + + public Double monthOverMonthEmissionsChangeRatio() { + return this.innerModel().monthOverMonthEmissionsChangeRatio(); + } + + public Double monthlyEmissionsChangeValue() { + return this.innerModel().monthlyEmissionsChangeValue(); + } + + public CarbonEmissionDataInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonServicesClientImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonServicesClientImpl.java new file mode 100644 index 000000000000..28775e1d7112 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonServicesClientImpl.java @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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.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.carbonoptimization.fluent.CarbonServicesClient; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import com.azure.resourcemanager.carbonoptimization.implementation.models.CarbonEmissionDataListResult; +import com.azure.resourcemanager.carbonoptimization.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 CarbonClientImpl client; + + /** + * Initializes an instance of CarbonServicesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CarbonServicesClientImpl(CarbonClientImpl client) { + this.service + = RestProxy.create(CarbonServicesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CarbonClientCarbonServices to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CarbonClientCarbonSe") + public interface CarbonServicesService { + @Headers({ "Content-Type: application/json" }) + @Post("/providers/Microsoft.Carbon/carbonEmissionReports") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> queryCarbonEmissionReports(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + @BodyParam("application/json") QueryFilter queryParameters, Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/providers/Microsoft.Carbon/queryCarbonEmissionDataAvailableDateRange") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> queryCarbonEmissionDataAvailableDateRange( + @HostParam("endpoint") 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 PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + queryCarbonEmissionReportsSinglePageAsync(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(), accept, queryParameters, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)) + .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 PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + queryCarbonEmissionReportsSinglePageAsync(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(), accept, queryParameters, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), null, null)); + } + + /** + * 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 as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux queryCarbonEmissionReportsAsync(QueryFilter queryParameters) { + return new PagedFlux<>(() -> queryCarbonEmissionReportsSinglePageAsync(queryParameters)); + } + + /** + * 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 as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux queryCarbonEmissionReportsAsync(QueryFilter queryParameters, + Context context) { + return new PagedFlux<>(() -> queryCarbonEmissionReportsSinglePageAsync(queryParameters, 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 as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters) { + return new PagedIterable<>(queryCarbonEmissionReportsAsync(queryParameters)); + } + + /** + * 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 as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters, + Context context) { + return new PagedIterable<>(queryCarbonEmissionReportsAsync(queryParameters, 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 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonServicesImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonServicesImpl.java new file mode 100644 index 000000000000..fa3aedb8d3a2 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/CarbonServicesImpl.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.implementation; + +import com.azure.core.http.rest.PagedIterable; +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.carbonoptimization.fluent.CarbonServicesClient; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionDataAvailableDateRange; +import com.azure.resourcemanager.carbonoptimization.models.CarbonServices; +import com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.CarbonoptimizationManager serviceManager; + + public CarbonServicesImpl(CarbonServicesClient innerClient, + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters) { + PagedIterable inner = this.serviceClient().queryCarbonEmissionReports(queryParameters); + return ResourceManagerUtils.mapPage(inner, inner1 -> new CarbonEmissionDataImpl(inner1, this.manager())); + } + + public PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters, Context context) { + PagedIterable inner + = this.serviceClient().queryCarbonEmissionReports(queryParameters, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new CarbonEmissionDataImpl(inner1, this.manager())); + } + + 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.carbonoptimization.CarbonoptimizationManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationImpl.java new file mode 100644 index 000000000000..abff9aa4ec91 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationImpl.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.implementation; + +import com.azure.resourcemanager.carbonoptimization.fluent.models.OperationInner; +import com.azure.resourcemanager.carbonoptimization.models.ActionType; +import com.azure.resourcemanager.carbonoptimization.models.Operation; +import com.azure.resourcemanager.carbonoptimization.models.OperationDisplay; +import com.azure.resourcemanager.carbonoptimization.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager serviceManager; + + OperationImpl(OperationInner innerObject, + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager 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.carbonoptimization.CarbonoptimizationManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationsClientImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..c1964003fe87 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.fluent.OperationsClient; +import com.azure.resourcemanager.carbonoptimization.fluent.models.OperationInner; +import com.azure.resourcemanager.carbonoptimization.implementation.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 CarbonClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(CarbonClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CarbonClientOperations to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CarbonClientOperatio") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Carbon/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") 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("endpoint") 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationsImpl.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationsImpl.java new file mode 100644 index 000000000000..26c693b659ca --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.fluent.OperationsClient; +import com.azure.resourcemanager.carbonoptimization.fluent.models.OperationInner; +import com.azure.resourcemanager.carbonoptimization.models.Operation; +import com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.CarbonoptimizationManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager 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.carbonoptimization.CarbonoptimizationManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/ResourceManagerUtils.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..547b3db8bfe3 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/models/CarbonEmissionDataListResult.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/models/CarbonEmissionDataListResult.java new file mode 100644 index 000000000000..56d0723db40b --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/models/CarbonEmissionDataListResult.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.implementation.models; + +import com.azure.core.annotation.Immutable; +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.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import com.azure.resourcemanager.carbonoptimization.models.SubscriptionAccessDecision; +import java.io.IOException; +import java.util.List; + +/** + * List of carbon emission results. + */ +@Immutable +public final class CarbonEmissionDataListResult 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 CarbonEmissionDataListResult class. + */ + private CarbonEmissionDataListResult() { + } + + /** + * Get the value property: The CarbonEmissionData items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * 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; + } + + /** + * Get the subscriptionAccessDecisionList property: The access decision list for each input subscription. + * + * @return the subscriptionAccessDecisionList value. + */ + public List subscriptionAccessDecisionList() { + return this.subscriptionAccessDecisionList; + } + + /** + * 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 CarbonEmissionDataListResult")); + } else { + value().forEach(e -> e.validate()); + } + if (subscriptionAccessDecisionList() != null) { + subscriptionAccessDecisionList().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CarbonEmissionDataListResult.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 CarbonEmissionDataListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CarbonEmissionDataListResult 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 CarbonEmissionDataListResult. + */ + public static CarbonEmissionDataListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CarbonEmissionDataListResult deserializedCarbonEmissionDataListResult = new CarbonEmissionDataListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> CarbonEmissionDataInner.fromJson(reader1)); + deserializedCarbonEmissionDataListResult.value = value; + } else if ("skipToken".equals(fieldName)) { + deserializedCarbonEmissionDataListResult.skipToken = reader.getString(); + } else if ("subscriptionAccessDecisionList".equals(fieldName)) { + List subscriptionAccessDecisionList + = reader.readArray(reader1 -> SubscriptionAccessDecision.fromJson(reader1)); + deserializedCarbonEmissionDataListResult.subscriptionAccessDecisionList + = subscriptionAccessDecisionList; + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionDataListResult; + }); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/models/OperationListResult.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/models/OperationListResult.java new file mode 100644 index 000000000000..f559d53c2bb3 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/models/OperationListResult.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.implementation.models; + +import com.azure.core.annotation.Immutable; +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.carbonoptimization.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 { + /* + * The Operation items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @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) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model OperationListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + 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 IllegalStateException If the deserialized JSON object was missing any required properties. + * @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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/package-info.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/implementation/package-info.java new file mode 100644 index 000000000000..58056a41d317 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/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) TypeSpec Code Generator. + +/** + * Package containing the implementations for Carbonoptimization. + * Carbon Report Resource Provider query API. + */ +package com.azure.resourcemanager.carbonoptimization.implementation; diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/AccessDecisionEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/AccessDecisionEnum.java new file mode 100644 index 000000000000..c1dd784170c1 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/AccessDecisionEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum for Access Decision. + */ +public final class AccessDecisionEnum extends ExpandableStringEnum { + /** + * Access allowed. + */ + public static final AccessDecisionEnum ALLOWED = fromString("Allowed"); + + /** + * Access denied. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ActionType.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ActionType.java new file mode 100644 index 000000000000..96ced2b02797 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ActionType.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Actions are for internal-only APIs. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionData.java new file mode 100644 index 000000000000..9e802c600e96 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionData.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; + +/** + * An immutable client-side representation of CarbonEmissionData. + */ +public interface CarbonEmissionData { + /** + * Gets the dataType property: The data type of the query result, indicating the format of the returned response. + * + * @return the dataType value. + */ + ResponseDataTypeEnum dataType(); + + /** + * Gets 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. + */ + double latestMonthEmissions(); + + /** + * Gets 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. + */ + double previousMonthEmissions(); + + /** + * Gets 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. + */ + Double monthOverMonthEmissionsChangeRatio(); + + /** + * Gets the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + Double monthlyEmissionsChangeValue(); + + /** + * Gets the inner com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner object. + * + * @return the inner object. + */ + CarbonEmissionDataInner innerModel(); +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionDataAvailableDateRange.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionDataAvailableDateRange.java new file mode 100644 index 000000000000..bc1ff7be917c --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionDataAvailableDateRange.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.resourcemanager.carbonoptimization.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.carbonoptimization.fluent.models.CarbonEmissionDataAvailableDateRangeInner object. + * + * @return the inner object. + */ + CarbonEmissionDataAvailableDateRangeInner innerModel(); +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionItemDetailData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionItemDetailData.java new file mode 100644 index 000000000000..d0d63bd673d1 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionItemDetailData.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for detailed carbon emissions. + */ +@Immutable +public final class CarbonEmissionItemDetailData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of CarbonEmissionItemDetailData class. + */ + private 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; + } + + /** + * Get the categoryType property: Item category, see supported type value defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionItemDetailData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionMonthlySummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionMonthlySummaryData.java new file mode 100644 index 000000000000..22fea95f803e --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionMonthlySummaryData.java @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Monthly Carbon Emissions Summary. + */ +@Immutable +public final class CarbonEmissionMonthlySummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of CarbonEmissionMonthlySummaryData class. + */ + private 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; + } + + /** + * 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; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionMonthlySummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionOverallSummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionOverallSummaryData.java new file mode 100644 index 000000000000..82be262b00c3 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionOverallSummaryData.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Overall Carbon Emissions Summary. + */ +@Immutable +public final class CarbonEmissionOverallSummaryData extends CarbonEmissionDataInner { + /* + * The data type of the query result, indicating the format of the returned response. + */ + private ResponseDataTypeEnum dataType = ResponseDataTypeEnum.OVERALL_SUMMARY_DATA; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of CarbonEmissionOverallSummaryData class. + */ + private 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; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.monthlyEmissionsChangeValue + = reader.getNullable(JsonReader::getDouble); + } else if ("dataType".equals(fieldName)) { + deserializedCarbonEmissionOverallSummaryData.dataType + = ResponseDataTypeEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCarbonEmissionOverallSummaryData; + }); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionTopItemMonthlySummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionTopItemMonthlySummaryData.java new file mode 100644 index 000000000000..d1f88b293363 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionTopItemMonthlySummaryData.java @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Top Items Carbon Emissions by Month. + */ +@Immutable +public final class CarbonEmissionTopItemMonthlySummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of CarbonEmissionTopItemMonthlySummaryData class. + */ + private 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; + } + + /** + * Get the categoryType property: Item category, see supported type value defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * 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; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionTopItemMonthlySummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionTopItemsSummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionTopItemsSummaryData.java new file mode 100644 index 000000000000..5fd82ba5d468 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonEmissionTopItemsSummaryData.java @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Top Items by Category Type. + */ +@Immutable +public final class CarbonEmissionTopItemsSummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of CarbonEmissionTopItemsSummaryData class. + */ + private 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; + } + + /** + * 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; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedCarbonEmissionTopItemsSummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonServices.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonServices.java new file mode 100644 index 000000000000..fdbfbccf56cf --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CarbonServices.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.http.rest.PagedIterable; +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. + * @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 as paginated response with {@link PagedIterable}. + */ + PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters); + + /** + * 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 as paginated response with {@link PagedIterable}. + */ + PagedIterable queryCarbonEmissionReports(QueryFilter queryParameters, Context context); + + /** + * 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CategoryTypeEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CategoryTypeEnum.java new file mode 100644 index 000000000000..3727b74495aa --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/CategoryTypeEnum.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * Emissions aggregated at the subscription level. + */ + public static final CategoryTypeEnum SUBSCRIPTION = fromString("Subscription"); + + /** + * Emissions aggregated at the resource group level. + */ + public static final CategoryTypeEnum RESOURCE_GROUP = fromString("ResourceGroup"); + + /** + * Emissions aggregated at the location level. + */ + public static final CategoryTypeEnum LOCATION = fromString("Location"); + + /** + * Emissions aggregated at the resource level. + */ + public static final CategoryTypeEnum RESOURCE = fromString("Resource"); + + /** + * Emissions aggregated at the resource type level. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/DateRange.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/DateRange.java new file mode 100644 index 000000000000..38d3af714638 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/DateRange.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/EmissionScopeEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/EmissionScopeEnum.java new file mode 100644 index 000000000000..b9edc587f67e --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/EmissionScopeEnum.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * Scope1 carbon emission. + */ + public static final EmissionScopeEnum SCOPE1 = fromString("Scope1"); + + /** + * Scope2 carbon emission. + */ + public static final EmissionScopeEnum SCOPE2 = fromString("Scope2"); + + /** + * Scope3 carbon emission. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ItemDetailsQueryFilter.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ItemDetailsQueryFilter.java new file mode 100644 index 000000000000..a1c7bbe47edb --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ItemDetailsQueryFilter.java @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/MonthlySummaryReportQueryFilter.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/MonthlySummaryReportQueryFilter.java new file mode 100644 index 000000000000..0b4104a00bc2 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/MonthlySummaryReportQueryFilter.java @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Operation.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Operation.java new file mode 100644 index 000000000000..b83cc62a8cbc --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.resourcemanager.carbonoptimization.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 Azure Resource Manager/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: Extensible 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.carbonoptimization.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OperationDisplay.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OperationDisplay.java new file mode 100644 index 000000000000..c745bfc94288 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OperationDisplay.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 and 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. + */ + private 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Operations.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Operations.java new file mode 100644 index 000000000000..138c9c969679 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OrderByColumnEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OrderByColumnEnum.java new file mode 100644 index 000000000000..09771086d535 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OrderByColumnEnum.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * The itemName filed in ItemDetailsReport result, see CarbonEmissionItemDetailData for more information. + */ + public static final OrderByColumnEnum ITEM_NAME = fromString("ItemName"); + + /** + * The latestMonthEmissions filed in ItemDetailsReport result, see CarbonEmissionItemDetailData for more + * information. + */ + public static final OrderByColumnEnum LATEST_MONTH_EMISSIONS = fromString("LatestMonthEmissions"); + + /** + * The previousMonthEmissions filed in ItemDetailsReport result, see CarbonEmissionItemDetailData for more + * information. + */ + public static final OrderByColumnEnum PREVIOUS_MONTH_EMISSIONS = fromString("PreviousMonthEmissions"); + + /** + * The monthOverMonthEmissionsChangeRatio filed in ItemDetailsReport result, see CarbonEmissionItemDetailData for + * more information. + */ + public static final OrderByColumnEnum MONTH_OVER_MONTH_EMISSIONS_CHANGE_RATIO + = fromString("MonthOverMonthEmissionsChangeRatio"); + + /** + * The monthlyEmissionsChangeValue filed in ItemDetailsReport result, see CarbonEmissionItemDetailData for more + * information. + */ + public static final OrderByColumnEnum MONTHLY_EMISSIONS_CHANGE_VALUE = fromString("MonthlyEmissionsChangeValue"); + + /** + * The resourceGroup filed in ResourceCarbonEmissionItemDetailData result, see ResourceCarbonEmissionItemDetailData + * for more information. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Origin.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Origin.java new file mode 100644 index 000000000000..26e025e8e8ed --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * Indicates the operation is initiated by a user. + */ + public static final Origin USER = fromString("user"); + + /** + * Indicates the operation is initiated by a system. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Indicates the operation is initiated by a user or system. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OverallSummaryReportQueryFilter.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OverallSummaryReportQueryFilter.java new file mode 100644 index 000000000000..ea9db8b4419c --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/OverallSummaryReportQueryFilter.java @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/QueryFilter.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/QueryFilter.java new file mode 100644 index 000000000000..20142dc1100f --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/QueryFilter.java @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 ("OverallSummaryReport".equals(discriminatorValue)) { + return OverallSummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("MonthlySummaryReport".equals(discriminatorValue)) { + return MonthlySummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("TopItemsSummaryReport".equals(discriminatorValue)) { + return TopItemsSummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("TopItemsMonthlySummaryReport".equals(discriminatorValue)) { + return TopItemsMonthlySummaryReportQueryFilter.fromJson(readerToUse.reset()); + } else if ("ItemDetailsReport".equals(discriminatorValue)) { + return ItemDetailsQueryFilter.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ReportTypeEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ReportTypeEnum.java new file mode 100644 index 000000000000..a716dd0766bb --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ReportTypeEnum.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * Overall summary report provides total carbon emissions for the specified date range and query parameters, as well + * as comparative values for a high-level overview. This report type can accept different values in the start and + * end fields within DateRange (e.g., start: 2024-03-01 and end: 2024-06-01). + */ + public static final ReportTypeEnum OVERALL_SUMMARY_REPORT = fromString("OverallSummaryReport"); + + /** + * MonthlySummaryReport provides carbon emissions data by month for the specified query parameters. This report type + * can accept different values in the start and end fields within DateRange (e.g., start: 2024-03-01 and end: + * 2024-06-01). + */ + public static final ReportTypeEnum MONTHLY_SUMMARY_REPORT = fromString("MonthlySummaryReport"); + + /** + * TopItemsSummaryReport provides the N highest-emitting items for the specified query filters. This report returns + * data for a single month at a time, so it requires the same values for the start and end fields within DateRange. + * A maximum of N=10 items can be returned at a time. + */ + public static final ReportTypeEnum TOP_ITEMS_SUMMARY_REPORT = fromString("TopItemsSummaryReport"); + + /** + * TopItemsMonthlyReport provides the N highest-emitting items by month for the specified query filter. Returns + * emissions data for the top N items by month within the given date range. A maximum of N=10 items can be returned + * at a time. + */ + public static final ReportTypeEnum TOP_ITEMS_MONTHLY_SUMMARY_REPORT = fromString("TopItemsMonthlySummaryReport"); + + /** + * ItemDetailsReport provides a granular list of items based on the specified CategoryType (e.g., Resource, + * ResourceGroup, ResourceType, Location, or Subscription) for the query filter. This report can be queried for only + * one month at a time, requiring the same values in the start and end fields within DateRange. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionItemDetailData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionItemDetailData.java new file mode 100644 index 000000000000..3252ce374d9c --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionItemDetailData.java @@ -0,0 +1,323 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Resource detailed carbon emissions. + */ +@Immutable +public final class ResourceCarbonEmissionItemDetailData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of ResourceCarbonEmissionItemDetailData class. + */ + private 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; + } + + /** + * Get the categoryType property: Resource Item category, see supported value defined in CategoryTypeEnum. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the resourceGroup property: Resource Group. + * + * @return the resourceGroup value. + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * 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; + } + + /** + * Get the location property: Resource Location (e.g., 'east us'). + * + * @return the location value. + */ + public String location() { + return this.location; + } + + /** + * Get the resourceType property: The type of resource, for example: microsoft.storage/storageaccounts. + * + * @return the resourceType value. + */ + public String resourceType() { + return this.resourceType; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceCarbonEmissionItemDetailData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java new file mode 100644 index 000000000000..b451e68fd947 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionTopItemMonthlySummaryData.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for top items carbon emissions by month for resource. + */ +@Immutable +public final class ResourceCarbonEmissionTopItemMonthlySummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of ResourceCarbonEmissionTopItemMonthlySummaryData class. + */ + private 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; + } + + /** + * Get the categoryType property: Resource Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Get the date property: Monthly date string, format is yyyy-MM-dd. + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the resourceGroup property: Resource Group. + * + * @return the resourceGroup value. + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * 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; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions + = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.previousMonthEmissions + = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemMonthlySummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionTopItemsSummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionTopItemsSummaryData.java new file mode 100644 index 000000000000..43583c448a68 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceCarbonEmissionTopItemsSummaryData.java @@ -0,0 +1,290 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Top Items For Resource Category. + */ +@Immutable +public final class ResourceCarbonEmissionTopItemsSummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of ResourceCarbonEmissionTopItemsSummaryData class. + */ + private 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; + } + + /** + * 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; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the resourceGroup property: Resource group name. + * + * @return the resourceGroup value. + */ + public String resourceGroup() { + return this.resourceGroup; + } + + /** + * 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; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceCarbonEmissionTopItemsSummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionItemDetailData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionItemDetailData.java new file mode 100644 index 000000000000..aa5b3a8abc28 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionItemDetailData.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Resource Group detailed carbon emissions. + */ +@Immutable +public final class ResourceGroupCarbonEmissionItemDetailData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of ResourceGroupCarbonEmissionItemDetailData class. + */ + private 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; + } + + /** + * Get the categoryType property: ResourceGroup Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the resourceGroupUrl property: Resource Group url, value format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @return the resourceGroupUrl value. + */ + public String resourceGroupUrl() { + return this.resourceGroupUrl; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.previousMonthEmissions = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionItemDetailData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java new file mode 100644 index 000000000000..7087b5519126 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionTopItemMonthlySummaryData.java @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for top items carbon emissions by month for resource group. + */ +@Immutable +public final class ResourceGroupCarbonEmissionTopItemMonthlySummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of ResourceGroupCarbonEmissionTopItemMonthlySummaryData class. + */ + private 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; + } + + /** + * Get the categoryType property: ResourceGroup Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Get the date property: Monthly date string, format is yyyy-MM-dd. + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the resourceGroupUrl property: Resource Group url, the format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @return the resourceGroupUrl value. + */ + public String resourceGroupUrl() { + return this.resourceGroupUrl; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions + = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.previousMonthEmissions + = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemMonthlySummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java new file mode 100644 index 000000000000..ade4437e1569 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResourceGroupCarbonEmissionTopItemsSummaryData.java @@ -0,0 +1,267 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import java.io.IOException; + +/** + * Response for Top Items For ResourceGroup. + */ +@Immutable +public final class ResourceGroupCarbonEmissionTopItemsSummaryData extends CarbonEmissionDataInner { + /* + * 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; + + /* + * The change in carbon emissions between the current and previous period, calculated as: latestMonthEmissions - + * previousMonthEmissions. + */ + private Double monthlyEmissionsChangeValue; + + /* + * The percentage change in carbon emissions between the current and previous DateRange. This is calculated as: + * (latestMonthEmissions - previousMonthEmissions) / previousMonthEmissions. + */ + private Double monthOverMonthEmissionsChangeRatio; + + /* + * 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; + + /* + * 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; + + /** + * Creates an instance of ResourceGroupCarbonEmissionTopItemsSummaryData class. + */ + private 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; + } + + /** + * Get the categoryType property: ResourceGroup Item category. + * + * @return the categoryType value. + */ + public CategoryTypeEnum categoryType() { + return this.categoryType; + } + + /** + * Get the subscriptionId property: Subscription Id. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the resourceGroupUrl property: Resource Group url, value format is + * '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}'. + * + * @return the resourceGroupUrl value. + */ + public String resourceGroupUrl() { + return this.resourceGroupUrl; + } + + /** + * Get the monthlyEmissionsChangeValue property: The change in carbon emissions between the current and previous + * period, calculated as: latestMonthEmissions - previousMonthEmissions. + * + * @return the monthlyEmissionsChangeValue value. + */ + @Override + public Double monthlyEmissionsChangeValue() { + return this.monthlyEmissionsChangeValue; + } + + /** + * 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. + */ + @Override + public Double monthOverMonthEmissionsChangeRatio() { + return this.monthOverMonthEmissionsChangeRatio; + } + + /** + * 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. + */ + @Override + public double previousMonthEmissions() { + return this.previousMonthEmissions; + } + + /** + * 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. + */ + @Override + public double latestMonthEmissions() { + return this.latestMonthEmissions; + } + + /** + * 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.latestMonthEmissions + = reader.getDouble(); + } else if ("previousMonthEmissions".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.previousMonthEmissions + = reader.getDouble(); + } else if ("monthOverMonthEmissionsChangeRatio".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.monthOverMonthEmissionsChangeRatio + = reader.getNullable(JsonReader::getDouble); + } else if ("monthlyEmissionsChangeValue".equals(fieldName)) { + deserializedResourceGroupCarbonEmissionTopItemsSummaryData.monthlyEmissionsChangeValue + = 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResponseDataTypeEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResponseDataTypeEnum.java new file mode 100644 index 000000000000..deb25756bab6 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/ResponseDataTypeEnum.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * The response data type for OverallSummaryReport. + */ + public static final ResponseDataTypeEnum OVERALL_SUMMARY_DATA = fromString("OverallSummaryData"); + + /** + * The response data type for MonthlySummaryReport. + */ + public static final ResponseDataTypeEnum MONTHLY_SUMMARY_DATA = fromString("MonthlySummaryData"); + + /** + * The response data type for TopItemsSummaryReport. + */ + public static final ResponseDataTypeEnum TOP_ITEMS_SUMMARY_DATA = fromString("TopItemsSummaryData"); + + /** + * The response data type for Resource's TopItemsSummaryReport. + */ + public static final ResponseDataTypeEnum RESOURCE_TOP_ITEMS_SUMMARY_DATA + = fromString("ResourceTopItemsSummaryData"); + + /** + * The response data type for ResourceGroup's TopItemsSummaryReport. + */ + public static final ResponseDataTypeEnum RESOURCE_GROUP_TOP_ITEMS_SUMMARY_DATA + = fromString("ResourceGroupTopItemsSummaryData"); + + /** + * The response data type for TopItemsMonthlySummaryReport. + */ + public static final ResponseDataTypeEnum TOP_ITEMS_MONTHLY_SUMMARY_DATA = fromString("TopItemsMonthlySummaryData"); + + /** + * The response data type for Resource's TopItemsMonthlySummaryReport. + */ + public static final ResponseDataTypeEnum RESOURCE_TOP_ITEMS_MONTHLY_SUMMARY_DATA + = fromString("ResourceTopItemsMonthlySummaryData"); + + /** + * The response data type for ResourceGroup's TopItemsMonthlySummaryReport. + */ + public static final ResponseDataTypeEnum RESOURCE_GROUP_TOP_ITEMS_MONTHLY_SUMMARY_DATA + = fromString("ResourceGroupTopItemsMonthlySummaryData"); + + /** + * The response data type for ItemDetailsReport. + */ + public static final ResponseDataTypeEnum ITEM_DETAILS_DATA = fromString("ItemDetailsData"); + + /** + * The response data type for Resource's ItemDetailsReport. + */ + public static final ResponseDataTypeEnum RESOURCE_ITEM_DETAILS_DATA = fromString("ResourceItemDetailsData"); + + /** + * The response data type for ResourceGroup's ItemDetailsReport. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/SortDirectionEnum.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/SortDirectionEnum.java new file mode 100644 index 000000000000..7bcdbd1ce15e --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/SortDirectionEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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 { + /** + * Descending order for query result. + */ + public static final SortDirectionEnum DESC = fromString("Desc"); + + /** + * Ascending order for query result. + */ + 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/SubscriptionAccessDecision.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/SubscriptionAccessDecision.java new file mode 100644 index 000000000000..1fa6121d03d3 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/SubscriptionAccessDecision.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.models; + +import com.azure.core.annotation.Immutable; +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. + */ +@Immutable +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. + */ + private SubscriptionAccessDecision() { + } + + /** + * Get the subscriptionId property: Id of Subscription. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Get the decision property: Access decision to subscription. + * + * @return the decision value. + */ + public AccessDecisionEnum decision() { + return this.decision; + } + + /** + * Get the denialReason property: The reason why access request got denied. + * + * @return the denialReason value. + */ + public String denialReason() { + return this.denialReason; + } + + /** + * 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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/TopItemsMonthlySummaryReportQueryFilter.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/TopItemsMonthlySummaryReportQueryFilter.java new file mode 100644 index 000000000000..4106bfc66b60 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/TopItemsMonthlySummaryReportQueryFilter.java @@ -0,0 +1,256 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/TopItemsSummaryReportQueryFilter.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/TopItemsSummaryReportQueryFilter.java new file mode 100644 index 000000000000..7e6dede912ad --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/TopItemsSummaryReportQueryFilter.java @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/package-info.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/models/package-info.java new file mode 100644 index 000000000000..1e398e15ead4 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/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) TypeSpec Code Generator. + +/** + * Package containing the data models for Carbonoptimization. + * Carbon Report Resource Provider query API. + */ +package com.azure.resourcemanager.carbonoptimization.models; diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/package-info.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/package-info.java new file mode 100644 index 000000000000..a8df16e85b1c --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/com/azure/resourcemanager/carbonoptimization/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Carbonoptimization. + * Carbon Report Resource Provider query API. + */ +package com.azure.resourcemanager.carbonoptimization; diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/module-info.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/module-info.java new file mode 100644 index 000000000000..3c8c833fd1d4 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.carbonoptimization { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.carbonoptimization; + exports com.azure.resourcemanager.carbonoptimization.fluent; + exports com.azure.resourcemanager.carbonoptimization.fluent.models; + exports com.azure.resourcemanager.carbonoptimization.models; + + opens com.azure.resourcemanager.carbonoptimization.fluent.models to com.azure.core; + opens com.azure.resourcemanager.carbonoptimization.models to com.azure.core; + opens com.azure.resourcemanager.carbonoptimization.implementation.models to com.azure.core; +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbonoptimization/proxy-config.json b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbonoptimization/proxy-config.json new file mode 100644 index 000000000000..f388a82fc0c5 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbonoptimization/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.carbonoptimization.implementation.CarbonServicesClientImpl$CarbonServicesService"],["com.azure.resourcemanager.carbonoptimization.implementation.OperationsClientImpl$OperationsService"]] \ No newline at end of file diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbonoptimization/reflect-config.json b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbonoptimization/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-carbonoptimization/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/azure-resourcemanager-carbonoptimization.properties b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/azure-resourcemanager-carbonoptimization.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/main/resources/azure-resourcemanager-carbonoptimization.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java new file mode 100644 index 000000000000..00945ed135c4 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +/** + * Samples for CarbonService QueryCarbonEmissionDataAvailableDateRange. + */ +public final class CarbonServiceQueryCarbonEmissionDataAvailableDateRangeSamples { + /* + * x-ms-original-file: 2025-04-01/carbonEmissionsDataAvailableDateRange.json + */ + /** + * Sample code: CarbonService_QueryCarbonEmissionDataAvailableDateRange. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void carbonServiceQueryCarbonEmissionDataAvailableDateRange( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionDataAvailableDateRangeWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java new file mode 100644 index 000000000000..3112922d26ac --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServiceQueryCarbonEmissionReportsSamples.java @@ -0,0 +1,514 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ItemDetailsQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.MonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.OrderByColumnEnum; +import com.azure.resourcemanager.carbonoptimization.models.OverallSummaryReportQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.SortDirectionEnum; +import com.azure.resourcemanager.carbonoptimization.models.TopItemsMonthlySummaryReportQueryFilter; +import com.azure.resourcemanager.carbonoptimization.models.TopItemsSummaryReportQueryFilter; +import java.time.LocalDate; +import java.util.Arrays; + +/** + * Samples for CarbonService QueryCarbonEmissionReports. + */ +public final class CarbonServiceQueryCarbonEmissionReportsSamples { + /* + * x-ms-original-file: 2025-04-01/queryCarbonEmissionsTopNResourceTypeItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceTypeReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsMonthlySummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Monthly Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void + queryCarbonEmissionMonthlySummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsSubscriptionItemDetailsReportReport.json + */ + /** + * Sample code: QueryCarbonEmission Subscriptions item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionSubscriptionsItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceGroupItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceGroup item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceGroupItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N resource monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsOverallSummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionOverallSummaryReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsTopNSubscriptionItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNSubscriptionsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceGroupItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceGroupReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNSubscriptionItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Subscriptions monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNSubscriptionsMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNLocationItemsReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNLocationsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceItemDetailsReportWithPaginationToken.json + */ + /** + * Sample code: QueryCarbonEmission resource item details Report with pagination token. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceItemDetailsReportWithPaginationToken( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsLocationItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission Location item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionLocationItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsMonthlySummaryReport.json + */ + /** + * Sample code: QueryCarbonEmission Overall Monthly Summary Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionOverallMonthlySummaryReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsOverallSummaryReportWithOtherOptionalFilter.json + */ + /** + * Sample code: QueryCarbonEmission Overall Summary Report with optional filter - locationList, resourceTypeList, + * resourceGroupUrlList. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void + queryCarbonEmissionOverallSummaryReportWithOptionalFilterLocationListResourceTypeListResourceGroupUrlList( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports( + 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: 2025-04-01/queryCarbonEmissionsTopNLocationItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N Locations monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNLocationsMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceTypeItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceType monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceTypeMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsResourceTypeItemDetailsReport.json + */ + /** + * Sample code: QueryCarbonEmission ResourceType item details Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionResourceTypeItemDetailsReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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: 2025-04-01/queryCarbonEmissionsTopNResourceGroupItemsMonthlyReport.json + */ + /** + * Sample code: QueryCarbonEmission Top N ResourceGroup monthly Report. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void queryCarbonEmissionTopNResourceGroupMonthlyReport( + com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.carbonServices() + .queryCarbonEmissionReports(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/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/OperationsListSamples.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/OperationsListSamples.java new file mode 100644 index 000000000000..b1ca34ba3e46 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/samples/java/com/azure/resourcemanager/carbonoptimization/generated/OperationsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2025-04-01/listOperations.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to CarbonoptimizationManager. + */ + public static void operationsList(com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionDataAvailableDateRangeInnerTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionDataAvailableDateRangeInnerTests.java new file mode 100644 index 000000000000..51b2384cd28d --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionDataAvailableDateRangeInnerTests.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataAvailableDateRangeInner; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionDataAvailableDateRangeInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionDataAvailableDateRangeInner model + = BinaryData.fromString("{\"startDate\":\"nohjt\",\"endDate\":\"kwh\"}") + .toObject(CarbonEmissionDataAvailableDateRangeInner.class); + Assertions.assertEquals("nohjt", model.startDate()); + Assertions.assertEquals("kwh", model.endDate()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionDataInnerTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionDataInnerTests.java new file mode 100644 index 000000000000..ac3e21522173 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionDataInnerTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.fluent.models.CarbonEmissionDataInner; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionDataInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionDataInner model = BinaryData.fromString( + "{\"dataType\":\"CarbonEmissionData\",\"latestMonthEmissions\":66.31782921196866,\"previousMonthEmissions\":33.6984093273467,\"monthOverMonthEmissionsChangeRatio\":97.70980700102018,\"monthlyEmissionsChangeValue\":30.187615152865177}") + .toObject(CarbonEmissionDataInner.class); + Assertions.assertEquals(66.31782921196866, model.latestMonthEmissions()); + Assertions.assertEquals(33.6984093273467, model.previousMonthEmissions()); + Assertions.assertEquals(97.70980700102018D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(30.187615152865177D, model.monthlyEmissionsChangeValue()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionItemDetailDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionItemDetailDataTests.java new file mode 100644 index 000000000000..73585e6e6c9a --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionItemDetailDataTests.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionItemDetailData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionItemDetailDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionItemDetailData model = BinaryData.fromString( + "{\"dataType\":\"ItemDetailsData\",\"itemName\":\"tnwu\",\"categoryType\":\"Subscription\",\"latestMonthEmissions\":32.667894710257784,\"previousMonthEmissions\":37.459629809296715,\"monthOverMonthEmissionsChangeRatio\":48.564128567474796,\"monthlyEmissionsChangeValue\":30.857593323830567}") + .toObject(CarbonEmissionItemDetailData.class); + Assertions.assertEquals(32.667894710257784, model.latestMonthEmissions()); + Assertions.assertEquals(37.459629809296715, model.previousMonthEmissions()); + Assertions.assertEquals(48.564128567474796D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(30.857593323830567D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("tnwu", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.SUBSCRIPTION, model.categoryType()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionMonthlySummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionMonthlySummaryDataTests.java new file mode 100644 index 000000000000..755a08722f8a --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionMonthlySummaryDataTests.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionMonthlySummaryData; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionMonthlySummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionMonthlySummaryData model = BinaryData.fromString( + "{\"dataType\":\"MonthlySummaryData\",\"date\":\"icndvkaozwyifty\",\"carbonIntensity\":33.074298095641666,\"latestMonthEmissions\":37.38192215915729,\"previousMonthEmissions\":93.96749891622001,\"monthOverMonthEmissionsChangeRatio\":63.022673862088986,\"monthlyEmissionsChangeValue\":70.96928500130538}") + .toObject(CarbonEmissionMonthlySummaryData.class); + Assertions.assertEquals(37.38192215915729, model.latestMonthEmissions()); + Assertions.assertEquals(93.96749891622001, model.previousMonthEmissions()); + Assertions.assertEquals(63.022673862088986D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(70.96928500130538D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("icndvkaozwyifty", model.date()); + Assertions.assertEquals(33.074298095641666, model.carbonIntensity()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionOverallSummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionOverallSummaryDataTests.java new file mode 100644 index 000000000000..2842a0f58bc4 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionOverallSummaryDataTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionOverallSummaryData; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionOverallSummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionOverallSummaryData model = BinaryData.fromString( + "{\"dataType\":\"OverallSummaryData\",\"latestMonthEmissions\":98.39277900938401,\"previousMonthEmissions\":83.20217812652965,\"monthOverMonthEmissionsChangeRatio\":70.60696068590889,\"monthlyEmissionsChangeValue\":91.44667847523249}") + .toObject(CarbonEmissionOverallSummaryData.class); + Assertions.assertEquals(98.39277900938401, model.latestMonthEmissions()); + Assertions.assertEquals(83.20217812652965, model.previousMonthEmissions()); + Assertions.assertEquals(70.60696068590889D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(91.44667847523249D, model.monthlyEmissionsChangeValue()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionTopItemMonthlySummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionTopItemMonthlySummaryDataTests.java new file mode 100644 index 000000000000..c0858762f913 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionTopItemMonthlySummaryDataTests.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionTopItemMonthlySummaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionTopItemMonthlySummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionTopItemMonthlySummaryData model = BinaryData.fromString( + "{\"dataType\":\"TopItemsMonthlySummaryData\",\"itemName\":\"utduqktapspwgcu\",\"categoryType\":\"Resource\",\"date\":\"tumkdosvqwhbm\",\"latestMonthEmissions\":77.20989115341301,\"previousMonthEmissions\":14.188551295894204,\"monthOverMonthEmissionsChangeRatio\":25.363232512736268,\"monthlyEmissionsChangeValue\":56.94086077283642}") + .toObject(CarbonEmissionTopItemMonthlySummaryData.class); + Assertions.assertEquals(77.20989115341301, model.latestMonthEmissions()); + Assertions.assertEquals(14.188551295894204, model.previousMonthEmissions()); + Assertions.assertEquals(25.363232512736268D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(56.94086077283642D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("utduqktapspwgcu", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE, model.categoryType()); + Assertions.assertEquals("tumkdosvqwhbm", model.date()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionTopItemsSummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionTopItemsSummaryDataTests.java new file mode 100644 index 000000000000..157c0823bf63 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonEmissionTopItemsSummaryDataTests.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionTopItemsSummaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import org.junit.jupiter.api.Assertions; + +public final class CarbonEmissionTopItemsSummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CarbonEmissionTopItemsSummaryData model = BinaryData.fromString( + "{\"dataType\":\"TopItemsSummaryData\",\"itemName\":\"niwpwcukj\",\"categoryType\":\"ResourceGroup\",\"latestMonthEmissions\":29.348962683922853,\"previousMonthEmissions\":36.07977033198502,\"monthOverMonthEmissionsChangeRatio\":54.508796010660944,\"monthlyEmissionsChangeValue\":17.8025238081559}") + .toObject(CarbonEmissionTopItemsSummaryData.class); + Assertions.assertEquals(29.348962683922853, model.latestMonthEmissions()); + Assertions.assertEquals(36.07977033198502, model.previousMonthEmissions()); + Assertions.assertEquals(54.508796010660944D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(17.8025238081559D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("niwpwcukj", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_GROUP, model.categoryType()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServicesQueryCarbonEmissionDataAvailableDateRangeWithResponseMockTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServicesQueryCarbonEmissionDataAvailableDateRangeWithResponseMockTests.java new file mode 100644 index 000000000000..3aae2e78a457 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServicesQueryCarbonEmissionDataAvailableDateRangeWithResponseMockTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionDataAvailableDateRange; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class CarbonServicesQueryCarbonEmissionDataAvailableDateRangeWithResponseMockTests { + @Test + public void testQueryCarbonEmissionDataAvailableDateRangeWithResponse() throws Exception { + String responseStr = "{\"startDate\":\"kdkexxp\",\"endDate\":\"ofmx\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CarbonoptimizationManager manager = CarbonoptimizationManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + CarbonEmissionDataAvailableDateRange response = manager.carbonServices() + .queryCarbonEmissionDataAvailableDateRangeWithResponse(com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("kdkexxp", response.startDate()); + Assertions.assertEquals("ofmx", response.endDate()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServicesQueryCarbonEmissionReportsMockTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServicesQueryCarbonEmissionReportsMockTests.java new file mode 100644 index 000000000000..e5e341649173 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/CarbonServicesQueryCarbonEmissionReportsMockTests.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager; +import com.azure.resourcemanager.carbonoptimization.models.CarbonEmissionData; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.QueryFilter; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class CarbonServicesQueryCarbonEmissionReportsMockTests { + @Test + public void testQueryCarbonEmissionReports() throws Exception { + String responseStr + = "{\"value\":[{\"dataType\":\"CarbonEmissionData\",\"latestMonthEmissions\":47.453901230584684,\"previousMonthEmissions\":39.88341647038772,\"monthOverMonthEmissionsChangeRatio\":61.07224203836401,\"monthlyEmissionsChangeValue\":62.667987966762}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CarbonoptimizationManager manager = CarbonoptimizationManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.carbonServices() + .queryCarbonEmissionReports( + new QueryFilter().withDateRange(new DateRange()) + .withSubscriptionList(Arrays.asList("dtqajzyulpkudj", "rlkhbzhfepgzgq", "xzlocxscp")) + .withResourceGroupUrlList(Arrays.asList("rhhbcs", "l", "mmajtjaodx")) + .withResourceTypeList(Arrays.asList("bdxkqpxokaj", "onpimexgstxg")) + .withLocationList(Arrays.asList("dg", "aajrm", "djwzrlov", "clwhijcoejctbz")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE3, EmissionScopeEnum.SCOPE1)), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals(47.453901230584684, response.iterator().next().latestMonthEmissions()); + Assertions.assertEquals(39.88341647038772, response.iterator().next().previousMonthEmissions()); + Assertions.assertEquals(61.07224203836401D, response.iterator().next().monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(62.667987966762D, response.iterator().next().monthlyEmissionsChangeValue()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/DateRangeTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/DateRangeTests.java new file mode 100644 index 000000000000..bba93382a723 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/DateRangeTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; + +public final class DateRangeTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DateRange model = BinaryData.fromString("{}").toObject(DateRange.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DateRange model = new DateRange(); + model = BinaryData.fromObject(model).toObject(DateRange.class); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/MonthlySummaryReportQueryFilterTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/MonthlySummaryReportQueryFilterTests.java new file mode 100644 index 000000000000..be7e6ca6d327 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/MonthlySummaryReportQueryFilterTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.MonthlySummaryReportQueryFilter; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class MonthlySummaryReportQueryFilterTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + MonthlySummaryReportQueryFilter model = BinaryData.fromString( + "{\"reportType\":\"MonthlySummaryReport\",\"dateRange\":{},\"subscriptionList\":[\"f\",\"dio\",\"jpslwejd\"],\"resourceGroupUrlList\":[\"ryo\",\"psoacctazakljl\",\"hbcryffdfdosyge\"],\"resourceTypeList\":[\"ojakhmsbzjhcrze\",\"dphlxaolt\",\"qtrgqjbpfzfsinzg\",\"f\"],\"locationList\":[\"wzo\",\"xjtfelluwfzit\",\"np\",\"qfpjk\"],\"carbonScopeList\":[\"Scope3\",\"Scope1\",\"Scope1\",\"Scope1\"]}") + .toObject(MonthlySummaryReportQueryFilter.class); + Assertions.assertEquals("f", model.subscriptionList().get(0)); + Assertions.assertEquals("ryo", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("ojakhmsbzjhcrze", model.resourceTypeList().get(0)); + Assertions.assertEquals("wzo", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE3, model.carbonScopeList().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + MonthlySummaryReportQueryFilter model = new MonthlySummaryReportQueryFilter().withDateRange(new DateRange()) + .withSubscriptionList(Arrays.asList("f", "dio", "jpslwejd")) + .withResourceGroupUrlList(Arrays.asList("ryo", "psoacctazakljl", "hbcryffdfdosyge")) + .withResourceTypeList(Arrays.asList("ojakhmsbzjhcrze", "dphlxaolt", "qtrgqjbpfzfsinzg", "f")) + .withLocationList(Arrays.asList("wzo", "xjtfelluwfzit", "np", "qfpjk")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE3, EmissionScopeEnum.SCOPE1, + EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE1)); + model = BinaryData.fromObject(model).toObject(MonthlySummaryReportQueryFilter.class); + Assertions.assertEquals("f", model.subscriptionList().get(0)); + Assertions.assertEquals("ryo", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("ojakhmsbzjhcrze", model.resourceTypeList().get(0)); + Assertions.assertEquals("wzo", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE3, model.carbonScopeList().get(0)); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationDisplayTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationDisplayTests.java new file mode 100644 index 000000000000..4d4c3136abe9 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationDisplayTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.OperationDisplay; + +public final class OperationDisplayTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationDisplay model = BinaryData.fromString( + "{\"provider\":\"cdm\",\"resource\":\"rcryuanzwuxzdxta\",\"operation\":\"lhmwhfpmrqobm\",\"description\":\"kknryrtihf\"}") + .toObject(OperationDisplay.class); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationInnerTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationInnerTests.java new file mode 100644 index 000000000000..43bb0233fe06 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationInnerTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.fluent.models.OperationInner; + +public final class OperationInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationInner model = BinaryData.fromString( + "{\"name\":\"nygj\",\"isDataAction\":true,\"display\":{\"provider\":\"eqsrdeupewnwreit\",\"resource\":\"yflusarhmofc\",\"operation\":\"smy\",\"description\":\"kdtmlxhekuk\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}") + .toObject(OperationInner.class); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationListResultTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationListResultTests.java new file mode 100644 index 000000000000..79cdf13b19ca --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationListResultTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.implementation.models.OperationListResult; +import org.junit.jupiter.api.Assertions; + +public final class OperationListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationListResult model = BinaryData.fromString( + "{\"value\":[{\"name\":\"hq\",\"isDataAction\":true,\"display\":{\"provider\":\"pybczmehmtzopb\",\"resource\":\"h\",\"operation\":\"pidgsybbejhphoyc\",\"description\":\"xaobhdxbmtqioqjz\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"fpownoizhwlr\",\"isDataAction\":false,\"display\":{\"provider\":\"oqijgkdmbpaz\",\"resource\":\"bc\",\"operation\":\"pdznrbtcqqjnqgl\",\"description\":\"gnufoooj\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"esaagdfm\",\"isDataAction\":true,\"display\":{\"provider\":\"j\",\"resource\":\"ifkwmrvktsizntoc\",\"operation\":\"a\",\"description\":\"ajpsquc\"},\"origin\":\"system\",\"actionType\":\"Internal\"}],\"nextLink\":\"kfo\"}") + .toObject(OperationListResult.class); + Assertions.assertEquals("kfo", model.nextLink()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationsListMockTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationsListMockTests.java new file mode 100644 index 000000000000..34f9b0c25118 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OperationsListMockTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.carbonoptimization.CarbonoptimizationManager; +import com.azure.resourcemanager.carbonoptimization.models.Operation; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class OperationsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"name\":\"oifiyipjxsqwpgr\",\"isDataAction\":false,\"display\":{\"provider\":\"rcjxvsnbyxqabn\",\"resource\":\"cpc\",\"operation\":\"hurzafblj\",\"description\":\"pbtoqcjmkl\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CarbonoptimizationManager manager = CarbonoptimizationManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OverallSummaryReportQueryFilterTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OverallSummaryReportQueryFilterTests.java new file mode 100644 index 000000000000..8ff03185fb39 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/OverallSummaryReportQueryFilterTests.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.OverallSummaryReportQueryFilter; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class OverallSummaryReportQueryFilterTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OverallSummaryReportQueryFilter model = BinaryData.fromString( + "{\"reportType\":\"OverallSummaryReport\",\"dateRange\":{},\"subscriptionList\":[\"ni\",\"joxzjnchgejspodm\"],\"resourceGroupUrlList\":[\"zyde\",\"o\",\"wyahuxinpmqnja\",\"wixjsprozvcp\"],\"resourceTypeList\":[\"gjvw\"],\"locationList\":[\"atscmd\",\"pjhulsuuvmkj\"],\"carbonScopeList\":[\"Scope1\",\"Scope2\"]}") + .toObject(OverallSummaryReportQueryFilter.class); + Assertions.assertEquals("ni", model.subscriptionList().get(0)); + Assertions.assertEquals("zyde", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("gjvw", model.resourceTypeList().get(0)); + Assertions.assertEquals("atscmd", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE1, model.carbonScopeList().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + OverallSummaryReportQueryFilter model = new OverallSummaryReportQueryFilter().withDateRange(new DateRange()) + .withSubscriptionList(Arrays.asList("ni", "joxzjnchgejspodm")) + .withResourceGroupUrlList(Arrays.asList("zyde", "o", "wyahuxinpmqnja", "wixjsprozvcp")) + .withResourceTypeList(Arrays.asList("gjvw")) + .withLocationList(Arrays.asList("atscmd", "pjhulsuuvmkj")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE2)); + model = BinaryData.fromObject(model).toObject(OverallSummaryReportQueryFilter.class); + Assertions.assertEquals("ni", model.subscriptionList().get(0)); + Assertions.assertEquals("zyde", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("gjvw", model.resourceTypeList().get(0)); + Assertions.assertEquals("atscmd", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE1, model.carbonScopeList().get(0)); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/QueryFilterTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/QueryFilterTests.java new file mode 100644 index 000000000000..9af777cab52f --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/QueryFilterTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.QueryFilter; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class QueryFilterTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + QueryFilter model = BinaryData.fromString( + "{\"reportType\":\"QueryFilter\",\"dateRange\":{},\"subscriptionList\":[\"ijbpzvgnwzsymgl\",\"uf\",\"yzkohdbihanuf\",\"fcbjysagithxqha\"],\"resourceGroupUrlList\":[\"pikxwczbyscnpqxu\",\"ivyqniwbybrkxvd\",\"mjgr\"],\"resourceTypeList\":[\"vukxgau\",\"ccsnhsjc\"],\"locationList\":[\"j\",\"kryhtnapczwlokj\"],\"carbonScopeList\":[\"Scope3\",\"Scope2\",\"Scope2\"]}") + .toObject(QueryFilter.class); + Assertions.assertEquals("ijbpzvgnwzsymgl", model.subscriptionList().get(0)); + Assertions.assertEquals("pikxwczbyscnpqxu", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("vukxgau", model.resourceTypeList().get(0)); + Assertions.assertEquals("j", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE3, model.carbonScopeList().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + QueryFilter model = new QueryFilter().withDateRange(new DateRange()) + .withSubscriptionList(Arrays.asList("ijbpzvgnwzsymgl", "uf", "yzkohdbihanuf", "fcbjysagithxqha")) + .withResourceGroupUrlList(Arrays.asList("pikxwczbyscnpqxu", "ivyqniwbybrkxvd", "mjgr")) + .withResourceTypeList(Arrays.asList("vukxgau", "ccsnhsjc")) + .withLocationList(Arrays.asList("j", "kryhtnapczwlokj")) + .withCarbonScopeList( + Arrays.asList(EmissionScopeEnum.SCOPE3, EmissionScopeEnum.SCOPE2, EmissionScopeEnum.SCOPE2)); + model = BinaryData.fromObject(model).toObject(QueryFilter.class); + Assertions.assertEquals("ijbpzvgnwzsymgl", model.subscriptionList().get(0)); + Assertions.assertEquals("pikxwczbyscnpqxu", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("vukxgau", model.resourceTypeList().get(0)); + Assertions.assertEquals("j", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE3, model.carbonScopeList().get(0)); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionItemDetailDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionItemDetailDataTests.java new file mode 100644 index 000000000000..0c9958fceeac --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionItemDetailDataTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ResourceCarbonEmissionItemDetailData; +import org.junit.jupiter.api.Assertions; + +public final class ResourceCarbonEmissionItemDetailDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceCarbonEmissionItemDetailData model = BinaryData.fromString( + "{\"dataType\":\"ResourceItemDetailsData\",\"itemName\":\"kyfi\",\"categoryType\":\"ResourceGroup\",\"subscriptionId\":\"fidfvzw\",\"resourceGroup\":\"zuhtymwisdkfthwx\",\"resourceId\":\"nteiwaopv\",\"location\":\"ijcmmx\",\"resourceType\":\"ufufsrp\",\"latestMonthEmissions\":74.0755200384253,\"previousMonthEmissions\":56.62892405768821,\"monthOverMonthEmissionsChangeRatio\":42.455758085656015,\"monthlyEmissionsChangeValue\":38.43033430574524}") + .toObject(ResourceCarbonEmissionItemDetailData.class); + Assertions.assertEquals(74.0755200384253, model.latestMonthEmissions()); + Assertions.assertEquals(56.62892405768821, model.previousMonthEmissions()); + Assertions.assertEquals(42.455758085656015D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(38.43033430574524D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("kyfi", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_GROUP, model.categoryType()); + Assertions.assertEquals("fidfvzw", model.subscriptionId()); + Assertions.assertEquals("zuhtymwisdkfthwx", model.resourceGroup()); + Assertions.assertEquals("nteiwaopv", model.resourceId()); + Assertions.assertEquals("ijcmmx", model.location()); + Assertions.assertEquals("ufufsrp", model.resourceType()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionTopItemMonthlySummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionTopItemMonthlySummaryDataTests.java new file mode 100644 index 000000000000..3e111b966408 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionTopItemMonthlySummaryDataTests.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ResourceCarbonEmissionTopItemMonthlySummaryData; +import org.junit.jupiter.api.Assertions; + +public final class ResourceCarbonEmissionTopItemMonthlySummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceCarbonEmissionTopItemMonthlySummaryData model = BinaryData.fromString( + "{\"dataType\":\"ResourceTopItemsMonthlySummaryData\",\"itemName\":\"mbe\",\"categoryType\":\"ResourceGroup\",\"date\":\"pbhtqqrolfpfpsa\",\"subscriptionId\":\"gbquxigj\",\"resourceGroup\":\"jgzjaoyfhrtx\",\"resourceId\":\"lnerkujysvleju\",\"latestMonthEmissions\":53.270921871511824,\"previousMonthEmissions\":32.5671340961653,\"monthOverMonthEmissionsChangeRatio\":84.4490802290868,\"monthlyEmissionsChangeValue\":25.93289205065018}") + .toObject(ResourceCarbonEmissionTopItemMonthlySummaryData.class); + Assertions.assertEquals(53.270921871511824, model.latestMonthEmissions()); + Assertions.assertEquals(32.5671340961653, model.previousMonthEmissions()); + Assertions.assertEquals(84.4490802290868D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(25.93289205065018D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("mbe", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_GROUP, model.categoryType()); + Assertions.assertEquals("pbhtqqrolfpfpsa", model.date()); + Assertions.assertEquals("gbquxigj", model.subscriptionId()); + Assertions.assertEquals("jgzjaoyfhrtx", model.resourceGroup()); + Assertions.assertEquals("lnerkujysvleju", model.resourceId()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionTopItemsSummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionTopItemsSummaryDataTests.java new file mode 100644 index 000000000000..bcbce4ba94ea --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceCarbonEmissionTopItemsSummaryDataTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ResourceCarbonEmissionTopItemsSummaryData; +import org.junit.jupiter.api.Assertions; + +public final class ResourceCarbonEmissionTopItemsSummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceCarbonEmissionTopItemsSummaryData model = BinaryData.fromString( + "{\"dataType\":\"ResourceTopItemsSummaryData\",\"itemName\":\"lwckbasyypnddhs\",\"categoryType\":\"Location\",\"subscriptionId\":\"bacphejko\",\"resourceGroup\":\"ynqgoulzndlikwyq\",\"resourceId\":\"gfgibm\",\"latestMonthEmissions\":20.09751560915065,\"previousMonthEmissions\":30.00180250560771,\"monthOverMonthEmissionsChangeRatio\":66.59647381820668,\"monthlyEmissionsChangeValue\":22.220514848143623}") + .toObject(ResourceCarbonEmissionTopItemsSummaryData.class); + Assertions.assertEquals(20.09751560915065, model.latestMonthEmissions()); + Assertions.assertEquals(30.00180250560771, model.previousMonthEmissions()); + Assertions.assertEquals(66.59647381820668D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(22.220514848143623D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("lwckbasyypnddhs", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.LOCATION, model.categoryType()); + Assertions.assertEquals("bacphejko", model.subscriptionId()); + Assertions.assertEquals("ynqgoulzndlikwyq", model.resourceGroup()); + Assertions.assertEquals("gfgibm", model.resourceId()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionItemDetailDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionItemDetailDataTests.java new file mode 100644 index 000000000000..c0170f8bb9a4 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionItemDetailDataTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ResourceGroupCarbonEmissionItemDetailData; +import org.junit.jupiter.api.Assertions; + +public final class ResourceGroupCarbonEmissionItemDetailDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceGroupCarbonEmissionItemDetailData model = BinaryData.fromString( + "{\"dataType\":\"ResourceGroupItemDetailsData\",\"itemName\":\"tbzsgfyccs\",\"categoryType\":\"Location\",\"subscriptionId\":\"wmdwzjeiachboo\",\"resourceGroupUrl\":\"flnrosfqpteehzz\",\"latestMonthEmissions\":67.05551920666015,\"previousMonthEmissions\":45.17035712965603,\"monthOverMonthEmissionsChangeRatio\":0.45290535725276415,\"monthlyEmissionsChangeValue\":96.27415947539853}") + .toObject(ResourceGroupCarbonEmissionItemDetailData.class); + Assertions.assertEquals(67.05551920666015, model.latestMonthEmissions()); + Assertions.assertEquals(45.17035712965603, model.previousMonthEmissions()); + Assertions.assertEquals(0.45290535725276415D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(96.27415947539853D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("tbzsgfyccs", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.LOCATION, model.categoryType()); + Assertions.assertEquals("wmdwzjeiachboo", model.subscriptionId()); + Assertions.assertEquals("flnrosfqpteehzz", model.resourceGroupUrl()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionTopItemMonthlySummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionTopItemMonthlySummaryDataTests.java new file mode 100644 index 000000000000..144cac0bd6fb --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionTopItemMonthlySummaryDataTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ResourceGroupCarbonEmissionTopItemMonthlySummaryData; +import org.junit.jupiter.api.Assertions; + +public final class ResourceGroupCarbonEmissionTopItemMonthlySummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceGroupCarbonEmissionTopItemMonthlySummaryData model = BinaryData.fromString( + "{\"dataType\":\"ResourceGroupTopItemsMonthlySummaryData\",\"itemName\":\"kcprbnw\",\"categoryType\":\"ResourceGroup\",\"date\":\"gjvtbv\",\"subscriptionId\":\"ysszdnrujqguh\",\"resourceGroupUrl\":\"uouq\",\"latestMonthEmissions\":90.6761757010279,\"previousMonthEmissions\":57.60858367831252,\"monthOverMonthEmissionsChangeRatio\":28.107280914327326,\"monthlyEmissionsChangeValue\":48.90151152333295}") + .toObject(ResourceGroupCarbonEmissionTopItemMonthlySummaryData.class); + Assertions.assertEquals(90.6761757010279, model.latestMonthEmissions()); + Assertions.assertEquals(57.60858367831252, model.previousMonthEmissions()); + Assertions.assertEquals(28.107280914327326D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(48.90151152333295D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("kcprbnw", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_GROUP, model.categoryType()); + Assertions.assertEquals("gjvtbv", model.date()); + Assertions.assertEquals("ysszdnrujqguh", model.subscriptionId()); + Assertions.assertEquals("uouq", model.resourceGroupUrl()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionTopItemsSummaryDataTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionTopItemsSummaryDataTests.java new file mode 100644 index 000000000000..b4b034480722 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/ResourceGroupCarbonEmissionTopItemsSummaryDataTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.ResourceGroupCarbonEmissionTopItemsSummaryData; +import org.junit.jupiter.api.Assertions; + +public final class ResourceGroupCarbonEmissionTopItemsSummaryDataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceGroupCarbonEmissionTopItemsSummaryData model = BinaryData.fromString( + "{\"dataType\":\"ResourceGroupTopItemsSummaryData\",\"itemName\":\"bzqqedqytbciq\",\"categoryType\":\"Resource\",\"subscriptionId\":\"uflmm\",\"resourceGroupUrl\":\"kzsmodm\",\"latestMonthEmissions\":44.037906073975165,\"previousMonthEmissions\":34.71329293163695,\"monthOverMonthEmissionsChangeRatio\":4.0319472412470585,\"monthlyEmissionsChangeValue\":18.998142520154726}") + .toObject(ResourceGroupCarbonEmissionTopItemsSummaryData.class); + Assertions.assertEquals(44.037906073975165, model.latestMonthEmissions()); + Assertions.assertEquals(34.71329293163695, model.previousMonthEmissions()); + Assertions.assertEquals(4.0319472412470585D, model.monthOverMonthEmissionsChangeRatio()); + Assertions.assertEquals(18.998142520154726D, model.monthlyEmissionsChangeValue()); + Assertions.assertEquals("bzqqedqytbciq", model.itemName()); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE, model.categoryType()); + Assertions.assertEquals("uflmm", model.subscriptionId()); + Assertions.assertEquals("kzsmodm", model.resourceGroupUrl()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/SubscriptionAccessDecisionTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/SubscriptionAccessDecisionTests.java new file mode 100644 index 000000000000..d881a955d6fe --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/SubscriptionAccessDecisionTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.AccessDecisionEnum; +import com.azure.resourcemanager.carbonoptimization.models.SubscriptionAccessDecision; +import org.junit.jupiter.api.Assertions; + +public final class SubscriptionAccessDecisionTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SubscriptionAccessDecision model = BinaryData + .fromString("{\"subscriptionId\":\"pvswjdkirso\",\"decision\":\"Denied\",\"denialReason\":\"xhcr\"}") + .toObject(SubscriptionAccessDecision.class); + Assertions.assertEquals("pvswjdkirso", model.subscriptionId()); + Assertions.assertEquals(AccessDecisionEnum.DENIED, model.decision()); + Assertions.assertEquals("xhcr", model.denialReason()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/TopItemsMonthlySummaryReportQueryFilterTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/TopItemsMonthlySummaryReportQueryFilterTests.java new file mode 100644 index 000000000000..e15e5902c70d --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/TopItemsMonthlySummaryReportQueryFilterTests.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.TopItemsMonthlySummaryReportQueryFilter; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class TopItemsMonthlySummaryReportQueryFilterTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TopItemsMonthlySummaryReportQueryFilter model = BinaryData.fromString( + "{\"reportType\":\"TopItemsMonthlySummaryReport\",\"categoryType\":\"ResourceGroup\",\"topItems\":1437097866,\"dateRange\":{},\"subscriptionList\":[\"fxqeof\"],\"resourceGroupUrlList\":[\"qjhqjbas\"],\"resourceTypeList\":[\"mjqulngsn\",\"nbybkzgcwrwcl\",\"xwrljdouskcqvkoc\",\"cjdkwtnhxbnjbi\"],\"locationList\":[\"rglssainqpj\",\"nzl\",\"jfm\",\"pee\"],\"carbonScopeList\":[\"Scope3\",\"Scope1\"]}") + .toObject(TopItemsMonthlySummaryReportQueryFilter.class); + Assertions.assertEquals("fxqeof", model.subscriptionList().get(0)); + Assertions.assertEquals("qjhqjbas", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("mjqulngsn", model.resourceTypeList().get(0)); + Assertions.assertEquals("rglssainqpj", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE3, model.carbonScopeList().get(0)); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_GROUP, model.categoryType()); + Assertions.assertEquals(1437097866, model.topItems()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TopItemsMonthlySummaryReportQueryFilter model + = new TopItemsMonthlySummaryReportQueryFilter().withDateRange(new DateRange()) + .withSubscriptionList(Arrays.asList("fxqeof")) + .withResourceGroupUrlList(Arrays.asList("qjhqjbas")) + .withResourceTypeList(Arrays.asList("mjqulngsn", "nbybkzgcwrwcl", "xwrljdouskcqvkoc", "cjdkwtnhxbnjbi")) + .withLocationList(Arrays.asList("rglssainqpj", "nzl", "jfm", "pee")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE3, EmissionScopeEnum.SCOPE1)) + .withCategoryType(CategoryTypeEnum.RESOURCE_GROUP) + .withTopItems(1437097866); + model = BinaryData.fromObject(model).toObject(TopItemsMonthlySummaryReportQueryFilter.class); + Assertions.assertEquals("fxqeof", model.subscriptionList().get(0)); + Assertions.assertEquals("qjhqjbas", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("mjqulngsn", model.resourceTypeList().get(0)); + Assertions.assertEquals("rglssainqpj", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE3, model.carbonScopeList().get(0)); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_GROUP, model.categoryType()); + Assertions.assertEquals(1437097866, model.topItems()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/TopItemsSummaryReportQueryFilterTests.java b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/TopItemsSummaryReportQueryFilterTests.java new file mode 100644 index 000000000000..2c6c6de5c414 --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/src/test/java/com/azure/resourcemanager/carbonoptimization/generated/TopItemsSummaryReportQueryFilterTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.carbonoptimization.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.carbonoptimization.models.CategoryTypeEnum; +import com.azure.resourcemanager.carbonoptimization.models.DateRange; +import com.azure.resourcemanager.carbonoptimization.models.EmissionScopeEnum; +import com.azure.resourcemanager.carbonoptimization.models.TopItemsSummaryReportQueryFilter; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class TopItemsSummaryReportQueryFilterTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TopItemsSummaryReportQueryFilter model = BinaryData.fromString( + "{\"reportType\":\"TopItemsSummaryReport\",\"categoryType\":\"ResourceType\",\"topItems\":1694152390,\"dateRange\":{},\"subscriptionList\":[\"pfxxy\"],\"resourceGroupUrlList\":[\"i\",\"mayhuybbkpodepoo\",\"inuvamiheogn\"],\"resourceTypeList\":[\"zxtheotusivyevcc\",\"qi\"],\"locationList\":[\"un\",\"bwjzr\",\"fygxgispemvtzfk\"],\"carbonScopeList\":[\"Scope1\",\"Scope1\"]}") + .toObject(TopItemsSummaryReportQueryFilter.class); + Assertions.assertEquals("pfxxy", model.subscriptionList().get(0)); + Assertions.assertEquals("i", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("zxtheotusivyevcc", model.resourceTypeList().get(0)); + Assertions.assertEquals("un", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE1, model.carbonScopeList().get(0)); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_TYPE, model.categoryType()); + Assertions.assertEquals(1694152390, model.topItems()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TopItemsSummaryReportQueryFilter model = new TopItemsSummaryReportQueryFilter().withDateRange(new DateRange()) + .withSubscriptionList(Arrays.asList("pfxxy")) + .withResourceGroupUrlList(Arrays.asList("i", "mayhuybbkpodepoo", "inuvamiheogn")) + .withResourceTypeList(Arrays.asList("zxtheotusivyevcc", "qi")) + .withLocationList(Arrays.asList("un", "bwjzr", "fygxgispemvtzfk")) + .withCarbonScopeList(Arrays.asList(EmissionScopeEnum.SCOPE1, EmissionScopeEnum.SCOPE1)) + .withCategoryType(CategoryTypeEnum.RESOURCE_TYPE) + .withTopItems(1694152390); + model = BinaryData.fromObject(model).toObject(TopItemsSummaryReportQueryFilter.class); + Assertions.assertEquals("pfxxy", model.subscriptionList().get(0)); + Assertions.assertEquals("i", model.resourceGroupUrlList().get(0)); + Assertions.assertEquals("zxtheotusivyevcc", model.resourceTypeList().get(0)); + Assertions.assertEquals("un", model.locationList().get(0)); + Assertions.assertEquals(EmissionScopeEnum.SCOPE1, model.carbonScopeList().get(0)); + Assertions.assertEquals(CategoryTypeEnum.RESOURCE_TYPE, model.categoryType()); + Assertions.assertEquals(1694152390, model.topItems()); + } +} diff --git a/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/tsp-location.yaml b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/tsp-location.yaml new file mode 100644 index 000000000000..d7817f6e7e4d --- /dev/null +++ b/sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/carbon/Carbon.Management +commit: f5897f91405ea2d7c0c2a3ccc9fd384ff83efdab +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/carbonoptimization/ci.yml b/sdk/carbonoptimization/ci.yml new file mode 100644 index 000000000000..517bffc6e42d --- /dev/null +++ b/sdk/carbonoptimization/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/carbonoptimization/ci.yml + - sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/ + exclude: + - sdk/carbonoptimization/pom.xml + - sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/carbonoptimization/ci.yml + - sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/ + exclude: + - sdk/carbonoptimization/pom.xml + - sdk/carbonoptimization/azure-resourcemanager-carbonoptimization/pom.xml + +parameters: + - name: release_azureresourcemanagercarbonoptimization + displayName: azure-resourcemanager-carbonoptimization + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: carbonoptimization + Artifacts: + - name: azure-resourcemanager-carbonoptimization + groupId: com.azure.resourcemanager + safeName: azureresourcemanagercarbonoptimization + releaseInBatch: ${{ parameters.release_azureresourcemanagercarbonoptimization }} diff --git a/sdk/carbonoptimization/pom.xml b/sdk/carbonoptimization/pom.xml new file mode 100644 index 000000000000..8c80b5621ac3 --- /dev/null +++ b/sdk/carbonoptimization/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-carbonoptimization-service + pom + 1.0.0 + + + azure-resourcemanager-carbonoptimization + +