Skip to content

Commit

Permalink
[Automation] Generate Fluent Lite from Swagger support#package-2024-04 (
Browse files Browse the repository at this point in the history
  • Loading branch information
azure-sdk authored Dec 19, 2024
1 parent b0384e5 commit 79ffe5f
Show file tree
Hide file tree
Showing 104 changed files with 2,533 additions and 698 deletions.
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ com.azure.resourcemanager:azure-resourcemanager-mariadb;1.0.0-beta.3;1.0.0-beta.
com.azure.resourcemanager:azure-resourcemanager-servicefabric;1.0.0-beta.5;1.0.0-beta.6
com.azure.resourcemanager:azure-resourcemanager-peering;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-policyinsights;1.0.0-beta.4;1.0.0-beta.5
com.azure.resourcemanager:azure-resourcemanager-support;1.0.0;1.1.0-beta.1
com.azure.resourcemanager:azure-resourcemanager-support;1.0.0;1.1.0
com.azure.resourcemanager:azure-resourcemanager-subscription;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-powerbidedicated;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-storageimportexport;1.0.0-beta.3;1.0.0-beta.4
Expand Down
15 changes: 11 additions & 4 deletions sdk/support/azure-resourcemanager-support/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Release History

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

### Features Added
- Azure Resource Manager support client library for Java. This package contains Microsoft Azure SDK for support Management SDK. Microsoft Azure Support Resource Provider. Package tag package-2024-04. 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

