Skip to content

Commit

Permalink
[Automation] Generate Fluent Lite from Swagger quantum#package-2023-1…
Browse files Browse the repository at this point in the history
…1-13-preview (#43160)
  • Loading branch information
azure-sdk authored Dec 3, 2024
1 parent c275a5d commit f70e5fd
Show file tree
Hide file tree
Showing 54 changed files with 1,448 additions and 696 deletions.
42 changes: 38 additions & 4 deletions sdk/quantum/azure-resourcemanager-quantum/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
# Release History

## 1.0.0-beta.3 (Unreleased)
## 1.0.0-beta.3 (2024-12-03)

### Features Added
- Azure Resource Manager AzureQuantum client library for Java. This package contains Microsoft Azure SDK for AzureQuantum Management SDK. Package tag package-2023-11-13-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

### Breaking Changes

### Bugs Fixed
#### Serialization/Deserialization change

- `Jackson` is removed from dependency and no longer supported.

##### Migration Guide

If you are using `Jackson`/`ObjectMapper` for manual serialization/deserialization, configure your `ObjectMapper` for backward compatibility:
```java
objectMapper.registerModule(com.azure.core.serializer.json.jackson.JacksonJsonProvider.getJsonSerializableDatabindModule());
```

#### `models.QuantumWorkspace$Definition` was modified

* `withStorageAccount(java.lang.String)` was removed
* `withProviders(java.util.List)` was removed
* `withApiKeyEnabled(java.lang.Boolean)` was removed

#### `models.QuantumWorkspace` was modified

* `apiKeyEnabled()` was removed
* `storageAccount()` was removed
* `provisioningState()` was removed
* `providers()` was removed
* `usable()` was removed
* `endpointUri()` was removed

### Features Added

* `models.WorkspaceResourceProperties` was added

#### `models.QuantumWorkspace$Definition` was modified

* `withProperties(models.WorkspaceResourceProperties)` was added

#### `models.QuantumWorkspace` was modified

### Other Changes
* `properties()` was added

## 1.0.0-beta.2 (2024-03-15)

Expand Down
13 changes: 5 additions & 8 deletions sdk/quantum/azure-resourcemanager-quantum/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-quantum</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.3</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand All @@ -45,15 +45,11 @@ Azure Management Libraries require a `TokenCredential` implementation for authen

### Authentication

By default, Microsoft Entra ID token authentication depends on correct configuration of the following environment variables.
Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package.

- `AZURE_CLIENT_ID` for Azure client ID.
- `AZURE_TENANT_ID` for Azure tenant ID.
- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate.
Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

In addition, Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

With above configuration, `azure` client can be authenticated using the following code:
Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code:

```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
Expand Down Expand Up @@ -97,6 +93,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
[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
Expand Down
43 changes: 26 additions & 17 deletions sdk/quantum/azure-resourcemanager-quantum/SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ public final class WorkspaceOperationCheckNameAvailabilitySamples {
public static void
quantumWorkspacesCheckNameAvailability(com.azure.resourcemanager.quantum.AzureQuantumManager manager) {
manager.workspaceOperations()
.checkNameAvailabilityWithResponse("westus2", new CheckNameAvailabilityParameters()
.withName("sample-workspace-name").withType("Microsoft.Quantum/Workspaces"),
.checkNameAvailabilityWithResponse("westus2",
new CheckNameAvailabilityParameters().withName("sample-workspace-name")
.withType("Microsoft.Quantum/Workspaces"),
com.azure.core.util.Context.NONE);
}
}
Expand All @@ -112,8 +113,8 @@ public final class WorkspaceOperationListKeysSamples {
* @param manager Entry point to AzureQuantumManager.
*/
public static void listKeys(com.azure.resourcemanager.quantum.AzureQuantumManager manager) {
manager.workspaceOperations().listKeysWithResponse("quantumResourcegroup", "quantumworkspace1",
com.azure.core.util.Context.NONE);
manager.workspaceOperations()
.listKeysWithResponse("quantumResourcegroup", "quantumworkspace1", com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -139,9 +140,10 @@ public final class WorkspaceOperationRegenerateKeysSamples {
* @param manager Entry point to AzureQuantumManager.
*/
public static void regenerateKey(com.azure.resourcemanager.quantum.AzureQuantumManager manager) {
manager.workspaceOperations().regenerateKeysWithResponse("quantumResourcegroup", "quantumworkspace1",
new ApiKeys().withKeys(Arrays.asList(KeyType.PRIMARY, KeyType.SECONDARY)),
com.azure.core.util.Context.NONE);
manager.workspaceOperations()
.regenerateKeysWithResponse("quantumResourcegroup", "quantumworkspace1",
new ApiKeys().withKeys(Arrays.asList(KeyType.PRIMARY, KeyType.SECONDARY)),
com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -150,6 +152,7 @@ public final class WorkspaceOperationRegenerateKeysSamples {

```java
import com.azure.resourcemanager.quantum.models.Provider;
import com.azure.resourcemanager.quantum.models.WorkspaceResourceProperties;
import java.util.Arrays;

/**
Expand All @@ -167,13 +170,16 @@ public final class WorkspacesCreateOrUpdateSamples {
* @param manager Entry point to AzureQuantumManager.
*/
public static void quantumWorkspacesPut(com.azure.resourcemanager.quantum.AzureQuantumManager manager) {
manager.workspaces().define("quantumworkspace1").withRegion("West US")
manager.workspaces()
.define("quantumworkspace1")
.withRegion("West US")
.withExistingResourceGroup("quantumResourcegroup")
.withProviders(Arrays.asList(new Provider().withProviderId("Honeywell").withProviderSku("Basic"),
new Provider().withProviderId("IonQ").withProviderSku("Basic"),
new Provider().withProviderId("OneQBit").withProviderSku("Basic")))
.withStorageAccount(
"/subscriptions/1C4B2828-7D49-494F-933D-061373BE28C2/resourceGroups/quantumResourcegroup/providers/Microsoft.Storage/storageAccounts/testStorageAccount")
.withProperties(new WorkspaceResourceProperties()
.withProviders(Arrays.asList(new Provider().withProviderId("Honeywell").withProviderSku("Basic"),
new Provider().withProviderId("IonQ").withProviderSku("Basic"),
new Provider().withProviderId("OneQBit").withProviderSku("Basic")))
.withStorageAccount(
"/subscriptions/1C4B2828-7D49-494F-933D-061373BE28C2/resourceGroups/quantumResourcegroup/providers/Microsoft.Storage/storageAccounts/testStorageAccount"))
.create();
}
}
Expand Down Expand Up @@ -219,8 +225,9 @@ public final class WorkspacesGetByResourceGroupSamples {
* @param manager Entry point to AzureQuantumManager.
*/
public static void quantumWorkspacesGet(com.azure.resourcemanager.quantum.AzureQuantumManager manager) {
manager.workspaces().getByResourceGroupWithResponse("quantumResourcegroup", "quantumworkspace1",
com.azure.core.util.Context.NONE);
manager.workspaces()
.getByResourceGroupWithResponse("quantumResourcegroup", "quantumworkspace1",
com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -292,8 +299,10 @@ public final class WorkspacesUpdateTagsSamples {
* @param manager Entry point to AzureQuantumManager.
*/
public static void quantumWorkspacesPatchTags(com.azure.resourcemanager.quantum.AzureQuantumManager manager) {
QuantumWorkspace resource = manager.workspaces().getByResourceGroupWithResponse("quantumResourcegroup",
"quantumworkspace1", com.azure.core.util.Context.NONE).getValue();
QuantumWorkspace resource = manager.workspaces()
.getByResourceGroupWithResponse("quantumResourcegroup", "quantumworkspace1",
com.azure.core.util.Context.NONE)
.getValue();
resource.update().withTags(mapOf("tag1", "value1", "tag2", "value2")).apply();
}

Expand Down
1 change: 1 addition & 0 deletions sdk/quantum/azure-resourcemanager-quantum/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<jacoco.min.linecoverage>0</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0</jacoco.min.branchcoverage>
<revapi.skip>true</revapi.skip>
<spotless.skip>false</spotless.skip>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand All @@ -19,7 +20,6 @@
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.http.policy.ArmChallengeAuthenticationPolicy;
import com.azure.core.management.profile.AzureProfile;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
Expand Down Expand Up @@ -216,7 +216,7 @@ public AzureQuantumManager authenticate(TokenCredential credential, AzureProfile
.append("-")
.append("com.azure.resourcemanager.quantum")
.append("/")
.append("1.0.0-beta.2");
.append("1.0.0-beta.3");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder.append(" (")
.append(Configuration.getGlobalConfiguration().get("java.version"))
Expand Down Expand Up @@ -249,7 +249,7 @@ public AzureQuantumManager authenticate(TokenCredential credential, AzureProfile
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, scopes.toArray(new String[0])));
policies.addAll(this.policies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
package com.azure.resourcemanager.quantum.fluent.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
* Result of check name availability.
*/
@Fluent
public final class CheckNameAvailabilityResultInner {
public final class CheckNameAvailabilityResultInner implements JsonSerializable<CheckNameAvailabilityResultInner> {
/*
* Indicator of availability of the Quantum Workspace resource name.
*/
@JsonProperty(value = "nameAvailable")
private Boolean nameAvailable;

/*
* The reason of unavailability.
*/
@JsonProperty(value = "reason")
private String reason;

/*
* The detailed info regarding the reason associated with the Namespace.
*/
@JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY)
private String message;

/**
Expand Down Expand Up @@ -92,4 +93,47 @@ public String message() {
*/
public void validate() {
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeBooleanField("nameAvailable", this.nameAvailable);
jsonWriter.writeStringField("reason", this.reason);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of CheckNameAvailabilityResultInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of CheckNameAvailabilityResultInner 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 CheckNameAvailabilityResultInner.
*/
public static CheckNameAvailabilityResultInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
CheckNameAvailabilityResultInner deserializedCheckNameAvailabilityResultInner
= new CheckNameAvailabilityResultInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("nameAvailable".equals(fieldName)) {
deserializedCheckNameAvailabilityResultInner.nameAvailable
= reader.getNullable(JsonReader::getBoolean);
} else if ("reason".equals(fieldName)) {
deserializedCheckNameAvailabilityResultInner.reason = reader.getString();
} else if ("message".equals(fieldName)) {
deserializedCheckNameAvailabilityResultInner.message = reader.getString();
} else {
reader.skipChildren();
}
}

return deserializedCheckNameAvailabilityResultInner;
});
}
}
Loading

0 comments on commit f70e5fd

Please sign in to comment.