Skip to content

Commit

Permalink
[Automation] Generate Fluent Lite from Swagger chaos#package-2024-01 (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
azure-sdk authored Dec 19, 2024
1 parent 6579e94 commit 8886d80
Show file tree
Hide file tree
Showing 128 changed files with 3,327 additions and 1,443 deletions.
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ com.azure.resourcemanager:azure-resourcemanager-managementgroups;1.0.0-beta.2;1.
com.azure.resourcemanager:azure-resourcemanager-managednetworkfabric;1.1.0;1.2.0-beta.1
com.azure.resourcemanager:azure-resourcemanager-iotfirmwaredefense;1.1.0;1.2.0-beta.1
com.azure.resourcemanager:azure-resourcemanager-quantum;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-chaos;1.1.0;1.2.0
com.azure.resourcemanager:azure-resourcemanager-sphere;1.1.0;1.2.0-beta.1
com.azure.resourcemanager:azure-resourcemanager-chaos;1.1.0;1.2.0-beta.1
com.azure.resourcemanager:azure-resourcemanager-defendereasm;1.0.0-beta.2;1.0.0-beta.3
com.azure.resourcemanager:azure-resourcemanager-hdinsight-containers;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-apicenter;1.1.0;1.2.0-beta.1
Expand Down
58 changes: 54 additions & 4 deletions sdk/chaos/azure-resourcemanager-chaos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,64 @@
# Release History

## 1.2.0-beta.1 (Unreleased)
## 1.2.0 (2024-12-19)

### Features Added
- Azure Resource Manager Chaos client library for Java. This package contains Microsoft Azure SDK for Chaos Management SDK. Chaos Management Client. Package tag package-2024-01. 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.OperationStatus` was modified

* `java.lang.String endTime()` -> `java.time.OffsetDateTime endTime()`
* `java.lang.String startTime()` -> `java.time.OffsetDateTime startTime()`

### Features Added

#### `models.ChaosTargetListSelector` was modified

* `type()` was added

#### `models.DelayAction` was modified

* `type()` was added

#### `models.ChaosTargetQuerySelector` was modified

* `type()` was added

#### `models.ContinuousAction` was modified

* `type()` was added

#### `models.ChaosTargetFilter` was modified

* `type()` was added

#### `models.ChaosTargetSimpleFilter` was modified

* `type()` was added

#### `models.ChaosExperimentAction` was modified

* `type()` was added

#### `models.DiscreteAction` was modified

* `type()` was added

#### `models.ChaosTargetSelector` was modified

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

## 1.1.0 (2024-03-15)

Expand Down
26 changes: 18 additions & 8 deletions sdk/chaos/azure-resourcemanager-chaos/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-chaos</artifactId>
<version>1.1.0</version>
<version>1.2.0</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 All @@ -74,6 +70,19 @@ See [API design][design] for general introduction on design and key concepts on

## Examples

```java
keyVaultManager.vaults()
.define(kvName)
.withRegion(REGION)
.withExistingResourceGroup(resourceGroupName)
.withRoleBasedAccessControl()
.withSku(SkuName.STANDARD)
.create();