### Other Changes
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());
```

## 1.0.0 (2024-04-23)

Expand Down
13 changes: 5 additions & 8 deletions sdk/support/azure-resourcemanager-support/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-support</artifactId>
<version>1.0.0</version>
<version>1.1.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 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
248 changes: 169 additions & 79 deletions sdk/support/azure-resourcemanager-support/SAMPLE.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion sdk/support/azure-resourcemanager-support/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-support</artifactId>
<version>1.1.0-beta.1</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-support;current} -->
<version>1.1.0</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-support;current} -->
<packaging>jar</packaging>

<name>Microsoft Azure SDK for support Management</name>
Expand Down Expand Up @@ -45,6 +45,7 @@
<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>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
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.HttpLoggingPolicy;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
import com.azure.core.http.policy.RetryOptions;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.management.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 @@ -28,10 +28,10 @@
import com.azure.resourcemanager.support.implementation.ChatTranscriptsNoSubscriptionsImpl;
import com.azure.resourcemanager.support.implementation.CommunicationsImpl;
import com.azure.resourcemanager.support.implementation.CommunicationsNoSubscriptionsImpl;
import com.azure.resourcemanager.support.implementation.FilesImpl;
import com.azure.resourcemanager.support.implementation.FilesNoSubscriptionsImpl;
import com.azure.resourcemanager.support.implementation.FileWorkspacesImpl;
import com.azure.resourcemanager.support.implementation.FileWorkspacesNoSubscriptionsImpl;
import com.azure.resourcemanager.support.implementation.FilesImpl;
import com.azure.resourcemanager.support.implementation.FilesNoSubscriptionsImpl;
import com.azure.resourcemanager.support.implementation.MicrosoftSupportBuilder;
import com.azure.resourcemanager.support.implementation.OperationsImpl;
import com.azure.resourcemanager.support.implementation.ProblemClassificationsImpl;
Expand All @@ -42,10 +42,10 @@
import com.azure.resourcemanager.support.models.ChatTranscriptsNoSubscriptions;
import com.azure.resourcemanager.support.models.Communications;
import com.azure.resourcemanager.support.models.CommunicationsNoSubscriptions;
import com.azure.resourcemanager.support.models.Files;
import com.azure.resourcemanager.support.models.FilesNoSubscriptions;
import com.azure.resourcemanager.support.models.FileWorkspaces;
import com.azure.resourcemanager.support.models.FileWorkspacesNoSubscriptions;
import com.azure.resourcemanager.support.models.Files;
import com.azure.resourcemanager.support.models.FilesNoSubscriptions;
import com.azure.resourcemanager.support.models.Operations;
import com.azure.resourcemanager.support.models.ProblemClassifications;
import com.azure.resourcemanager.support.models.Services;
Expand Down Expand Up @@ -253,7 +253,7 @@ public SupportManager authenticate(TokenCredential credential, AzureProfile prof
.append("-")
.append("com.azure.resourcemanager.support")
.append("/")
.append("1.0.0");
.append("1.1.0");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder.append(" (")
.append(Configuration.getGlobalConfiguration().get("java.version"))
Expand Down Expand Up @@ -286,7 +286,7 @@ public SupportManager authenticate(TokenCredential credential, AzureProfile prof
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 @@ -7,8 +7,11 @@
import com.azure.core.annotation.Fluent;
import com.azure.core.management.ProxyResource;
import com.azure.core.management.SystemData;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.support.models.MessageProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;

Expand All @@ -20,15 +23,28 @@ public final class ChatTranscriptDetailsInner extends ProxyResource {
/*
* Properties of the resource.
*/
@JsonProperty(value = "properties")
private ChatTranscriptDetailsProperties innerProperties;

/*
* Azure Resource Manager metadata containing createdBy and modifiedBy information.
*/
@JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
private SystemData systemData;

/*
* The type of the resource.
*/
private String type;

/*
* The name of the resource.
*/
private String name;

/*
* Fully qualified resource Id for the resource.
*/
private String id;

/**
* Creates an instance of ChatTranscriptDetailsInner class.
*/
Expand All @@ -53,6 +69,36 @@ public SystemData systemData() {
return this.systemData;
}

/**
* Get the type property: The type of the resource.
*
* @return the type value.
*/
@Override
public String type() {
return this.type;
}

/**
* Get the name property: The name of the resource.
*
* @return the name value.
*/
@Override
public String name() {
return this.name;
}

/**
* Get the id property: Fully qualified resource Id for the resource.
*
* @return the id value.
*/
@Override
public String id() {
return this.id;
}

/**
* Get the messages property: List of chat transcript communication resources.
*
Expand Down Expand Up @@ -95,4 +141,50 @@ public void validate() {
innerProperties().validate();
}
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("properties", this.innerProperties);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of ChatTranscriptDetailsInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ChatTranscriptDetailsInner if the JsonReader was pointing to an instance of it, or null if
* it was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the ChatTranscriptDetailsInner.
*/
public static ChatTranscriptDetailsInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ChatTranscriptDetailsInner deserializedChatTranscriptDetailsInner = new ChatTranscriptDetailsInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("id".equals(fieldName)) {
deserializedChatTranscriptDetailsInner.id = reader.getString();
} else if ("name".equals(fieldName)) {
deserializedChatTranscriptDetailsInner.name = reader.getString();
} else if ("type".equals(fieldName)) {
deserializedChatTranscriptDetailsInner.type = reader.getString();
} else if ("properties".equals(fieldName)) {
deserializedChatTranscriptDetailsInner.innerProperties
= ChatTranscriptDetailsProperties.fromJson(reader);
} else if ("systemData".equals(fieldName)) {
deserializedChatTranscriptDetailsInner.systemData = SystemData.fromJson(reader);
} else {
reader.skipChildren();
}
}

return deserializedChatTranscriptDetailsInner;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@
package com.azure.resourcemanager.support.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.support.models.MessageProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;

/**
* Describes the properties of a Chat Transcript Details resource.
*/
@Fluent
public final class ChatTranscriptDetailsProperties {
public final class ChatTranscriptDetailsProperties implements JsonSerializable<ChatTranscriptDetailsProperties> {
/*
* List of chat transcript communication resources.
*/
@JsonProperty(value = "messages")
private List<MessageProperties> messages;

/*
* Time in UTC (ISO 8601 format) when the chat began.
*/
@JsonProperty(value = "startTime", access = JsonProperty.Access.WRITE_ONLY)
private OffsetDateTime startTime;

/**
Expand Down Expand Up @@ -72,4 +75,45 @@ public void validate() {
messages().forEach(e -> e.validate());
}
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeArrayField("messages", this.messages, (writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}

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

if ("messages".equals(fieldName)) {
List<MessageProperties> messages = reader.readArray(reader1 -> MessageProperties.fromJson(reader1));
deserializedChatTranscriptDetailsProperties.messages = messages;
} else if ("startTime".equals(fieldName)) {
deserializedChatTranscriptDetailsProperties.startTime = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else {
reader.skipChildren();
}
}

return deserializedChatTranscriptDetailsProperties;
});
}
}
Loading

0 comments on commit 79ffe5f

Please sign in to comment.