Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/commerce/azure-resourcemanager-commerce/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 1.0.0-beta.2 (Unreleased)
## 1.0.0-beta.1 (2022-03-17)

- 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)

Expand Down
5 changes: 4 additions & 1 deletion sdk/commerce/azure-resourcemanager-commerce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-commerce</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions sdk/commerce/azure-resourcemanager-commerce/SAMPLE.md
Original file line number Diff line number Diff line change
@@ -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);
}
}
```

98 changes: 49 additions & 49 deletions sdk/commerce/azure-resourcemanager-commerce/pom.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
</parent>

<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-commerce</artifactId>
<version>1.0.0-beta.2</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-commerce;current} -->
<packaging>jar</packaging>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-commerce</artifactId>
<version>1.0.0-beta.2</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-commerce;current} -->
<packaging>jar</packaging>

<name>Microsoft Azure SDK for Usage Management</name>
<description>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.</description>
<url>https://github.com/Azure/azure-sdk-for-java</url>
<name>Microsoft Azure SDK for Usage Management</name>
<description>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.</description>
<url>https://github.com/Azure/azure-sdk-for-java</url>

<licenses>
<license>
<name>The MIT License (MIT)</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
<licenses>
<license>
<name>The MIT License (MIT)</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/Azure/azure-sdk-for-java</url>
<connection>scm:git:git@github.com:Azure/azure-sdk-for-java.git</connection>
<developerConnection>scm:git:git@github.com:Azure/azure-sdk-for-java.git</developerConnection>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<id>microsoft</id>
<name>Microsoft</name>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jacoco.skip>true</jacoco.skip>
</properties>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.26.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-management</artifactId>
<version>1.5.3</version> <!-- {x-version-update;com.azure:azure-core-management;dependency} -->
</dependency>
</dependencies>
<scm>
<url>https://github.com/Azure/azure-sdk-for-java</url>
<connection>scm:git:git@github.com:Azure/azure-sdk-for-java.git</connection>
<developerConnection>scm:git:git@github.com:Azure/azure-sdk-for-java.git</developerConnection>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<id>microsoft</id>
<name>Microsoft</name>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jacoco.skip>true</jacoco.skip>
</properties>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.26.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-management</artifactId>
<version>1.5.3</version> <!-- {x-version-update;com.azure:azure-core-management;dependency} -->
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
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;
import com.azure.core.http.policy.HttpPolicyProviders;
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;
Expand All @@ -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 {
Expand Down Expand Up @@ -76,11 +78,12 @@ public static Configurable configure() {

/** The Configurable allowing configurations to be set. */
public static final class Configurable {
private final ClientLogger logger = new ClientLogger(Configurable.class);
private static final ClientLogger LOGGER = new ClientLogger(Configurable.class);

private HttpClient httpClient;
private HttpLogOptions httpLogOptions;
private final List<HttpPipelinePolicy> policies = new ArrayList<>();
private final List<String> scopes = new ArrayList<>();
private RetryPolicy retryPolicy;
private Duration defaultPollInterval;

Expand Down Expand Up @@ -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.
*
Expand All @@ -138,9 +152,11 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
* @return the configurable object itself.
*/
public Configurable withDefaultPollInterval(Duration defaultPollInterval) {
this.defaultPollInterval = Objects.requireNonNull(defaultPollInterval, "'retryPolicy' cannot be null.");
this.defaultPollInterval =
Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null.");
if (this.defaultPollInterval.isNegative()) {
throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative"));
throw LOGGER
.logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative"));
}
return this;
}
Expand Down Expand Up @@ -176,20 +192,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<HttpPipelinePolicy> 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResourceRateCardInfoInner> getWithResponse(String filter, Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface UsageAggregatesClient {
* @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 the Get UsageAggregates operation response.
* @return the Get UsageAggregates operation response as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
PagedIterable<UsageAggregationInner> list(OffsetDateTime reportedStartTime, OffsetDateTime reportedEndTime);
Expand All @@ -46,7 +46,7 @@ public interface UsageAggregatesClient {
* @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 the Get UsageAggregates operation response.
* @return the Get UsageAggregates operation response as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
PagedIterable<UsageAggregationInner> list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
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.MeterInfo;
import com.azure.resourcemanager.commerce.models.OfferTermInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.azure.resourcemanager.commerce.models.OfferTermInfoAutoGenerated;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Price and Metadata information for resources. */
@Fluent
public final class ResourceRateCardInfoInner {
@JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceRateCardInfoInner.class);

/*
* The currency in which the rates are provided.
*/
Expand All @@ -39,7 +35,7 @@ public final class ResourceRateCardInfoInner {
* A list of offer terms.
*/
@JsonProperty(value = "OfferTerms")
private List<OfferTermInfo> offerTerms;
private List<OfferTermInfoAutoGenerated> offerTerms;

/*
* A list of meters.
Expand Down Expand Up @@ -112,7 +108,7 @@ public ResourceRateCardInfoInner withIsTaxIncluded(Boolean isTaxIncluded) {
*
* @return the offerTerms value.
*/
public List<OfferTermInfo> offerTerms() {
public List<OfferTermInfoAutoGenerated> offerTerms() {
return this.offerTerms;
}

Expand All @@ -122,7 +118,7 @@ public List<OfferTermInfo> offerTerms() {
* @param offerTerms the offerTerms value to set.
* @return the ResourceRateCardInfoInner object itself.
*/
public ResourceRateCardInfoInner withOfferTerms(List<OfferTermInfo> offerTerms) {
public ResourceRateCardInfoInner withOfferTerms(List<OfferTermInfoAutoGenerated> offerTerms) {
this.offerTerms = offerTerms;
return this;
}
Expand Down
Loading