From 17af47fdd27dee43dd6bae307ac881b0cfd2ce60 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 9 Feb 2022 06:41:18 +0000 Subject: [PATCH] CodeGen from PR 17628 in Azure/azure-rest-api-specs Adding xms-ids for Commerce (#17628) --- .../CHANGELOG.md | 3 +- .../azure-resourcemanager-commerce/README.md | 5 +- .../azure-resourcemanager-commerce/SAMPLE.md | 31 ++ .../azure-resourcemanager-commerce/pom.xml | 98 ++--- .../commerce/UsageManager.java | 37 +- .../commerce/fluent/RateCardsClient.java | 2 +- .../models/ResourceRateCardInfoInner.java | 8 +- .../fluent/models/UsageAggregationInner.java | 175 ++++----- .../commerce/fluent/models/UsageSample.java | 344 ++++++++++++++++++ .../implementation/RateCardsClientImpl.java | 10 +- .../ResourceRateCardInfoImpl.java | 6 +- .../UsageAggregatesClientImpl.java | 12 +- .../commerce/models/MeterInfo.java | 2 + .../commerce/models/MonetaryCommitment.java | 4 +- .../commerce/models/MonetaryCredit.java | 2 +- .../commerce/models/OfferTermInfo.java | 79 ++-- .../models/OfferTermInfoAutoGenerated.java | 65 ++++ .../commerce/models/OfferTermInfoValue.java | 50 --- .../commerce/models/RateCards.java | 2 +- .../commerce/models/RecurringCharge.java | 2 +- .../commerce/models/ResourceRateCardInfo.java | 2 +- .../generated/RateCardGetSamples.java | 26 ++ 22 files changed, 691 insertions(+), 274 deletions(-) create mode 100644 sdk/commerce/azure-resourcemanager-commerce/SAMPLE.md create mode 100644 sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageSample.java create mode 100644 sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoAutoGenerated.java delete mode 100644 sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoValue.java create mode 100644 sdk/commerce/azure-resourcemanager-commerce/src/samples/java/com/azure/resourcemanager/commerce/generated/RateCardGetSamples.java diff --git a/sdk/commerce/azure-resourcemanager-commerce/CHANGELOG.md b/sdk/commerce/azure-resourcemanager-commerce/CHANGELOG.md index f98bc1b9712aa..12452b7a44eaf 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/CHANGELOG.md +++ b/sdk/commerce/azure-resourcemanager-commerce/CHANGELOG.md @@ -1,7 +1,8 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.1 (2022-02-09) +- Azure Resource Manager Usage client library for Java. This package contains Microsoft Azure SDK for Usage Management SDK. Package tag package-2015-06-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ## 1.0.0-beta.1 (2021-04-13) diff --git a/sdk/commerce/azure-resourcemanager-commerce/README.md b/sdk/commerce/azure-resourcemanager-commerce/README.md index 4d39d5f1dc281..6c2ad86ecee8b 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/README.md +++ b/sdk/commerce/azure-resourcemanager-commerce/README.md @@ -32,7 +32,7 @@ Various documentation is available to help you get started com.azure.resourcemanager azure-resourcemanager-commerce - 1.0.0-beta.1 + 1.0.0-beta.2 ``` [//]: # ({x-version-update-end}) @@ -74,6 +74,9 @@ See [API design][design] for general introduction on design and key concepts on ## Examples +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/commerce/azure-resourcemanager-commerce/SAMPLE.md) + + ## Troubleshooting ## Next steps diff --git a/sdk/commerce/azure-resourcemanager-commerce/SAMPLE.md b/sdk/commerce/azure-resourcemanager-commerce/SAMPLE.md new file mode 100644 index 0000000000000..da3099f5db6ca --- /dev/null +++ b/sdk/commerce/azure-resourcemanager-commerce/SAMPLE.md @@ -0,0 +1,31 @@ +# Code snippets and samples + + +## RateCard + +- [Get](#ratecard_get) +### RateCard_Get + +```java +import com.azure.core.util.Context; + +/** Samples for RateCard Get. */ +public final class RateCardGetSamples { + /* + * x-ms-original-file: specification/commerce/resource-manager/Microsoft.Commerce/preview/2015-06-01-preview/examples/GetRateCard.json + */ + /** + * Sample code: GetRateCard. + * + * @param manager Entry point to UsageManager. + */ + public static void getRateCard(com.azure.resourcemanager.commerce.UsageManager manager) { + manager + .rateCards() + .getWithResponse( + "OfferDurableId eq 'MS-AZR-0003P' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'", + Context.NONE); + } +} +``` + diff --git a/sdk/commerce/azure-resourcemanager-commerce/pom.xml b/sdk/commerce/azure-resourcemanager-commerce/pom.xml index df1449fd9a8eb..66f54c93a25f7 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/pom.xml +++ b/sdk/commerce/azure-resourcemanager-commerce/pom.xml @@ -1,55 +1,55 @@ - 4.0.0 - - com.azure - azure-client-sdk-parent - 1.7.0 - ../../parents/azure-client-sdk-parent - + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + - com.azure.resourcemanager - azure-resourcemanager-commerce - 1.0.0-beta.2 - jar + com.azure.resourcemanager + azure-resourcemanager-commerce + 1.0.0-beta.2 + jar - Microsoft Azure SDK for Usage Management - This package contains Microsoft Azure SDK for Usage Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2015-06-preview. - https://github.com/Azure/azure-sdk-for-java + Microsoft Azure SDK for Usage Management + This package contains Microsoft Azure SDK for Usage Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2015-06-preview. + https://github.com/Azure/azure-sdk-for-java - - - The MIT License (MIT) - http://opensource.org/licenses/MIT - repo - - + + + 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 - true - - - - com.azure - azure-core - 1.25.0 - - - com.azure - azure-core-management - 1.5.2 - - + + 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 + true + + + + com.azure + azure-core + 1.25.0 + + + com.azure + azure-core-management + 1.5.2 + + diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/UsageManager.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/UsageManager.java index cefee4c355c8e..89e8e71e3f5e7 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/UsageManager.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/UsageManager.java @@ -8,8 +8,8 @@ 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.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; @@ -17,6 +17,7 @@ import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; import com.azure.core.management.profile.AzureProfile; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; @@ -31,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** Entry point to UsageManager. */ public final class UsageManager { @@ -81,6 +83,7 @@ public static final class Configurable { private HttpClient httpClient; private HttpLogOptions httpLogOptions; private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); private RetryPolicy retryPolicy; private Duration defaultPollInterval; @@ -120,6 +123,17 @@ public Configurable withPolicy(HttpPipelinePolicy policy) { 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. * @@ -176,20 +190,33 @@ public UsageManager authenticate(TokenCredential credential, AzureProfile profil userAgentBuilder.append(" (auto-generated)"); } + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } if (retryPolicy == null) { retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); } List policies = new ArrayList<>(); policies.add(new UserAgentPolicy(userAgentBuilder.toString())); 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 ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); policies - .add( - new BearerTokenAuthenticationPolicy( - credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); - policies.addAll(this.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 = diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/RateCardsClient.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/RateCardsClient.java index 8463a9589ec9f..03ec81c5233ba 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/RateCardsClient.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/RateCardsClient.java @@ -46,7 +46,7 @@ public interface RateCardsClient { * @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 price and Metadata information for resources. + * @return price and Metadata information for resources along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) Response getWithResponse(String filter, Context context); diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/ResourceRateCardInfoInner.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/ResourceRateCardInfoInner.java index ef7d8c5ef553b..a9cdb2197c74b 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/ResourceRateCardInfoInner.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/ResourceRateCardInfoInner.java @@ -7,7 +7,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.logging.ClientLogger; import com.azure.resourcemanager.commerce.models.MeterInfo; -import com.azure.resourcemanager.commerce.models.OfferTermInfo; +import com.azure.resourcemanager.commerce.models.OfferTermInfoAutoGenerated; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; @@ -39,7 +39,7 @@ public final class ResourceRateCardInfoInner { * A list of offer terms. */ @JsonProperty(value = "OfferTerms") - private List offerTerms; + private List offerTerms; /* * A list of meters. @@ -112,7 +112,7 @@ public ResourceRateCardInfoInner withIsTaxIncluded(Boolean isTaxIncluded) { * * @return the offerTerms value. */ - public List offerTerms() { + public List offerTerms() { return this.offerTerms; } @@ -122,7 +122,7 @@ public List offerTerms() { * @param offerTerms the offerTerms value to set. * @return the ResourceRateCardInfoInner object itself. */ - public ResourceRateCardInfoInner withOfferTerms(List offerTerms) { + public ResourceRateCardInfoInner withOfferTerms(List offerTerms) { this.offerTerms = offerTerms; return this; } diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageAggregationInner.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageAggregationInner.java index 8a36a3fcb1c1e..cfa99e957c635 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageAggregationInner.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageAggregationInner.java @@ -5,7 +5,6 @@ package com.azure.resourcemanager.commerce.fluent.models; import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.JsonFlatten; import com.azure.core.util.logging.ClientLogger; import com.azure.resourcemanager.commerce.models.InfoField; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -14,9 +13,8 @@ import java.util.UUID; /** Describes the usageAggregation. */ -@JsonFlatten @Fluent -public class UsageAggregationInner { +public final class UsageAggregationInner { @JsonIgnore private final ClientLogger logger = new ClientLogger(UsageAggregationInner.class); /* @@ -38,78 +36,10 @@ public class UsageAggregationInner { private String type; /* - * The subscription identifier for the Azure user. + * Usage data. */ - @JsonProperty(value = "properties.subscriptionId") - private UUID subscriptionId; - - /* - * Unique ID for the resource that was consumed (aka ResourceID). - */ - @JsonProperty(value = "properties.meterId") - private String meterId; - - /* - * UTC start time for the usage bucket to which this usage aggregate - * belongs. - */ - @JsonProperty(value = "properties.usageStartTime") - private OffsetDateTime usageStartTime; - - /* - * UTC end time for the usage bucket to which this usage aggregate belongs. - */ - @JsonProperty(value = "properties.usageEndTime") - private OffsetDateTime usageEndTime; - - /* - * The amount of the resource consumption that occurred in this time frame. - */ - @JsonProperty(value = "properties.quantity") - private Float quantity; - - /* - * The unit in which the usage for this resource is being counted, e.g. - * Hours, GB. - */ - @JsonProperty(value = "properties.unit") - private String unit; - - /* - * Friendly name of the resource being consumed. - */ - @JsonProperty(value = "properties.meterName") - private String meterName; - - /* - * Category of the consumed resource. - */ - @JsonProperty(value = "properties.meterCategory") - private String meterCategory; - - /* - * Sub-category of the consumed resource. - */ - @JsonProperty(value = "properties.meterSubCategory") - private String meterSubCategory; - - /* - * Region of the meterId used for billing purposes - */ - @JsonProperty(value = "properties.meterRegion") - private String meterRegion; - - /* - * Key-value pairs of instance details (legacy format). - */ - @JsonProperty(value = "properties.infoFields") - private InfoField infoFields; - - /* - * Key-value pairs of instance details represented as a string. - */ - @JsonProperty(value = "properties.instanceData") - private String instanceData; + @JsonProperty(value = "properties") + private UsageSample innerProperties; /** * Get the id property: Unique Id for the usage aggregate. @@ -171,13 +101,22 @@ public UsageAggregationInner withType(String type) { return this; } + /** + * Get the innerProperties property: Usage data. + * + * @return the innerProperties value. + */ + private UsageSample innerProperties() { + return this.innerProperties; + } + /** * Get the subscriptionId property: The subscription identifier for the Azure user. * * @return the subscriptionId value. */ public UUID subscriptionId() { - return this.subscriptionId; + return this.innerProperties() == null ? null : this.innerProperties().subscriptionId(); } /** @@ -187,7 +126,10 @@ public UUID subscriptionId() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withSubscriptionId(UUID subscriptionId) { - this.subscriptionId = subscriptionId; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withSubscriptionId(subscriptionId); return this; } @@ -197,7 +139,7 @@ public UsageAggregationInner withSubscriptionId(UUID subscriptionId) { * @return the meterId value. */ public String meterId() { - return this.meterId; + return this.innerProperties() == null ? null : this.innerProperties().meterId(); } /** @@ -207,7 +149,10 @@ public String meterId() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withMeterId(String meterId) { - this.meterId = meterId; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withMeterId(meterId); return this; } @@ -217,7 +162,7 @@ public UsageAggregationInner withMeterId(String meterId) { * @return the usageStartTime value. */ public OffsetDateTime usageStartTime() { - return this.usageStartTime; + return this.innerProperties() == null ? null : this.innerProperties().usageStartTime(); } /** @@ -227,7 +172,10 @@ public OffsetDateTime usageStartTime() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withUsageStartTime(OffsetDateTime usageStartTime) { - this.usageStartTime = usageStartTime; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withUsageStartTime(usageStartTime); return this; } @@ -237,7 +185,7 @@ public UsageAggregationInner withUsageStartTime(OffsetDateTime usageStartTime) { * @return the usageEndTime value. */ public OffsetDateTime usageEndTime() { - return this.usageEndTime; + return this.innerProperties() == null ? null : this.innerProperties().usageEndTime(); } /** @@ -247,7 +195,10 @@ public OffsetDateTime usageEndTime() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withUsageEndTime(OffsetDateTime usageEndTime) { - this.usageEndTime = usageEndTime; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withUsageEndTime(usageEndTime); return this; } @@ -257,7 +208,7 @@ public UsageAggregationInner withUsageEndTime(OffsetDateTime usageEndTime) { * @return the quantity value. */ public Float quantity() { - return this.quantity; + return this.innerProperties() == null ? null : this.innerProperties().quantity(); } /** @@ -267,7 +218,10 @@ public Float quantity() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withQuantity(Float quantity) { - this.quantity = quantity; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withQuantity(quantity); return this; } @@ -277,7 +231,7 @@ public UsageAggregationInner withQuantity(Float quantity) { * @return the unit value. */ public String unit() { - return this.unit; + return this.innerProperties() == null ? null : this.innerProperties().unit(); } /** @@ -287,7 +241,10 @@ public String unit() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withUnit(String unit) { - this.unit = unit; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withUnit(unit); return this; } @@ -297,7 +254,7 @@ public UsageAggregationInner withUnit(String unit) { * @return the meterName value. */ public String meterName() { - return this.meterName; + return this.innerProperties() == null ? null : this.innerProperties().meterName(); } /** @@ -307,7 +264,10 @@ public String meterName() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withMeterName(String meterName) { - this.meterName = meterName; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withMeterName(meterName); return this; } @@ -317,7 +277,7 @@ public UsageAggregationInner withMeterName(String meterName) { * @return the meterCategory value. */ public String meterCategory() { - return this.meterCategory; + return this.innerProperties() == null ? null : this.innerProperties().meterCategory(); } /** @@ -327,7 +287,10 @@ public String meterCategory() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withMeterCategory(String meterCategory) { - this.meterCategory = meterCategory; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withMeterCategory(meterCategory); return this; } @@ -337,7 +300,7 @@ public UsageAggregationInner withMeterCategory(String meterCategory) { * @return the meterSubCategory value. */ public String meterSubCategory() { - return this.meterSubCategory; + return this.innerProperties() == null ? null : this.innerProperties().meterSubCategory(); } /** @@ -347,7 +310,10 @@ public String meterSubCategory() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withMeterSubCategory(String meterSubCategory) { - this.meterSubCategory = meterSubCategory; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withMeterSubCategory(meterSubCategory); return this; } @@ -357,7 +323,7 @@ public UsageAggregationInner withMeterSubCategory(String meterSubCategory) { * @return the meterRegion value. */ public String meterRegion() { - return this.meterRegion; + return this.innerProperties() == null ? null : this.innerProperties().meterRegion(); } /** @@ -367,7 +333,10 @@ public String meterRegion() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withMeterRegion(String meterRegion) { - this.meterRegion = meterRegion; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withMeterRegion(meterRegion); return this; } @@ -377,7 +346,7 @@ public UsageAggregationInner withMeterRegion(String meterRegion) { * @return the infoFields value. */ public InfoField infoFields() { - return this.infoFields; + return this.innerProperties() == null ? null : this.innerProperties().infoFields(); } /** @@ -387,7 +356,10 @@ public InfoField infoFields() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withInfoFields(InfoField infoFields) { - this.infoFields = infoFields; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withInfoFields(infoFields); return this; } @@ -397,7 +369,7 @@ public UsageAggregationInner withInfoFields(InfoField infoFields) { * @return the instanceData value. */ public String instanceData() { - return this.instanceData; + return this.innerProperties() == null ? null : this.innerProperties().instanceData(); } /** @@ -407,7 +379,10 @@ public String instanceData() { * @return the UsageAggregationInner object itself. */ public UsageAggregationInner withInstanceData(String instanceData) { - this.instanceData = instanceData; + if (this.innerProperties() == null) { + this.innerProperties = new UsageSample(); + } + this.innerProperties().withInstanceData(instanceData); return this; } @@ -417,8 +392,8 @@ public UsageAggregationInner withInstanceData(String instanceData) { * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { - if (infoFields() != null) { - infoFields().validate(); + if (innerProperties() != null) { + innerProperties().validate(); } } } diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageSample.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageSample.java new file mode 100644 index 0000000000000..284fd08718815 --- /dev/null +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/fluent/models/UsageSample.java @@ -0,0 +1,344 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.commerce.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.commerce.models.InfoField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.UUID; + +/** Describes a sample of the usageAggregation. */ +@Fluent +public final class UsageSample { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsageSample.class); + + /* + * The subscription identifier for the Azure user. + */ + @JsonProperty(value = "subscriptionId") + private UUID subscriptionId; + + /* + * Unique ID for the resource that was consumed (aka ResourceID). + */ + @JsonProperty(value = "meterId") + private String meterId; + + /* + * UTC start time for the usage bucket to which this usage aggregate + * belongs. + */ + @JsonProperty(value = "usageStartTime") + private OffsetDateTime usageStartTime; + + /* + * UTC end time for the usage bucket to which this usage aggregate belongs. + */ + @JsonProperty(value = "usageEndTime") + private OffsetDateTime usageEndTime; + + /* + * The amount of the resource consumption that occurred in this time frame. + */ + @JsonProperty(value = "quantity") + private Float quantity; + + /* + * The unit in which the usage for this resource is being counted, e.g. + * Hours, GB. + */ + @JsonProperty(value = "unit") + private String unit; + + /* + * Friendly name of the resource being consumed. + */ + @JsonProperty(value = "meterName") + private String meterName; + + /* + * Category of the consumed resource. + */ + @JsonProperty(value = "meterCategory") + private String meterCategory; + + /* + * Sub-category of the consumed resource. + */ + @JsonProperty(value = "meterSubCategory") + private String meterSubCategory; + + /* + * Region of the meterId used for billing purposes + */ + @JsonProperty(value = "meterRegion") + private String meterRegion; + + /* + * Key-value pairs of instance details (legacy format). + */ + @JsonProperty(value = "infoFields") + private InfoField infoFields; + + /* + * Key-value pairs of instance details represented as a string. + */ + @JsonProperty(value = "instanceData") + private String instanceData; + + /** + * Get the subscriptionId property: The subscription identifier for the Azure user. + * + * @return the subscriptionId value. + */ + public UUID subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: The subscription identifier for the Azure user. + * + * @param subscriptionId the subscriptionId value to set. + * @return the UsageSample object itself. + */ + public UsageSample withSubscriptionId(UUID subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the meterId property: Unique ID for the resource that was consumed (aka ResourceID). + * + * @return the meterId value. + */ + public String meterId() { + return this.meterId; + } + + /** + * Set the meterId property: Unique ID for the resource that was consumed (aka ResourceID). + * + * @param meterId the meterId value to set. + * @return the UsageSample object itself. + */ + public UsageSample withMeterId(String meterId) { + this.meterId = meterId; + return this; + } + + /** + * Get the usageStartTime property: UTC start time for the usage bucket to which this usage aggregate belongs. + * + * @return the usageStartTime value. + */ + public OffsetDateTime usageStartTime() { + return this.usageStartTime; + } + + /** + * Set the usageStartTime property: UTC start time for the usage bucket to which this usage aggregate belongs. + * + * @param usageStartTime the usageStartTime value to set. + * @return the UsageSample object itself. + */ + public UsageSample withUsageStartTime(OffsetDateTime usageStartTime) { + this.usageStartTime = usageStartTime; + return this; + } + + /** + * Get the usageEndTime property: UTC end time for the usage bucket to which this usage aggregate belongs. + * + * @return the usageEndTime value. + */ + public OffsetDateTime usageEndTime() { + return this.usageEndTime; + } + + /** + * Set the usageEndTime property: UTC end time for the usage bucket to which this usage aggregate belongs. + * + * @param usageEndTime the usageEndTime value to set. + * @return the UsageSample object itself. + */ + public UsageSample withUsageEndTime(OffsetDateTime usageEndTime) { + this.usageEndTime = usageEndTime; + return this; + } + + /** + * Get the quantity property: The amount of the resource consumption that occurred in this time frame. + * + * @return the quantity value. + */ + public Float quantity() { + return this.quantity; + } + + /** + * Set the quantity property: The amount of the resource consumption that occurred in this time frame. + * + * @param quantity the quantity value to set. + * @return the UsageSample object itself. + */ + public UsageSample withQuantity(Float quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get the unit property: The unit in which the usage for this resource is being counted, e.g. Hours, GB. + * + * @return the unit value. + */ + public String unit() { + return this.unit; + } + + /** + * Set the unit property: The unit in which the usage for this resource is being counted, e.g. Hours, GB. + * + * @param unit the unit value to set. + * @return the UsageSample object itself. + */ + public UsageSample withUnit(String unit) { + this.unit = unit; + return this; + } + + /** + * Get the meterName property: Friendly name of the resource being consumed. + * + * @return the meterName value. + */ + public String meterName() { + return this.meterName; + } + + /** + * Set the meterName property: Friendly name of the resource being consumed. + * + * @param meterName the meterName value to set. + * @return the UsageSample object itself. + */ + public UsageSample withMeterName(String meterName) { + this.meterName = meterName; + return this; + } + + /** + * Get the meterCategory property: Category of the consumed resource. + * + * @return the meterCategory value. + */ + public String meterCategory() { + return this.meterCategory; + } + + /** + * Set the meterCategory property: Category of the consumed resource. + * + * @param meterCategory the meterCategory value to set. + * @return the UsageSample object itself. + */ + public UsageSample withMeterCategory(String meterCategory) { + this.meterCategory = meterCategory; + return this; + } + + /** + * Get the meterSubCategory property: Sub-category of the consumed resource. + * + * @return the meterSubCategory value. + */ + public String meterSubCategory() { + return this.meterSubCategory; + } + + /** + * Set the meterSubCategory property: Sub-category of the consumed resource. + * + * @param meterSubCategory the meterSubCategory value to set. + * @return the UsageSample object itself. + */ + public UsageSample withMeterSubCategory(String meterSubCategory) { + this.meterSubCategory = meterSubCategory; + return this; + } + + /** + * Get the meterRegion property: Region of the meterId used for billing purposes. + * + * @return the meterRegion value. + */ + public String meterRegion() { + return this.meterRegion; + } + + /** + * Set the meterRegion property: Region of the meterId used for billing purposes. + * + * @param meterRegion the meterRegion value to set. + * @return the UsageSample object itself. + */ + public UsageSample withMeterRegion(String meterRegion) { + this.meterRegion = meterRegion; + return this; + } + + /** + * Get the infoFields property: Key-value pairs of instance details (legacy format). + * + * @return the infoFields value. + */ + public InfoField infoFields() { + return this.infoFields; + } + + /** + * Set the infoFields property: Key-value pairs of instance details (legacy format). + * + * @param infoFields the infoFields value to set. + * @return the UsageSample object itself. + */ + public UsageSample withInfoFields(InfoField infoFields) { + this.infoFields = infoFields; + return this; + } + + /** + * Get the instanceData property: Key-value pairs of instance details represented as a string. + * + * @return the instanceData value. + */ + public String instanceData() { + return this.instanceData; + } + + /** + * Set the instanceData property: Key-value pairs of instance details represented as a string. + * + * @param instanceData the instanceData value to set. + * @return the UsageSample object itself. + */ + public UsageSample withInstanceData(String instanceData) { + this.instanceData = instanceData; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (infoFields() != null) { + infoFields().validate(); + } + } +} diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/RateCardsClientImpl.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/RateCardsClientImpl.java index ab0122223ba84..0697f9529c530 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/RateCardsClientImpl.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/RateCardsClientImpl.java @@ -81,7 +81,8 @@ Mono> get( * @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 price and Metadata information for resources. + * @return price and Metadata information for resources along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getWithResponseAsync(String filter) { @@ -130,7 +131,8 @@ private Mono> getWithResponseAsync(String fi * @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 price and Metadata information for resources. + * @return price and Metadata information for resources along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getWithResponseAsync(String filter, Context context) { @@ -175,7 +177,7 @@ private Mono> getWithResponseAsync(String fi * @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 price and Metadata information for resources. + * @return price and Metadata information for resources on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono getAsync(String filter) { @@ -226,7 +228,7 @@ public ResourceRateCardInfoInner get(String filter) { * @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 price and Metadata information for resources. + * @return price and Metadata information for resources along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(String filter, Context context) { diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/ResourceRateCardInfoImpl.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/ResourceRateCardInfoImpl.java index 05e0eafe42cc8..b877ec00b3015 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/ResourceRateCardInfoImpl.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/ResourceRateCardInfoImpl.java @@ -6,7 +6,7 @@ import com.azure.resourcemanager.commerce.fluent.models.ResourceRateCardInfoInner; import com.azure.resourcemanager.commerce.models.MeterInfo; -import com.azure.resourcemanager.commerce.models.OfferTermInfo; +import com.azure.resourcemanager.commerce.models.OfferTermInfoAutoGenerated; import com.azure.resourcemanager.commerce.models.ResourceRateCardInfo; import java.util.Collections; import java.util.List; @@ -34,8 +34,8 @@ public Boolean isTaxIncluded() { return this.innerModel().isTaxIncluded(); } - public List offerTerms() { - List inner = this.innerModel().offerTerms(); + public List offerTerms() { + List inner = this.innerModel().offerTerms(); if (inner != null) { return Collections.unmodifiableList(inner); } else { diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/UsageAggregatesClientImpl.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/UsageAggregatesClientImpl.java index fa34ef6365c2b..9032e10f7b168 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/UsageAggregatesClientImpl.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/implementation/UsageAggregatesClientImpl.java @@ -106,7 +106,8 @@ Mono> listNext( * @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 the Get UsageAggregates operation response. + * @return the Get UsageAggregates operation response along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync( @@ -182,7 +183,8 @@ private Mono> listSinglePageAsync( * @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 the Get UsageAggregates operation response. + * @return the Get UsageAggregates operation response along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync( @@ -395,7 +397,8 @@ public PagedIterable list( * @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 the Get UsageAggregates operation response. + * @return the Get UsageAggregates operation response along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink) { @@ -431,7 +434,8 @@ private Mono> listNextSinglePageAsync(Strin * @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 the Get UsageAggregates operation response. + * @return the Get UsageAggregates operation response along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink, Context context) { diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MeterInfo.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MeterInfo.java index 6686aaccbf418..2b06c821477ae 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MeterInfo.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MeterInfo.java @@ -7,6 +7,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.logging.ClientLogger; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.time.OffsetDateTime; import java.util.List; @@ -69,6 +70,7 @@ public final class MeterInfo { * corresponding price */ @JsonProperty(value = "MeterRates") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map meterRates; /* diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCommitment.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCommitment.java index 7b6e23696ae3f..111ce42bf0316 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCommitment.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCommitment.java @@ -7,6 +7,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.logging.ClientLogger; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; @@ -20,7 +21,7 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "Name") @JsonTypeName("Monetary Commitment") @Fluent -public final class MonetaryCommitment extends OfferTermInfo { +public final class MonetaryCommitment extends OfferTermInfoAutoGenerated { @JsonIgnore private final ClientLogger logger = new ClientLogger(MonetaryCommitment.class); /* @@ -30,6 +31,7 @@ public final class MonetaryCommitment extends OfferTermInfo { * Commitment'. */ @JsonProperty(value = "TieredDiscount") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map tieredDiscount; /* diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCredit.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCredit.java index b4af426b36bca..ec9d33ef756e1 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCredit.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/MonetaryCredit.java @@ -19,7 +19,7 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "Name") @JsonTypeName("Monetary Credit") @Fluent -public final class MonetaryCredit extends OfferTermInfo { +public final class MonetaryCredit extends OfferTermInfoAutoGenerated { @JsonIgnore private final ClientLogger logger = new ClientLogger(MonetaryCredit.class); /* diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfo.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfo.java index 6facad9c2da42..985d59a0acf0f 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfo.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfo.java @@ -4,62 +4,47 @@ package com.azure.resourcemanager.commerce.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.logging.ClientLogger; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; -/** Describes the offer term. */ -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - property = "Name", - defaultImpl = OfferTermInfo.class) -@JsonTypeName("OfferTermInfo") -@JsonSubTypes({ - @JsonSubTypes.Type(name = "Monetary Credit", value = MonetaryCredit.class), - @JsonSubTypes.Type(name = "Monetary Commitment", value = MonetaryCommitment.class), - @JsonSubTypes.Type(name = "Recurring Charge", value = RecurringCharge.class) -}) -@Fluent -public class OfferTermInfo { - @JsonIgnore private final ClientLogger logger = new ClientLogger(OfferTermInfo.class); +/** Defines values for OfferTermInfo. */ +public enum OfferTermInfo { + /** Enum value Recurring Charge. */ + RECURRING_CHARGE("Recurring Charge"), - /* - * Indicates the date from which the offer term is effective. - */ - @JsonProperty(value = "EffectiveDate") - private OffsetDateTime effectiveDate; + /** Enum value Monetary Commitment. */ + MONETARY_COMMITMENT("Monetary Commitment"), - /** - * Get the effectiveDate property: Indicates the date from which the offer term is effective. - * - * @return the effectiveDate value. - */ - public OffsetDateTime effectiveDate() { - return this.effectiveDate; + /** Enum value Monetary Credit. */ + MONETARY_CREDIT("Monetary Credit"); + + /** The actual serialized value for a OfferTermInfo instance. */ + private final String value; + + OfferTermInfo(String value) { + this.value = value; } /** - * Set the effectiveDate property: Indicates the date from which the offer term is effective. + * Parses a serialized value to a OfferTermInfo instance. * - * @param effectiveDate the effectiveDate value to set. - * @return the OfferTermInfo object itself. + * @param value the serialized value to parse. + * @return the parsed OfferTermInfo object, or null if unable to parse. */ - public OfferTermInfo withEffectiveDate(OffsetDateTime effectiveDate) { - this.effectiveDate = effectiveDate; - return this; + @JsonCreator + public static OfferTermInfo fromString(String value) { + OfferTermInfo[] items = OfferTermInfo.values(); + for (OfferTermInfo item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; } - /** - * Validates the instance. - * - * @throws IllegalArgumentException thrown if the instance is not valid. - */ - public void validate() { + @JsonValue + @Override + public String toString() { + return this.value; } } diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoAutoGenerated.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoAutoGenerated.java new file mode 100644 index 0000000000000..79fbb02b29be6 --- /dev/null +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoAutoGenerated.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.commerce.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.OffsetDateTime; + +/** Describes the offer term. */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "Name", + defaultImpl = OfferTermInfoAutoGenerated.class) +@JsonTypeName("OfferTermInfoAutoGenerated") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "Monetary Credit", value = MonetaryCredit.class), + @JsonSubTypes.Type(name = "Monetary Commitment", value = MonetaryCommitment.class), + @JsonSubTypes.Type(name = "Recurring Charge", value = RecurringCharge.class) +}) +@Fluent +public class OfferTermInfoAutoGenerated { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OfferTermInfoAutoGenerated.class); + + /* + * Indicates the date from which the offer term is effective. + */ + @JsonProperty(value = "EffectiveDate") + private OffsetDateTime effectiveDate; + + /** + * Get the effectiveDate property: Indicates the date from which the offer term is effective. + * + * @return the effectiveDate value. + */ + public OffsetDateTime effectiveDate() { + return this.effectiveDate; + } + + /** + * Set the effectiveDate property: Indicates the date from which the offer term is effective. + * + * @param effectiveDate the effectiveDate value to set. + * @return the OfferTermInfoAutoGenerated object itself. + */ + public OfferTermInfoAutoGenerated withEffectiveDate(OffsetDateTime effectiveDate) { + this.effectiveDate = effectiveDate; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoValue.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoValue.java deleted file mode 100644 index acf51ccc70edb..0000000000000 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/OfferTermInfoValue.java +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.resourcemanager.commerce.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** Defines values for OfferTermInfoValue. */ -public enum OfferTermInfoValue { - /** Enum value Recurring Charge. */ - RECURRING_CHARGE("Recurring Charge"), - - /** Enum value Monetary Commitment. */ - MONETARY_COMMITMENT("Monetary Commitment"), - - /** Enum value Monetary Credit. */ - MONETARY_CREDIT("Monetary Credit"); - - /** The actual serialized value for a OfferTermInfoValue instance. */ - private final String value; - - OfferTermInfoValue(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a OfferTermInfoValue instance. - * - * @param value the serialized value to parse. - * @return the parsed OfferTermInfoValue object, or null if unable to parse. - */ - @JsonCreator - public static OfferTermInfoValue fromString(String value) { - OfferTermInfoValue[] items = OfferTermInfoValue.values(); - for (OfferTermInfoValue item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RateCards.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RateCards.java index 3eb8f17ff6345..71be777b41c58 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RateCards.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RateCards.java @@ -42,7 +42,7 @@ public interface RateCards { * @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 price and Metadata information for resources. + * @return price and Metadata information for resources along with {@link Response}. */ Response getWithResponse(String filter, Context context); } diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RecurringCharge.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RecurringCharge.java index 5e621a54f083e..7f12934eafe58 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RecurringCharge.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/RecurringCharge.java @@ -16,7 +16,7 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "Name") @JsonTypeName("Recurring Charge") @Fluent -public final class RecurringCharge extends OfferTermInfo { +public final class RecurringCharge extends OfferTermInfoAutoGenerated { @JsonIgnore private final ClientLogger logger = new ClientLogger(RecurringCharge.class); /* diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/ResourceRateCardInfo.java b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/ResourceRateCardInfo.java index d2d740ac56a77..bd7ccdb02ea3d 100644 --- a/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/ResourceRateCardInfo.java +++ b/sdk/commerce/azure-resourcemanager-commerce/src/main/java/com/azure/resourcemanager/commerce/models/ResourceRateCardInfo.java @@ -35,7 +35,7 @@ public interface ResourceRateCardInfo { * * @return the offerTerms value. */ - List offerTerms(); + List offerTerms(); /** * Gets the meters property: A list of meters. diff --git a/sdk/commerce/azure-resourcemanager-commerce/src/samples/java/com/azure/resourcemanager/commerce/generated/RateCardGetSamples.java b/sdk/commerce/azure-resourcemanager-commerce/src/samples/java/com/azure/resourcemanager/commerce/generated/RateCardGetSamples.java new file mode 100644 index 0000000000000..80462e9335f4a --- /dev/null +++ b/sdk/commerce/azure-resourcemanager-commerce/src/samples/java/com/azure/resourcemanager/commerce/generated/RateCardGetSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.commerce.generated; + +import com.azure.core.util.Context; + +/** Samples for RateCard Get. */ +public final class RateCardGetSamples { + /* + * x-ms-original-file: specification/commerce/resource-manager/Microsoft.Commerce/preview/2015-06-01-preview/examples/GetRateCard.json + */ + /** + * Sample code: GetRateCard. + * + * @param manager Entry point to UsageManager. + */ + public static void getRateCard(com.azure.resourcemanager.commerce.UsageManager manager) { + manager + .rateCards() + .getWithResponse( + "OfferDurableId eq 'MS-AZR-0003P' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'", + Context.NONE); + } +}