target = chaosManager.targets()
.createOrUpdate(resourceGroupName, "microsoft.keyvault", "vaults", kvName, "microsoft-keyvault",
new TargetInner().withLocation(REGION.name()).withProperties(Collections.emptyMap()));
```
[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/chaos/azure-resourcemanager-chaos/SAMPLE.md)


Expand All @@ -97,6 +106,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
95 changes: 55 additions & 40 deletions sdk/chaos/azure-resourcemanager-chaos/SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public final class CapabilitiesCreateOrUpdateSamples {
*/
public static void createUpdateACapabilityThatExtendsAVirtualMachineTargetResource(
com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.capabilities().createOrUpdateWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines",
"exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", new CapabilityInner(),
com.azure.core.util.Context.NONE);
manager.capabilities()
.createOrUpdateWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-VirtualMachine", "Shutdown-1.0", new CapabilityInner(), com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -87,8 +87,9 @@ public final class CapabilitiesDeleteSamples {
*/
public static void deleteACapabilityThatExtendsAVirtualMachineTargetResource(
com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.capabilities().deleteWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-VirtualMachine", "Shutdown-1.0", com.azure.core.util.Context.NONE);
manager.capabilities()
.deleteWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-VirtualMachine", "Shutdown-1.0", com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -111,8 +112,9 @@ public final class CapabilitiesGetSamples {
*/
public static void
getACapabilityThatExtendsAVirtualMachineTargetResource(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.capabilities().getWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-VirtualMachine", "Shutdown-1.0", com.azure.core.util.Context.NONE);
manager.capabilities()
.getWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-VirtualMachine", "Shutdown-1.0", com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -135,8 +137,9 @@ public final class CapabilitiesListSamples {
*/
public static void listAllCapabilitiesThatExtendAVirtualMachineTargetResource(
com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.capabilities().list("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-VirtualMachine", null, com.azure.core.util.Context.NONE);
manager.capabilities()
.list("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", null,
com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -159,8 +162,8 @@ public final class CapabilityTypesGetSamples {
*/
public static void getACapabilityTypeForAVirtualMachineTargetResourceOnWestus2Location(
com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.capabilityTypes().getWithResponse("westus2", "Microsoft-VirtualMachine", "Shutdown-1.0",
com.azure.core.util.Context.NONE);
manager.capabilityTypes()
.getWithResponse("westus2", "Microsoft-VirtualMachine", "Shutdown-1.0", com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -239,7 +242,9 @@ public final class ExperimentsCreateOrUpdateSamples {
* @param manager Entry point to ChaosManager.
*/
public static void createUpdateAExperimentInAResourceGroup(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.experiments().define("exampleExperiment").withRegion("eastus2euap")
manager.experiments()
.define("exampleExperiment")
.withRegion("eastus2euap")
.withExistingResourceGroup("exampleRG")
.withSteps(
Arrays.asList(new ChaosExperimentStep().withName("step1")
Expand All @@ -251,9 +256,11 @@ public final class ExperimentsCreateOrUpdateSamples {
Arrays.asList(new KeyValuePair().withKey("fakeTokenPlaceholder").withValue("false")))
.withSelectorId("selector1")))))))
.withSelectors(Arrays.asList(new ChaosTargetListSelector().withId("selector1")
.withTargets(Arrays.asList(new TargetReference().withType(TargetReferenceType.CHAOS_TARGET).withId(
"/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine")))))
.withIdentity(new ResourceIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED)).create();
.withTargets(Arrays.asList(new TargetReference().withType(TargetReferenceType.CHAOS_TARGET)
.withId(
"/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine")))))
.withIdentity(new ResourceIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
.create();
}
}
```
Expand Down Expand Up @@ -297,8 +304,9 @@ public final class ExperimentsExecutionDetailsSamples {
* @param manager Entry point to ChaosManager.
*/
public static void getExperimentExecutionDetails(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.experiments().executionDetailsWithResponse("exampleRG", "exampleExperiment",
"f24500ad-744e-4a26-864b-b76199eac333", com.azure.core.util.Context.NONE);
manager.experiments()
.executionDetailsWithResponse("exampleRG", "exampleExperiment", "f24500ad-744e-4a26-864b-b76199eac333",
com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -320,8 +328,8 @@ public final class ExperimentsGetByResourceGroupSamples {
* @param manager Entry point to ChaosManager.
*/
public static void getAExperimentInAResourceGroup(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.experiments().getByResourceGroupWithResponse("exampleRG", "exampleExperiment",
com.azure.core.util.Context.NONE);
manager.experiments()
.getByResourceGroupWithResponse("exampleRG", "exampleExperiment", com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -343,8 +351,9 @@ public final class ExperimentsGetExecutionSamples {
* @param manager Entry point to ChaosManager.
*/
public static void getTheExecutionOfAExperiment(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.experiments().getExecutionWithResponse("exampleRG", "exampleExperiment",
"f24500ad-744e-4a26-864b-b76199eac333", com.azure.core.util.Context.NONE);
manager.experiments()
.getExecutionWithResponse("exampleRG", "exampleExperiment", "f24500ad-744e-4a26-864b-b76199eac333",
com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -466,10 +475,12 @@ public final class ExperimentsUpdateSamples {
Experiment resource = manager.experiments()
.getByResourceGroupWithResponse("exampleRG", "exampleExperiment", com.azure.core.util.Context.NONE)
.getValue();
resource.update().withTags(mapOf("key1", "fakeTokenPlaceholder", "key2", "fakeTokenPlaceholder")).withIdentity(
new ResourceIdentity().withType(ResourceIdentityType.USER_ASSIGNED).withUserAssignedIdentities(mapOf(
"/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.ManagedIdentity/userAssignedIdentity/exampleUMI",
new UserAssignedIdentity())))
resource.update()
.withTags(mapOf("key1", "fakeTokenPlaceholder", "key2", "fakeTokenPlaceholder"))
.withIdentity(new ResourceIdentity().withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.ManagedIdentity/userAssignedIdentity/exampleUMI",
new UserAssignedIdentity())))
.apply();
}

Expand Down Expand Up @@ -504,8 +515,8 @@ public final class OperationStatusesGetSamples {
* @param manager Entry point to ChaosManager.
*/
public static void getSpecificOperationStatus(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.operationStatuses().getWithResponse("West US", "713192d7-503f-477a-9cfe-4efc3ee2bd11",
com.azure.core.util.Context.NONE);
manager.operationStatuses()
.getWithResponse("West US", "713192d7-503f-477a-9cfe-4efc3ee2bd11", com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -579,13 +590,14 @@ public final class TargetsCreateOrUpdateSamples {
*/
public static void createUpdateATargetThatExtendsAVirtualMachineResource(
com.azure.resourcemanager.chaos.ChaosManager manager) throws IOException {
manager.targets().createOrUpdateWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-Agent",
new TargetInner().withProperties(mapOf("identities",
SerializerFactory.createDefaultManagementSerializerAdapter().deserialize(
"[{\"type\":\"CertificateSubjectIssuer\",\"subject\":\"CN=example.subject\"}]", Object.class,
SerializerEncoding.JSON))),
com.azure.core.util.Context.NONE);
manager.targets()
.createOrUpdateWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-Agent",
new TargetInner().withProperties(mapOf("identities",
SerializerFactory.createDefaultManagementSerializerAdapter()
.deserialize("[{\"type\":\"CertificateSubjectIssuer\",\"subject\":\"CN=example.subject\"}]",
Object.class, SerializerEncoding.JSON))),
com.azure.core.util.Context.NONE);
}

// Use "Map.of" if available
Expand Down Expand Up @@ -620,8 +632,9 @@ public final class TargetsDeleteSamples {
*/
public static void
deleteATargetThatExtendsAVirtualMachineResource(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.targets().deleteWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-Agent", com.azure.core.util.Context.NONE);
manager.targets()
.deleteWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent",
com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -644,8 +657,9 @@ public final class TargetsGetSamples {
*/
public static void
getATargetThatExtendsAVirtualMachineResource(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.targets().getWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM",
"Microsoft-Agent", com.azure.core.util.Context.NONE);
manager.targets()
.getWithResponse("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent",
com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -668,8 +682,9 @@ public final class TargetsListSamples {
*/
public static void
listAllTargetsThatExtendAVirtualMachineResource(com.azure.resourcemanager.chaos.ChaosManager manager) {
manager.targets().list("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", null,
com.azure.core.util.Context.NONE);
manager.targets()
.list("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", null,
com.azure.core.util.Context.NONE);
}
}
```
Expand Down
4 changes: 3 additions & 1 deletion sdk/chaos/azure-resourcemanager-chaos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-chaos</artifactId>
<version>1.2.0-beta.1</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-chaos;current} -->
<version>1.2.0</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-chaos;current} -->
<packaging>jar</packaging>

<name>Microsoft Azure SDK for Chaos Management</name>
Expand Down Expand Up @@ -45,6 +45,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jacoco.min.linecoverage>0</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0</jacoco.min.branchcoverage>
<spotless.skip>false</spotless.skip>
<revapi.skip>true</revapi.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 @@ -229,7 +229,7 @@ public ChaosManager authenticate(TokenCredential credential, AzureProfile profil
.append("-")
.append("com.azure.resourcemanager.chaos")
.append("/")
.append("1.1.0");
.append("1.2.0");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder.append(" (")
.append(Configuration.getGlobalConfiguration().get("java.version"))
Expand Down Expand Up @@ -262,7 +262,7 @@ public ChaosManager authenticate(TokenCredential credential, AzureProfile profil
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
Loading

0 comments on commit 8886d80

Please sign in to comment.