diff --git a/.vscode/cspell.json b/.vscode/cspell.json index a424713924dd8..287ed01d3842b 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -1328,6 +1328,17 @@ "tmpdir", "aarch", "CNCF" + ] + }, + { + "filename": "sdk/translation/azure-ai-translation-document/**", + "words": [ + "cancelacurrentlyprocessingorqueuedtranslation", + "returnsalistofbatchrequestssubmittedandthestatusforeachrequest", + "returnsalistofsupporteddocumentformats", + "returnsthestatusofasingledocumentinabatchtranslationrequest", + "submitadocumenttranslationrequesttothedocumenttranslationservice", + "translateasingledocument" ] } ], diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 916c7a05b7925..32d9d0579d822 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -45,7 +45,7 @@ com.azure:azure-ai-formrecognizer-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-ai-inference;1.0.0-beta.2;1.0.0-beta.3 com.azure:azure-ai-metricsadvisor;1.2.2;1.3.0-beta.1 com.azure:azure-ai-metricsadvisor-perf;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-ai-openai;1.0.0-beta.11;1.0.0-beta.12 +com.azure:azure-ai-openai;1.0.0-beta.12;1.0.0-beta.13 com.azure:azure-ai-openai-assistants;1.0.0-beta.4;1.0.0-beta.5 com.azure:azure-ai-personalizer;1.0.0-beta.1;1.0.0-beta.2 com.azure:azure-ai-textanalytics;5.5.2;5.6.0-beta.1 @@ -76,7 +76,7 @@ com.azure:azure-communication-common-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-communication-email;1.0.17;1.1.0-beta.2 com.azure:azure-communication-identity;1.6.0;1.7.0-beta.1 com.azure:azure-communication-jobrouter;1.1.8;2.0.0-beta.1 -com.azure:azure-communication-messages;1.0.7;1.1.0-beta.1 +com.azure:azure-communication-messages;1.0.7;1.1.0 com.azure:azure-communication-phonenumbers;1.1.17;1.2.0-beta.4 com.azure:azure-communication-rooms;1.1.6;1.2.0-beta.1 com.azure:azure-communication-sms;1.1.28;1.2.0-beta.1 @@ -208,7 +208,7 @@ com.azure:identity-test-container;1.0.0-beta.1;1.0.0-beta.1 com.azure:identity-test-function;1.0.0-beta.1;1.0.0-beta.1 com.azure:identity-test-vm;1.0.0-beta.1;1.0.0-beta.1 com.azure:identity-test-webapp;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-ai-vision-face;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-ai-vision-face;1.0.0-beta.2;1.0.0-beta.3 com.azure.spring:azure-monitor-spring-native;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:azure-monitor-spring-native-test;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:spring-cloud-azure-appconfiguration-config-web;5.17.0;5.18.0-beta.1 diff --git a/sdk/communication/azure-communication-messages/CHANGELOG.md b/sdk/communication/azure-communication-messages/CHANGELOG.md index bd2a0843a41b7..c1fee7671813c 100644 --- a/sdk/communication/azure-communication-messages/CHANGELOG.md +++ b/sdk/communication/azure-communication-messages/CHANGELOG.md @@ -1,15 +1,13 @@ # Release History -## 1.1.0-beta.1 (Unreleased) +## 1.1.0 (2024-10-30) ### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - +- Added ImageNotificationContent to send image messgae. +- Added DocumentNotificationContent to send document message. +- Added VideoNotificationContent to send video message. +- Added AudioNotificationContent to send audio message. +- Deprecated MediaNotificationContent. ## 1.0.7 (2024-09-27) diff --git a/sdk/communication/azure-communication-messages/README.md b/sdk/communication/azure-communication-messages/README.md index c338095e47887..ae32c5cf99a7d 100644 --- a/sdk/communication/azure-communication-messages/README.md +++ b/sdk/communication/azure-communication-messages/README.md @@ -194,12 +194,13 @@ private void sendTextMessage() { } ``` -```java readme-sample-sendMediaMessage +```java readme-sample-sendImageMessage /* - * This sample shows how to send simple media (image, video, document) message with below details + * This sample shows how to send image message with below details. + * Supported image - image/jpeg (.jpeg), image/png (.png) * Note: Business cannot initiate conversation with media message. * */ -public void sendMediaMessage() { +public void sendImageMessage() { //Update the Media URL String mediaUrl = "https://wallpapercave.com/wp/wp2163723.jpg"; List recipients = new ArrayList<>(); @@ -208,7 +209,67 @@ public void sendMediaMessage() { .connectionString("") .buildClient(); SendMessageResult result = client.send( - new MediaNotificationContent("", recipients, mediaUrl)); + new ImageNotificationContent("", recipients, mediaUrl)); + + result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId())); +} +``` +```java readme-sample-sendVideoMessage +/* + * This sample shows how to send video message with below details + * Supported video - video/3gp (.3gp), video/mp4 (.mp4) + * Note: Business cannot initiate conversation with media message. + * */ +public void sendVideoMessage() { + //Update the Media URL + String mediaUrl = "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4"; + List recipients = new ArrayList<>(); + recipients.add(""); + NotificationMessagesClient client = new NotificationMessagesClientBuilder() + .connectionString("") + .buildClient(); + SendMessageResult result = client.send( + new VideoNotificationContent("", recipients, mediaUrl)); + + result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId())); +} +``` +```java readme-sample-sendAudioMessage +/* + * This sample shows how to send audio message with below details + * Supported audio - audio/aac (.aac), audio/amr (.amr), audio/mpeg (.mp3), audio/a4a (.mp4), audio/ogg (.ogg ) + * Note: Business cannot initiate conversation with media message. + * */ +public void sendAudioMessage() { + //Update the Media URL + String mediaUrl = "https://sample-videos.com/audio/mp3/wave.mp3"; + List recipients = new ArrayList<>(); + recipients.add(""); + NotificationMessagesClient client = new NotificationMessagesClientBuilder() + .connectionString("") + .buildClient(); + SendMessageResult result = client.send( + new AudioNotificationContent("", recipients, mediaUrl)); + + result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId())); +} +``` +```java readme-sample-sendDocumentMessage +/* + * This sample shows how to send document message with below details + * Supported Document type - Plain Text (.txt), PDF (.pdf), Microsoft Excel, Word, PowerPoint + * Note: Business cannot initiate conversation with media message. + * */ +public void sendDocumentMessage() { + //Update the Media URL + String mediaUrl = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"; + List recipients = new ArrayList<>(); + recipients.add(""); + NotificationMessagesClient client = new NotificationMessagesClientBuilder() + .connectionString("") + .buildClient(); + SendMessageResult result = client.send( + new DocumentNotificationContent("", recipients, mediaUrl)); result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId())); } diff --git a/sdk/communication/azure-communication-messages/assets.json b/sdk/communication/azure-communication-messages/assets.json index bcf0221813eab..99d7da0bd362f 100644 --- a/sdk/communication/azure-communication-messages/assets.json +++ b/sdk/communication/azure-communication-messages/assets.json @@ -2,5 +2,5 @@ "AssetsRepo" : "Azure/azure-sdk-assets", "AssetsRepoPrefixPath" : "java", "TagPrefix" : "java/communication/azure-communication-messages", - "Tag" : "java/communication/azure-communication-messages_4553d6f877" + "Tag" : "java/communication/azure-communication-messages_d7c7441f3b" } diff --git a/sdk/communication/azure-communication-messages/customization/src/main/java/MessagesSdkCustomization.java b/sdk/communication/azure-communication-messages/customization/src/main/java/MessagesSdkCustomization.java index dac741e12c28f..c1b3621219e8c 100644 --- a/sdk/communication/azure-communication-messages/customization/src/main/java/MessagesSdkCustomization.java +++ b/sdk/communication/azure-communication-messages/customization/src/main/java/MessagesSdkCustomization.java @@ -12,6 +12,7 @@ import com.github.javaparser.ast.type.ClassOrInterfaceType; import com.github.javaparser.javadoc.Javadoc; import com.github.javaparser.javadoc.description.JavadocDescription; +import com.github.javaparser.javadoc.description.JavadocSnippet; import org.slf4j.Logger; public class MessagesSdkCustomization extends Customization { @@ -25,26 +26,27 @@ public void customize(LibraryCustomization libraryCustomization, Logger logger) updateBuilderClass(packageCustomization, "MessageTemplateClientBuilder"); PackageCustomization modelsPackage = libraryCustomization.getPackage("com.azure.communication.messages.models"); + updateModelClassModifierToAbstract(modelsPackage, "NotificationContent"); + updateModelClassModifierToAbstract(modelsPackage, "MessageTemplateValue"); + updateModelClassModifierToAbstract(modelsPackage, "MessageTemplateItem"); customizeMessageTemplateLocation(modelsPackage); - customizeNotificationContentModel(modelsPackage); - customizeMessageTemplateValueModel(modelsPackage); customizeMessageTemplateItemModel(modelsPackage); PackageCustomization channelsModelsPackage = libraryCustomization.getPackage( "com.azure.communication.messages.models.channels"); updateWhatsAppMessageTemplateItemWithBinaryDataContent(channelsModelsPackage); - } - private void customizeNotificationContentModel(PackageCustomization modelsPackage) { - modelsPackage.getClass("NotificationContent") - .customizeAst(ast -> ast.getPrimaryType() - .ifPresent(clazz -> clazz.getConstructors().get(0).setModifiers(Modifier.Keyword.PROTECTED))); + AddDeprecateAnnotationToMediaNotificationContent(modelsPackage); + + AddDeprecateAnnotationForImageV0CommunicationKind(modelsPackage); } - private void customizeMessageTemplateValueModel(PackageCustomization modelsPackage) { - modelsPackage.getClass("MessageTemplateValue") - .customizeAst(ast -> ast.getPrimaryType() - .ifPresent(clazz -> clazz.getConstructors().get(0).setModifiers(Modifier.Keyword.PROTECTED))); + private void updateModelClassModifierToAbstract(PackageCustomization modelsPackage, String className) { + modelsPackage.getClass(className) + .customizeAst(ast -> ast.getClassByName(className) + .ifPresent(clazz -> clazz.setModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.ABSTRACT) + .getConstructors().get(0).setModifiers(Modifier.Keyword.PROTECTED))); + removeJsonKnownDiscriminatorMethod(modelsPackage, className); } private void customizeMessageTemplateItemModel(PackageCustomization modelsPackage) { @@ -190,4 +192,52 @@ private void updateWhatsAppMessageTemplateItemWithBinaryDataContent(PackageCusto }); }); } + + private void removeJsonKnownDiscriminatorMethod(PackageCustomization modelPackage, String className) { + modelPackage.getClass(className).customizeAst(ast -> { + ast.getClassByName(className).ifPresent( clazz -> { + String fromJson = clazz.getMethodsByName("fromJson") + .get(0).getBody().get().toString() + .replace("return fromJsonKnownDiscriminator(readerToUse.reset());", + "throw new IllegalStateException(\"Invalid Kind value - \"+discriminatorValue); "); + clazz.getMethodsByName("fromJson").get(0).setBody(StaticJavaParser.parseBlock(fromJson)); + clazz.getMethodsByName("fromJsonKnownDiscriminator").get(0).remove(); + }); + }); + } + + private void AddDeprecateAnnotationToMediaNotificationContent(PackageCustomization modelsPackage) { + modelsPackage.getClass("MediaNotificationContent").customizeAst(ast -> { + ast.getClassByName("MediaNotificationContent").ifPresent(clazz -> { + clazz.addAnnotation(Deprecated.class); + + // Remove the @deprecated comment as it cause special character and fails in style check + clazz.getJavadoc().ifPresent(doc -> { + String description = doc.getDescription().getElements().get(0).toText() + .replace("@deprecated", "@deprecated"); + doc.getDescription().getElements().set(0, new JavadocSnippet(description)); + clazz.setJavadocComment(doc.toComment()); + }); + }); + }); + } + + private void AddDeprecateAnnotationForImageV0CommunicationKind(PackageCustomization modelsPackage) { + modelsPackage.getClass("CommunicationMessageKind").customizeAst(ast -> { + ast.getClassByName("CommunicationMessageKind") + .flatMap(clazz -> clazz.getFieldByName("IMAGE_V0")) + .ifPresent(f -> { + f.addAnnotation(Deprecated.class); + f.getJavadocComment().ifPresent(comment -> { + /* + Reducing size comment by replacing with @deprecated since it doesn't fit single line + and fails in style check + */ + String content = comment.getContent() + .replace("Image message type.", "@deprecated"); + f.setJavadocComment(content); + }); + }); + }); + } } diff --git a/sdk/communication/azure-communication-messages/pom.xml b/sdk/communication/azure-communication-messages/pom.xml index 4fb996e6294a4..bf0b2141f92b1 100644 --- a/sdk/communication/azure-communication-messages/pom.xml +++ b/sdk/communication/azure-communication-messages/pom.xml @@ -14,7 +14,7 @@ com.azure azure-communication-messages - 1.1.0-beta.1 + 1.1.0 jar Microsoft Azure client library for Azure Communication Services - Messaging application diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/MessagesServiceVersion.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/MessagesServiceVersion.java index e09840cd4d7ad..8673e42220368 100644 --- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/MessagesServiceVersion.java +++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/MessagesServiceVersion.java @@ -13,7 +13,12 @@ public enum MessagesServiceVersion implements ServiceVersion { /** * Enum value 2024-02-01. */ - V2024_02_01("2024-02-01"); + V2024_02_01("2024-02-01"), + + /** + * Enum value 2024-08-30. + */ + V2024_08_30("2024-08-30"); private final String version; @@ -35,6 +40,6 @@ public String getVersion() { * @return The latest {@link MessagesServiceVersion}. */ public static MessagesServiceVersion getLatest() { - return V2024_02_01; + return V2024_08_30; } } diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesAsyncClient.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesAsyncClient.java index 2374283383fe0..435f82449d3b1 100644 --- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesAsyncClient.java +++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesAsyncClient.java @@ -55,7 +55,7 @@ public final class NotificationMessagesAsyncClient { *
      * {@code
      * {
-     *     kind: String(text/image/template) (Required)
+     *     kind: String(text/image/image_v0/document/video/audio/template) (Required)
      *     channelRegistrationId: String (Required)
      *     to (Required): [
      *         String (Required)
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesClient.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesClient.java
index 9578f7260c053..59266523b678f 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesClient.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/NotificationMessagesClient.java
@@ -53,7 +53,7 @@ public final class NotificationMessagesClient {
      * 
      * {@code
      * {
-     *     kind: String(text/image/template) (Required)
+     *     kind: String(text/image/image_v0/document/video/audio/template) (Required)
      *     channelRegistrationId: String (Required)
      *     to (Required): [
      *         String (Required)
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/implementation/NotificationMessagesClientImpl.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/implementation/NotificationMessagesClientImpl.java
index 1861083bdada6..a9176df99148d 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/implementation/NotificationMessagesClientImpl.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/implementation/NotificationMessagesClientImpl.java
@@ -212,7 +212,7 @@ Response downloadMediaSync(@HostParam("endpoint") String endpoint,
      * 
      * {@code
      * {
-     *     kind: String(text/image/template) (Required)
+     *     kind: String(text/image/image_v0/document/video/audio/template) (Required)
      *     channelRegistrationId: String (Required)
      *     to (Required): [
      *         String (Required)
@@ -284,7 +284,7 @@ public Mono> sendWithResponseAsync(BinaryData notificationC
      * 
      * {@code
      * {
-     *     kind: String(text/image/template) (Required)
+     *     kind: String(text/image/image_v0/document/video/audio/template) (Required)
      *     channelRegistrationId: String (Required)
      *     to (Required): [
      *         String (Required)
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/AudioNotificationContent.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/AudioNotificationContent.java
new file mode 100644
index 0000000000000..450865f37efc1
--- /dev/null
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/AudioNotificationContent.java
@@ -0,0 +1,118 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+package com.azure.communication.messages.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A request to send an audio notification.
+ */
+@Immutable
+public final class AudioNotificationContent extends NotificationContent {
+
+    /*
+     * The type discriminator describing a notification type.
+     */
+    @Generated
+    private CommunicationMessageKind kind = CommunicationMessageKind.AUDIO;
+
+    /*
+     * A media url for the file. Required if the type is one of the supported media types, e.g. image
+     */
+    @Generated
+    private final String mediaUrl;
+
+    /**
+     * Creates an instance of AudioNotificationContent class.
+     *
+     * @param channelRegistrationId the channelRegistrationId value to set.
+     * @param to the to value to set.
+     * @param mediaUrl the mediaUrl value to set.
+     */
+    @Generated
+    public AudioNotificationContent(String channelRegistrationId, List to, String mediaUrl) {
+        super(channelRegistrationId, to);
+        this.mediaUrl = mediaUrl;
+    }
+
+    /**
+     * Get the kind property: The type discriminator describing a notification type.
+     *
+     * @return the kind value.
+     */
+    @Generated
+    @Override
+    public CommunicationMessageKind getKind() {
+        return this.kind;
+    }
+
+    /**
+     * Get the mediaUrl property: A media url for the file. Required if the type is one of the supported media types,
+     * e.g. image.
+     *
+     * @return the mediaUrl value.
+     */
+    @Generated
+    public String getMediaUrl() {
+        return this.mediaUrl;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Generated
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("channelRegistrationId", getChannelRegistrationId());
+        jsonWriter.writeArrayField("to", getTo(), (writer, element) -> writer.writeString(element));
+        jsonWriter.writeStringField("mediaUri", this.mediaUrl);
+        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of AudioNotificationContent from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of AudioNotificationContent 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 AudioNotificationContent.
+     */
+    @Generated
+    public static AudioNotificationContent fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            String channelRegistrationId = null;
+            List to = null;
+            String mediaUrl = null;
+            CommunicationMessageKind kind = CommunicationMessageKind.AUDIO;
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("channelRegistrationId".equals(fieldName)) {
+                    channelRegistrationId = reader.getString();
+                } else if ("to".equals(fieldName)) {
+                    to = reader.readArray(reader1 -> reader1.getString());
+                } else if ("mediaUri".equals(fieldName)) {
+                    mediaUrl = reader.getString();
+                } else if ("kind".equals(fieldName)) {
+                    kind = CommunicationMessageKind.fromString(reader.getString());
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            AudioNotificationContent deserializedAudioNotificationContent
+                = new AudioNotificationContent(channelRegistrationId, to, mediaUrl);
+            deserializedAudioNotificationContent.kind = kind;
+            return deserializedAudioNotificationContent;
+        });
+    }
+}
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/CommunicationMessageKind.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/CommunicationMessageKind.java
index 8aedde4b16f37..b07ef3e8bcbf9 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/CommunicationMessageKind.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/CommunicationMessageKind.java
@@ -8,7 +8,7 @@
 import java.util.Collection;
 
 /**
- * The type of message. Supports text, image, template.
+ * The type of message.
  */
 public final class CommunicationMessageKind extends ExpandableStringEnum {
 
@@ -60,4 +60,29 @@ public static CommunicationMessageKind fromString(String name) {
     public static Collection values() {
         return values(CommunicationMessageKind.class);
     }
+
+    /**
+     * Document message type.
+     */
+    @Generated
+    public static final CommunicationMessageKind DOCUMENT = fromString("document");
+
+    /**
+     * Video message type.
+     */
+    @Generated
+    public static final CommunicationMessageKind VIDEO = fromString("video");
+
+    /**
+     * Audio message type.
+     */
+    @Generated
+    public static final CommunicationMessageKind AUDIO = fromString("audio");
+
+    /**
+     * @deprecated Legacy image type for `MediaNotificationContent` which is being deprecated.
+     */
+    @Generated
+    @Deprecated()
+    public static final CommunicationMessageKind IMAGE_V0 = fromString("image_v0");
 }
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/DocumentNotificationContent.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/DocumentNotificationContent.java
new file mode 100644
index 0000000000000..d3f208b267317
--- /dev/null
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/DocumentNotificationContent.java
@@ -0,0 +1,184 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+package com.azure.communication.messages.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A request to send a document notification.
+ */
+@Fluent
+public final class DocumentNotificationContent extends NotificationContent {
+
+    /*
+     * The type discriminator describing a notification type.
+     */
+    @Generated
+    private CommunicationMessageKind kind = CommunicationMessageKind.DOCUMENT;
+
+    /*
+     * Optional name for the file.
+     */
+    @Generated
+    private String fileName;
+
+    /*
+     * A media url for the file. Required if the type is one of the supported media types, e.g. image
+     */
+    @Generated
+    private final String mediaUrl;
+
+    /**
+     * Creates an instance of DocumentNotificationContent class.
+     *
+     * @param channelRegistrationId the channelRegistrationId value to set.
+     * @param to the to value to set.
+     * @param mediaUrl the mediaUrl value to set.
+     */
+    @Generated
+    public DocumentNotificationContent(String channelRegistrationId, List to, String mediaUrl) {
+        super(channelRegistrationId, to);
+        this.mediaUrl = mediaUrl;
+    }
+
+    /**
+     * Get the kind property: The type discriminator describing a notification type.
+     *
+     * @return the kind value.
+     */
+    @Generated
+    @Override
+    public CommunicationMessageKind getKind() {
+        return this.kind;
+    }
+
+    /**
+     * Get the fileName property: Optional name for the file.
+     *
+     * @return the fileName value.
+     */
+    @Generated
+    public String getFileName() {
+        return this.fileName;
+    }
+
+    /**
+     * Set the fileName property: Optional name for the file.
+     *
+     * @param fileName the fileName value to set.
+     * @return the DocumentNotificationContent object itself.
+     */
+    @Generated
+    public DocumentNotificationContent setFileName(String fileName) {
+        this.fileName = fileName;
+        return this;
+    }
+
+    /**
+     * Get the mediaUrl property: A media url for the file. Required if the type is one of the supported media types,
+     * e.g. image.
+     *
+     * @return the mediaUrl value.
+     */
+    @Generated
+    public String getMediaUrl() {
+        return this.mediaUrl;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Generated
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("channelRegistrationId", getChannelRegistrationId());
+        jsonWriter.writeArrayField("to", getTo(), (writer, element) -> writer.writeString(element));
+        jsonWriter.writeStringField("mediaUri", this.mediaUrl);
+        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+        jsonWriter.writeStringField("caption", this.caption);
+        jsonWriter.writeStringField("fileName", this.fileName);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of DocumentNotificationContent from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of DocumentNotificationContent 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 DocumentNotificationContent.
+     */
+    @Generated
+    public static DocumentNotificationContent fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            String channelRegistrationId = null;
+            List to = null;
+            String mediaUrl = null;
+            CommunicationMessageKind kind = CommunicationMessageKind.DOCUMENT;
+            String caption = null;
+            String fileName = null;
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("channelRegistrationId".equals(fieldName)) {
+                    channelRegistrationId = reader.getString();
+                } else if ("to".equals(fieldName)) {
+                    to = reader.readArray(reader1 -> reader1.getString());
+                } else if ("mediaUri".equals(fieldName)) {
+                    mediaUrl = reader.getString();
+                } else if ("kind".equals(fieldName)) {
+                    kind = CommunicationMessageKind.fromString(reader.getString());
+                } else if ("caption".equals(fieldName)) {
+                    caption = reader.getString();
+                } else if ("fileName".equals(fieldName)) {
+                    fileName = reader.getString();
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            DocumentNotificationContent deserializedDocumentNotificationContent
+                = new DocumentNotificationContent(channelRegistrationId, to, mediaUrl);
+            deserializedDocumentNotificationContent.kind = kind;
+            deserializedDocumentNotificationContent.caption = caption;
+            deserializedDocumentNotificationContent.fileName = fileName;
+            return deserializedDocumentNotificationContent;
+        });
+    }
+
+    /*
+     * Optional text content.
+     */
+    @Generated
+    private String caption;
+
+    /**
+     * Get the caption property: Optional text content.
+     *
+     * @return the caption value.
+     */
+    @Generated
+    public String getCaption() {
+        return this.caption;
+    }
+
+    /**
+     * Set the caption property: Optional text content.
+     *
+     * @param caption the caption value to set.
+     * @return the DocumentNotificationContent object itself.
+     */
+    @Generated
+    public DocumentNotificationContent setCaption(String caption) {
+        this.caption = caption;
+        return this;
+    }
+}
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/ImageNotificationContent.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/ImageNotificationContent.java
new file mode 100644
index 0000000000000..d0f98ff2112e0
--- /dev/null
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/ImageNotificationContent.java
@@ -0,0 +1,151 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+package com.azure.communication.messages.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A request to send an image notification.
+ */
+@Fluent
+public final class ImageNotificationContent extends NotificationContent {
+
+    /*
+     * The type discriminator describing a notification type.
+     */
+    @Generated
+    private CommunicationMessageKind kind = CommunicationMessageKind.IMAGE;
+
+    /*
+     * A media url for the file. Required if the type is one of the supported media types, e.g. image
+     */
+    @Generated
+    private final String mediaUrl;
+
+    /**
+     * Creates an instance of ImageNotificationContent class.
+     *
+     * @param channelRegistrationId the channelRegistrationId value to set.
+     * @param to the to value to set.
+     * @param mediaUrl the mediaUrl value to set.
+     */
+    @Generated
+    public ImageNotificationContent(String channelRegistrationId, List to, String mediaUrl) {
+        super(channelRegistrationId, to);
+        this.mediaUrl = mediaUrl;
+    }
+
+    /**
+     * Get the kind property: The type discriminator describing a notification type.
+     *
+     * @return the kind value.
+     */
+    @Generated
+    @Override
+    public CommunicationMessageKind getKind() {
+        return this.kind;
+    }
+
+    /**
+     * Get the mediaUrl property: A media url for the file. Required if the type is one of the supported media types,
+     * e.g. image.
+     *
+     * @return the mediaUrl value.
+     */
+    @Generated
+    public String getMediaUrl() {
+        return this.mediaUrl;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Generated
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("channelRegistrationId", getChannelRegistrationId());
+        jsonWriter.writeArrayField("to", getTo(), (writer, element) -> writer.writeString(element));
+        jsonWriter.writeStringField("mediaUri", this.mediaUrl);
+        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+        jsonWriter.writeStringField("caption", this.caption);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of ImageNotificationContent from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of ImageNotificationContent 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 ImageNotificationContent.
+     */
+    @Generated
+    public static ImageNotificationContent fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            String channelRegistrationId = null;
+            List to = null;
+            String mediaUrl = null;
+            CommunicationMessageKind kind = CommunicationMessageKind.IMAGE;
+            String caption = null;
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("channelRegistrationId".equals(fieldName)) {
+                    channelRegistrationId = reader.getString();
+                } else if ("to".equals(fieldName)) {
+                    to = reader.readArray(reader1 -> reader1.getString());
+                } else if ("mediaUri".equals(fieldName)) {
+                    mediaUrl = reader.getString();
+                } else if ("kind".equals(fieldName)) {
+                    kind = CommunicationMessageKind.fromString(reader.getString());
+                } else if ("caption".equals(fieldName)) {
+                    caption = reader.getString();
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            ImageNotificationContent deserializedImageNotificationContent
+                = new ImageNotificationContent(channelRegistrationId, to, mediaUrl);
+            deserializedImageNotificationContent.kind = kind;
+            deserializedImageNotificationContent.caption = caption;
+            return deserializedImageNotificationContent;
+        });
+    }
+
+    /*
+     * Optional text content.
+     */
+    @Generated
+    private String caption;
+
+    /**
+     * Get the caption property: Optional text content.
+     *
+     * @return the caption value.
+     */
+    @Generated
+    public String getCaption() {
+        return this.caption;
+    }
+
+    /**
+     * Set the caption property: Optional text content.
+     *
+     * @param caption the caption value to set.
+     * @return the ImageNotificationContent object itself.
+     */
+    @Generated
+    public ImageNotificationContent setCaption(String caption) {
+        this.caption = caption;
+        return this;
+    }
+}
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MediaNotificationContent.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MediaNotificationContent.java
index 26b337f5b1634..ad58f904a703c 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MediaNotificationContent.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MediaNotificationContent.java
@@ -12,16 +12,17 @@
 import java.util.List;
 
 /**
- * A request to send a media notification.
+ * @deprecated A request to send an image notification.
  */
 @Fluent
+@Deprecated()
 public final class MediaNotificationContent extends NotificationContent {
 
     /*
      * The type discriminator describing a notification type.
      */
     @Generated
-    private CommunicationMessageKind kind = CommunicationMessageKind.IMAGE;
+    private CommunicationMessageKind kind = CommunicationMessageKind.IMAGE_V0;
 
     /*
      * Optional text content.
@@ -122,7 +123,7 @@ public static MediaNotificationContent fromJson(JsonReader jsonReader) throws IO
             String channelRegistrationId = null;
             List to = null;
             String mediaUrl = null;
-            CommunicationMessageKind kind = CommunicationMessageKind.IMAGE;
+            CommunicationMessageKind kind = CommunicationMessageKind.IMAGE_V0;
             String content = null;
             while (reader.nextToken() != JsonToken.END_OBJECT) {
                 String fieldName = reader.getFieldName();
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateItem.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateItem.java
index 4dd0cd30fb5bd..df1fc05f1c4b0 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateItem.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateItem.java
@@ -17,7 +17,7 @@
  * The message template as returned from the service.
  */
 @Immutable
-public class MessageTemplateItem implements JsonSerializable {
+public abstract class MessageTemplateItem implements JsonSerializable {
 
     static {
         MessageTemplateItemAccessHelper.setAccessor(MessageTemplateItem::setName);
@@ -156,38 +156,9 @@ public static MessageTemplateItem fromJson(JsonReader jsonReader) throws IOExcep
                 if ("whatsApp".equals(discriminatorValue)) {
                     return WhatsAppMessageTemplateItem.fromJson(readerToUse.reset());
                 } else {
-                    return fromJsonKnownDiscriminator(readerToUse.reset());
+                    throw new IllegalStateException("Invalid Kind value - " + discriminatorValue);
                 }
             }
         });
     }
-
-    @Generated
-    static MessageTemplateItem fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
-        return jsonReader.readObject(reader -> {
-            String name = null;
-            String language = null;
-            MessageTemplateStatus status = null;
-            CommunicationMessagesChannel kind = null;
-            while (reader.nextToken() != JsonToken.END_OBJECT) {
-                String fieldName = reader.getFieldName();
-                reader.nextToken();
-                if ("name".equals(fieldName)) {
-                    name = reader.getString();
-                } else if ("language".equals(fieldName)) {
-                    language = reader.getString();
-                } else if ("status".equals(fieldName)) {
-                    status = MessageTemplateStatus.fromString(reader.getString());
-                } else if ("kind".equals(fieldName)) {
-                    kind = CommunicationMessagesChannel.fromString(reader.getString());
-                } else {
-                    reader.skipChildren();
-                }
-            }
-            MessageTemplateItem deserializedMessageTemplateItem = new MessageTemplateItem(language, status);
-            deserializedMessageTemplateItem.name = name;
-            deserializedMessageTemplateItem.kind = kind;
-            return deserializedMessageTemplateItem;
-        });
-    }
 }
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateValue.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateValue.java
index bec3dda77c2cd..6f7f6d7962129 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateValue.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/MessageTemplateValue.java
@@ -15,7 +15,7 @@
  * The class describes a parameter of a template.
  */
 @Immutable
-public class MessageTemplateValue implements JsonSerializable {
+public abstract class MessageTemplateValue implements JsonSerializable {
 
     /*
      * The type discriminator describing a template parameter type.
@@ -35,7 +35,7 @@ public class MessageTemplateValue implements JsonSerializable {
-            String refValue = null;
-            MessageTemplateValueKind kind = null;
-            while (reader.nextToken() != JsonToken.END_OBJECT) {
-                String fieldName = reader.getFieldName();
-                reader.nextToken();
-                if ("name".equals(fieldName)) {
-                    refValue = reader.getString();
-                } else if ("kind".equals(fieldName)) {
-                    kind = MessageTemplateValueKind.fromString(reader.getString());
-                } else {
-                    reader.skipChildren();
-                }
-            }
-            MessageTemplateValue deserializedMessageTemplateValue = new MessageTemplateValue(refValue);
-            deserializedMessageTemplateValue.kind = kind;
-            return deserializedMessageTemplateValue;
-        });
-    }
 }
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/NotificationContent.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/NotificationContent.java
index 4471be0dfff5a..cd28761960e12 100644
--- a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/NotificationContent.java
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/NotificationContent.java
@@ -16,7 +16,7 @@
  * Details of the message to send.
  */
 @Immutable
-public class NotificationContent implements JsonSerializable {
+public abstract class NotificationContent implements JsonSerializable {
 
     /*
      * The type discriminator describing a notification type.
@@ -43,7 +43,7 @@ public class NotificationContent implements JsonSerializable to) {
+    protected NotificationContent(String channelRegistrationId, List to) {
         this.channelRegistrationId = channelRegistrationId;
         this.to = to;
     }
@@ -120,39 +120,22 @@ public static NotificationContent fromJson(JsonReader jsonReader) throws IOExcep
                 // Use the discriminator value to determine which subtype should be deserialized.
                 if ("text".equals(discriminatorValue)) {
                     return TextNotificationContent.fromJson(readerToUse.reset());
-                } else if ("image".equals(discriminatorValue)) {
+                } else if ("image_v0".equals(discriminatorValue)) {
                     return MediaNotificationContent.fromJson(readerToUse.reset());
+                } else if ("image".equals(discriminatorValue)) {
+                    return ImageNotificationContent.fromJson(readerToUse.reset());
+                } else if ("document".equals(discriminatorValue)) {
+                    return DocumentNotificationContent.fromJson(readerToUse.reset());
+                } else if ("video".equals(discriminatorValue)) {
+                    return VideoNotificationContent.fromJson(readerToUse.reset());
+                } else if ("audio".equals(discriminatorValue)) {
+                    return AudioNotificationContent.fromJson(readerToUse.reset());
                 } else if ("template".equals(discriminatorValue)) {
                     return TemplateNotificationContent.fromJson(readerToUse.reset());
                 } else {
-                    return fromJsonKnownDiscriminator(readerToUse.reset());
-                }
-            }
-        });
-    }
-
-    @Generated
-    static NotificationContent fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
-        return jsonReader.readObject(reader -> {
-            String channelRegistrationId = null;
-            List to = null;
-            CommunicationMessageKind kind = null;
-            while (reader.nextToken() != JsonToken.END_OBJECT) {
-                String fieldName = reader.getFieldName();
-                reader.nextToken();
-                if ("channelRegistrationId".equals(fieldName)) {
-                    channelRegistrationId = reader.getString();
-                } else if ("to".equals(fieldName)) {
-                    to = reader.readArray(reader1 -> reader1.getString());
-                } else if ("kind".equals(fieldName)) {
-                    kind = CommunicationMessageKind.fromString(reader.getString());
-                } else {
-                    reader.skipChildren();
+                    throw new IllegalStateException("Invalid Kind value - " + discriminatorValue);
                 }
             }
-            NotificationContent deserializedNotificationContent = new NotificationContent(channelRegistrationId, to);
-            deserializedNotificationContent.kind = kind;
-            return deserializedNotificationContent;
         });
     }
 }
diff --git a/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/VideoNotificationContent.java b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/VideoNotificationContent.java
new file mode 100644
index 0000000000000..506f0befb2605
--- /dev/null
+++ b/sdk/communication/azure-communication-messages/src/main/java/com/azure/communication/messages/models/VideoNotificationContent.java
@@ -0,0 +1,151 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+package com.azure.communication.messages.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A request to send a video notification.
+ */
+@Fluent
+public final class VideoNotificationContent extends NotificationContent {
+
+    /*
+     * The type discriminator describing a notification type.
+     */
+    @Generated
+    private CommunicationMessageKind kind = CommunicationMessageKind.VIDEO;
+
+    /*
+     * A media url for the file. Required if the type is one of the supported media types, e.g. image
+     */
+    @Generated
+    private final String mediaUrl;
+
+    /**
+     * Creates an instance of VideoNotificationContent class.
+     *
+     * @param channelRegistrationId the channelRegistrationId value to set.
+     * @param to the to value to set.
+     * @param mediaUrl the mediaUrl value to set.
+     */
+    @Generated
+    public VideoNotificationContent(String channelRegistrationId, List to, String mediaUrl) {
+        super(channelRegistrationId, to);
+        this.mediaUrl = mediaUrl;
+    }
+
+    /**
+     * Get the kind property: The type discriminator describing a notification type.
+     *
+     * @return the kind value.
+     */
+    @Generated
+    @Override
+    public CommunicationMessageKind getKind() {
+        return this.kind;
+    }
+
+    /**
+     * Get the mediaUrl property: A media url for the file. Required if the type is one of the supported media types,
+     * e.g. image.
+     *
+     * @return the mediaUrl value.
+     */
+    @Generated
+    public String getMediaUrl() {
+        return this.mediaUrl;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Generated
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("channelRegistrationId", getChannelRegistrationId());
+        jsonWriter.writeArrayField("to", getTo(), (writer, element) -> writer.writeString(element));
+        jsonWriter.writeStringField("mediaUri", this.mediaUrl);
+        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+        jsonWriter.writeStringField("caption", this.caption);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of VideoNotificationContent from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of VideoNotificationContent 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 VideoNotificationContent.
+     */
+    @Generated
+    public static VideoNotificationContent fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            String channelRegistrationId = null;
+            List to = null;
+            String mediaUrl = null;
+            CommunicationMessageKind kind = CommunicationMessageKind.VIDEO;
+            String caption = null;
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("channelRegistrationId".equals(fieldName)) {
+                    channelRegistrationId = reader.getString();
+                } else if ("to".equals(fieldName)) {
+                    to = reader.readArray(reader1 -> reader1.getString());
+                } else if ("mediaUri".equals(fieldName)) {
+                    mediaUrl = reader.getString();
+                } else if ("kind".equals(fieldName)) {
+                    kind = CommunicationMessageKind.fromString(reader.getString());
+                } else if ("caption".equals(fieldName)) {
+                    caption = reader.getString();
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            VideoNotificationContent deserializedVideoNotificationContent
+                = new VideoNotificationContent(channelRegistrationId, to, mediaUrl);
+            deserializedVideoNotificationContent.kind = kind;
+            deserializedVideoNotificationContent.caption = caption;
+            return deserializedVideoNotificationContent;
+        });
+    }
+
+    /*
+     * Optional text content.
+     */
+    @Generated
+    private String caption;
+
+    /**
+     * Get the caption property: Optional text content.
+     *
+     * @return the caption value.
+     */
+    @Generated
+    public String getCaption() {
+        return this.caption;
+    }
+
+    /**
+     * Set the caption property: Optional text content.
+     *
+     * @param caption the caption value to set.
+     * @return the VideoNotificationContent object itself.
+     */
+    @Generated
+    public VideoNotificationContent setCaption(String caption) {
+        this.caption = caption;
+        return this;
+    }
+}
diff --git a/sdk/communication/azure-communication-messages/src/main/resources/META-INF/azure-communication-messages_apiview_properties.json b/sdk/communication/azure-communication-messages/src/main/resources/META-INF/azure-communication-messages_apiview_properties.json
index d1daa4831af35..47302ac76e22f 100644
--- a/sdk/communication/azure-communication-messages/src/main/resources/META-INF/azure-communication-messages_apiview_properties.json
+++ b/sdk/communication/azure-communication-messages/src/main/resources/META-INF/azure-communication-messages_apiview_properties.json
@@ -17,8 +17,11 @@
     "com.azure.communication.messages.NotificationMessagesClient.send": "Azure.Communication.MessagesService.NotificationMessagesClient.send",
     "com.azure.communication.messages.NotificationMessagesClient.sendWithResponse": "Azure.Communication.MessagesService.NotificationMessagesClient.send",
     "com.azure.communication.messages.NotificationMessagesClientBuilder": "ClientForAcsMessages.NotificationMessagesClient",
+    "com.azure.communication.messages.models.AudioNotificationContent": "Azure.Communication.MessagesService.AudioNotificationContent",
     "com.azure.communication.messages.models.CommunicationMessageKind": "Azure.Communication.MessagesService.CommunicationMessageKind",
     "com.azure.communication.messages.models.CommunicationMessagesChannel": "Azure.Communication.MessagesService.CommunicationMessagesChannel",
+    "com.azure.communication.messages.models.DocumentNotificationContent": "Azure.Communication.MessagesService.DocumentNotificationContent",
+    "com.azure.communication.messages.models.ImageNotificationContent": "Azure.Communication.MessagesService.ImageNotificationContent",
     "com.azure.communication.messages.models.MediaNotificationContent": "Azure.Communication.MessagesService.MediaNotificationContent",
     "com.azure.communication.messages.models.MessageReceipt": "Azure.Communication.MessagesService.MessageReceipt",
     "com.azure.communication.messages.models.MessageTemplate": "Azure.Communication.MessagesService.MessageTemplate",
@@ -38,6 +41,7 @@
     "com.azure.communication.messages.models.SendMessageResult": "Azure.Communication.MessagesService.SendMessageResult",
     "com.azure.communication.messages.models.TemplateNotificationContent": "Azure.Communication.MessagesService.TemplateNotificationContent",
     "com.azure.communication.messages.models.TextNotificationContent": "Azure.Communication.MessagesService.TextNotificationContent",
+    "com.azure.communication.messages.models.VideoNotificationContent": "Azure.Communication.MessagesService.VideoNotificationContent",
     "com.azure.communication.messages.models.channels.WhatsAppMessageButtonSubType": "Azure.Communication.MessagesService.WhatsAppMessageButtonSubType",
     "com.azure.communication.messages.models.channels.WhatsAppMessageTemplateBindings": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindings",
     "com.azure.communication.messages.models.channels.WhatsAppMessageTemplateBindingsButton": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindingsButton",
diff --git a/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/NotificationMessageSample.java b/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/NotificationMessageSample.java
index 85cf08512fa82..748149927ce85 100644
--- a/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/NotificationMessageSample.java
+++ b/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/NotificationMessageSample.java
@@ -3,6 +3,9 @@
 
 package com.azure.communication.messages;
 
+import com.azure.communication.messages.models.AudioNotificationContent;
+import com.azure.communication.messages.models.DocumentNotificationContent;
+import com.azure.communication.messages.models.ImageNotificationContent;
 import com.azure.communication.messages.models.MessageTemplate;
 import com.azure.communication.messages.models.MessageTemplateBindings;
 import com.azure.communication.messages.models.MessageTemplateDocument;
@@ -11,9 +14,9 @@
 import com.azure.communication.messages.models.MessageTemplateText;
 import com.azure.communication.messages.models.MessageTemplateValue;
 import com.azure.communication.messages.models.MessageTemplateVideo;
-import com.azure.communication.messages.models.MediaNotificationContent;
 import com.azure.communication.messages.models.TextNotificationContent;
 import com.azure.communication.messages.models.TemplateNotificationContent;
+import com.azure.communication.messages.models.VideoNotificationContent;
 import com.azure.communication.messages.models.SendMessageResult;
 import com.azure.communication.messages.models.channels.WhatsAppMessageButtonSubType;
 import com.azure.communication.messages.models.channels.WhatsAppMessageTemplateBindings;
@@ -317,16 +320,73 @@ private static void sendTextMessage() {
     }
 
     /*
-     * This sample shows how to send simple media (image, video, document) message with below details
+     * This sample shows how to send image message with below details
      * Note: Business cannot initiate conversation with media message.
      * */
-    public static void sendMediaMessage() {
+    public static void sendImageMessage() {
         //Update the Media URL
         String mediaUrl = "https://wallpapercave.com/wp/wp2163723.jpg";
 
         NotificationMessagesClient client = createClientWithConnectionString();
         SendMessageResult result = client.send(
-            new MediaNotificationContent(CHANNEL_ID, TO_LIST, mediaUrl));
+            new ImageNotificationContent(CHANNEL_ID, TO_LIST, mediaUrl));
+
+        result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
+    }
+
+    /*
+     * This sample shows how to send video message with below details
+     * Supported video - video/3gp (.3gp), video/mp4 (.mp4)
+     * Note: Business cannot initiate conversation with media message.
+     * */
+    public void sendVideoMessage() {
+        //Update the Media URL
+        String mediaUrl = "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4";
+        List recipients = new ArrayList<>();
+        recipients.add("");
+        NotificationMessagesClient client = new NotificationMessagesClientBuilder()
+            .connectionString("")
+            .buildClient();
+        SendMessageResult result = client.send(
+            new VideoNotificationContent("", recipients, mediaUrl));
+
+        result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
+    }
+
+    /*
+     * This sample shows how to send audio message with below details
+     * Supported audio - audio/aac (.aac), audio/amr (.amr), audio/mpeg (.mp3), audio/a4a (.mp4), audio/ogg (.ogg )
+     * Note: Business cannot initiate conversation with media message.
+     * */
+    public void sendAudioMessage() {
+        //Update the Media URL
+        String mediaUrl = "https://sample-videos.com/audio/mp3/wave.mp3";
+        List recipients = new ArrayList<>();
+        recipients.add("");
+        NotificationMessagesClient client = new NotificationMessagesClientBuilder()
+            .connectionString("")
+            .buildClient();
+        SendMessageResult result = client.send(
+            new AudioNotificationContent("", recipients, mediaUrl));
+
+        result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
+    }
+
+    /*
+     * This sample shows how to send document message with below details
+     * Supported Document type - Plain Text (.txt), PDF (.pdf), Microsoft Excel, Word, PowerPoint
+     * Note: Business cannot initiate conversation with media message.
+     * */
+    public void sendDocumentMessage() {
+        //Update the Media URL
+        String mediaUrl = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf";
+        List recipients = new ArrayList<>();
+        recipients.add("");
+        NotificationMessagesClient client = new NotificationMessagesClientBuilder()
+            .connectionString("")
+            .buildClient();
+        SendMessageResult result = client.send(
+            new DocumentNotificationContent("", recipients, mediaUrl));
 
         result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
     }
diff --git a/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/ReadmeSamples.java b/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/ReadmeSamples.java
index 2f8f79f5fbf14..29d9a33c754cf 100644
--- a/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/ReadmeSamples.java
+++ b/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages/ReadmeSamples.java
@@ -4,15 +4,18 @@
 
 package com.azure.communication.messages;
 
+import com.azure.communication.messages.models.AudioNotificationContent;
+import com.azure.communication.messages.models.DocumentNotificationContent;
+import com.azure.communication.messages.models.ImageNotificationContent;
 import com.azure.communication.messages.models.MessageTemplate;
 import com.azure.communication.messages.models.MessageTemplateBindings;
+import com.azure.communication.messages.models.MessageTemplateItem;
 import com.azure.communication.messages.models.MessageTemplateText;
 import com.azure.communication.messages.models.MessageTemplateValue;
-import com.azure.communication.messages.models.MessageTemplateItem;
-import com.azure.communication.messages.models.MediaNotificationContent;
-import com.azure.communication.messages.models.TextNotificationContent;
-import com.azure.communication.messages.models.TemplateNotificationContent;
 import com.azure.communication.messages.models.SendMessageResult;
+import com.azure.communication.messages.models.TemplateNotificationContent;
+import com.azure.communication.messages.models.TextNotificationContent;
+import com.azure.communication.messages.models.VideoNotificationContent;
 import com.azure.communication.messages.models.channels.WhatsAppMessageTemplateBindings;
 import com.azure.communication.messages.models.channels.WhatsAppMessageTemplateBindingsComponent;
 import com.azure.communication.messages.models.channels.WhatsAppMessageTemplateItem;
@@ -152,12 +155,13 @@ private void sendTextMessage() {
     }
     // END: readme-sample-sendTextMessage
 
-    // BEGIN: readme-sample-sendMediaMessage
+    // BEGIN: readme-sample-sendImageMessage
     /*
-     * This sample shows how to send simple media (image, video, document) message with below details
+     * This sample shows how to send image message with below details.
+     * Supported image - image/jpeg (.jpeg), image/png (.png)
      * Note: Business cannot initiate conversation with media message.
      * */
-    public void sendMediaMessage() {
+    public void sendImageMessage() {
         //Update the Media URL
         String mediaUrl = "https://wallpapercave.com/wp/wp2163723.jpg";
         List recipients = new ArrayList<>();
@@ -166,11 +170,74 @@ public void sendMediaMessage() {
             .connectionString("")
             .buildClient();
         SendMessageResult result = client.send(
-            new MediaNotificationContent("", recipients, mediaUrl));
+            new ImageNotificationContent("", recipients, mediaUrl));
+
+        result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
+    }
+    // END: readme-sample-sendImageMessage
+
+    // BEGIN: readme-sample-sendVideoMessage
+    /*
+     * This sample shows how to send video message with below details
+     * Supported video - video/3gp (.3gp), video/mp4 (.mp4)
+     * Note: Business cannot initiate conversation with media message.
+     * */
+    public void sendVideoMessage() {
+        //Update the Media URL
+        String mediaUrl = "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4";
+        List recipients = new ArrayList<>();
+        recipients.add("");
+        NotificationMessagesClient client = new NotificationMessagesClientBuilder()
+            .connectionString("")
+            .buildClient();
+        SendMessageResult result = client.send(
+            new VideoNotificationContent("", recipients, mediaUrl));
+
+        result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
+    }
+    // END: readme-sample-sendVideoMessage
+
+    // BEGIN: readme-sample-sendAudioMessage
+    /*
+     * This sample shows how to send audio message with below details
+     * Supported audio - audio/aac (.aac), audio/amr (.amr), audio/mpeg (.mp3), audio/a4a (.mp4), audio/ogg (.ogg )
+     * Note: Business cannot initiate conversation with media message.
+     * */
+    public void sendAudioMessage() {
+        //Update the Media URL
+        String mediaUrl = "https://sample-videos.com/audio/mp3/wave.mp3";
+        List recipients = new ArrayList<>();
+        recipients.add("");
+        NotificationMessagesClient client = new NotificationMessagesClientBuilder()
+            .connectionString("")
+            .buildClient();
+        SendMessageResult result = client.send(
+            new AudioNotificationContent("", recipients, mediaUrl));
+
+        result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
+    }
+    // END: readme-sample-sendAudioMessage
+
+    // BEGIN: readme-sample-sendDocumentMessage
+    /*
+     * This sample shows how to send document message with below details
+     * Supported Document type - Plain Text (.txt), PDF (.pdf), Microsoft Excel, Word, PowerPoint
+     * Note: Business cannot initiate conversation with media message.
+     * */
+    public void sendDocumentMessage() {
+        //Update the Media URL
+        String mediaUrl = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf";
+        List recipients = new ArrayList<>();
+        recipients.add("");
+        NotificationMessagesClient client = new NotificationMessagesClientBuilder()
+            .connectionString("")
+            .buildClient();
+        SendMessageResult result = client.send(
+            new DocumentNotificationContent("", recipients, mediaUrl));
 
         result.getReceipts().forEach(r -> System.out.println("Message sent to:" + r.getTo() + " and message id:" + r.getMessageId()));
     }
-    // END: readme-sample-sendMediaMessage
+    // END: readme-sample-sendDocumentMessage
 
     public static void getMessageTemplateWithConnectionString() {
         // BEGIN: readme-sample-ListTemplates
diff --git a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java
index ebb1ceae39920..f3774effad7e0 100644
--- a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java
+++ b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java
@@ -28,7 +28,7 @@ public class CommunicationMessagesTestBase extends TestProxyTestBase {
             "endpoint=https://REDACTED.int.communication.azure.net;accessKey=secret");
 
     protected static final String CHANNEL_REGISTRATION_ID = Configuration.getGlobalConfiguration()
-        .get("SENDER_CHANNEL_REGISTRATION_ID", "77ffd898-ec44-42cd-b560-57a8903d05c7");
+        .get("SENDER_CHANNEL_REGISTRATION_ID", "bc73327d-d246-4983-9e13-284468af7240");
 
     protected static final String RECIPIENT_IDENTIFIER = Configuration.getGlobalConfiguration()
         .get("RECIPIENT_IDENTIFIER", "+11234567788");
diff --git a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateAsyncClientTest.java b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateAsyncClientTest.java
index 27181554086ff..662f90acb1605 100644
--- a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateAsyncClientTest.java
+++ b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateAsyncClientTest.java
@@ -41,22 +41,6 @@ public void shouldReturnWhatsTemplateListAsync(HttpClient httpClient) {
             });
     }
 
-    @ParameterizedTest
-    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
-    public void shouldReturnWhatsTemplateListWithTokenCredentialAsyncClient(HttpClient httpClient) {
-        messageTemplateClient = buildMessageTemplateAsyncClientWithTokenCredential(httpClient);
-
-        messageTemplateClient.listTemplates(CHANNEL_REGISTRATION_ID)
-            .toStream()
-            .forEach(template -> {
-                assertNotNull(template.getName());
-                assertNotNull(template.getLanguage());
-                assertNotNull(template.getStatus());
-                assertInstanceOf(WhatsAppMessageTemplateItem.class, template);
-                assertNotNull(((WhatsAppMessageTemplateItem) template).getContent());
-            });
-    }
-
     @ParameterizedTest
     @MethodSource("com.azure.core.test.TestBase#getHttpClients")
     public void shouldThrowExceptionForInvalidChannelIdAsync(HttpClient httpClient) {
diff --git a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateClientTest.java b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateClientTest.java
index e235223c962c9..9f463d558e3a1 100644
--- a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateClientTest.java
+++ b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/MessageTemplateClientTest.java
@@ -40,8 +40,8 @@ public void shouldReturnWhatsTemplateList(HttpClient httpClient) {
 
     @ParameterizedTest
     @MethodSource("com.azure.core.test.TestBase#getHttpClients")
-    public void shouldReturnWhatsTemplateListWithTokenCredentialClient(HttpClient httpClient) {
-        messageTemplateClient = buildMessageTemplateClientWithTokenCredential(httpClient);
+    public void shouldReturnWhatsTemplateListInSinglePage(HttpClient httpClient) {
+        messageTemplateClient = buildMessageTemplateClient(httpClient);
 
         messageTemplateClient.listTemplates(CHANNEL_REGISTRATION_ID)
             .stream()
diff --git a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessageAsyncClientTest.java b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessageAsyncClientTest.java
index 62b015a88a83e..5290d09161379 100644
--- a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessageAsyncClientTest.java
+++ b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessageAsyncClientTest.java
@@ -55,7 +55,7 @@ public void shouldSendImageMessage(HttpClient httpClient) {
         List recipients = new ArrayList<>();
         recipients.add(RECIPIENT_IDENTIFIER);
         StepVerifier
-            .create(messagesClient.send(new MediaNotificationContent(CHANNEL_REGISTRATION_ID,
+            .create(messagesClient.send(new ImageNotificationContent(CHANNEL_REGISTRATION_ID,
                 recipients, "https://wallpapercave.com/wp/wp2163723.jpg")))
             .assertNext(resp -> {
                 assertEquals(1, resp.getReceipts().size());
@@ -64,6 +64,54 @@ public void shouldSendImageMessage(HttpClient httpClient) {
             .verifyComplete();
     }
 
+    @ParameterizedTest
+    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
+    public void shouldSendVideoMessage(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesAsyncClient(httpClient);
+        List recipients = new ArrayList<>();
+        recipients.add(RECIPIENT_IDENTIFIER);
+        StepVerifier
+            .create(messagesClient.send(new VideoNotificationContent(CHANNEL_REGISTRATION_ID,
+                recipients, "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4")))
+            .assertNext(resp -> {
+                assertEquals(1, resp.getReceipts().size());
+                assertNotNull(resp.getReceipts().get(0).getMessageId());
+            })
+            .verifyComplete();
+    }
+
+    @ParameterizedTest
+    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
+    public void shouldSendAudioMessage(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesAsyncClient(httpClient);
+        List recipients = new ArrayList<>();
+        recipients.add(RECIPIENT_IDENTIFIER);
+        StepVerifier
+            .create(messagesClient.send(new AudioNotificationContent(CHANNEL_REGISTRATION_ID,
+                recipients, "https://sample-videos.com/audio/mp3/wave.mp3")))
+            .assertNext(resp -> {
+                assertEquals(1, resp.getReceipts().size());
+                assertNotNull(resp.getReceipts().get(0).getMessageId());
+            })
+            .verifyComplete();
+    }
+
+    @ParameterizedTest
+    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
+    public void shouldSendDocumentMessage(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesAsyncClient(httpClient);
+        List recipients = new ArrayList<>();
+        recipients.add(RECIPIENT_IDENTIFIER);
+        StepVerifier
+            .create(messagesClient.send(new AudioNotificationContent(CHANNEL_REGISTRATION_ID,
+                recipients, "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")))
+            .assertNext(resp -> {
+                assertEquals(1, resp.getReceipts().size());
+                assertNotNull(resp.getReceipts().get(0).getMessageId());
+            })
+            .verifyComplete();
+    }
+
     @ParameterizedTest
     @MethodSource("com.azure.core.test.TestBase#getHttpClients")
     public void shouldSendMessageTemplateWithImage(HttpClient httpClient) {
@@ -182,47 +230,6 @@ public void shouldSendMessageTemplateWithQuickAction(HttpClient httpClient) {
             .verifyComplete();
     }
 
-    @ParameterizedTest
-    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
-    public void shouldSendMessageQuickActionTemplateWithTokenCredential(HttpClient httpClient) {
-        messagesClient = buildNotificationMessagesAsyncClientWithTokenCredential(httpClient);
-        List recipients = new ArrayList<>();
-        recipients.add(RECIPIENT_IDENTIFIER);
-
-        //Add template parameter type with value in a list
-        List messageTemplateValues = new ArrayList<>();
-        messageTemplateValues.add(new MessageTemplateText("Name", "Arif"));
-        messageTemplateValues.add(new MessageTemplateQuickAction("Yes").setPayload("Yes"));
-        messageTemplateValues.add(new MessageTemplateQuickAction("No").setPayload("No"));
-
-        // Add parameter binding for template body in a list
-        List templateBodyBindings = new ArrayList<>();
-        templateBodyBindings.add(new WhatsAppMessageTemplateBindingsComponent("Name"));
-
-        // Add parameter binding for template buttons in a list
-        List templateButtonBindings = new ArrayList<>();
-        templateButtonBindings.add(new WhatsAppMessageTemplateBindingsButton(WhatsAppMessageButtonSubType.QUICK_REPLY, "Yes"));
-        templateButtonBindings.add(new WhatsAppMessageTemplateBindingsButton(WhatsAppMessageButtonSubType.QUICK_REPLY, "No"));
-
-        MessageTemplateBindings templateBindings = new WhatsAppMessageTemplateBindings()
-            .setBody(templateBodyBindings) // Set the parameter binding for template body
-            .setButtons(templateButtonBindings); // Set the parameter binding for template buttons
-
-        MessageTemplate messageTemplate = new MessageTemplate("sample_issue_resolution", "en_US")
-            .setBindings(templateBindings)
-            .setValues(messageTemplateValues);
-
-        StepVerifier
-            .create(messagesClient.send(new TemplateNotificationContent(CHANNEL_REGISTRATION_ID,
-                recipients, messageTemplate)))
-            .assertNext(resp -> {
-                assertNotNull(resp.getReceipts());
-                assertEquals(1, resp.getReceipts().size());
-                assertNotNull(resp.getReceipts().get(0).getMessageId());
-            })
-            .verifyComplete();
-    }
-
     @ParameterizedTest
     @MethodSource("com.azure.core.test.TestBase#getHttpClients")
     public void shouldSendMessageTemplateWithDocument(HttpClient httpClient) {
diff --git a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessagesClientTest.java b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessagesClientTest.java
index b43d05ce8e758..026678f614fe3 100644
--- a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessagesClientTest.java
+++ b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/NotificationMessagesClientTest.java
@@ -52,7 +52,7 @@ public void shouldSendImageMessage(HttpClient httpClient) {
         List recipients = new ArrayList<>();
         recipients.add(RECIPIENT_IDENTIFIER);
 
-        SendMessageResult result = messagesClient.send(new MediaNotificationContent(CHANNEL_REGISTRATION_ID,
+        SendMessageResult result = messagesClient.send(new ImageNotificationContent(CHANNEL_REGISTRATION_ID,
             recipients, "https://wallpapercave.com/wp/wp2163723.jpg"));
 
         assertEquals(1, result.getReceipts().size());
@@ -61,28 +61,29 @@ public void shouldSendImageMessage(HttpClient httpClient) {
 
     @ParameterizedTest
     @MethodSource("com.azure.core.test.TestBase#getHttpClients")
-    public void shouldSendMessageTemplateWithImage(HttpClient httpClient) {
+    public void shouldSendImageMessageWithCaption(HttpClient httpClient) {
         messagesClient = buildNotificationMessagesClient(httpClient);
         List recipients = new ArrayList<>();
         recipients.add(RECIPIENT_IDENTIFIER);
+        ImageNotificationContent imageMessage = new ImageNotificationContent(CHANNEL_REGISTRATION_ID,
+            recipients, "https://wallpapercave.com/wp/wp2163723.jpg");
+        imageMessage.setCaption("wow!");
 
-        //Update Template Name and language according your template associate to your channel.
-        MessageTemplate template = new MessageTemplate("sample_shipping_confirmation", "en_US");
+        SendMessageResult result = messagesClient.send(imageMessage);
 
-        //Update template parameter type and value
-        List messageTemplateValues = new ArrayList<>();
-        messageTemplateValues.add(new MessageTemplateText("Days", "5"));
-        template.setValues(messageTemplateValues);
+        assertEquals(1, result.getReceipts().size());
+        assertNotNull(result.getReceipts().get(0).getMessageId());
+    }
 
-        //Update template parameter binding
-        List components = new ArrayList<>();
-        components.add(new WhatsAppMessageTemplateBindingsComponent("Days"));
-        MessageTemplateBindings bindings = new WhatsAppMessageTemplateBindings()
-            .setBody(components);
-        template.setBindings(bindings);
+    @ParameterizedTest
+    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
+    public void shouldSendVideoMessage(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesClient(httpClient);
+        List recipients = new ArrayList<>();
+        recipients.add(RECIPIENT_IDENTIFIER);
 
-        SendMessageResult result = messagesClient.send(new TemplateNotificationContent(CHANNEL_REGISTRATION_ID,
-            recipients, template));
+        SendMessageResult result = messagesClient.send(new VideoNotificationContent(CHANNEL_REGISTRATION_ID,
+            recipients, "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4"));
 
         assertEquals(1, result.getReceipts().size());
         assertNotNull(result.getReceipts().get(0).getMessageId());
@@ -90,8 +91,36 @@ public void shouldSendMessageTemplateWithImage(HttpClient httpClient) {
 
     @ParameterizedTest
     @MethodSource("com.azure.core.test.TestBase#getHttpClients")
-    public void shouldSendMessageImageTemplateWithTokenCredential(HttpClient httpClient) {
-        messagesClient = buildNotificationMessagesClientWithTokenCredential(httpClient);
+    public void shouldSendAudioMessage(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesClient(httpClient);
+        List recipients = new ArrayList<>();
+        recipients.add(RECIPIENT_IDENTIFIER);
+
+        SendMessageResult result = messagesClient.send(new AudioNotificationContent(CHANNEL_REGISTRATION_ID,
+            recipients, "https://sample-videos.com/audio/mp3/wave.mp3"));
+
+        assertEquals(1, result.getReceipts().size());
+        assertNotNull(result.getReceipts().get(0).getMessageId());
+    }
+
+    @ParameterizedTest
+    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
+    public void shouldSendDocumentMessage(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesClient(httpClient);
+        List recipients = new ArrayList<>();
+        recipients.add(RECIPIENT_IDENTIFIER);
+
+        SendMessageResult result = messagesClient.send(new DocumentNotificationContent(CHANNEL_REGISTRATION_ID,
+            recipients, "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"));
+
+        assertEquals(1, result.getReceipts().size());
+        assertNotNull(result.getReceipts().get(0).getMessageId());
+    }
+
+    @ParameterizedTest
+    @MethodSource("com.azure.core.test.TestBase#getHttpClients")
+    public void shouldSendMessageImageTemplate(HttpClient httpClient) {
+        messagesClient = buildNotificationMessagesClient(httpClient);
         List recipients = new ArrayList<>();
         recipients.add(RECIPIENT_IDENTIFIER);
 
diff --git a/sdk/communication/azure-communication-messages/tsp-location.yaml b/sdk/communication/azure-communication-messages/tsp-location.yaml
index 31194c444abf7..277f8c2c5f5a2 100644
--- a/sdk/communication/azure-communication-messages/tsp-location.yaml
+++ b/sdk/communication/azure-communication-messages/tsp-location.yaml
@@ -1,4 +1,4 @@
 directory: specification/communication/Communication.Messages
-commit: 60dde357b17863d4c569c660464f6f6eb894b3b0
+commit: abe3209e7c6924a58ab560ebab2349bc8fde6aa7
 repo: Azure/azure-rest-api-specs
 additionalDirectories: null
diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md
index c7b3480448345..f40b1ed8fd544 100644
--- a/sdk/cosmos/azure-cosmos/CHANGELOG.md
+++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md
@@ -10,6 +10,13 @@
 
 #### Other Changes
 
+### 4.63.4 (2024-10-15)
+
+#### Bugs Fixed
+* Fixed an issue where a `NullPointerException` was thrown with circuit breaker enabled and partition split / merge scenarios. - See [PR 42178](https://github.com/Azure/azure-sdk-for-java/pull/42178)
+* Fixed an issue when a `Batch` operation hitting end-to-end timeout would not capture diagnostics correctly. - See [PR 42178](https://github.com/Azure/azure-sdk-for-java/pull/42178)
+* Fixed an issue where holding onto a `CosmosException` instance would hold a strong reference to a `RxDocumentClientImpl` instance preventing garbage collection of the `RxDocumentClientImpl` instance. - See [PR 42178](https://github.com/Azure/azure-sdk-for-java/pull/42178)
+
 ### 4.64.0 (2024-10-10)
 
 #### Features Added
diff --git a/sdk/face/azure-ai-vision-face/CHANGELOG.md b/sdk/face/azure-ai-vision-face/CHANGELOG.md
index a141882bda568..b7a9ec7987a0a 100644
--- a/sdk/face/azure-ai-vision-face/CHANGELOG.md
+++ b/sdk/face/azure-ai-vision-face/CHANGELOG.md
@@ -1,5 +1,15 @@
 # Release History
 
+## 1.0.0-beta.3 (Unreleased)
+
+### Features Added
+
+### Breaking Changes
+
+### Bugs Fixed
+
+### Other Changes
+
 ## 1.0.0-beta.2 (2024-10-23)
 
 - Added support for the Large Face List and Large Person Group:
diff --git a/sdk/face/azure-ai-vision-face/pom.xml b/sdk/face/azure-ai-vision-face/pom.xml
index a5c56725d3b00..3cb0f8db0a2ce 100644
--- a/sdk/face/azure-ai-vision-face/pom.xml
+++ b/sdk/face/azure-ai-vision-face/pom.xml
@@ -14,7 +14,7 @@
 
   com.azure
   azure-ai-vision-face
-  1.0.0-beta.2 
+  1.0.0-beta.3 
   jar
 
   Microsoft Azure SDK for Face
diff --git a/sdk/openai/azure-ai-openai/CHANGELOG.md b/sdk/openai/azure-ai-openai/CHANGELOG.md
index 0f5b6ec266281..2a8da05e422fa 100644
--- a/sdk/openai/azure-ai-openai/CHANGELOG.md
+++ b/sdk/openai/azure-ai-openai/CHANGELOG.md
@@ -1,5 +1,15 @@
 # Release History
 
+## 1.0.0-beta.13 (Unreleased)
+
+### Features Added
+
+### Breaking Changes
+
+### Bugs Fixed
+
+### Other Changes
+
 ## 1.0.0-beta.12 (2024-10-22)
 
 ### Features Added
diff --git a/sdk/openai/azure-ai-openai/pom.xml b/sdk/openai/azure-ai-openai/pom.xml
index 4f0ef976422f6..d5b144923eb16 100644
--- a/sdk/openai/azure-ai-openai/pom.xml
+++ b/sdk/openai/azure-ai-openai/pom.xml
@@ -14,7 +14,7 @@
 
   com.azure
   azure-ai-openai
-  1.0.0-beta.12 
+  1.0.0-beta.13 
   jar
 
   Microsoft Azure Client Library For OpenAI
diff --git a/sdk/personalizer/azure-ai-personalizer/assets.json b/sdk/personalizer/azure-ai-personalizer/assets.json
index 390aa8eafad08..13b4b9049b281 100644
--- a/sdk/personalizer/azure-ai-personalizer/assets.json
+++ b/sdk/personalizer/azure-ai-personalizer/assets.json
@@ -2,5 +2,5 @@
   "AssetsRepo": "Azure/azure-sdk-assets",
   "AssetsRepoPrefixPath": "java",
   "TagPrefix": "java/personalizer/azure-ai-personalizer",
-  "Tag": "java/personalizer/azure-ai-personalizer_2583cef92d"
+  "Tag": "java/personalizer/azure-ai-personalizer_8067625503"
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/pom.xml b/sdk/personalizer/azure-ai-personalizer/pom.xml
index 7f9d028c1c9f0..6e29feb10affd 100644
--- a/sdk/personalizer/azure-ai-personalizer/pom.xml
+++ b/sdk/personalizer/azure-ai-personalizer/pom.xml
@@ -36,9 +36,7 @@
     
     
       --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED
-      --add-exports com.azure.ai.personalizer/com.azure.ai.personalizer.testmodels=com.fasterxml.jackson.databind
       --add-opens com.azure.ai.personalizer/com.azure.ai.personalizer=ALL-UNNAMED
-      --add-opens com.azure.ai.personalizer/com.azure.ai.personalizer.testmodels=com.fasterxml.jackson.databind
       --add-opens com.azure.ai.personalizer/com.azure.ai.personalizer.testmodels=com.azure.core
     
 
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/PersonalizerAdministrationAsyncClient.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/PersonalizerAdministrationAsyncClient.java
index e7beeb74d22d0..221fb97c36cd9 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/PersonalizerAdministrationAsyncClient.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/PersonalizerAdministrationAsyncClient.java
@@ -512,23 +512,8 @@ public Mono> exportModelWithResponse(boolean isSigned) {
      * @return the model file generated by Personalizer service.
      */
     Mono> exportModelWithResponse(boolean isSigned, Context context) {
-        return service.getModels().getWithResponseAsync(isSigned, context).flatMap(streamResponse -> {
-            return BinaryData.fromFlux(streamResponse.getValue())
-                .flatMap(binaryData -> {
-                    Response response = new SimpleResponse<>(
-                        streamResponse.getRequest(),
-                        streamResponse.getStatusCode(),
-                        streamResponse.getHeaders(),
-                        binaryData);
-                    return Mono.just(response);
-                }).doFinally(ignored -> {
-                    try {
-                        streamResponse.close();
-                    } catch (Exception e) {
-                        logger.logThrowableAsError(e);
-                    }
-                });
-        }).onErrorMap(Transforms::mapToHttpResponseExceptionIfExists);
+        return service.getModels().getWithResponseAsync(isSigned, context)
+            .onErrorMap(Transforms::mapToHttpResponseExceptionIfExists);
     }
 
     /**
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/EvaluationsCreateHeaders.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/EvaluationsCreateHeaders.java
index 1854f5a21df8f..7b9bca31db564 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/EvaluationsCreateHeaders.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/EvaluationsCreateHeaders.java
@@ -5,31 +5,32 @@
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Fluent;
+import com.azure.core.http.HttpHeaderName;
 import com.azure.core.http.HttpHeaders;
-import com.fasterxml.jackson.annotation.JsonProperty;
 
-/** The EvaluationsCreateHeaders model. */
+/**
+ * The EvaluationsCreateHeaders model.
+ */
 @Fluent
 public final class EvaluationsCreateHeaders {
     /*
      * The Location property.
      */
-    @JsonProperty(value = "Location")
     private String location;
 
     // HttpHeaders containing the raw property values.
     /**
      * Creates an instance of EvaluationsCreateHeaders class.
-     *
+     * 
      * @param rawHeaders The raw HttpHeaders that will be used to create the property values.
      */
     public EvaluationsCreateHeaders(HttpHeaders rawHeaders) {
-        this.location = rawHeaders.getValue("Location");
+        this.location = rawHeaders.getValue(HttpHeaderName.LOCATION);
     }
 
     /**
      * Get the location property: The Location property.
-     *
+     * 
      * @return the location value.
      */
     public String getLocation() {
@@ -38,7 +39,7 @@ public String getLocation() {
 
     /**
      * Set the location property: The Location property.
-     *
+     * 
      * @param location the location value to set.
      * @return the EvaluationsCreateHeaders object itself.
      */
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerDateRange.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerDateRange.java
index edfa85483d541..9dae6d95fb68f 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerDateRange.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerDateRange.java
@@ -5,39 +5,111 @@
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Immutable;
-import com.fasterxml.jackson.annotation.JsonProperty;
+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 java.io.IOException;
 import java.time.OffsetDateTime;
 
-/** A date range starting at From and ending at To. */
+/**
+ * A date range starting at From and ending at To.
+ */
 @Immutable
-public class PersonalizerDateRange {
+public class PersonalizerDateRange implements JsonSerializable {
     /*
      * Start date for the range.
      */
-    @JsonProperty(value = "from", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime from;
 
     /*
      * End date for the range.
      */
-    @JsonProperty(value = "to", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime to;
 
+    /**
+     * Creates an instance of PersonalizerDateRange class.
+     */
+    public PersonalizerDateRange() {
+    }
+
     /**
      * Get the from property: Start date for the range.
-     *
+     * 
      * @return the from value.
      */
     public OffsetDateTime getFrom() {
         return this.from;
     }
 
+    /**
+     * Set the from property: Start date for the range.
+     * 
+     * @param from the from value to set.
+     * @return the PersonalizerDateRange object itself.
+     */
+    PersonalizerDateRange setFrom(OffsetDateTime from) {
+        this.from = from;
+        return this;
+    }
+
     /**
      * Get the to property: End date for the range.
-     *
+     * 
      * @return the to value.
      */
     public OffsetDateTime getTo() {
         return this.to;
     }
+
+    /**
+     * Set the to property: End date for the range.
+     * 
+     * @param to the to value to set.
+     * @return the PersonalizerDateRange object itself.
+     */
+    PersonalizerDateRange setTo(OffsetDateTime to) {
+        this.to = to;
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerDateRange from the JsonReader.
+     * 
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerDateRange 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 PersonalizerDateRange.
+     */
+    public static PersonalizerDateRange fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerDateRange deserializedPersonalizerDateRange = new PersonalizerDateRange();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+
+                if ("from".equals(fieldName)) {
+                    deserializedPersonalizerDateRange.from = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("to".equals(fieldName)) {
+                    deserializedPersonalizerDateRange.to = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else {
+                    reader.skipChildren();
+                }
+            }
+
+            return deserializedPersonalizerDateRange;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluation.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluation.java
index 75526ce0f25d6..8434413f8d52a 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluation.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluation.java
@@ -1,85 +1,88 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 // Code generated by Microsoft (R) AutoRest Code Generator.
-
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.ai.personalizer.models.EvaluationJobStatus;
 import com.azure.ai.personalizer.models.EvaluationType;
 import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+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 java.io.IOException;
 import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 
-/** A counterfactual evaluation. */
+/**
+ * A counterfactual evaluation.
+ */
 @Fluent
-public final class PersonalizerEvaluation {
+public final class PersonalizerEvaluation implements JsonSerializable {
+
     /*
      * The ID of the evaluation.
      */
-    @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY)
     private String id;
 
     /*
      * The name of the evaluation.
      */
-    @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY)
     private String name;
 
     /*
      * The start time of the evaluation.
      */
-    @JsonProperty(value = "startTime", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime startTime;
 
     /*
      * The end time of the evaluation.
      */
-    @JsonProperty(value = "endTime", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime endTime;
 
     /*
      * The ID of the job processing the evaluation.
      */
-    @JsonProperty(value = "jobId", access = JsonProperty.Access.WRITE_ONLY)
     private String jobId;
 
     /*
      * The status of the job processing the evaluation.
      */
-    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
     private EvaluationJobStatus status;
 
     /*
      * The results of the evaluation.
      */
-    @JsonProperty(value = "policyResults")
     private List policyResults;
 
     /*
      * Feature Importance.
      */
-    @JsonProperty(value = "featureImportance")
     private List> featureImportance;
 
     /*
      * Evaluation type (manual or through Automatic Optimization).
      */
-    @JsonProperty(value = "evaluationType")
     private EvaluationType evaluationType;
 
     /*
      * Thr optimal policy.
      */
-    @JsonProperty(value = "optimalPolicy")
     private String optimalPolicy;
 
     /*
      * Creation time.
      */
-    @JsonProperty(value = "creationTime")
     private OffsetDateTime creationTime;
 
+    /**
+     * Creates an instance of PersonalizerEvaluation class.
+     */
+    public PersonalizerEvaluation() {
+    }
+
     /**
      * Get the id property: The ID of the evaluation.
      *
@@ -233,4 +236,72 @@ PersonalizerEvaluation setCreationTime(OffsetDateTime creationTime) {
         this.creationTime = creationTime;
         return this;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeArrayField("policyResults", this.policyResults, (writer, element) -> writer.writeJson(element));
+        jsonWriter.writeArrayField("featureImportance", this.featureImportance,
+            (writer, element) -> writer.writeArray(element, (writer1, element1) -> writer1.writeString(element1)));
+        jsonWriter.writeStringField("evaluationType",
+            this.evaluationType == null ? null : this.evaluationType.toString());
+        jsonWriter.writeStringField("optimalPolicy", this.optimalPolicy);
+        jsonWriter.writeStringField("creationTime",
+            this.creationTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.creationTime));
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerEvaluation from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerEvaluation 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 PersonalizerEvaluation.
+     */
+    public static PersonalizerEvaluation fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerEvaluation deserializedPersonalizerEvaluation = new PersonalizerEvaluation();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("id".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.id = reader.getString();
+                } else if ("name".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.name = reader.getString();
+                } else if ("startTime".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.startTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("endTime".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.endTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("jobId".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.jobId = reader.getString();
+                } else if ("status".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.status = EvaluationJobStatus.fromString(reader.getString());
+                } else if ("policyResults".equals(fieldName)) {
+                    List policyResults
+                        = reader.readArray(reader1 -> PersonalizerPolicyResult.fromJson(reader1));
+                    deserializedPersonalizerEvaluation.policyResults = policyResults;
+                } else if ("featureImportance".equals(fieldName)) {
+                    List> featureImportance
+                        = reader.readArray(reader1 -> reader1.readArray(reader2 -> reader2.getString()));
+                    deserializedPersonalizerEvaluation.featureImportance = featureImportance;
+                } else if ("evaluationType".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.evaluationType = EvaluationType.fromString(reader.getString());
+                } else if ("optimalPolicy".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.optimalPolicy = reader.getString();
+                } else if ("creationTime".equals(fieldName)) {
+                    deserializedPersonalizerEvaluation.creationTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            return deserializedPersonalizerEvaluation;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluationOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluationOptions.java
index a0387a2e224ae..ca13a4faa23f3 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluationOptions.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerEvaluationOptions.java
@@ -5,69 +5,77 @@
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+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 java.io.IOException;
 import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 
-/** A counterfactual evaluation. */
+/**
+ * A counterfactual evaluation.
+ */
 @Fluent
-public final class PersonalizerEvaluationOptions {
+public final class PersonalizerEvaluationOptions implements JsonSerializable {
     /*
-     * True if the evaluation should explore for a more optimal learning
-     * settings.
+     * True if the evaluation should explore for a more optimal learning settings.
      */
-    @JsonProperty(value = "enableOfflineExperimentation")
-    private Boolean enableOfflineExperimentation;
+    private Boolean offlineExperimentationEnabled;
 
     /*
      * The name of the evaluation.
      */
-    @JsonProperty(value = "name", required = true)
     private String name;
 
     /*
      * The start time of the evaluation.
      */
-    @JsonProperty(value = "startTime", required = true)
     private OffsetDateTime startTime;
 
     /*
      * The end time of the evaluation.
      */
-    @JsonProperty(value = "endTime", required = true)
     private OffsetDateTime endTime;
 
     /*
      * Additional learning settings to evaluate.
      */
-    @JsonProperty(value = "policies", required = true)
     private List policies;
 
     /**
-     * Get the enableOfflineExperimentation property: True if the evaluation should explore for a more optimal learning
+     * Creates an instance of PersonalizerEvaluationOptions class.
+     */
+    public PersonalizerEvaluationOptions() {
+    }
+
+    /**
+     * Get the offlineExperimentationEnabled property: True if the evaluation should explore for a more optimal learning
      * settings.
-     *
-     * @return the enableOfflineExperimentation value.
+     * 
+     * @return the offlineExperimentationEnabled value.
      */
     public Boolean isOfflineExperimentationEnabled() {
-        return this.enableOfflineExperimentation;
+        return this.offlineExperimentationEnabled;
     }
 
     /**
-     * Set the enableOfflineExperimentation property: True if the evaluation should explore for a more optimal learning
+     * Set the offlineExperimentationEnabled property: True if the evaluation should explore for a more optimal learning
      * settings.
-     *
-     * @param enableOfflineExperimentation the enableOfflineExperimentation value to set.
+     * 
+     * @param offlineExperimentationEnabled the offlineExperimentationEnabled value to set.
      * @return the PersonalizerEvaluationOptions object itself.
      */
-    public PersonalizerEvaluationOptions setOfflineExperimentationEnabled(Boolean enableOfflineExperimentation) {
-        this.enableOfflineExperimentation = enableOfflineExperimentation;
+    public PersonalizerEvaluationOptions setOfflineExperimentationEnabled(Boolean offlineExperimentationEnabled) {
+        this.offlineExperimentationEnabled = offlineExperimentationEnabled;
         return this;
     }
 
     /**
      * Get the name property: The name of the evaluation.
-     *
+     * 
      * @return the name value.
      */
     public String getName() {
@@ -76,7 +84,7 @@ public String getName() {
 
     /**
      * Set the name property: The name of the evaluation.
-     *
+     * 
      * @param name the name value to set.
      * @return the PersonalizerEvaluationOptions object itself.
      */
@@ -87,7 +95,7 @@ public PersonalizerEvaluationOptions setName(String name) {
 
     /**
      * Get the startTime property: The start time of the evaluation.
-     *
+     * 
      * @return the startTime value.
      */
     public OffsetDateTime getStartTime() {
@@ -96,7 +104,7 @@ public OffsetDateTime getStartTime() {
 
     /**
      * Set the startTime property: The start time of the evaluation.
-     *
+     * 
      * @param startTime the startTime value to set.
      * @return the PersonalizerEvaluationOptions object itself.
      */
@@ -107,7 +115,7 @@ public PersonalizerEvaluationOptions setStartTime(OffsetDateTime startTime) {
 
     /**
      * Get the endTime property: The end time of the evaluation.
-     *
+     * 
      * @return the endTime value.
      */
     public OffsetDateTime getEndTime() {
@@ -116,7 +124,7 @@ public OffsetDateTime getEndTime() {
 
     /**
      * Set the endTime property: The end time of the evaluation.
-     *
+     * 
      * @param endTime the endTime value to set.
      * @return the PersonalizerEvaluationOptions object itself.
      */
@@ -127,7 +135,7 @@ public PersonalizerEvaluationOptions setEndTime(OffsetDateTime endTime) {
 
     /**
      * Get the policies property: Additional learning settings to evaluate.
-     *
+     * 
      * @return the policies value.
      */
     public List getPolicies() {
@@ -136,7 +144,7 @@ public List getPolicies() {
 
     /**
      * Set the policies property: Additional learning settings to evaluate.
-     *
+     * 
      * @param policies the policies value to set.
      * @return the PersonalizerEvaluationOptions object itself.
      */
@@ -144,4 +152,61 @@ public PersonalizerEvaluationOptions setPolicies(List polici
         this.policies = policies;
         return this;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("name", this.name);
+        jsonWriter.writeStringField("startTime",
+            this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
+        jsonWriter.writeStringField("endTime",
+            this.endTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTime));
+        jsonWriter.writeArrayField("policies", this.policies, (writer, element) -> writer.writeJson(element));
+        jsonWriter.writeBooleanField("enableOfflineExperimentation", this.offlineExperimentationEnabled);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerEvaluationOptions from the JsonReader.
+     * 
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerEvaluationOptions 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 PersonalizerEvaluationOptions.
+     */
+    public static PersonalizerEvaluationOptions fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerEvaluationOptions deserializedPersonalizerEvaluationOptions
+                = new PersonalizerEvaluationOptions();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+
+                if ("name".equals(fieldName)) {
+                    deserializedPersonalizerEvaluationOptions.name = reader.getString();
+                } else if ("startTime".equals(fieldName)) {
+                    deserializedPersonalizerEvaluationOptions.startTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("endTime".equals(fieldName)) {
+                    deserializedPersonalizerEvaluationOptions.endTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("policies".equals(fieldName)) {
+                    List policies
+                        = reader.readArray(reader1 -> PersonalizerPolicy.fromJson(reader1));
+                    deserializedPersonalizerEvaluationOptions.policies = policies;
+                } else if ("enableOfflineExperimentation".equals(fieldName)) {
+                    deserializedPersonalizerEvaluationOptions.offlineExperimentationEnabled
+                        = reader.getNullable(JsonReader::getBoolean);
+                } else {
+                    reader.skipChildren();
+                }
+            }
+
+            return deserializedPersonalizerEvaluationOptions;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogProperties.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogProperties.java
index cc2624e0a0b9d..1f0a657b86ac2 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogProperties.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogProperties.java
@@ -1,28 +1,72 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 // Code generated by Microsoft (R) AutoRest Code Generator.
-
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Immutable;
-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;
 
-/** Properties related to data used to train the model. */
+/**
+ * Properties related to data used to train the model.
+ */
 @Immutable
-public final class PersonalizerLogProperties {
+public final class PersonalizerLogProperties implements JsonSerializable {
+
     /*
      * Date range.
      */
-    @JsonProperty(value = "dateRange", access = JsonProperty.Access.WRITE_ONLY)
     private PersonalizerLogPropertiesDateRange dateRange;
 
+    /**
+     * Creates an instance of PersonalizerLogProperties class.
+     */
+    public PersonalizerLogProperties() {
+    }
+
     /**
      * Get the dateRange property: Date range.
      *
      * @return the dateRange value.
      */
     public PersonalizerDateRange getDateRange() {
-        PersonalizerLogPropertiesDateRange returnValue = this.dateRange;
-        return returnValue;
+        return this.dateRange;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerLogProperties from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerLogProperties 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 PersonalizerLogProperties.
+     */
+    public static PersonalizerLogProperties fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerLogProperties deserializedPersonalizerLogProperties = new PersonalizerLogProperties();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("dateRange".equals(fieldName)) {
+                    deserializedPersonalizerLogProperties.dateRange
+                        = PersonalizerLogPropertiesDateRange.fromJson(reader);
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            return deserializedPersonalizerLogProperties;
+        });
     }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogPropertiesDateRange.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogPropertiesDateRange.java
index 52ff641f8c048..b2a1ead38f458 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogPropertiesDateRange.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerLogPropertiesDateRange.java
@@ -1,12 +1,93 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 // Code generated by Microsoft (R) AutoRest Code Generator.
-
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Immutable;
+import com.azure.core.util.CoreUtils;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.time.OffsetDateTime;
 
-/** Date range. */
+/**
+ * Date range.
+ */
 @Immutable
 class PersonalizerLogPropertiesDateRange extends PersonalizerDateRange {
+
+    /*
+     * End date for the range.
+     */
+    private OffsetDateTime to;
+
+    /*
+     * Start date for the range.
+     */
+    private OffsetDateTime from;
+
+    /**
+     * Creates an instance of PersonalizerLogPropertiesDateRange class.
+     */
+    PersonalizerLogPropertiesDateRange() {
+    }
+
+    /**
+     * Get the to property: End date for the range.
+     *
+     * @return the to value.
+     */
+    @Override
+    public OffsetDateTime getTo() {
+        return this.to;
+    }
+
+    /**
+     * Get the from property: Start date for the range.
+     *
+     * @return the from value.
+     */
+    @Override
+    public OffsetDateTime getFrom() {
+        return this.from;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerLogPropertiesDateRange from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerLogPropertiesDateRange 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 PersonalizerLogPropertiesDateRange.
+     */
+    public static PersonalizerLogPropertiesDateRange fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerLogPropertiesDateRange deserializedPersonalizerLogPropertiesDateRange
+                = new PersonalizerLogPropertiesDateRange();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("from".equals(fieldName)) {
+                    deserializedPersonalizerLogPropertiesDateRange.from = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("to".equals(fieldName)) {
+                    deserializedPersonalizerLogPropertiesDateRange.to = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            return deserializedPersonalizerLogPropertiesDateRange;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerModelProperties.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerModelProperties.java
index 5669b9697c2d3..1a87d6d4ed5e5 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerModelProperties.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerModelProperties.java
@@ -5,27 +5,38 @@
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Immutable;
-import com.fasterxml.jackson.annotation.JsonProperty;
+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 java.io.IOException;
 import java.time.OffsetDateTime;
 
-/** Properties related to the trained model. */
+/**
+ * Properties related to the trained model.
+ */
 @Immutable
-public final class PersonalizerModelProperties {
+public final class PersonalizerModelProperties implements JsonSerializable {
     /*
      * Creation time of the model.
      */
-    @JsonProperty(value = "creationTime", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime creationTime;
 
     /*
      * Last time the model was modified.
      */
-    @JsonProperty(value = "lastModifiedTime", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime lastModifiedTime;
 
+    /**
+     * Creates an instance of PersonalizerModelProperties class.
+     */
+    public PersonalizerModelProperties() {
+    }
+
     /**
      * Get the creationTime property: Creation time of the model.
-     *
+     * 
      * @return the creationTime value.
      */
     public OffsetDateTime getCreationTime() {
@@ -34,10 +45,49 @@ public OffsetDateTime getCreationTime() {
 
     /**
      * Get the lastModifiedTime property: Last time the model was modified.
-     *
+     * 
      * @return the lastModifiedTime value.
      */
     public OffsetDateTime getLastModifiedTime() {
         return this.lastModifiedTime;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerModelProperties from the JsonReader.
+     * 
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerModelProperties 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 PersonalizerModelProperties.
+     */
+    public static PersonalizerModelProperties fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerModelProperties deserializedPersonalizerModelProperties = new PersonalizerModelProperties();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+
+                if ("creationTime".equals(fieldName)) {
+                    deserializedPersonalizerModelProperties.creationTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("lastModifiedTime".equals(fieldName)) {
+                    deserializedPersonalizerModelProperties.lastModifiedTime = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else {
+                    reader.skipChildren();
+                }
+            }
+
+            return deserializedPersonalizerModelProperties;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicy.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicy.java
index 4483cb29704f7..3840be94772d4 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicy.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicy.java
@@ -5,26 +5,36 @@
 package com.azure.ai.personalizer.administration.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;
 
-/** Learning settings specifying how to train the model. */
+/**
+ * Learning settings specifying how to train the model.
+ */
 @Fluent
-public final class PersonalizerPolicy {
+public final class PersonalizerPolicy implements JsonSerializable {
     /*
      * Name of the learning settings.
      */
-    @JsonProperty(value = "name", required = true)
     private String name;
 
     /*
      * Arguments of the learning settings.
      */
-    @JsonProperty(value = "arguments", required = true)
     private String arguments;
 
+    /**
+     * Creates an instance of PersonalizerPolicy class.
+     */
+    public PersonalizerPolicy() {
+    }
+
     /**
      * Get the name property: Name of the learning settings.
-     *
+     * 
      * @return the name value.
      */
     public String getName() {
@@ -33,7 +43,7 @@ public String getName() {
 
     /**
      * Set the name property: Name of the learning settings.
-     *
+     * 
      * @param name the name value to set.
      * @return the PersonalizerPolicy object itself.
      */
@@ -44,7 +54,7 @@ public PersonalizerPolicy setName(String name) {
 
     /**
      * Get the arguments property: Arguments of the learning settings.
-     *
+     * 
      * @return the arguments value.
      */
     public String getArguments() {
@@ -53,7 +63,7 @@ public String getArguments() {
 
     /**
      * Set the arguments property: Arguments of the learning settings.
-     *
+     * 
      * @param arguments the arguments value to set.
      * @return the PersonalizerPolicy object itself.
      */
@@ -61,4 +71,44 @@ public PersonalizerPolicy setArguments(String arguments) {
         this.arguments = arguments;
         return this;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("name", this.name);
+        jsonWriter.writeStringField("arguments", this.arguments);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerPolicy from the JsonReader.
+     * 
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerPolicy 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 PersonalizerPolicy.
+     */
+    public static PersonalizerPolicy fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerPolicy deserializedPersonalizerPolicy = new PersonalizerPolicy();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+
+                if ("name".equals(fieldName)) {
+                    deserializedPersonalizerPolicy.name = reader.getString();
+                } else if ("arguments".equals(fieldName)) {
+                    deserializedPersonalizerPolicy.arguments = reader.getString();
+                } else {
+                    reader.skipChildren();
+                }
+            }
+
+            return deserializedPersonalizerPolicy;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyReferenceOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyReferenceOptions.java
index 138f7e4dbccfc..3778b13f898bb 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyReferenceOptions.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyReferenceOptions.java
@@ -5,26 +5,36 @@
 package com.azure.ai.personalizer.administration.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;
 
-/** Reference to the policy within the evaluation. */
+/**
+ * Reference to the policy within the evaluation.
+ */
 @Fluent
-public final class PersonalizerPolicyReferenceOptions {
+public final class PersonalizerPolicyReferenceOptions implements JsonSerializable {
     /*
      * Evaluation Id of the evaluation.
      */
-    @JsonProperty(value = "evaluationId", required = true)
     private String evaluationId;
 
     /*
      * Name of the learning settings.
      */
-    @JsonProperty(value = "policyName", required = true)
     private String policyName;
 
+    /**
+     * Creates an instance of PersonalizerPolicyReferenceOptions class.
+     */
+    public PersonalizerPolicyReferenceOptions() {
+    }
+
     /**
      * Get the evaluationId property: Evaluation Id of the evaluation.
-     *
+     * 
      * @return the evaluationId value.
      */
     public String getEvaluationId() {
@@ -33,7 +43,7 @@ public String getEvaluationId() {
 
     /**
      * Set the evaluationId property: Evaluation Id of the evaluation.
-     *
+     * 
      * @param evaluationId the evaluationId value to set.
      * @return the PersonalizerPolicyReferenceOptions object itself.
      */
@@ -44,7 +54,7 @@ public PersonalizerPolicyReferenceOptions setEvaluationId(String evaluationId) {
 
     /**
      * Get the policyName property: Name of the learning settings.
-     *
+     * 
      * @return the policyName value.
      */
     public String getPolicyName() {
@@ -53,7 +63,7 @@ public String getPolicyName() {
 
     /**
      * Set the policyName property: Name of the learning settings.
-     *
+     * 
      * @param policyName the policyName value to set.
      * @return the PersonalizerPolicyReferenceOptions object itself.
      */
@@ -61,4 +71,45 @@ public PersonalizerPolicyReferenceOptions setPolicyName(String policyName) {
         this.policyName = policyName;
         return this;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("evaluationId", this.evaluationId);
+        jsonWriter.writeStringField("policyName", this.policyName);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerPolicyReferenceOptions from the JsonReader.
+     * 
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerPolicyReferenceOptions 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 PersonalizerPolicyReferenceOptions.
+     */
+    public static PersonalizerPolicyReferenceOptions fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerPolicyReferenceOptions deserializedPersonalizerPolicyReferenceOptions
+                = new PersonalizerPolicyReferenceOptions();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+
+                if ("evaluationId".equals(fieldName)) {
+                    deserializedPersonalizerPolicyReferenceOptions.evaluationId = reader.getString();
+                } else if ("policyName".equals(fieldName)) {
+                    deserializedPersonalizerPolicyReferenceOptions.policyName = reader.getString();
+                } else {
+                    reader.skipChildren();
+                }
+            }
+
+            return deserializedPersonalizerPolicyReferenceOptions;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResult.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResult.java
index 3c51e6ab887cb..026a6806916bf 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResult.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResult.java
@@ -1,49 +1,54 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 // Code generated by Microsoft (R) AutoRest Code Generator.
-
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.ai.personalizer.models.PolicySource;
 import com.azure.core.annotation.Immutable;
-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;
 import java.util.List;
 
 /**
  * This class contains the Learning Settings information and the results of the Offline Evaluation using that policy.
  */
 @Immutable
-public final class PersonalizerPolicyResult {
+public final class PersonalizerPolicyResult implements JsonSerializable {
+
     /*
      * The name of the Learning Settings.
      */
-    @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY)
     private String name;
 
     /*
      * The arguments of the Learning Settings.
      */
-    @JsonProperty(value = "arguments", access = JsonProperty.Access.WRITE_ONLY)
     private String arguments;
 
     /*
      * The source of the Learning Settings.
      */
-    @JsonProperty(value = "policySource", access = JsonProperty.Access.WRITE_ONLY)
     private PolicySource policySource;
 
     /*
      * The aggregate results of the Offline Evaluation.
      */
-    @JsonProperty(value = "summary", access = JsonProperty.Access.WRITE_ONLY)
     private List summary;
 
     /*
      * The aggregate total of the Offline Evaluation.
      */
-    @JsonProperty(value = "totalSummary", access = JsonProperty.Access.WRITE_ONLY)
     private PersonalizerPolicyResultTotalSummary totalSummary;
 
+    /**
+     * Creates an instance of PersonalizerPolicyResult class.
+     */
+    public PersonalizerPolicyResult() {
+    }
+
     /**
      * Get the name property: The name of the Learning Settings.
      *
@@ -86,7 +91,50 @@ public List getSummary() {
      * @return the totalSummary value.
      */
     public PersonalizerPolicyResultSummary getTotalSummary() {
-        PersonalizerPolicyResultTotalSummary returnValue = this.totalSummary;
-        return returnValue;
+        return this.totalSummary;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerPolicyResult from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerPolicyResult 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 PersonalizerPolicyResult.
+     */
+    public static PersonalizerPolicyResult fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerPolicyResult deserializedPersonalizerPolicyResult = new PersonalizerPolicyResult();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("name".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResult.name = reader.getString();
+                } else if ("arguments".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResult.arguments = reader.getString();
+                } else if ("policySource".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResult.policySource = PolicySource.fromString(reader.getString());
+                } else if ("summary".equals(fieldName)) {
+                    List summary
+                        = reader.readArray(reader1 -> PersonalizerPolicyResultSummary.fromJson(reader1));
+                    deserializedPersonalizerPolicyResult.summary = summary;
+                } else if ("totalSummary".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResult.totalSummary
+                        = PersonalizerPolicyResultTotalSummary.fromJson(reader);
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            return deserializedPersonalizerPolicyResult;
+        });
     }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultSummary.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultSummary.java
index 6d16fc4eca296..f75a9f6061896 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultSummary.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultSummary.java
@@ -1,39 +1,42 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 // Code generated by Microsoft (R) AutoRest Code Generator.
-
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+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 java.io.IOException;
 import java.time.Duration;
 import java.time.OffsetDateTime;
 
-/** This class contains the summary of evaluating a policy on a counterfactual evaluation. */
+/**
+ * This class contains the summary of evaluating a policy on a counterfactual evaluation.
+ */
 @Fluent
-public class PersonalizerPolicyResultSummary {
+public class PersonalizerPolicyResultSummary implements JsonSerializable {
+
     /*
      * Timestamp of the aggregation.
      */
-    @JsonProperty(value = "timeStamp", access = JsonProperty.Access.WRITE_ONLY)
     private OffsetDateTime timeStamp;
 
     /*
      * Numerator for IPS estimator.
      */
-    @JsonProperty(value = "ipsEstimatorNumerator", access = JsonProperty.Access.WRITE_ONLY)
     private Float ipsEstimatorNumerator;
 
     /*
      * Denominator for IPS estimator.
      */
-    @JsonProperty(value = "ipsEstimatorDenominator", access = JsonProperty.Access.WRITE_ONLY)
     private Float ipsEstimatorDenominator;
 
     /*
      * Denominator for SNIPS estimator.
      */
-    @JsonProperty(value = "snipsEstimatorDenominator", access = JsonProperty.Access.WRITE_ONLY)
     private Float snipsEstimatorDenominator;
 
     /*
@@ -41,33 +44,34 @@ public class PersonalizerPolicyResultSummary {
      * For example, PT5M (5 mins). For information about the time format,
      * see http://en.wikipedia.org/wiki/ISO_8601#Durations
      */
-    @JsonProperty(value = "aggregateTimeWindow", access = JsonProperty.Access.WRITE_ONLY)
     private Duration aggregateTimeWindow;
 
     /*
      * Probability of non-zero values for the Policy evaluation.
      */
-    @JsonProperty(value = "nonZeroProbability")
     private Float nonZeroProbability;
 
     /*
      * Sum of Squares for the Policy evaluation results.
      */
-    @JsonProperty(value = "sumOfSquares", access = JsonProperty.Access.WRITE_ONLY)
     private Float sumOfSquares;
 
     /*
      * Gaussian confidence interval for the Policy evaluation.
      */
-    @JsonProperty(value = "confidenceInterval", access = JsonProperty.Access.WRITE_ONLY)
     private Float confidenceInterval;
 
     /*
      * Average reward.
      */
-    @JsonProperty(value = "averageReward", access = JsonProperty.Access.WRITE_ONLY)
     private Float averageReward;
 
+    /**
+     * Creates an instance of PersonalizerPolicyResultSummary class.
+     */
+    public PersonalizerPolicyResultSummary() {
+    }
+
     /**
      * Get the timeStamp property: Timestamp of the aggregation.
      *
@@ -77,6 +81,17 @@ public OffsetDateTime getTimeStamp() {
         return this.timeStamp;
     }
 
+    /**
+     * Set the timeStamp property: Timestamp of the aggregation.
+     *
+     * @param timeStamp the timeStamp value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setTimeStamp(OffsetDateTime timeStamp) {
+        this.timeStamp = timeStamp;
+        return this;
+    }
+
     /**
      * Get the ipsEstimatorNumerator property: Numerator for IPS estimator.
      *
@@ -86,6 +101,17 @@ public Float getIpsEstimatorNumerator() {
         return this.ipsEstimatorNumerator;
     }
 
+    /**
+     * Set the ipsEstimatorNumerator property: Numerator for IPS estimator.
+     *
+     * @param ipsEstimatorNumerator the ipsEstimatorNumerator value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setIpsEstimatorNumerator(Float ipsEstimatorNumerator) {
+        this.ipsEstimatorNumerator = ipsEstimatorNumerator;
+        return this;
+    }
+
     /**
      * Get the ipsEstimatorDenominator property: Denominator for IPS estimator.
      *
@@ -95,6 +121,17 @@ public Float getIpsEstimatorDenominator() {
         return this.ipsEstimatorDenominator;
     }
 
+    /**
+     * Set the ipsEstimatorDenominator property: Denominator for IPS estimator.
+     *
+     * @param ipsEstimatorDenominator the ipsEstimatorDenominator value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setIpsEstimatorDenominator(Float ipsEstimatorDenominator) {
+        this.ipsEstimatorDenominator = ipsEstimatorDenominator;
+        return this;
+    }
+
     /**
      * Get the snipsEstimatorDenominator property: Denominator for SNIPS estimator.
      *
@@ -105,8 +142,20 @@ public Float getSnipsEstimatorDenominator() {
     }
 
     /**
-     * Get the aggregateTimeWindow property: Time window for aggregation. For example, PT5M (5 mins). For information
-     * about the time format, see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * Set the snipsEstimatorDenominator property: Denominator for SNIPS estimator.
+     *
+     * @param snipsEstimatorDenominator the snipsEstimatorDenominator value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setSnipsEstimatorDenominator(Float snipsEstimatorDenominator) {
+        this.snipsEstimatorDenominator = snipsEstimatorDenominator;
+        return this;
+    }
+
+    /**
+     * Get the aggregateTimeWindow property: Time window for aggregation.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
      *
      * @return the aggregateTimeWindow value.
      */
@@ -114,6 +163,19 @@ public Duration getAggregateTimeWindow() {
         return this.aggregateTimeWindow;
     }
 
+    /**
+     * Set the aggregateTimeWindow property: Time window for aggregation.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     *
+     * @param aggregateTimeWindow the aggregateTimeWindow value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setAggregateTimeWindow(Duration aggregateTimeWindow) {
+        this.aggregateTimeWindow = aggregateTimeWindow;
+        return this;
+    }
+
     /**
      * Get the nonZeroProbability property: Probability of non-zero values for the Policy evaluation.
      *
@@ -143,6 +205,17 @@ public Float getSumOfSquares() {
         return this.sumOfSquares;
     }
 
+    /**
+     * Set the sumOfSquares property: Sum of Squares for the Policy evaluation results.
+     *
+     * @param sumOfSquares the sumOfSquares value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setSumOfSquares(Float sumOfSquares) {
+        this.sumOfSquares = sumOfSquares;
+        return this;
+    }
+
     /**
      * Get the confidenceInterval property: Gaussian confidence interval for the Policy evaluation.
      *
@@ -152,6 +225,17 @@ public Float getConfidenceInterval() {
         return this.confidenceInterval;
     }
 
+    /**
+     * Set the confidenceInterval property: Gaussian confidence interval for the Policy evaluation.
+     *
+     * @param confidenceInterval the confidenceInterval value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setConfidenceInterval(Float confidenceInterval) {
+        this.confidenceInterval = confidenceInterval;
+        return this;
+    }
+
     /**
      * Get the averageReward property: Average reward.
      *
@@ -160,4 +244,74 @@ public Float getConfidenceInterval() {
     public Float getAverageReward() {
         return this.averageReward;
     }
+
+    /**
+     * Set the averageReward property: Average reward.
+     *
+     * @param averageReward the averageReward value to set.
+     * @return the PersonalizerPolicyResultSummary object itself.
+     */
+    PersonalizerPolicyResultSummary setAverageReward(Float averageReward) {
+        this.averageReward = averageReward;
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeNumberField("nonZeroProbability", this.nonZeroProbability);
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerPolicyResultSummary from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerPolicyResultSummary 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 PersonalizerPolicyResultSummary.
+     */
+    public static PersonalizerPolicyResultSummary fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerPolicyResultSummary deserializedPersonalizerPolicyResultSummary
+                = new PersonalizerPolicyResultSummary();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("timeStamp".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.timeStamp = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("ipsEstimatorNumerator".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.ipsEstimatorNumerator
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("ipsEstimatorDenominator".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.ipsEstimatorDenominator
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("snipsEstimatorDenominator".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.snipsEstimatorDenominator
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("aggregateTimeWindow".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.aggregateTimeWindow
+                        = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
+                } else if ("nonZeroProbability".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.nonZeroProbability
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("sumOfSquares".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.sumOfSquares = reader.getNullable(JsonReader::getFloat);
+                } else if ("confidenceInterval".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.confidenceInterval
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("averageReward".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultSummary.averageReward
+                        = reader.getNullable(JsonReader::getFloat);
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            return deserializedPersonalizerPolicyResultSummary;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultTotalSummary.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultTotalSummary.java
index 1ef1a6ea77769..694d0c15a02a9 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultTotalSummary.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerPolicyResultTotalSummary.java
@@ -1,12 +1,219 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 // Code generated by Microsoft (R) AutoRest Code Generator.
-
 package com.azure.ai.personalizer.administration.models;
 
 import com.azure.core.annotation.Fluent;
+import com.azure.core.util.CoreUtils;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.time.Duration;
+import java.time.OffsetDateTime;
 
-/** The aggregate total of the Offline Evaluation. */
+/**
+ * The aggregate total of the Offline Evaluation.
+ */
 @Fluent
 class PersonalizerPolicyResultTotalSummary extends PersonalizerPolicyResultSummary {
+
+    /*
+     * Average reward.
+     */
+    private Float averageReward;
+
+    /*
+     * Gaussian confidence interval for the Policy evaluation.
+     */
+    private Float confidenceInterval;
+
+    /*
+     * Sum of Squares for the Policy evaluation results.
+     */
+    private Float sumOfSquares;
+
+    /*
+     * Time window for aggregation.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations
+     */
+    private Duration aggregateTimeWindow;
+
+    /*
+     * Denominator for SNIPS estimator.
+     */
+    private Float snipsEstimatorDenominator;
+
+    /*
+     * Denominator for IPS estimator.
+     */
+    private Float ipsEstimatorDenominator;
+
+    /*
+     * Numerator for IPS estimator.
+     */
+    private Float ipsEstimatorNumerator;
+
+    /*
+     * Timestamp of the aggregation.
+     */
+    private OffsetDateTime timeStamp;
+
+    /**
+     * Creates an instance of PersonalizerPolicyResultTotalSummary class.
+     */
+    PersonalizerPolicyResultTotalSummary() {
+    }
+
+    /**
+     * Get the averageReward property: Average reward.
+     *
+     * @return the averageReward value.
+     */
+    @Override
+    public Float getAverageReward() {
+        return this.averageReward;
+    }
+
+    /**
+     * Get the confidenceInterval property: Gaussian confidence interval for the Policy evaluation.
+     *
+     * @return the confidenceInterval value.
+     */
+    @Override
+    public Float getConfidenceInterval() {
+        return this.confidenceInterval;
+    }
+
+    /**
+     * Get the sumOfSquares property: Sum of Squares for the Policy evaluation results.
+     *
+     * @return the sumOfSquares value.
+     */
+    @Override
+    public Float getSumOfSquares() {
+        return this.sumOfSquares;
+    }
+
+    /**
+     * Get the aggregateTimeWindow property: Time window for aggregation.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     *
+     * @return the aggregateTimeWindow value.
+     */
+    @Override
+    public Duration getAggregateTimeWindow() {
+        return this.aggregateTimeWindow;
+    }
+
+    /**
+     * Get the snipsEstimatorDenominator property: Denominator for SNIPS estimator.
+     *
+     * @return the snipsEstimatorDenominator value.
+     */
+    @Override
+    public Float getSnipsEstimatorDenominator() {
+        return this.snipsEstimatorDenominator;
+    }
+
+    /**
+     * Get the ipsEstimatorDenominator property: Denominator for IPS estimator.
+     *
+     * @return the ipsEstimatorDenominator value.
+     */
+    @Override
+    public Float getIpsEstimatorDenominator() {
+        return this.ipsEstimatorDenominator;
+    }
+
+    /**
+     * Get the ipsEstimatorNumerator property: Numerator for IPS estimator.
+     *
+     * @return the ipsEstimatorNumerator value.
+     */
+    @Override
+    public Float getIpsEstimatorNumerator() {
+        return this.ipsEstimatorNumerator;
+    }
+
+    /**
+     * Get the timeStamp property: Timestamp of the aggregation.
+     *
+     * @return the timeStamp value.
+     */
+    @Override
+    public OffsetDateTime getTimeStamp() {
+        return this.timeStamp;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public PersonalizerPolicyResultTotalSummary setNonZeroProbability(Float nonZeroProbability) {
+        super.setNonZeroProbability(nonZeroProbability);
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeNumberField("nonZeroProbability", getNonZeroProbability());
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerPolicyResultTotalSummary from the JsonReader.
+     *
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerPolicyResultTotalSummary 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 PersonalizerPolicyResultTotalSummary.
+     */
+    public static PersonalizerPolicyResultTotalSummary fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerPolicyResultTotalSummary deserializedPersonalizerPolicyResultTotalSummary
+                = new PersonalizerPolicyResultTotalSummary();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+                if ("timeStamp".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.timeStamp = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("ipsEstimatorNumerator".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.ipsEstimatorNumerator
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("ipsEstimatorDenominator".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.ipsEstimatorDenominator
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("snipsEstimatorDenominator".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.snipsEstimatorDenominator
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("aggregateTimeWindow".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.aggregateTimeWindow
+                        = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
+                } else if ("nonZeroProbability".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary
+                        .setNonZeroProbability(reader.getNullable(JsonReader::getFloat));
+                } else if ("sumOfSquares".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.sumOfSquares
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("confidenceInterval".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.confidenceInterval
+                        = reader.getNullable(JsonReader::getFloat);
+                } else if ("averageReward".equals(fieldName)) {
+                    deserializedPersonalizerPolicyResultTotalSummary.averageReward
+                        = reader.getNullable(JsonReader::getFloat);
+                } else {
+                    reader.skipChildren();
+                }
+            }
+            return deserializedPersonalizerPolicyResultTotalSummary;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerServiceProperties.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerServiceProperties.java
index d39478fdda1b7..185589ad0df2a 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerServiceProperties.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/PersonalizerServiceProperties.java
@@ -6,110 +6,108 @@
 
 import com.azure.ai.personalizer.models.LearningMode;
 import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+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 java.io.IOException;
 import java.time.Duration;
 import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
 
-/** The configuration of the service. */
+/**
+ * The configuration of the service.
+ */
 @Fluent
-public final class PersonalizerServiceProperties {
+public final class PersonalizerServiceProperties implements JsonSerializable {
     /*
      * The time span waited until a request is marked with the default reward
      * and should be between 5 seconds and 2 days.
      * For example, PT5M (5 mins). For information about the time format,
      * see http://en.wikipedia.org/wiki/ISO_8601#Durations
      */
-    @JsonProperty(value = "rewardWaitTime", required = true)
     private Duration rewardWaitTime;
 
     /*
-     * The reward given if a reward is not received within the specified wait
-     * time.
+     * The reward given if a reward is not received within the specified wait time.
      */
-    @JsonProperty(value = "defaultReward", required = true)
     private float defaultReward;
 
     /*
-     * The function used to process rewards, if multiple reward scores are
-     * received before rewardWaitTime is over.
+     * The function used to process rewards, if multiple reward scores are received before rewardWaitTime is over.
      */
-    @JsonProperty(value = "rewardAggregation", required = true)
     private String rewardAggregation;
 
     /*
      * The percentage of rank responses that will use exploration.
      */
-    @JsonProperty(value = "explorationPercentage", required = true)
     private float explorationPercentage;
 
     /*
-     * Personalizer will start using the most updated trained model for online
-     * ranks automatically every specified time period.
+     * Personalizer will start using the most updated trained model for online ranks automatically every specified time
+     * period.
      * For example, PT5M (5 mins). For information about the time format,
      * see http://en.wikipedia.org/wiki/ISO_8601#Durations
      */
-    @JsonProperty(value = "modelExportFrequency", required = true)
     private Duration modelExportFrequency;
 
     /*
      * Flag indicates whether log mirroring is enabled.
      */
-    @JsonProperty(value = "logMirrorEnabled")
     private Boolean logMirrorEnabled;
 
     /*
      * Azure storage account container SAS URI for log mirroring.
      */
-    @JsonProperty(value = "logMirrorSasUri")
     private String logMirrorSasUrl;
 
     /*
-     * Number of days historical logs are to be maintained. -1 implies the logs
-     * will never be deleted.
+     * Number of days historical logs are to be maintained. -1 implies the logs will never be deleted.
      */
-    @JsonProperty(value = "logRetentionDays", required = true)
     private int logRetentionDays;
 
     /*
      * Last time model training configuration was updated
      */
-    @JsonProperty(value = "lastConfigurationEditDate")
     private OffsetDateTime lastConfigurationEditDate;
 
     /*
      * Learning Modes for Personalizer
      */
-    @JsonProperty(value = "learningMode")
     private LearningMode learningMode;
 
     /*
-     * Flag indicating whether Personalizer will automatically optimize
-     * Learning Settings by running Offline Evaluations periodically.
+     * Flag indicating whether Personalizer will automatically optimize Learning Settings by running Offline Evaluations
+     * periodically.
      */
-    @JsonProperty(value = "isAutoOptimizationEnabled")
     private Boolean isAutoOptimizationEnabled;
 
     /*
-     * Frequency of automatic optimization. Only relevant if
-     * IsAutoOptimizationEnabled is true.
+     * Frequency of automatic optimization. Only relevant if IsAutoOptimizationEnabled is true.
      * For example, PT5M (5 mins). For information about the time format,
      * \r\nsee http://en.wikipedia.org/wiki/ISO_8601#Durations
      */
-    @JsonProperty(value = "autoOptimizationFrequency")
     private Duration autoOptimizationFrequency;
 
     /*
-     * Date when the first automatic optimization evaluation must be performed.
-     * Only relevant if IsAutoOptimizationEnabled is true.
+     * Date when the first automatic optimization evaluation must be performed. Only relevant if
+     * IsAutoOptimizationEnabled is true.
      */
-    @JsonProperty(value = "autoOptimizationStartDate")
     private OffsetDateTime autoOptimizationStartDate;
 
     /**
-     * Get the rewardWaitTime property: The time span waited until a request is marked with the default reward and
-     * should be between 5 seconds and 2 days. For example, PT5M (5 mins). For information about the time format, see
-     * http://en.wikipedia.org/wiki/ISO_8601#Durations.
-     *
+     * Creates an instance of PersonalizerServiceProperties class.
+     */
+    public PersonalizerServiceProperties() {
+    }
+
+    /**
+     * Get the rewardWaitTime property: The time span waited until a request is marked with the default reward
+     * and should be between 5 seconds and 2 days.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * 
      * @return the rewardWaitTime value.
      */
     public Duration getRewardWaitTime() {
@@ -117,10 +115,11 @@ public Duration getRewardWaitTime() {
     }
 
     /**
-     * Set the rewardWaitTime property: The time span waited until a request is marked with the default reward and
-     * should be between 5 seconds and 2 days. For example, PT5M (5 mins). For information about the time format, see
-     * http://en.wikipedia.org/wiki/ISO_8601#Durations.
-     *
+     * Set the rewardWaitTime property: The time span waited until a request is marked with the default reward
+     * and should be between 5 seconds and 2 days.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * 
      * @param rewardWaitTime the rewardWaitTime value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -131,7 +130,7 @@ public PersonalizerServiceProperties setRewardWaitTime(Duration rewardWaitTime)
 
     /**
      * Get the defaultReward property: The reward given if a reward is not received within the specified wait time.
-     *
+     * 
      * @return the defaultReward value.
      */
     public float getDefaultReward() {
@@ -140,7 +139,7 @@ public float getDefaultReward() {
 
     /**
      * Set the defaultReward property: The reward given if a reward is not received within the specified wait time.
-     *
+     * 
      * @param defaultReward the defaultReward value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -152,7 +151,7 @@ public PersonalizerServiceProperties setDefaultReward(float defaultReward) {
     /**
      * Get the rewardAggregation property: The function used to process rewards, if multiple reward scores are received
      * before rewardWaitTime is over.
-     *
+     * 
      * @return the rewardAggregation value.
      */
     public String getRewardAggregation() {
@@ -162,7 +161,7 @@ public String getRewardAggregation() {
     /**
      * Set the rewardAggregation property: The function used to process rewards, if multiple reward scores are received
      * before rewardWaitTime is over.
-     *
+     * 
      * @param rewardAggregation the rewardAggregation value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -173,7 +172,7 @@ public PersonalizerServiceProperties setRewardAggregation(String rewardAggregati
 
     /**
      * Get the explorationPercentage property: The percentage of rank responses that will use exploration.
-     *
+     * 
      * @return the explorationPercentage value.
      */
     public float getExplorationPercentage() {
@@ -182,7 +181,7 @@ public float getExplorationPercentage() {
 
     /**
      * Set the explorationPercentage property: The percentage of rank responses that will use exploration.
-     *
+     * 
      * @param explorationPercentage the explorationPercentage value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -193,9 +192,10 @@ public PersonalizerServiceProperties setExplorationPercentage(float explorationP
 
     /**
      * Get the modelExportFrequency property: Personalizer will start using the most updated trained model for online
-     * ranks automatically every specified time period. For example, PT5M (5 mins). For information about the time
-     * format, see http://en.wikipedia.org/wiki/ISO_8601#Durations.
-     *
+     * ranks automatically every specified time period.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * 
      * @return the modelExportFrequency value.
      */
     public Duration getModelExportFrequency() {
@@ -204,9 +204,10 @@ public Duration getModelExportFrequency() {
 
     /**
      * Set the modelExportFrequency property: Personalizer will start using the most updated trained model for online
-     * ranks automatically every specified time period. For example, PT5M (5 mins). For information about the time
-     * format, see http://en.wikipedia.org/wiki/ISO_8601#Durations.
-     *
+     * ranks automatically every specified time period.
+     * For example, PT5M (5 mins). For information about the time format,
+     * see http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * 
      * @param modelExportFrequency the modelExportFrequency value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -217,7 +218,7 @@ public PersonalizerServiceProperties setModelExportFrequency(Duration modelExpor
 
     /**
      * Get the logMirrorEnabled property: Flag indicates whether log mirroring is enabled.
-     *
+     * 
      * @return the logMirrorEnabled value.
      */
     public Boolean isLogMirrorEnabled() {
@@ -226,7 +227,7 @@ public Boolean isLogMirrorEnabled() {
 
     /**
      * Set the logMirrorEnabled property: Flag indicates whether log mirroring is enabled.
-     *
+     * 
      * @param logMirrorEnabled the logMirrorEnabled value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -237,7 +238,7 @@ public PersonalizerServiceProperties setLogMirrorEnabled(Boolean logMirrorEnable
 
     /**
      * Get the logMirrorSasUrl property: Azure storage account container SAS URI for log mirroring.
-     *
+     * 
      * @return the logMirrorSasUrl value.
      */
     public String getLogMirrorSasUrl() {
@@ -245,8 +246,8 @@ public String getLogMirrorSasUrl() {
     }
 
     /**
-     * Get the logMirrorSasUrl property: Azure storage account container SAS URI for log mirroring.
-     *
+     * Set the logMirrorSasUrl property: Azure storage account container SAS URI for log mirroring.
+     * 
      * @param logMirrorSasUrl the logMirrorSasUrl value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -258,7 +259,7 @@ public PersonalizerServiceProperties setLogMirrorSasUrl(String logMirrorSasUrl)
     /**
      * Get the logRetentionDays property: Number of days historical logs are to be maintained. -1 implies the logs will
      * never be deleted.
-     *
+     * 
      * @return the logRetentionDays value.
      */
     public int getLogRetentionDays() {
@@ -268,7 +269,7 @@ public int getLogRetentionDays() {
     /**
      * Set the logRetentionDays property: Number of days historical logs are to be maintained. -1 implies the logs will
      * never be deleted.
-     *
+     * 
      * @param logRetentionDays the logRetentionDays value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -279,7 +280,7 @@ public PersonalizerServiceProperties setLogRetentionDays(int logRetentionDays) {
 
     /**
      * Get the lastConfigurationEditDate property: Last time model training configuration was updated.
-     *
+     * 
      * @return the lastConfigurationEditDate value.
      */
     public OffsetDateTime getLastConfigurationEditDate() {
@@ -288,7 +289,7 @@ public OffsetDateTime getLastConfigurationEditDate() {
 
     /**
      * Set the lastConfigurationEditDate property: Last time model training configuration was updated.
-     *
+     * 
      * @param lastConfigurationEditDate the lastConfigurationEditDate value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -299,7 +300,7 @@ public PersonalizerServiceProperties setLastConfigurationEditDate(OffsetDateTime
 
     /**
      * Get the learningMode property: Learning Modes for Personalizer.
-     *
+     * 
      * @return the learningMode value.
      */
     public LearningMode getLearningMode() {
@@ -308,7 +309,7 @@ public LearningMode getLearningMode() {
 
     /**
      * Set the learningMode property: Learning Modes for Personalizer.
-     *
+     * 
      * @param learningMode the learningMode value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -320,7 +321,7 @@ public PersonalizerServiceProperties setLearningMode(LearningMode learningMode)
     /**
      * Get the isAutoOptimizationEnabled property: Flag indicating whether Personalizer will automatically optimize
      * Learning Settings by running Offline Evaluations periodically.
-     *
+     * 
      * @return the isAutoOptimizationEnabled value.
      */
     public Boolean isAutoOptimizationEnabled() {
@@ -330,7 +331,7 @@ public Boolean isAutoOptimizationEnabled() {
     /**
      * Set the isAutoOptimizationEnabled property: Flag indicating whether Personalizer will automatically optimize
      * Learning Settings by running Offline Evaluations periodically.
-     *
+     * 
      * @param isAutoOptimizationEnabled the isAutoOptimizationEnabled value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -341,9 +342,10 @@ public PersonalizerServiceProperties setIsAutoOptimizationEnabled(Boolean isAuto
 
     /**
      * Get the autoOptimizationFrequency property: Frequency of automatic optimization. Only relevant if
-     * IsAutoOptimizationEnabled is true. For example, PT5M (5 mins). For information about the time format, \r\nsee
-     * http://en.wikipedia.org/wiki/ISO_8601#Durations.
-     *
+     * IsAutoOptimizationEnabled is true.
+     * For example, PT5M (5 mins). For information about the time format,
+     * \r\nsee http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * 
      * @return the autoOptimizationFrequency value.
      */
     public Duration getAutoOptimizationFrequency() {
@@ -352,9 +354,10 @@ public Duration getAutoOptimizationFrequency() {
 
     /**
      * Set the autoOptimizationFrequency property: Frequency of automatic optimization. Only relevant if
-     * IsAutoOptimizationEnabled is true. For example, PT5M (5 mins). For information about the time format, \r\nsee
-     * http://en.wikipedia.org/wiki/ISO_8601#Durations.
-     *
+     * IsAutoOptimizationEnabled is true.
+     * For example, PT5M (5 mins). For information about the time format,
+     * \r\nsee http://en.wikipedia.org/wiki/ISO_8601#Durations.
+     * 
      * @param autoOptimizationFrequency the autoOptimizationFrequency value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -366,7 +369,7 @@ public PersonalizerServiceProperties setAutoOptimizationFrequency(Duration autoO
     /**
      * Get the autoOptimizationStartDate property: Date when the first automatic optimization evaluation must be
      * performed. Only relevant if IsAutoOptimizationEnabled is true.
-     *
+     * 
      * @return the autoOptimizationStartDate value.
      */
     public OffsetDateTime getAutoOptimizationStartDate() {
@@ -376,7 +379,7 @@ public OffsetDateTime getAutoOptimizationStartDate() {
     /**
      * Set the autoOptimizationStartDate property: Date when the first automatic optimization evaluation must be
      * performed. Only relevant if IsAutoOptimizationEnabled is true.
-     *
+     * 
      * @param autoOptimizationStartDate the autoOptimizationStartDate value to set.
      * @return the PersonalizerServiceProperties object itself.
      */
@@ -384,4 +387,94 @@ public PersonalizerServiceProperties setAutoOptimizationStartDate(OffsetDateTime
         this.autoOptimizationStartDate = autoOptimizationStartDate;
         return this;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.writeStartObject();
+        jsonWriter.writeStringField("rewardWaitTime", CoreUtils.durationToStringWithDays(this.rewardWaitTime));
+        jsonWriter.writeFloatField("defaultReward", this.defaultReward);
+        jsonWriter.writeStringField("rewardAggregation", this.rewardAggregation);
+        jsonWriter.writeFloatField("explorationPercentage", this.explorationPercentage);
+        jsonWriter.writeStringField("modelExportFrequency",
+            CoreUtils.durationToStringWithDays(this.modelExportFrequency));
+        jsonWriter.writeIntField("logRetentionDays", this.logRetentionDays);
+        jsonWriter.writeBooleanField("logMirrorEnabled", this.logMirrorEnabled);
+        jsonWriter.writeStringField("logMirrorSasUri", this.logMirrorSasUrl);
+        jsonWriter.writeStringField("lastConfigurationEditDate",
+            this.lastConfigurationEditDate == null
+                ? null
+                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastConfigurationEditDate));
+        jsonWriter.writeStringField("learningMode", this.learningMode == null ? null : this.learningMode.toString());
+        jsonWriter.writeBooleanField("isAutoOptimizationEnabled", this.isAutoOptimizationEnabled);
+        jsonWriter.writeStringField("autoOptimizationFrequency",
+            CoreUtils.durationToStringWithDays(this.autoOptimizationFrequency));
+        jsonWriter.writeStringField("autoOptimizationStartDate",
+            this.autoOptimizationStartDate == null
+                ? null
+                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.autoOptimizationStartDate));
+        return jsonWriter.writeEndObject();
+    }
+
+    /**
+     * Reads an instance of PersonalizerServiceProperties from the JsonReader.
+     * 
+     * @param jsonReader The JsonReader being read.
+     * @return An instance of PersonalizerServiceProperties 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 PersonalizerServiceProperties.
+     */
+    public static PersonalizerServiceProperties fromJson(JsonReader jsonReader) throws IOException {
+        return jsonReader.readObject(reader -> {
+            PersonalizerServiceProperties deserializedPersonalizerServiceProperties
+                = new PersonalizerServiceProperties();
+            while (reader.nextToken() != JsonToken.END_OBJECT) {
+                String fieldName = reader.getFieldName();
+                reader.nextToken();
+
+                if ("rewardWaitTime".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.rewardWaitTime
+                        = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
+                } else if ("defaultReward".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.defaultReward = reader.getFloat();
+                } else if ("rewardAggregation".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.rewardAggregation = reader.getString();
+                } else if ("explorationPercentage".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.explorationPercentage = reader.getFloat();
+                } else if ("modelExportFrequency".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.modelExportFrequency
+                        = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
+                } else if ("logRetentionDays".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.logRetentionDays = reader.getInt();
+                } else if ("logMirrorEnabled".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.logMirrorEnabled
+                        = reader.getNullable(JsonReader::getBoolean);
+                } else if ("logMirrorSasUri".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.logMirrorSasUrl = reader.getString();
+                } else if ("lastConfigurationEditDate".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.lastConfigurationEditDate = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else if ("learningMode".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.learningMode
+                        = LearningMode.fromString(reader.getString());
+                } else if ("isAutoOptimizationEnabled".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.isAutoOptimizationEnabled
+                        = reader.getNullable(JsonReader::getBoolean);
+                } else if ("autoOptimizationFrequency".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.autoOptimizationFrequency
+                        = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
+                } else if ("autoOptimizationStartDate".equals(fieldName)) {
+                    deserializedPersonalizerServiceProperties.autoOptimizationStartDate = reader
+                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+                } else {
+                    reader.skipChildren();
+                }
+            }
+
+            return deserializedPersonalizerServiceProperties;
+        });
+    }
 }
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/package-info.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/package-info.java
index 1065246f12c76..ff88f372463e7 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/package-info.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/administration/models/package-info.java
@@ -3,10 +3,11 @@
 // Code generated by Microsoft (R) AutoRest Code Generator.
 
 /**
- * Package containing classes for PersonalizerClientV1Preview3. Personalizer Service is an Azure Cognitive Service that
- * makes it easy to target content and experiences without complex pre-analysis or cleanup of past data. Given a context
- * and featurized content, the Personalizer Service returns which content item to show to users in rewardActionId. As
- * rewards are sent in response to the use of rewardActionId, the reinforcement learning algorithm will improve the
- * model and improve performance of future rank calls.
+ * Package containing the data models for PersonalizerClientV1Preview3.
+ * Personalizer Service is an Azure Cognitive Service that makes it easy to target content and experiences without
+ * complex pre-analysis or cleanup of past data. Given a context and featurized content, the Personalizer Service
+ * returns which content item to show to users in rewardActionId. As rewards are sent in response to the use of
+ * rewardActionId, the reinforcement learning algorithm will improve the model and improve performance of future rank
+ * calls.
  */
 package com.azure.ai.personalizer.administration.models;
diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EvaluationsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EvaluationsImpl.java
index d3b359fa2307f..303c8aee573d1 100644
--- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EvaluationsImpl.java
+++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EvaluationsImpl.java
@@ -30,22 +30,28 @@
 import java.util.List;
 import reactor.core.publisher.Mono;
 
-/** An instance of this class provides access to all the operations defined in Evaluations. */
+/**
+ * An instance of this class provides access to all the operations defined in Evaluations.
+ */
 public final class EvaluationsImpl {
-    /** The proxy service used to perform REST calls. */
+    /**
+     * The proxy service used to perform REST calls.
+     */
     private final EvaluationsService service;
 
-    /** The service client containing this operation class. */
+    /**
+     * The service client containing this operation class.
+     */
     private final PersonalizerClientV1Preview3Impl client;
 
     /**
      * Initializes an instance of EvaluationsImpl.
-     *
+     * 
      * @param client the instance of the service client containing this operation class.
      */
     EvaluationsImpl(PersonalizerClientV1Preview3Impl client) {
-        this.service =
-                RestProxy.create(EvaluationsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
+        this.service
+            = RestProxy.create(EvaluationsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
         this.client = client;
     }
 
@@ -57,77 +63,70 @@ public final class EvaluationsImpl {
     @ServiceInterface(name = "PersonalizerClientV1")
     public interface EvaluationsService {
         @Get("/evaluations/{evaluationId}")
-        @ExpectedResponses({200})
+        @ExpectedResponses({ 200 })
         @UnexpectedResponseExceptionType(ErrorResponseException.class)
-        Mono> get(
-                @HostParam("Endpoint") String endpoint,
-                @HostParam("ApiVersion") String apiVersion,
-                @PathParam("evaluationId") String evaluationId,
-                @HeaderParam("Accept") String accept,
-                Context context);
+        Mono> get(@HostParam("Endpoint") String endpoint,
+            @HostParam("ApiVersion") String apiVersion, @PathParam("evaluationId") String evaluationId,
+            @HeaderParam("Accept") String accept, Context context);
 
         @Delete("/evaluations/{evaluationId}")
-        @ExpectedResponses({204})
+        @ExpectedResponses({ 204 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> delete(
-                @HostParam("Endpoint") String endpoint,
-                @HostParam("ApiVersion") String apiVersion,
-                @PathParam("evaluationId") String evaluationId,
-                Context context);
+        Mono> delete(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion,
+            @PathParam("evaluationId") String evaluationId, Context context);
 
         @Get("/evaluations")
-        @ExpectedResponses({200})
+        @ExpectedResponses({ 200 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono>> list(
-                @HostParam("Endpoint") String endpoint,
-                @HostParam("ApiVersion") String apiVersion,
-                @HeaderParam("Accept") String accept,
-                Context context);
+        Mono>> list(@HostParam("Endpoint") String endpoint,
+            @HostParam("ApiVersion") String apiVersion, @HeaderParam("Accept") String accept, Context context);
 
         @Post("/evaluations")
-        @ExpectedResponses({201})
+        @ExpectedResponses({ 201 })
         @UnexpectedResponseExceptionType(ErrorResponseException.class)
         Mono> create(
-                @HostParam("Endpoint") String endpoint,
-                @HostParam("ApiVersion") String apiVersion,
-                @BodyParam("application/json") PersonalizerEvaluationOptions evaluation,
-                @HeaderParam("Accept") String accept,
-                Context context);
+            @HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion,
+            @BodyParam("application/json") PersonalizerEvaluationOptions evaluation,
+            @HeaderParam("Accept") String accept, Context context);
+
+        @Post("/evaluations")
+        @ExpectedResponses({ 201 })
+        @UnexpectedResponseExceptionType(ErrorResponseException.class)
+        Mono> createNoCustomHeaders(@HostParam("Endpoint") String endpoint,
+            @HostParam("ApiVersion") String apiVersion,
+            @BodyParam("application/json") PersonalizerEvaluationOptions evaluation,
+            @HeaderParam("Accept") String accept, Context context);
     }
 
     /**
      * Get Evaluation.
-     *
-     * 

Get the Offline Evaluation associated with the Id. - * + * + * Get the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the Offline Evaluation associated with the Id along with {@link Response} on successful completion of - * {@link Mono}. + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(String evaluationId) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.get( - this.client.getEndpoint(), this.client.getApiVersion(), evaluationId, accept, context)); + return FluxUtil.withContext(context -> getWithResponseAsync(evaluationId, context)); } /** * Get Evaluation. - * - *

Get the Offline Evaluation associated with the Id. - * + * + * Get the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the Offline Evaluation associated with the Id along with {@link Response} on successful completion of - * {@link Mono}. + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(String evaluationId, Context context) { @@ -137,9 +136,9 @@ public Mono> getWithResponseAsync(String evalua /** * Get Evaluation. - * - *

Get the Offline Evaluation associated with the Id. - * + * + * Get the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -153,9 +152,9 @@ public Mono getAsync(String evaluationId) { /** * Get Evaluation. - * - *

Get the Offline Evaluation associated with the Id. - * + * + * Get the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -170,42 +169,42 @@ public Mono getAsync(String evaluationId, Context contex /** * Get Evaluation. - * - *

Get the Offline Evaluation associated with the Id. - * + * + * Get the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Offline Evaluation associated with the Id. + * @return the Offline Evaluation associated with the Id along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerEvaluation get(String evaluationId) { - return getAsync(evaluationId).block(); + public Response getWithResponse(String evaluationId, Context context) { + return getWithResponseAsync(evaluationId, context).block(); } /** * Get Evaluation. - * - *

Get the Offline Evaluation associated with the Id. - * + * + * Get the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Offline Evaluation associated with the Id along with {@link Response}. + * @return the Offline Evaluation associated with the Id. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String evaluationId, Context context) { - return getWithResponseAsync(evaluationId, context).block(); + public PersonalizerEvaluation get(String evaluationId) { + return getWithResponse(evaluationId, Context.NONE).getValue(); } /** * Delete Evaluation. - * - *

Delete the Offline Evaluation associated with the Id. - * + * + * Delete the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation to delete. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -214,16 +213,14 @@ public Response getWithResponse(String evaluationId, Con */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteWithResponseAsync(String evaluationId) { - return FluxUtil.withContext( - context -> - service.delete(this.client.getEndpoint(), this.client.getApiVersion(), evaluationId, context)); + return FluxUtil.withContext(context -> deleteWithResponseAsync(evaluationId, context)); } /** * Delete Evaluation. - * - *

Delete the Offline Evaluation associated with the Id. - * + * + * Delete the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation to delete. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -238,9 +235,9 @@ public Mono> deleteWithResponseAsync(String evaluationId, Context /** * Delete Evaluation. - * - *

Delete the Offline Evaluation associated with the Id. - * + * + * Delete the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation to delete. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -254,9 +251,9 @@ public Mono deleteAsync(String evaluationId) { /** * Delete Evaluation. - * - *

Delete the Offline Evaluation associated with the Id. - * + * + * Delete the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation to delete. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -271,57 +268,55 @@ public Mono deleteAsync(String evaluationId, Context context) { /** * Delete Evaluation. - * - *

Delete the Offline Evaluation associated with the Id. - * + * + * Delete the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation to delete. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void delete(String evaluationId) { - deleteAsync(evaluationId).block(); + public Response deleteWithResponse(String evaluationId, Context context) { + return deleteWithResponseAsync(evaluationId, context).block(); } /** * Delete Evaluation. - * - *

Delete the Offline Evaluation associated with the Id. - * + * + * Delete the Offline Evaluation associated with the Id. + * * @param evaluationId Id of the Offline Evaluation to delete. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteWithResponse(String evaluationId, Context context) { - return deleteWithResponseAsync(evaluationId, context).block(); + public void delete(String evaluationId) { + deleteWithResponse(evaluationId, Context.NONE); } /** * List Offline Evaluations. - * - *

List of all Offline Evaluations. - * + * + * List of all Offline Evaluations. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return array of PersonalizerEvaluation along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono>> listWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> listWithResponseAsync(context)); } /** * List Offline Evaluations. - * - *

List of all Offline Evaluations. - * + * + * List of all Offline Evaluations. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -336,9 +331,9 @@ public Mono>> listWithResponseAsync(Contex /** * List Offline Evaluations. - * - *

List of all Offline Evaluations. - * + * + * List of all Offline Evaluations. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return array of PersonalizerEvaluation on successful completion of {@link Mono}. @@ -350,9 +345,9 @@ public Mono> listAsync() { /** * List Offline Evaluations. - * - *

List of all Offline Evaluations. - * + * + * List of all Offline Evaluations. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -366,39 +361,39 @@ public Mono> listAsync(Context context) { /** * List Offline Evaluations. - * - *

List of all Offline Evaluations. - * + * + * List of all Offline Evaluations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return array of PersonalizerEvaluation. + * @return array of PersonalizerEvaluation along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public List list() { - return listAsync().block(); + public Response> listWithResponse(Context context) { + return listWithResponseAsync(context).block(); } /** * List Offline Evaluations. - * - *

List of all Offline Evaluations. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * List of all Offline Evaluations. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return array of PersonalizerEvaluation along with {@link Response}. + * @return array of PersonalizerEvaluation. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response> listWithResponse(Context context) { - return listWithResponseAsync(context).block(); + public List list() { + return listWithResponse(Context.NONE).getValue(); } /** * Create Offline Evaluation. - * - *

Submit a new Offline Evaluation job. - * + * + * Submit a new Offline Evaluation job. + * * @param evaluation The Offline Evaluation job definition. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -406,20 +401,16 @@ public Response> listWithResponse(Context context) * @return a counterfactual evaluation along with {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync( - PersonalizerEvaluationOptions evaluation) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.create( - this.client.getEndpoint(), this.client.getApiVersion(), evaluation, accept, context)); + public Mono> + createWithResponseAsync(PersonalizerEvaluationOptions evaluation) { + return FluxUtil.withContext(context -> createWithResponseAsync(evaluation, context)); } /** * Create Offline Evaluation. - * - *

Submit a new Offline Evaluation job. - * + * + * Submit a new Offline Evaluation job. + * * @param evaluation The Offline Evaluation job definition. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -428,17 +419,17 @@ public Mono> crea * @return a counterfactual evaluation along with {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync( - PersonalizerEvaluationOptions evaluation, Context context) { + public Mono> + createWithResponseAsync(PersonalizerEvaluationOptions evaluation, Context context) { final String accept = "application/json"; return service.create(this.client.getEndpoint(), this.client.getApiVersion(), evaluation, accept, context); } /** * Create Offline Evaluation. - * - *

Submit a new Offline Evaluation job. - * + * + * Submit a new Offline Evaluation job. + * * @param evaluation The Offline Evaluation job definition. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -452,9 +443,9 @@ public Mono createAsync(PersonalizerEvaluationOptions ev /** * Create Offline Evaluation. - * - *

Submit a new Offline Evaluation job. - * + * + * Submit a new Offline Evaluation job. + * * @param evaluation The Offline Evaluation job definition. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -469,9 +460,27 @@ public Mono createAsync(PersonalizerEvaluationOptions ev /** * Create Offline Evaluation. - * - *

Submit a new Offline Evaluation job. - * + * + * Submit a new Offline Evaluation job. + * + * @param evaluation The Offline Evaluation job definition. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a counterfactual evaluation along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase + createWithResponse(PersonalizerEvaluationOptions evaluation, Context context) { + return createWithResponseAsync(evaluation, context).block(); + } + + /** + * Create Offline Evaluation. + * + * Submit a new Offline Evaluation job. + * * @param evaluation The Offline Evaluation job definition. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -480,24 +489,61 @@ public Mono createAsync(PersonalizerEvaluationOptions ev */ @ServiceMethod(returns = ReturnType.SINGLE) public PersonalizerEvaluation create(PersonalizerEvaluationOptions evaluation) { - return createAsync(evaluation).block(); + return createWithResponse(evaluation, Context.NONE).getValue(); } /** * Create Offline Evaluation. - * - *

Submit a new Offline Evaluation job. - * + * + * Submit a new Offline Evaluation job. + * + * @param evaluation The Offline Evaluation job definition. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a counterfactual evaluation along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> + createNoCustomHeadersWithResponseAsync(PersonalizerEvaluationOptions evaluation) { + return FluxUtil.withContext(context -> createNoCustomHeadersWithResponseAsync(evaluation, context)); + } + + /** + * Create Offline Evaluation. + * + * Submit a new Offline Evaluation job. + * * @param evaluation The Offline Evaluation job definition. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a counterfactual evaluation along with {@link ResponseBase}. + * @return a counterfactual evaluation along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase createWithResponse( - PersonalizerEvaluationOptions evaluation, Context context) { - return createWithResponseAsync(evaluation, context).block(); + public Mono> + createNoCustomHeadersWithResponseAsync(PersonalizerEvaluationOptions evaluation, Context context) { + final String accept = "application/json"; + return service.createNoCustomHeaders(this.client.getEndpoint(), this.client.getApiVersion(), evaluation, accept, + context); + } + + /** + * Create Offline Evaluation. + * + * Submit a new Offline Evaluation job. + * + * @param evaluation The Offline Evaluation job definition. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a counterfactual evaluation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createNoCustomHeadersWithResponse(PersonalizerEvaluationOptions evaluation, + Context context) { + return createNoCustomHeadersWithResponseAsync(evaluation, context).block(); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EventsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EventsImpl.java index c21afc00d958e..5b8ea374b1dc3 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EventsImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/EventsImpl.java @@ -23,17 +23,23 @@ import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in Events. */ +/** + * An instance of this class provides access to all the operations defined in Events. + */ public final class EventsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final EventsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of EventsImpl. - * + * * @param client the instance of the service client containing this operation class. */ EventsImpl(PersonalizerClientV1Preview3Impl client) { @@ -49,33 +55,26 @@ public final class EventsImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface EventsService { @Post("/events/{eventId}/reward") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> reward( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @PathParam("eventId") String eventId, - @BodyParam("application/json") PersonalizerRewardOptions reward, - @HeaderParam("Accept") String accept, - Context context); + Mono> reward(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, + @PathParam("eventId") String eventId, @BodyParam("application/json") PersonalizerRewardOptions reward, + @HeaderParam("Accept") String accept, Context context); @Post("/events/{eventId}/activate") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> activate( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @PathParam("eventId") String eventId, - @HeaderParam("Accept") String accept, - Context context); + Mono> activate(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @PathParam("eventId") String eventId, + @HeaderParam("Accept") String accept, Context context); } /** * Post Reward. - * - *

Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the - * specified event. - * + * + * Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the specified + * event. + * * @param eventId The event id this reward applies to. * @param reward The reward should be a floating point number, typically between 0 and 1. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -85,24 +84,15 @@ Mono> activate( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rewardWithResponseAsync(String eventId, PersonalizerRewardOptions reward) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.reward( - this.client.getEndpoint(), - this.client.getApiVersion(), - eventId, - reward, - accept, - context)); + return FluxUtil.withContext(context -> rewardWithResponseAsync(eventId, reward, context)); } /** * Post Reward. - * - *

Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the - * specified event. - * + * + * Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the specified + * event. + * * @param eventId The event id this reward applies to. * @param reward The reward should be a floating point number, typically between 0 and 1. * @param context The context to associate with this operation. @@ -112,18 +102,18 @@ public Mono> rewardWithResponseAsync(String eventId, Personalizer * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rewardWithResponseAsync( - String eventId, PersonalizerRewardOptions reward, Context context) { + public Mono> rewardWithResponseAsync(String eventId, PersonalizerRewardOptions reward, + Context context) { final String accept = "application/json"; return service.reward(this.client.getEndpoint(), this.client.getApiVersion(), eventId, reward, accept, context); } /** * Post Reward. - * - *

Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the - * specified event. - * + * + * Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the specified + * event. + * * @param eventId The event id this reward applies to. * @param reward The reward should be a floating point number, typically between 0 and 1. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -138,10 +128,10 @@ public Mono rewardAsync(String eventId, PersonalizerRewardOptions reward) /** * Post Reward. - * - *

Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the - * specified event. - * + * + * Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the specified + * event. + * * @param eventId The event id this reward applies to. * @param reward The reward should be a floating point number, typically between 0 and 1. * @param context The context to associate with this operation. @@ -157,46 +147,46 @@ public Mono rewardAsync(String eventId, PersonalizerRewardOptions reward, /** * Post Reward. - * - *

Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the - * specified event. - * + * + * Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the specified + * event. + * * @param eventId The event id this reward applies to. * @param reward The reward should be a floating point number, typically between 0 and 1. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void reward(String eventId, PersonalizerRewardOptions reward) { - rewardAsync(eventId, reward).block(); + public Response rewardWithResponse(String eventId, PersonalizerRewardOptions reward, Context context) { + return rewardWithResponseAsync(eventId, reward, context).block(); } /** * Post Reward. - * - *

Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the - * specified event. - * + * + * Report reward between 0 and 1 that resulted from using the action specified in rewardActionId, for the specified + * event. + * * @param eventId The event id this reward applies to. * @param reward The reward should be a floating point number, typically between 0 and 1. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response rewardWithResponse(String eventId, PersonalizerRewardOptions reward, Context context) { - return rewardWithResponseAsync(eventId, reward, context).block(); + public void reward(String eventId, PersonalizerRewardOptions reward) { + rewardWithResponse(eventId, reward, Context.NONE); } /** * Activate Event. - * - *

Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be + * + * Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be * expected for it. - * + * * @param eventId The event ID to be activated. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -205,19 +195,15 @@ public Response rewardWithResponse(String eventId, PersonalizerRewardOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> activateWithResponseAsync(String eventId) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.activate( - this.client.getEndpoint(), this.client.getApiVersion(), eventId, accept, context)); + return FluxUtil.withContext(context -> activateWithResponseAsync(eventId, context)); } /** * Activate Event. - * - *

Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be + * + * Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be * expected for it. - * + * * @param eventId The event ID to be activated. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -233,10 +219,10 @@ public Mono> activateWithResponseAsync(String eventId, Context co /** * Activate Event. - * - *

Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be + * + * Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be * expected for it. - * + * * @param eventId The event ID to be activated. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -250,10 +236,10 @@ public Mono activateAsync(String eventId) { /** * Activate Event. - * - *

Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be + * + * Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be * expected for it. - * + * * @param eventId The event ID to be activated. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -268,35 +254,35 @@ public Mono activateAsync(String eventId, Context context) { /** * Activate Event. - * - *

Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be + * + * Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be * expected for it. - * + * * @param eventId The event ID to be activated. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void activate(String eventId) { - activateAsync(eventId).block(); + public Response activateWithResponse(String eventId, Context context) { + return activateWithResponseAsync(eventId, context).block(); } /** * Activate Event. - * - *

Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be + * + * Report that the specified event was actually used (e.g. by being displayed to the user) and a reward should be * expected for it. - * + * * @param eventId The event ID to be activated. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response activateWithResponse(String eventId, Context context) { - return activateWithResponseAsync(eventId, context).block(); + public void activate(String eventId) { + activateWithResponse(eventId, Context.NONE); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/LogsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/LogsImpl.java index 3b44a315f7ad8..80f2dad12d22a 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/LogsImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/LogsImpl.java @@ -28,17 +28,23 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in Logs. */ +/** + * An instance of this class provides access to all the operations defined in Logs. + */ public final class LogsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final LogsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of LogsImpl. - * + * * @param client the instance of the service client containing this operation class. */ LogsImpl(PersonalizerClientV1Preview3Impl client) { @@ -54,72 +60,53 @@ public final class LogsImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface LogsService { @Post("/logs/interactions") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> interactions( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/octet-stream") Flux body, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Accept") String accept, - Context context); + Mono> interactions(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/octet-stream") Flux body, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @Post("/logs/interactions") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> interactions( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/octet-stream") BinaryData body, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Accept") String accept, - Context context); + Mono> interactions(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/octet-stream") BinaryData body, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @Post("/logs/observations") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> observations( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/octet-stream") Flux body, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Accept") String accept, - Context context); + Mono> observations(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/octet-stream") Flux body, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @Post("/logs/observations") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> observations( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/octet-stream") BinaryData body, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Accept") String accept, - Context context); + Mono> observations(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/octet-stream") BinaryData body, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @Delete("/logs") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> delete( - @HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, Context context); + Mono> delete(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, + Context context); @Get("/logs/properties") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> getProperties( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> getProperties(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @HeaderParam("Accept") String accept, Context context); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -129,25 +116,16 @@ Mono> getProperties( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> interactionsWithResponseAsync(Flux body, long contentLength) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.interactions( - this.client.getEndpoint(), - this.client.getApiVersion(), - body, - contentLength, - accept, - context)); + return FluxUtil.withContext(context -> interactionsWithResponseAsync(body, contentLength, context)); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -157,20 +135,20 @@ public Mono> interactionsWithResponseAsync(Flux body, * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> interactionsWithResponseAsync( - Flux body, long contentLength, Context context) { + public Mono> interactionsWithResponseAsync(Flux body, long contentLength, + Context context) { final String accept = "application/json"; - return service.interactions( - this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, context); + return service.interactions(this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, + context); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -185,11 +163,11 @@ public Mono interactionsAsync(Flux body, long contentLength) { /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -205,49 +183,49 @@ public Mono interactionsAsync(Flux body, long contentLength, C /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void interactions(Flux body, long contentLength) { - interactionsAsync(body, contentLength).block(); + public Response interactionsWithResponse(Flux body, long contentLength, Context context) { + return interactionsWithResponseAsync(body, contentLength, context).block(); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response interactionsWithResponse(Flux body, long contentLength, Context context) { - return interactionsWithResponseAsync(body, contentLength, context).block(); + public void interactions(Flux body, long contentLength) { + interactionsWithResponse(body, contentLength, Context.NONE); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -257,25 +235,16 @@ public Response interactionsWithResponse(Flux body, long conte */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> interactionsWithResponseAsync(BinaryData body, long contentLength) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.interactions( - this.client.getEndpoint(), - this.client.getApiVersion(), - body, - contentLength, - accept, - context)); + return FluxUtil.withContext(context -> interactionsWithResponseAsync(body, contentLength, context)); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -287,17 +256,17 @@ public Mono> interactionsWithResponseAsync(BinaryData body, long @ServiceMethod(returns = ReturnType.SINGLE) public Mono> interactionsWithResponseAsync(BinaryData body, long contentLength, Context context) { final String accept = "application/json"; - return service.interactions( - this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, context); + return service.interactions(this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, + context); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -312,11 +281,11 @@ public Mono interactionsAsync(BinaryData body, long contentLength) { /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -332,49 +301,49 @@ public Mono interactionsAsync(BinaryData body, long contentLength, Context /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void interactions(BinaryData body, long contentLength) { - interactionsAsync(body, contentLength).block(); + public Response interactionsWithResponse(BinaryData body, long contentLength, Context context) { + return interactionsWithResponseAsync(body, contentLength, context).block(); } /** * Post interactions. - * - *

The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging interactions and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Interactions binary payload. * @param contentLength The Content-Length header for the request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response interactionsWithResponse(BinaryData body, long contentLength, Context context) { - return interactionsWithResponseAsync(body, contentLength, context).block(); + public void interactions(BinaryData body, long contentLength) { + interactionsWithResponse(body, contentLength, Context.NONE); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -384,25 +353,16 @@ public Response interactionsWithResponse(BinaryData body, long contentLeng */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> observationsWithResponseAsync(Flux body, long contentLength) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.observations( - this.client.getEndpoint(), - this.client.getApiVersion(), - body, - contentLength, - accept, - context)); + return FluxUtil.withContext(context -> observationsWithResponseAsync(body, contentLength, context)); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -412,20 +372,20 @@ public Mono> observationsWithResponseAsync(Flux body, * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> observationsWithResponseAsync( - Flux body, long contentLength, Context context) { + public Mono> observationsWithResponseAsync(Flux body, long contentLength, + Context context) { final String accept = "application/json"; - return service.observations( - this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, context); + return service.observations(this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, + context); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -440,11 +400,11 @@ public Mono observationsAsync(Flux body, long contentLength) { /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -460,49 +420,49 @@ public Mono observationsAsync(Flux body, long contentLength, C /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void observations(Flux body, long contentLength) { - observationsAsync(body, contentLength).block(); + public Response observationsWithResponse(Flux body, long contentLength, Context context) { + return observationsWithResponseAsync(body, contentLength, context).block(); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response observationsWithResponse(Flux body, long contentLength, Context context) { - return observationsWithResponseAsync(body, contentLength, context).block(); + public void observations(Flux body, long contentLength) { + observationsWithResponse(body, contentLength, Context.NONE); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -512,25 +472,16 @@ public Response observationsWithResponse(Flux body, long conte */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> observationsWithResponseAsync(BinaryData body, long contentLength) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.observations( - this.client.getEndpoint(), - this.client.getApiVersion(), - body, - contentLength, - accept, - context)); + return FluxUtil.withContext(context -> observationsWithResponseAsync(body, contentLength, context)); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -542,17 +493,17 @@ public Mono> observationsWithResponseAsync(BinaryData body, long @ServiceMethod(returns = ReturnType.SINGLE) public Mono> observationsWithResponseAsync(BinaryData body, long contentLength, Context context) { final String accept = "application/json"; - return service.observations( - this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, context); + return service.observations(this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, + context); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -567,11 +518,11 @@ public Mono observationsAsync(BinaryData body, long contentLength) { /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -587,62 +538,61 @@ public Mono observationsAsync(BinaryData body, long contentLength, Context /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void observations(BinaryData body, long contentLength) { - observationsAsync(body, contentLength).block(); + public Response observationsWithResponse(BinaryData body, long contentLength, Context context) { + return observationsWithResponseAsync(body, contentLength, context).block(); } /** * Post observations. - * - *

The endpoint is intended to be used from within a SDK for logging observations and accepts specific format + * + * The endpoint is intended to be used from within a SDK for logging observations and accepts specific format * defined in https://github.com/VowpalWabbit/reinforcement_learning. This endpoint should not be used by the * customer. - * + * * @param body Observations binary payload. * @param contentLength The Content-Length header for the request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response observationsWithResponse(BinaryData body, long contentLength, Context context) { - return observationsWithResponseAsync(body, contentLength, context).block(); + public void observations(BinaryData body, long contentLength) { + observationsWithResponse(body, contentLength, Context.NONE); } /** * Deletes Logs. - * - *

Delete all logs of Rank and Reward calls stored by Personalizer. - * + * + * Delete all logs of Rank and Reward calls stored by Personalizer. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteWithResponseAsync() { - return FluxUtil.withContext( - context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), context)); + return FluxUtil.withContext(context -> deleteWithResponseAsync(context)); } /** * Deletes Logs. - * - *

Delete all logs of Rank and Reward calls stored by Personalizer. - * + * + * Delete all logs of Rank and Reward calls stored by Personalizer. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -656,9 +606,9 @@ public Mono> deleteWithResponseAsync(Context context) { /** * Deletes Logs. - * - *

Delete all logs of Rank and Reward calls stored by Personalizer. - * + * + * Delete all logs of Rank and Reward calls stored by Personalizer. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return A {@link Mono} that completes when a successful response is received. @@ -670,9 +620,9 @@ public Mono deleteAsync() { /** * Deletes Logs. - * - *

Delete all logs of Rank and Reward calls stored by Personalizer. - * + * + * Delete all logs of Rank and Reward calls stored by Personalizer. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -686,55 +636,52 @@ public Mono deleteAsync(Context context) { /** * Deletes Logs. - * - *

Delete all logs of Rank and Reward calls stored by Personalizer. - * + * + * Delete all logs of Rank and Reward calls stored by Personalizer. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void delete() { - deleteAsync().block(); + public Response deleteWithResponse(Context context) { + return deleteWithResponseAsync(context).block(); } /** * Deletes Logs. - * - *

Delete all logs of Rank and Reward calls stored by Personalizer. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Delete all logs of Rank and Reward calls stored by Personalizer. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteWithResponse(Context context) { - return deleteWithResponseAsync(context).block(); + public void delete() { + deleteWithResponse(Context.NONE); } /** * Get Log Properties. - * - *

Get properties of the Personalizer logs. - * + * + * Get properties of the Personalizer logs. + * * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return properties of the Personalizer logs along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getPropertiesWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.getProperties(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> getPropertiesWithResponseAsync(context)); } /** * Get Log Properties. - * - *

Get properties of the Personalizer logs. - * + * + * Get properties of the Personalizer logs. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -749,9 +696,9 @@ public Mono> getPropertiesWithResponseAsync( /** * Get Log Properties. - * - *

Get properties of the Personalizer logs. - * + * + * Get properties of the Personalizer logs. + * * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return properties of the Personalizer logs on successful completion of {@link Mono}. @@ -763,9 +710,9 @@ public Mono getPropertiesAsync() { /** * Get Log Properties. - * - *

Get properties of the Personalizer logs. - * + * + * Get properties of the Personalizer logs. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -779,31 +726,31 @@ public Mono getPropertiesAsync(Context context) { /** * Get Log Properties. - * - *

Get properties of the Personalizer logs. - * + * + * Get properties of the Personalizer logs. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return properties of the Personalizer logs. + * @return properties of the Personalizer logs along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerLogProperties getProperties() { - return getPropertiesAsync().block(); + public Response getPropertiesWithResponse(Context context) { + return getPropertiesWithResponseAsync(context).block(); } /** * Get Log Properties. - * - *

Get properties of the Personalizer logs. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Get properties of the Personalizer logs. + * * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return properties of the Personalizer logs along with {@link Response}. + * @return properties of the Personalizer logs. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesWithResponse(Context context) { - return getPropertiesWithResponseAsync(context).block(); + public PersonalizerLogProperties getProperties() { + return getPropertiesWithResponse(Context.NONE).getValue(); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ModelsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ModelsImpl.java index b8e03583e75ce..1dde2b2ba7734 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ModelsImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ModelsImpl.java @@ -22,30 +22,30 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.RestProxy; -import com.azure.core.http.rest.StreamResponse; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; -import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; -import java.io.InputStream; -import java.io.SequenceInputStream; import java.nio.ByteBuffer; -import java.util.Enumeration; -import java.util.Iterator; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in Models. */ +/** + * An instance of this class provides access to all the operations defined in Models. + */ public final class ModelsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final ModelsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of ModelsImpl. - * + * * @param client the instance of the service client containing this operation class. */ ModelsImpl(PersonalizerClientV1Preview3Impl client) { @@ -61,178 +61,146 @@ public final class ModelsImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface ModelsService { @Get("/model") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono get( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @QueryParam("signed") Boolean signed, - @HeaderParam("Accept") String accept, - Context context); + Mono> get(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @QueryParam("signed") Boolean signed, + @HeaderParam("Accept") String accept, Context context); @Put("/model") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> importMethod( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/octet-stream") Flux body, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Accept") String accept, - Context context); + Mono> importMethod(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/octet-stream") Flux body, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @Put("/model") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> importMethod( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/octet-stream") BinaryData body, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Accept") String accept, - Context context); + Mono> importMethod(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/octet-stream") BinaryData body, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @Delete("/model") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> reset( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> reset(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, + @HeaderParam("Accept") String accept, Context context); @Get("/model/properties") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getProperties( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> getProperties(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @HeaderParam("Accept") String accept, Context context); } /** * Get Model. - * - *

Get the model file generated by Personalizer service. - * + * + * Get the model file generated by Personalizer service. + * * @param signed True if requesting signed model zip archive, false otherwise. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the model file generated by Personalizer service on successful completion of {@link Mono}. + * @return the model file generated by Personalizer service along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getWithResponseAsync(Boolean signed) { - final String accept = "application/octet-stream, application/json"; - return FluxUtil.withContext( - context -> - service.get(this.client.getEndpoint(), this.client.getApiVersion(), signed, accept, context)); + public Mono> getWithResponseAsync(Boolean signed) { + return FluxUtil.withContext(context -> getWithResponseAsync(signed, context)); } /** * Get Model. - * - *

Get the model file generated by Personalizer service. - * + * + * Get the model file generated by Personalizer service. + * * @param signed True if requesting signed model zip archive, false otherwise. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the model file generated by Personalizer service on successful completion of {@link Mono}. + * @return the model file generated by Personalizer service along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getWithResponseAsync(Boolean signed, Context context) { + public Mono> getWithResponseAsync(Boolean signed, Context context) { final String accept = "application/octet-stream, application/json"; return service.get(this.client.getEndpoint(), this.client.getApiVersion(), signed, accept, context); } /** * Get Model. - * - *

Get the model file generated by Personalizer service. - * + * + * Get the model file generated by Personalizer service. + * * @param signed True if requesting signed model zip archive, false otherwise. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the model file generated by Personalizer service. + * @return the model file generated by Personalizer service on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Flux getAsync(Boolean signed) { - return getWithResponseAsync(signed).flatMapMany(StreamResponse::getValue); + public Mono getAsync(Boolean signed) { + return getWithResponseAsync(signed).flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** * Get Model. - * - *

Get the model file generated by Personalizer service. - * + * + * Get the model file generated by Personalizer service. + * * @param signed True if requesting signed model zip archive, false otherwise. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the model file generated by Personalizer service. + * @return the model file generated by Personalizer service on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Flux getAsync(Boolean signed, Context context) { - return getWithResponseAsync(signed, context).flatMapMany(StreamResponse::getValue); + public Mono getAsync(Boolean signed, Context context) { + return getWithResponseAsync(signed, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** * Get Model. - * - *

Get the model file generated by Personalizer service. - * + * + * Get the model file generated by Personalizer service. + * * @param signed True if requesting signed model zip archive, false otherwise. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the model file generated by Personalizer service. + * @return the model file generated by Personalizer service along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public InputStream get(Boolean signed) { - Iterator iterator = - getAsync(signed).map(ByteBufferBackedInputStream::new).toStream().iterator(); - Enumeration enumeration = - new Enumeration() { - @Override - public boolean hasMoreElements() { - return iterator.hasNext(); - } - - @Override - public InputStream nextElement() { - return iterator.next(); - } - }; - return new SequenceInputStream(enumeration); + public Response getWithResponse(Boolean signed, Context context) { + return getWithResponseAsync(signed, context).block(); } /** * Get Model. - * - *

Get the model file generated by Personalizer service. - * + * + * Get the model file generated by Personalizer service. + * * @param signed True if requesting signed model zip archive, false otherwise. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the model file generated by Personalizer service. */ @ServiceMethod(returns = ReturnType.SINGLE) - public StreamResponse getWithResponse(Boolean signed, Context context) { - return getWithResponseAsync(signed, context).block(); + public BinaryData get(Boolean signed) { + return getWithResponse(signed, Context.NONE).getValue(); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -242,23 +210,14 @@ public StreamResponse getWithResponse(Boolean signed, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> importMethodWithResponseAsync(Flux body, long contentLength) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.importMethod( - this.client.getEndpoint(), - this.client.getApiVersion(), - body, - contentLength, - accept, - context)); + return FluxUtil.withContext(context -> importMethodWithResponseAsync(body, contentLength, context)); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -268,18 +227,18 @@ public Mono> importMethodWithResponseAsync(Flux body, * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> importMethodWithResponseAsync( - Flux body, long contentLength, Context context) { + public Mono> importMethodWithResponseAsync(Flux body, long contentLength, + Context context) { final String accept = "application/json"; - return service.importMethod( - this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, context); + return service.importMethod(this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, + context); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -294,9 +253,9 @@ public Mono importMethodAsync(Flux body, long contentLength) { /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -312,43 +271,43 @@ public Mono importMethodAsync(Flux body, long contentLength, C /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void importMethod(Flux body, long contentLength) { - importMethodAsync(body, contentLength).block(); + public Response importMethodWithResponse(Flux body, long contentLength, Context context) { + return importMethodWithResponseAsync(body, contentLength, context).block(); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response importMethodWithResponse(Flux body, long contentLength, Context context) { - return importMethodWithResponseAsync(body, contentLength, context).block(); + public void importMethod(Flux body, long contentLength) { + importMethodWithResponse(body, contentLength, Context.NONE); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -358,23 +317,14 @@ public Response importMethodWithResponse(Flux body, long conte */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> importMethodWithResponseAsync(BinaryData body, long contentLength) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.importMethod( - this.client.getEndpoint(), - this.client.getApiVersion(), - body, - contentLength, - accept, - context)); + return FluxUtil.withContext(context -> importMethodWithResponseAsync(body, contentLength, context)); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -386,15 +336,15 @@ public Mono> importMethodWithResponseAsync(BinaryData body, long @ServiceMethod(returns = ReturnType.SINGLE) public Mono> importMethodWithResponseAsync(BinaryData body, long contentLength, Context context) { final String accept = "application/json"; - return service.importMethod( - this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, context); + return service.importMethod(this.client.getEndpoint(), this.client.getApiVersion(), body, contentLength, accept, + context); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -409,9 +359,9 @@ public Mono importMethodAsync(BinaryData body, long contentLength) { /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. @@ -427,59 +377,57 @@ public Mono importMethodAsync(BinaryData body, long contentLength, Context /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void importMethod(BinaryData body, long contentLength) { - importMethodAsync(body, contentLength).block(); + public Response importMethodWithResponse(BinaryData body, long contentLength, Context context) { + return importMethodWithResponseAsync(body, contentLength, context).block(); } /** * Put the digitally signed model file. - * - *

Replace the existing model file for the Personalizer service. - * + * + * Replace the existing model file for the Personalizer service. + * * @param body The digitally signed model file obtained from getting the model. * @param contentLength The Content-Length header for the request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response importMethodWithResponse(BinaryData body, long contentLength, Context context) { - return importMethodWithResponseAsync(body, contentLength, context).block(); + public void importMethod(BinaryData body, long contentLength) { + importMethodWithResponse(body, contentLength, Context.NONE); } /** * Reset Model. - * - *

Resets the model file generated by Personalizer service. - * + * + * Resets the model file generated by Personalizer service. + * * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> resetWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.reset(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> resetWithResponseAsync(context)); } /** * Reset Model. - * - *

Resets the model file generated by Personalizer service. - * + * + * Resets the model file generated by Personalizer service. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -494,9 +442,9 @@ public Mono> resetWithResponseAsync(Context context) { /** * Reset Model. - * - *

Resets the model file generated by Personalizer service. - * + * + * Resets the model file generated by Personalizer service. + * * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return A {@link Mono} that completes when a successful response is received. @@ -508,9 +456,9 @@ public Mono resetAsync() { /** * Reset Model. - * - *

Resets the model file generated by Personalizer service. - * + * + * Resets the model file generated by Personalizer service. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -524,62 +472,59 @@ public Mono resetAsync(Context context) { /** * Reset Model. - * - *

Resets the model file generated by Personalizer service. - * + * + * Resets the model file generated by Personalizer service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void reset() { - resetAsync().block(); + public Response resetWithResponse(Context context) { + return resetWithResponseAsync(context).block(); } /** * Reset Model. - * - *

Resets the model file generated by Personalizer service. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Resets the model file generated by Personalizer service. + * * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response resetWithResponse(Context context) { - return resetWithResponseAsync(context).block(); + public void reset() { + resetWithResponse(Context.NONE); } /** * Get Model Properties. - * - *

Get properties of the model file generated by Personalizer service. - * + * + * Get properties of the model file generated by Personalizer service. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return properties of the model file generated by Personalizer service along with {@link Response} on successful - * completion of {@link Mono}. + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getPropertiesWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.getProperties(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> getPropertiesWithResponseAsync(context)); } /** * Get Model Properties. - * - *

Get properties of the model file generated by Personalizer service. - * + * + * Get properties of the model file generated by Personalizer service. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return properties of the model file generated by Personalizer service along with {@link Response} on successful - * completion of {@link Mono}. + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getPropertiesWithResponseAsync(Context context) { @@ -589,9 +534,9 @@ public Mono> getPropertiesWithResponseAsyn /** * Get Model Properties. - * - *

Get properties of the model file generated by Personalizer service. - * + * + * Get properties of the model file generated by Personalizer service. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return properties of the model file generated by Personalizer service on successful completion of {@link Mono}. @@ -603,9 +548,9 @@ public Mono getPropertiesAsync() { /** * Get Model Properties. - * - *

Get properties of the model file generated by Personalizer service. - * + * + * Get properties of the model file generated by Personalizer service. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -619,31 +564,31 @@ public Mono getPropertiesAsync(Context context) { /** * Get Model Properties. - * - *

Get properties of the model file generated by Personalizer service. - * + * + * Get properties of the model file generated by Personalizer service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return properties of the model file generated by Personalizer service. + * @return properties of the model file generated by Personalizer service along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerModelProperties getProperties() { - return getPropertiesAsync().block(); + public Response getPropertiesWithResponse(Context context) { + return getPropertiesWithResponseAsync(context).block(); } /** * Get Model Properties. - * - *

Get properties of the model file generated by Personalizer service. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Get properties of the model file generated by Personalizer service. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return properties of the model file generated by Personalizer service along with {@link Response}. + * @return properties of the model file generated by Personalizer service. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesWithResponse(Context context) { - return getPropertiesWithResponseAsync(context).block(); + public PersonalizerModelProperties getProperties() { + return getPropertiesWithResponse(Context.NONE).getValue(); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotEventsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotEventsImpl.java index d5d03ff2121df..9efcf5153d21b 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotEventsImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotEventsImpl.java @@ -23,22 +23,28 @@ import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in MultiSlotEvents. */ +/** + * An instance of this class provides access to all the operations defined in MultiSlotEvents. + */ public final class MultiSlotEventsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final MultiSlotEventsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of MultiSlotEventsImpl. - * + * * @param client the instance of the service client containing this operation class. */ MultiSlotEventsImpl(PersonalizerClientV1Preview3Impl client) { - this.service = - RestProxy.create(MultiSlotEventsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.service + = RestProxy.create(MultiSlotEventsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -50,35 +56,29 @@ public final class MultiSlotEventsImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface MultiSlotEventsService { @Post("/multislot/events/{eventId}/reward") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> reward( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @PathParam("eventId") String eventId, - @BodyParam("application/json") PersonalizerRewardMultiSlotOptions body, - @HeaderParam("Accept") String accept, - Context context); + Mono> reward(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, + @PathParam("eventId") String eventId, + @BodyParam("application/json") PersonalizerRewardMultiSlotOptions body, + @HeaderParam("Accept") String accept, Context context); @Post("/multislot/events/{eventId}/activate") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> activate( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @PathParam("eventId") String eventId, - @HeaderParam("Accept") String accept, - Context context); + Mono> activate(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @PathParam("eventId") String eventId, + @HeaderParam("Accept") String accept, Context context); } /** * Post multi-slot Rewards. - * - *

Report reward that resulted from using the action specified in rewardActionId for the slot. - * + * + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * * @param eventId The event id this reward applies to. * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0 - * and 1. + * and 1. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -86,26 +86,17 @@ Mono> activate( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rewardWithResponseAsync(String eventId, PersonalizerRewardMultiSlotOptions body) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.reward( - this.client.getEndpoint(), - this.client.getApiVersion(), - eventId, - body, - accept, - context)); + return FluxUtil.withContext(context -> rewardWithResponseAsync(eventId, body, context)); } /** * Post multi-slot Rewards. - * - *

Report reward that resulted from using the action specified in rewardActionId for the slot. - * + * + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * * @param eventId The event id this reward applies to. * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0 - * and 1. + * and 1. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -113,20 +104,20 @@ public Mono> rewardWithResponseAsync(String eventId, Personalizer * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rewardWithResponseAsync( - String eventId, PersonalizerRewardMultiSlotOptions body, Context context) { + public Mono> rewardWithResponseAsync(String eventId, PersonalizerRewardMultiSlotOptions body, + Context context) { final String accept = "application/json"; return service.reward(this.client.getEndpoint(), this.client.getApiVersion(), eventId, body, accept, context); } /** * Post multi-slot Rewards. - * - *

Report reward that resulted from using the action specified in rewardActionId for the slot. - * + * + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * * @param eventId The event id this reward applies to. * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0 - * and 1. + * and 1. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -139,12 +130,12 @@ public Mono rewardAsync(String eventId, PersonalizerRewardMultiSlotOptions /** * Post multi-slot Rewards. - * - *

Report reward that resulted from using the action specified in rewardActionId for the slot. - * + * + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * * @param eventId The event id this reward applies to. * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0 - * and 1. + * and 1. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -158,46 +149,46 @@ public Mono rewardAsync(String eventId, PersonalizerRewardMultiSlotOptions /** * Post multi-slot Rewards. - * - *

Report reward that resulted from using the action specified in rewardActionId for the slot. - * + * + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * * @param eventId The event id this reward applies to. * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0 - * and 1. + * and 1. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void reward(String eventId, PersonalizerRewardMultiSlotOptions body) { - rewardAsync(eventId, body).block(); + public Response rewardWithResponse(String eventId, PersonalizerRewardMultiSlotOptions body, Context context) { + return rewardWithResponseAsync(eventId, body, context).block(); } /** * Post multi-slot Rewards. - * - *

Report reward that resulted from using the action specified in rewardActionId for the slot. - * + * + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * * @param eventId The event id this reward applies to. * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0 - * and 1. - * @param context The context to associate with this operation. + * and 1. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response rewardWithResponse(String eventId, PersonalizerRewardMultiSlotOptions body, Context context) { - return rewardWithResponseAsync(eventId, body, context).block(); + public void reward(String eventId, PersonalizerRewardMultiSlotOptions body) { + rewardWithResponse(eventId, body, Context.NONE); } /** * Activate multi-slot Event. - * - *

Report that the specified event was actually used or displayed to the user and a rewards should be expected - * for it. - * + * + * Report that the specified event was actually used or displayed to the user and a rewards should be expected for + * it. + * * @param eventId The event ID this activation applies to. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -206,19 +197,15 @@ public Response rewardWithResponse(String eventId, PersonalizerRewardMulti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> activateWithResponseAsync(String eventId) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.activate( - this.client.getEndpoint(), this.client.getApiVersion(), eventId, accept, context)); + return FluxUtil.withContext(context -> activateWithResponseAsync(eventId, context)); } /** * Activate multi-slot Event. - * - *

Report that the specified event was actually used or displayed to the user and a rewards should be expected - * for it. - * + * + * Report that the specified event was actually used or displayed to the user and a rewards should be expected for + * it. + * * @param eventId The event ID this activation applies to. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -234,10 +221,10 @@ public Mono> activateWithResponseAsync(String eventId, Context co /** * Activate multi-slot Event. - * - *

Report that the specified event was actually used or displayed to the user and a rewards should be expected - * for it. - * + * + * Report that the specified event was actually used or displayed to the user and a rewards should be expected for + * it. + * * @param eventId The event ID this activation applies to. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -251,10 +238,10 @@ public Mono activateAsync(String eventId) { /** * Activate multi-slot Event. - * - *

Report that the specified event was actually used or displayed to the user and a rewards should be expected - * for it. - * + * + * Report that the specified event was actually used or displayed to the user and a rewards should be expected for + * it. + * * @param eventId The event ID this activation applies to. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -269,35 +256,35 @@ public Mono activateAsync(String eventId, Context context) { /** * Activate multi-slot Event. - * - *

Report that the specified event was actually used or displayed to the user and a rewards should be expected - * for it. - * + * + * Report that the specified event was actually used or displayed to the user and a rewards should be expected for + * it. + * * @param eventId The event ID this activation applies to. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void activate(String eventId) { - activateAsync(eventId).block(); + public Response activateWithResponse(String eventId, Context context) { + return activateWithResponseAsync(eventId, context).block(); } /** * Activate multi-slot Event. - * - *

Report that the specified event was actually used or displayed to the user and a rewards should be expected - * for it. - * + * + * Report that the specified event was actually used or displayed to the user and a rewards should be expected for + * it. + * * @param eventId The event ID this activation applies to. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response activateWithResponse(String eventId, Context context) { - return activateWithResponseAsync(eventId, context).block(); + public void activate(String eventId) { + activateWithResponse(eventId, Context.NONE); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotsImpl.java index aa74a3c72df59..7ca39871a2930 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotsImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/MultiSlotsImpl.java @@ -23,22 +23,28 @@ import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in MultiSlots. */ +/** + * An instance of this class provides access to all the operations defined in MultiSlots. + */ public final class MultiSlotsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final MultiSlotsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of MultiSlotsImpl. - * + * * @param client the instance of the service client containing this operation class. */ MultiSlotsImpl(PersonalizerClientV1Preview3Impl client) { - this.service = - RestProxy.create(MultiSlotsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.service + = RestProxy.create(MultiSlotsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -50,22 +56,20 @@ public final class MultiSlotsImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface MultiSlotsService { @Post("/multislot/rank") - @ExpectedResponses({201}) + @ExpectedResponses({ 201 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> rank( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/json") PersonalizerRankMultiSlotOptions body, - @HeaderParam("Accept") String accept, - Context context); + Mono> rank(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") PersonalizerRankMultiSlotOptions body, @HeaderParam("Accept") String accept, + Context context); } /** * Post multi-slot Rank. - * - *

Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. + * + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. * Returns which of the provided actions should be used in each slot, in each rewardActionId. - * + * * @param body A Personalizer multi-slot Rank request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -73,19 +77,17 @@ Mono> rank( * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rankWithResponseAsync( - PersonalizerRankMultiSlotOptions body) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.rank(this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context)); + public Mono> + rankWithResponseAsync(PersonalizerRankMultiSlotOptions body) { + return FluxUtil.withContext(context -> rankWithResponseAsync(body, context)); } /** * Post multi-slot Rank. - * - *

Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. + * + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. * Returns which of the provided actions should be used in each slot, in each rewardActionId. - * + * * @param body A Personalizer multi-slot Rank request. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -94,18 +96,18 @@ public Mono> rankWithResponseAsync( * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rankWithResponseAsync( - PersonalizerRankMultiSlotOptions body, Context context) { + public Mono> rankWithResponseAsync(PersonalizerRankMultiSlotOptions body, + Context context) { final String accept = "application/json"; return service.rank(this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context); } /** * Post multi-slot Rank. - * - *

Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. + * + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. * Returns which of the provided actions should be used in each slot, in each rewardActionId. - * + * * @param body A Personalizer multi-slot Rank request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -119,10 +121,10 @@ public Mono rankAsync(PersonalizerRankMultiSlot /** * Post multi-slot Rank. - * - *

Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. + * + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. * Returns which of the provided actions should be used in each slot, in each rewardActionId. - * + * * @param body A Personalizer multi-slot Rank request. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -137,37 +139,37 @@ public Mono rankAsync(PersonalizerRankMultiSlot /** * Post multi-slot Rank. - * - *

Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. + * + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. * Returns which of the provided actions should be used in each slot, in each rewardActionId. - * + * * @param body A Personalizer multi-slot Rank request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. + * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerRankMultiSlotResult rank(PersonalizerRankMultiSlotOptions body) { - return rankAsync(body).block(); + public Response rankWithResponse(PersonalizerRankMultiSlotOptions body, + Context context) { + return rankWithResponseAsync(body, context).block(); } /** * Post multi-slot Rank. - * - *

Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. + * + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list of slots. * Returns which of the provided actions should be used in each slot, in each rewardActionId. - * + * * @param body A Personalizer multi-slot Rank request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. + * @return the response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response rankWithResponse( - PersonalizerRankMultiSlotOptions body, Context context) { - return rankWithResponseAsync(body, context).block(); + public PersonalizerRankMultiSlotResult rank(PersonalizerRankMultiSlotOptions body) { + return rankWithResponse(body, Context.NONE).getValue(); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3Impl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3Impl.java index 409023ecee82c..79f896b832960 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3Impl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3Impl.java @@ -19,7 +19,6 @@ import com.azure.core.annotation.UnexpectedResponseExceptionType; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.CookiePolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.http.rest.Response; @@ -30,149 +29,177 @@ import com.azure.core.util.serializer.SerializerAdapter; import reactor.core.publisher.Mono; -/** Initializes a new instance of the PersonalizerClientV1Preview3 type. */ +/** + * Initializes a new instance of the PersonalizerClientV1Preview3 type. + */ public final class PersonalizerClientV1Preview3Impl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final PersonalizerClientV1Preview3Service service; - /** Supported Cognitive Services endpoint. */ + /** + * Supported Cognitive Services endpoint. + */ private final String endpoint; /** * Gets Supported Cognitive Services endpoint. - * + * * @return the endpoint value. */ public String getEndpoint() { return this.endpoint; } - /** Personalizer API version (for example, v1.0). */ + /** + * Supported Cognitive Services API version. + */ private final String apiVersion; /** - * Gets Personalizer API version (for example, v1.0). - * + * Gets Supported Cognitive Services API version. + * * @return the apiVersion value. */ public String getApiVersion() { return this.apiVersion; } - /** The HTTP pipeline to send requests through. */ + /** + * The HTTP pipeline to send requests through. + */ private final HttpPipeline httpPipeline; /** * Gets The HTTP pipeline to send requests through. - * + * * @return the httpPipeline value. */ public HttpPipeline getHttpPipeline() { return this.httpPipeline; } - /** The serializer to serialize an object into a string. */ + /** + * The serializer to serialize an object into a string. + */ private final SerializerAdapter serializerAdapter; /** * Gets The serializer to serialize an object into a string. - * + * * @return the serializerAdapter value. */ public SerializerAdapter getSerializerAdapter() { return this.serializerAdapter; } - /** The ServiceConfigurationsImpl object to access its operations. */ + /** + * The ServiceConfigurationsImpl object to access its operations. + */ private final ServiceConfigurationsImpl serviceConfigurations; /** * Gets the ServiceConfigurationsImpl object to access its operations. - * + * * @return the ServiceConfigurationsImpl object. */ public ServiceConfigurationsImpl getServiceConfigurations() { return this.serviceConfigurations; } - /** The PoliciesImpl object to access its operations. */ + /** + * The PoliciesImpl object to access its operations. + */ private final PoliciesImpl policies; /** * Gets the PoliciesImpl object to access its operations. - * + * * @return the PoliciesImpl object. */ public PoliciesImpl getPolicies() { return this.policies; } - /** The EvaluationsImpl object to access its operations. */ + /** + * The EvaluationsImpl object to access its operations. + */ private final EvaluationsImpl evaluations; /** * Gets the EvaluationsImpl object to access its operations. - * + * * @return the EvaluationsImpl object. */ public EvaluationsImpl getEvaluations() { return this.evaluations; } - /** The EventsImpl object to access its operations. */ + /** + * The EventsImpl object to access its operations. + */ private final EventsImpl events; /** * Gets the EventsImpl object to access its operations. - * + * * @return the EventsImpl object. */ public EventsImpl getEvents() { return this.events; } - /** The LogsImpl object to access its operations. */ + /** + * The LogsImpl object to access its operations. + */ private final LogsImpl logs; /** * Gets the LogsImpl object to access its operations. - * + * * @return the LogsImpl object. */ public LogsImpl getLogs() { return this.logs; } - /** The ModelsImpl object to access its operations. */ + /** + * The ModelsImpl object to access its operations. + */ private final ModelsImpl models; /** * Gets the ModelsImpl object to access its operations. - * + * * @return the ModelsImpl object. */ public ModelsImpl getModels() { return this.models; } - /** The MultiSlotEventsImpl object to access its operations. */ + /** + * The MultiSlotEventsImpl object to access its operations. + */ private final MultiSlotEventsImpl multiSlotEvents; /** * Gets the MultiSlotEventsImpl object to access its operations. - * + * * @return the MultiSlotEventsImpl object. */ public MultiSlotEventsImpl getMultiSlotEvents() { return this.multiSlotEvents; } - /** The MultiSlotsImpl object to access its operations. */ + /** + * The MultiSlotsImpl object to access its operations. + */ private final MultiSlotsImpl multiSlots; /** * Gets the MultiSlotsImpl object to access its operations. - * + * * @return the MultiSlotsImpl object. */ public MultiSlotsImpl getMultiSlots() { @@ -181,26 +208,21 @@ public MultiSlotsImpl getMultiSlots() { /** * Initializes an instance of PersonalizerClientV1Preview3 client. - * + * * @param endpoint Supported Cognitive Services endpoint. - * @param apiVersion Personalizer API version (for example, v1.0). + * @param apiVersion Supported Cognitive Services API version. */ PersonalizerClientV1Preview3Impl(String endpoint, String apiVersion) { - this( - new HttpPipelineBuilder() - .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) - .build(), - JacksonAdapter.createDefaultSerializerAdapter(), - endpoint, - apiVersion); + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion); } /** * Initializes an instance of PersonalizerClientV1Preview3 client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint Supported Cognitive Services endpoint. - * @param apiVersion Personalizer API version (for example, v1.0). + * @param apiVersion Supported Cognitive Services API version. */ PersonalizerClientV1Preview3Impl(HttpPipeline httpPipeline, String endpoint, String apiVersion) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion); @@ -208,14 +230,14 @@ public MultiSlotsImpl getMultiSlots() { /** * Initializes an instance of PersonalizerClientV1Preview3 client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. * @param endpoint Supported Cognitive Services endpoint. - * @param apiVersion Personalizer API version (for example, v1.0). + * @param apiVersion Supported Cognitive Services API version. */ - PersonalizerClientV1Preview3Impl( - HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, String apiVersion) { + PersonalizerClientV1Preview3Impl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String apiVersion) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; @@ -228,9 +250,8 @@ public MultiSlotsImpl getMultiSlots() { this.models = new ModelsImpl(this); this.multiSlotEvents = new MultiSlotEventsImpl(this); this.multiSlots = new MultiSlotsImpl(this); - this.service = - RestProxy.create( - PersonalizerClientV1Preview3Service.class, this.httpPipeline, this.getSerializerAdapter()); + this.service = RestProxy.create(PersonalizerClientV1Preview3Service.class, this.httpPipeline, + this.getSerializerAdapter()); } /** @@ -241,69 +262,65 @@ public MultiSlotsImpl getMultiSlots() { @ServiceInterface(name = "PersonalizerClientV1") public interface PersonalizerClientV1Preview3Service { @Post("/rank") - @ExpectedResponses({201}) + @ExpectedResponses({ 201 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> rank( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/json") PersonalizerRankOptions rankRequest, - @HeaderParam("Accept") String accept, - Context context); + Mono> rank(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") PersonalizerRankOptions rankRequest, @HeaderParam("Accept") String accept, + Context context); } /** * Post Rank. - * - *

Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided + * + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided * actions should be used by your application, in rewardActionId. - * + * * @param rankRequest A Personalizer Rank request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return returns which action to use as rewardActionId, and additional information about each action as a result - * of a Rank request along with {@link Response} on successful completion of {@link Mono}. + * of a Rank request along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rankWithResponseAsync(PersonalizerRankOptions rankRequest) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.rank(this.getEndpoint(), this.getApiVersion(), rankRequest, accept, context)); + return FluxUtil.withContext(context -> rankWithResponseAsync(rankRequest, context)); } /** * Post Rank. - * - *

Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided + * + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided * actions should be used by your application, in rewardActionId. - * + * * @param rankRequest A Personalizer Rank request. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return returns which action to use as rewardActionId, and additional information about each action as a result - * of a Rank request along with {@link Response} on successful completion of {@link Mono}. + * of a Rank request along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rankWithResponseAsync( - PersonalizerRankOptions rankRequest, Context context) { + public Mono> rankWithResponseAsync(PersonalizerRankOptions rankRequest, + Context context) { final String accept = "application/json"; return service.rank(this.getEndpoint(), this.getApiVersion(), rankRequest, accept, context); } /** * Post Rank. - * - *

Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided + * + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided * actions should be used by your application, in rewardActionId. - * + * * @param rankRequest A Personalizer Rank request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return returns which action to use as rewardActionId, and additional information about each action as a result - * of a Rank request on successful completion of {@link Mono}. + * of a Rank request on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono rankAsync(PersonalizerRankOptions rankRequest) { @@ -312,17 +329,17 @@ public Mono rankAsync(PersonalizerRankOptions rankReques /** * Post Rank. - * - *

Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided + * + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided * actions should be used by your application, in rewardActionId. - * + * * @param rankRequest A Personalizer Rank request. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return returns which action to use as rewardActionId, and additional information about each action as a result - * of a Rank request on successful completion of {@link Mono}. + * of a Rank request on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono rankAsync(PersonalizerRankOptions rankRequest, Context context) { @@ -331,38 +348,38 @@ public Mono rankAsync(PersonalizerRankOptions rankReques /** * Post Rank. - * - *

Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided + * + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided * actions should be used by your application, in rewardActionId. - * + * * @param rankRequest A Personalizer Rank request. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return returns which action to use as rewardActionId, and additional information about each action as a result - * of a Rank request. + * of a Rank request along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerRankResult rank(PersonalizerRankOptions rankRequest) { - return rankAsync(rankRequest).block(); + public Response rankWithResponse(PersonalizerRankOptions rankRequest, Context context) { + return rankWithResponseAsync(rankRequest, context).block(); } /** * Post Rank. - * - *

Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided + * + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of the provided * actions should be used by your application, in rewardActionId. - * + * * @param rankRequest A Personalizer Rank request. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return returns which action to use as rewardActionId, and additional information about each action as a result - * of a Rank request along with {@link Response}. + * of a Rank request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response rankWithResponse(PersonalizerRankOptions rankRequest, Context context) { - return rankWithResponseAsync(rankRequest, context).block(); + public PersonalizerRankResult rank(PersonalizerRankOptions rankRequest) { + return rankWithResponse(rankRequest, Context.NONE).getValue(); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3ImplBuilder.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3ImplBuilder.java index 2286b7e45acbf..9685dfbd46426 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3ImplBuilder.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PersonalizerClientV1Preview3ImplBuilder.java @@ -20,7 +20,6 @@ import com.azure.core.http.policy.AddHeadersFromContextPolicy; import com.azure.core.http.policy.AddHeadersPolicy; import com.azure.core.http.policy.AzureKeyCredentialPolicy; -import com.azure.core.http.policy.CookiePolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; @@ -39,24 +38,31 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; - -/** A builder for creating a new instance of the PersonalizerClientV1Preview3 type. */ -@ServiceClientBuilder(serviceClients = {PersonalizerClientV1Preview3Impl.class}) -public final class PersonalizerClientV1Preview3ImplBuilder - implements HttpTrait, - ConfigurationTrait, - AzureKeyCredentialTrait, - EndpointTrait { - @Generated private static final String SDK_NAME = "name"; +import java.util.Objects; + +/** + * A builder for creating a new instance of the PersonalizerClientV1Preview3 type. + */ +@ServiceClientBuilder(serviceClients = { PersonalizerClientV1Preview3Impl.class }) +public final class PersonalizerClientV1Preview3ImplBuilder implements + HttpTrait, ConfigurationTrait, + AzureKeyCredentialTrait, + EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; - @Generated private static final String SDK_VERSION = "version"; + @Generated + private static final String SDK_VERSION = "version"; - @Generated private final Map properties = new HashMap<>(); + @Generated + private static final Map PROPERTIES = new HashMap<>(); - @Generated private final List pipelinePolicies; + @Generated + private final List pipelinePolicies; - /** Create an instance of the PersonalizerClientV1Preview3ImplBuilder. */ + /** + * Create an instance of the PersonalizerClientV1Preview3ImplBuilder. + */ @Generated public PersonalizerClientV1Preview3ImplBuilder() { this.pipelinePolicies = new ArrayList<>(); @@ -65,9 +71,12 @@ public PersonalizerClientV1Preview3ImplBuilder() { /* * The HTTP pipeline to send requests through. */ - @Generated private HttpPipeline pipeline; + @Generated + private HttpPipeline pipeline; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder pipeline(HttpPipeline pipeline) { @@ -78,9 +87,12 @@ public PersonalizerClientV1Preview3ImplBuilder pipeline(HttpPipeline pipeline) { /* * The HTTP client used to send the request. */ - @Generated private HttpClient httpClient; + @Generated + private HttpClient httpClient; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder httpClient(HttpClient httpClient) { @@ -91,9 +103,12 @@ public PersonalizerClientV1Preview3ImplBuilder httpClient(HttpClient httpClient) /* * The logging configuration for HTTP requests and responses. */ - @Generated private HttpLogOptions httpLogOptions; + @Generated + private HttpLogOptions httpLogOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) { @@ -102,12 +117,14 @@ public PersonalizerClientV1Preview3ImplBuilder httpLogOptions(HttpLogOptions htt } /* - * The client options such as application ID and custom headers to set on a - * request. + * The client options such as application ID and custom headers to set on a request. */ - @Generated private ClientOptions clientOptions; + @Generated + private ClientOptions clientOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder clientOptions(ClientOptions clientOptions) { @@ -118,9 +135,12 @@ public PersonalizerClientV1Preview3ImplBuilder clientOptions(ClientOptions clien /* * The retry options to configure retry policy for failed requests. */ - @Generated private RetryOptions retryOptions; + @Generated + private RetryOptions retryOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder retryOptions(RetryOptions retryOptions) { @@ -128,21 +148,26 @@ public PersonalizerClientV1Preview3ImplBuilder retryOptions(RetryOptions retryOp return this; } - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); pipelinePolicies.add(customPolicy); return this; } /* - * The configuration store that is used during construction of the service - * client. + * The configuration store that is used during construction of the service client. */ - @Generated private Configuration configuration; + @Generated + private Configuration configuration; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder configuration(Configuration configuration) { @@ -153,9 +178,12 @@ public PersonalizerClientV1Preview3ImplBuilder configuration(Configuration confi /* * The AzureKeyCredential used for authentication. */ - @Generated private AzureKeyCredential azureKeyCredential; + @Generated + private AzureKeyCredential azureKeyCredential; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder credential(AzureKeyCredential azureKeyCredential) { @@ -166,9 +194,12 @@ public PersonalizerClientV1Preview3ImplBuilder credential(AzureKeyCredential azu /* * The service endpoint */ - @Generated private String endpoint; + @Generated + private String endpoint; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public PersonalizerClientV1Preview3ImplBuilder endpoint(String endpoint) { @@ -177,13 +208,14 @@ public PersonalizerClientV1Preview3ImplBuilder endpoint(String endpoint) { } /* - * Personalizer API version (for example, v1.0). + * Supported Cognitive Services API version. */ - @Generated private String apiVersion; + @Generated + private String apiVersion; /** - * Sets Personalizer API version (for example, v1.0). - * + * Sets Supported Cognitive Services API version. + * * @param apiVersion the apiVersion value. * @return the PersonalizerClientV1Preview3ImplBuilder. */ @@ -196,11 +228,12 @@ public PersonalizerClientV1Preview3ImplBuilder apiVersion(String apiVersion) { /* * The serializer to serialize an object into a string */ - @Generated private SerializerAdapter serializerAdapter; + @Generated + private SerializerAdapter serializerAdapter; /** * Sets The serializer to serialize an object into a string. - * + * * @param serializerAdapter the serializerAdapter value. * @return the PersonalizerClientV1Preview3ImplBuilder. */ @@ -211,14 +244,14 @@ public PersonalizerClientV1Preview3ImplBuilder serializerAdapter(SerializerAdapt } /* - * The retry policy that will attempt to retry failed requests, if - * applicable. + * The retry policy that will attempt to retry failed requests, if applicable. */ - @Generated private RetryPolicy retryPolicy; + @Generated + private RetryPolicy retryPolicy; /** * Sets The retry policy that will attempt to retry failed requests, if applicable. - * + * * @param retryPolicy the retryPolicy value. * @return the PersonalizerClientV1Preview3ImplBuilder. */ @@ -230,70 +263,63 @@ public PersonalizerClientV1Preview3ImplBuilder retryPolicy(RetryPolicy retryPoli /** * Builds an instance of PersonalizerClientV1Preview3Impl with the provided parameters. - * + * * @return an instance of PersonalizerClientV1Preview3Impl. */ @Generated public PersonalizerClientV1Preview3Impl buildClient() { - if (pipeline == null) { - this.pipeline = createHttpPipeline(); - } - if (apiVersion == null) { - this.apiVersion = "v1.1-preview.3"; - } - if (serializerAdapter == null) { - this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter(); - } - PersonalizerClientV1Preview3Impl client = - new PersonalizerClientV1Preview3Impl(pipeline, serializerAdapter, endpoint, apiVersion); + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SerializerAdapter localSerializerAdapter + = (serializerAdapter != null) ? serializerAdapter : JacksonAdapter.createDefaultSerializerAdapter(); + PersonalizerClientV1Preview3Impl client = new PersonalizerClientV1Preview3Impl(localPipeline, + localSerializerAdapter, this.endpoint, this.apiVersion); return client; } + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(apiVersion, "'apiVersion' cannot be null."); + } + @Generated private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration = - (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - if (httpLogOptions == null) { - httpLogOptions = new HttpLogOptions(); - } - if (clientOptions == null) { - clientOptions = new ClientOptions(); - } + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; List policies = new ArrayList<>(); - String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = new HttpHeaders(); - clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); - if (headers.getSize() > 0) { + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { policies.add(new AddHeadersPolicy(headers)); } - policies.addAll( - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .collect(Collectors.toList())); + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); policies.add(new AddDatePolicy()); - policies.add(new CookiePolicy()); if (azureKeyCredential != null) { policies.add(new AzureKeyCredentialPolicy("Ocp-Apim-Subscription-Key", azureKeyCredential)); } - policies.addAll( - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .collect(Collectors.toList())); + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(httpLogOptions)); - HttpPipeline httpPipeline = - new HttpPipelineBuilder() - .policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(clientOptions) - .build(); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); return httpPipeline; } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PoliciesImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PoliciesImpl.java index 420941062688b..02e9dd55e267d 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PoliciesImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/PoliciesImpl.java @@ -25,17 +25,23 @@ import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in Policies. */ +/** + * An instance of this class provides access to all the operations defined in Policies. + */ public final class PoliciesImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final PoliciesService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of PoliciesImpl. - * + * * @param client the instance of the service client containing this operation class. */ PoliciesImpl(PersonalizerClientV1Preview3Impl client) { @@ -51,62 +57,51 @@ public final class PoliciesImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface PoliciesService { @Get("/configurations/policy") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> get(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @HeaderParam("Accept") String accept, Context context); @Put("/configurations/policy") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> update( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/json") PersonalizerPolicy policy, - @HeaderParam("Accept") String accept, - Context context); + Mono> update(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @BodyParam("application/json") PersonalizerPolicy policy, + @HeaderParam("Accept") String accept, Context context); @Delete("/configurations/policy") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> reset( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> reset(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @HeaderParam("Accept") String accept, Context context); } /** * Get Policy. - * - *

Get the Learning Settings currently used by the Personalizer service. - * + * + * Get the Learning Settings currently used by the Personalizer service. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the Learning Settings currently used by the Personalizer service along with {@link Response} on - * successful completion of {@link Mono}. + * successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> getWithResponseAsync(context)); } /** * Get Policy. - * - *

Get the Learning Settings currently used by the Personalizer service. - * + * + * Get the Learning Settings currently used by the Personalizer service. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the Learning Settings currently used by the Personalizer service along with {@link Response} on - * successful completion of {@link Mono}. + * successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(Context context) { @@ -116,13 +111,13 @@ public Mono> getWithResponseAsync(Context context) /** * Get Policy. - * - *

Get the Learning Settings currently used by the Personalizer service. - * + * + * Get the Learning Settings currently used by the Personalizer service. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Learning Settings currently used by the Personalizer service on successful completion of {@link - * Mono}. + * @return the Learning Settings currently used by the Personalizer service on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getAsync() { @@ -131,15 +126,15 @@ public Mono getAsync() { /** * Get Policy. - * - *

Get the Learning Settings currently used by the Personalizer service. - * + * + * Get the Learning Settings currently used by the Personalizer service. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Learning Settings currently used by the Personalizer service on successful completion of {@link - * Mono}. + * @return the Learning Settings currently used by the Personalizer service on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getAsync(Context context) { @@ -148,67 +143,63 @@ public Mono getAsync(Context context) { /** * Get Policy. - * - *

Get the Learning Settings currently used by the Personalizer service. - * + * + * Get the Learning Settings currently used by the Personalizer service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Learning Settings currently used by the Personalizer service. + * @return the Learning Settings currently used by the Personalizer service along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerPolicy get() { - return getAsync().block(); + public Response getWithResponse(Context context) { + return getWithResponseAsync(context).block(); } /** * Get Policy. - * - *

Get the Learning Settings currently used by the Personalizer service. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Get the Learning Settings currently used by the Personalizer service. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Learning Settings currently used by the Personalizer service along with {@link Response}. + * @return the Learning Settings currently used by the Personalizer service. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(Context context) { - return getWithResponseAsync(context).block(); + public PersonalizerPolicy get() { + return getWithResponse(Context.NONE).getValue(); } /** * Update Policy. - * - *

Update the Learning Settings that the Personalizer service will use to train models. - * + * + * Update the Learning Settings that the Personalizer service will use to train models. + * * @param policy The learning settings. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return learning settings specifying how to train the model along with {@link Response} on successful completion - * of {@link Mono}. + * of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> updateWithResponseAsync(PersonalizerPolicy policy) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.update( - this.client.getEndpoint(), this.client.getApiVersion(), policy, accept, context)); + return FluxUtil.withContext(context -> updateWithResponseAsync(policy, context)); } /** * Update Policy. - * - *

Update the Learning Settings that the Personalizer service will use to train models. - * + * + * Update the Learning Settings that the Personalizer service will use to train models. + * * @param policy The learning settings. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return learning settings specifying how to train the model along with {@link Response} on successful completion - * of {@link Mono}. + * of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> updateWithResponseAsync(PersonalizerPolicy policy, Context context) { @@ -218,9 +209,9 @@ public Mono> updateWithResponseAsync(PersonalizerPo /** * Update Policy. - * - *

Update the Learning Settings that the Personalizer service will use to train models. - * + * + * Update the Learning Settings that the Personalizer service will use to train models. + * * @param policy The learning settings. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -234,9 +225,9 @@ public Mono updateAsync(PersonalizerPolicy policy) { /** * Update Policy. - * - *

Update the Learning Settings that the Personalizer service will use to train models. - * + * + * Update the Learning Settings that the Personalizer service will use to train models. + * * @param policy The learning settings. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -251,65 +242,63 @@ public Mono updateAsync(PersonalizerPolicy policy, Context c /** * Update Policy. - * - *

Update the Learning Settings that the Personalizer service will use to train models. - * + * + * Update the Learning Settings that the Personalizer service will use to train models. + * * @param policy The learning settings. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return learning settings specifying how to train the model. + * @return learning settings specifying how to train the model along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerPolicy update(PersonalizerPolicy policy) { - return updateAsync(policy).block(); + public Response updateWithResponse(PersonalizerPolicy policy, Context context) { + return updateWithResponseAsync(policy, context).block(); } /** * Update Policy. - * - *

Update the Learning Settings that the Personalizer service will use to train models. - * + * + * Update the Learning Settings that the Personalizer service will use to train models. + * * @param policy The learning settings. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return learning settings specifying how to train the model along with {@link Response}. + * @return learning settings specifying how to train the model. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateWithResponse(PersonalizerPolicy policy, Context context) { - return updateWithResponseAsync(policy, context).block(); + public PersonalizerPolicy update(PersonalizerPolicy policy) { + return updateWithResponse(policy, Context.NONE).getValue(); } /** * Reset Policy. - * - *

Resets the learning settings of the Personalizer service to default. - * + * + * Resets the learning settings of the Personalizer service to default. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return learning settings specifying how to train the model along with {@link Response} on successful completion - * of {@link Mono}. + * of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> resetWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.reset(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> resetWithResponseAsync(context)); } /** * Reset Policy. - * - *

Resets the learning settings of the Personalizer service to default. - * + * + * Resets the learning settings of the Personalizer service to default. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return learning settings specifying how to train the model along with {@link Response} on successful completion - * of {@link Mono}. + * of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> resetWithResponseAsync(Context context) { @@ -319,9 +308,9 @@ public Mono> resetWithResponseAsync(Context context /** * Reset Policy. - * - *

Resets the learning settings of the Personalizer service to default. - * + * + * Resets the learning settings of the Personalizer service to default. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return learning settings specifying how to train the model on successful completion of {@link Mono}. @@ -333,9 +322,9 @@ public Mono resetAsync() { /** * Reset Policy. - * - *

Resets the learning settings of the Personalizer service to default. - * + * + * Resets the learning settings of the Personalizer service to default. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -349,31 +338,31 @@ public Mono resetAsync(Context context) { /** * Reset Policy. - * - *

Resets the learning settings of the Personalizer service to default. - * + * + * Resets the learning settings of the Personalizer service to default. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return learning settings specifying how to train the model. + * @return learning settings specifying how to train the model along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerPolicy reset() { - return resetAsync().block(); + public Response resetWithResponse(Context context) { + return resetWithResponseAsync(context).block(); } /** * Reset Policy. - * - *

Resets the learning settings of the Personalizer service to default. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Resets the learning settings of the Personalizer service to default. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return learning settings specifying how to train the model along with {@link Response}. + * @return learning settings specifying how to train the model. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response resetWithResponse(Context context) { - return resetWithResponseAsync(context).block(); + public PersonalizerPolicy reset() { + return resetWithResponse(Context.NONE).getValue(); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ServiceConfigurationsImpl.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ServiceConfigurationsImpl.java index 2973cde1aa495..550dfa2e6dca6 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ServiceConfigurationsImpl.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/ServiceConfigurationsImpl.java @@ -26,23 +26,28 @@ import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in ServiceConfigurations. */ +/** + * An instance of this class provides access to all the operations defined in ServiceConfigurations. + */ public final class ServiceConfigurationsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final ServiceConfigurationsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final PersonalizerClientV1Preview3Impl client; /** * Initializes an instance of ServiceConfigurationsImpl. - * + * * @param client the instance of the service client containing this operation class. */ ServiceConfigurationsImpl(PersonalizerClientV1Preview3Impl client) { - this.service = - RestProxy.create( - ServiceConfigurationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.service = RestProxy.create(ServiceConfigurationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); this.client = client; } @@ -54,63 +59,54 @@ public final class ServiceConfigurationsImpl { @ServiceInterface(name = "PersonalizerClientV1") public interface ServiceConfigurationsService { @Get("/configurations/service") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> get(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, @HeaderParam("Accept") String accept, Context context); @Put("/configurations/service") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> update( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/json") PersonalizerServiceProperties config, - @HeaderParam("Accept") String accept, - Context context); + Mono> update(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") PersonalizerServiceProperties config, @HeaderParam("Accept") String accept, + Context context); @Post("/configurations/applyFromEvaluation") - @ExpectedResponses({204}) + @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> applyFromEvaluation( - @HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") String apiVersion, - @BodyParam("application/json") PersonalizerPolicyReferenceOptions body, - @HeaderParam("Accept") String accept, - Context context); + Mono> applyFromEvaluation(@HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") PersonalizerPolicyReferenceOptions body, + @HeaderParam("Accept") String accept, Context context); } /** * Get Service Configuration. - * - *

Get the Personalizer service configuration. - * + * + * Get the Personalizer service configuration. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Personalizer service configuration along with {@link Response} on successful completion of {@link - * Mono}. + * @return the Personalizer service configuration along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync() { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)); + return FluxUtil.withContext(context -> getWithResponseAsync(context)); } /** * Get Service Configuration. - * - *

Get the Personalizer service configuration. - * + * + * Get the Personalizer service configuration. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Personalizer service configuration along with {@link Response} on successful completion of {@link - * Mono}. + * @return the Personalizer service configuration along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(Context context) { @@ -120,9 +116,9 @@ public Mono> getWithResponseAsync(Contex /** * Get Service Configuration. - * - *

Get the Personalizer service configuration. - * + * + * Get the Personalizer service configuration. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the Personalizer service configuration on successful completion of {@link Mono}. @@ -134,9 +130,9 @@ public Mono getAsync() { /** * Get Service Configuration. - * - *

Get the Personalizer service configuration. - * + * + * Get the Personalizer service configuration. + * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -150,39 +146,39 @@ public Mono getAsync(Context context) { /** * Get Service Configuration. - * - *

Get the Personalizer service configuration. - * + * + * Get the Personalizer service configuration. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Personalizer service configuration. + * @return the Personalizer service configuration along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerServiceProperties get() { - return getAsync().block(); + public Response getWithResponse(Context context) { + return getWithResponseAsync(context).block(); } /** * Get Service Configuration. - * - *

Get the Personalizer service configuration. - * - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. + * + * Get the Personalizer service configuration. + * * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the Personalizer service configuration along with {@link Response}. + * @return the Personalizer service configuration. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(Context context) { - return getWithResponseAsync(context).block(); + public PersonalizerServiceProperties get() { + return getWithResponse(Context.NONE).getValue(); } /** * Update Service Configuration. - * - *

Update the Personalizer service configuration. - * + * + * Update the Personalizer service configuration. + * * @param config The personalizer service configuration. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -191,18 +187,14 @@ public Response getWithResponse(Context context) */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> updateWithResponseAsync(PersonalizerServiceProperties config) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.update( - this.client.getEndpoint(), this.client.getApiVersion(), config, accept, context)); + return FluxUtil.withContext(context -> updateWithResponseAsync(config, context)); } /** * Update Service Configuration. - * - *

Update the Personalizer service configuration. - * + * + * Update the Personalizer service configuration. + * * @param config The personalizer service configuration. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -211,17 +203,17 @@ public Mono> updateWithResponseAsync(Per * @return the configuration of the service along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateWithResponseAsync( - PersonalizerServiceProperties config, Context context) { + public Mono> updateWithResponseAsync(PersonalizerServiceProperties config, + Context context) { final String accept = "application/json"; return service.update(this.client.getEndpoint(), this.client.getApiVersion(), config, accept, context); } /** * Update Service Configuration. - * - *

Update the Personalizer service configuration. - * + * + * Update the Personalizer service configuration. + * * @param config The personalizer service configuration. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -235,9 +227,9 @@ public Mono updateAsync(PersonalizerServiceProper /** * Update Service Configuration. - * - *

Update the Personalizer service configuration. - * + * + * Update the Personalizer service configuration. + * * @param config The personalizer service configuration. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -252,42 +244,42 @@ public Mono updateAsync(PersonalizerServiceProper /** * Update Service Configuration. - * - *

Update the Personalizer service configuration. - * + * + * Update the Personalizer service configuration. + * * @param config The personalizer service configuration. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the configuration of the service. + * @return the configuration of the service along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PersonalizerServiceProperties update(PersonalizerServiceProperties config) { - return updateAsync(config).block(); + public Response updateWithResponse(PersonalizerServiceProperties config, + Context context) { + return updateWithResponseAsync(config, context).block(); } /** * Update Service Configuration. - * - *

Update the Personalizer service configuration. - * + * + * Update the Personalizer service configuration. + * * @param config The personalizer service configuration. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the configuration of the service along with {@link Response}. + * @return the configuration of the service. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateWithResponse( - PersonalizerServiceProperties config, Context context) { - return updateWithResponseAsync(config, context).block(); + public PersonalizerServiceProperties update(PersonalizerServiceProperties config) { + return updateWithResponse(config, Context.NONE).getValue(); } /** * Apply Learning Settings and model from a pre-existing Offline Evaluation, making them the current online Learning * Settings and model and replacing the previous ones. - * + * * @param body Reference to the policy within the evaluation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -296,17 +288,13 @@ public Response updateWithResponse( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> applyFromEvaluationWithResponseAsync(PersonalizerPolicyReferenceOptions body) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.applyFromEvaluation( - this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context)); + return FluxUtil.withContext(context -> applyFromEvaluationWithResponseAsync(body, context)); } /** * Apply Learning Settings and model from a pre-existing Offline Evaluation, making them the current online Learning * Settings and model and replacing the previous ones. - * + * * @param body Reference to the policy within the evaluation. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -315,17 +303,17 @@ public Mono> applyFromEvaluationWithResponseAsync(PersonalizerPol * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> applyFromEvaluationWithResponseAsync( - PersonalizerPolicyReferenceOptions body, Context context) { + public Mono> applyFromEvaluationWithResponseAsync(PersonalizerPolicyReferenceOptions body, + Context context) { final String accept = "application/json"; - return service.applyFromEvaluation( - this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context); + return service.applyFromEvaluation(this.client.getEndpoint(), this.client.getApiVersion(), body, accept, + context); } /** * Apply Learning Settings and model from a pre-existing Offline Evaluation, making them the current online Learning * Settings and model and replacing the previous ones. - * + * * @param body Reference to the policy within the evaluation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -340,7 +328,7 @@ public Mono applyFromEvaluationAsync(PersonalizerPolicyReferenceOptions bo /** * Apply Learning Settings and model from a pre-existing Offline Evaluation, making them the current online Learning * Settings and model and replacing the previous ones. - * + * * @param body Reference to the policy within the evaluation. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -356,30 +344,30 @@ public Mono applyFromEvaluationAsync(PersonalizerPolicyReferenceOptions bo /** * Apply Learning Settings and model from a pre-existing Offline Evaluation, making them the current online Learning * Settings and model and replacing the previous ones. - * + * * @param body Reference to the policy within the evaluation. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void applyFromEvaluation(PersonalizerPolicyReferenceOptions body) { - applyFromEvaluationAsync(body).block(); + public Response applyFromEvaluationWithResponse(PersonalizerPolicyReferenceOptions body, Context context) { + return applyFromEvaluationWithResponseAsync(body, context).block(); } /** * Apply Learning Settings and model from a pre-existing Offline Evaluation, making them the current online Learning * Settings and model and replacing the previous ones. - * + * * @param body Reference to the policy within the evaluation. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response applyFromEvaluationWithResponse(PersonalizerPolicyReferenceOptions body, Context context) { - return applyFromEvaluationWithResponseAsync(body, context).block(); + public void applyFromEvaluation(PersonalizerPolicyReferenceOptions body) { + applyFromEvaluationWithResponse(body, Context.NONE); } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/package-info.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/package-info.java index 15fb22325bf7a..915b178dcbdb2 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/package-info.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/implementation/package-info.java @@ -3,10 +3,11 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the implementations for PersonalizerClientV1Preview3. Personalizer Service is an Azure Cognitive - * Service that makes it easy to target content and experiences without complex pre-analysis or cleanup of past data. - * Given a context and featurized content, the Personalizer Service returns which content item to show to users in - * rewardActionId. As rewards are sent in response to the use of rewardActionId, the reinforcement learning algorithm - * will improve the model and improve performance of future rank calls. + * Package containing the implementations for PersonalizerClientV1Preview3. + * Personalizer Service is an Azure Cognitive Service that makes it easy to target content and experiences without + * complex pre-analysis or cleanup of past data. Given a context and featurized content, the Personalizer Service + * returns which content item to show to users in rewardActionId. As rewards are sent in response to the use of + * rewardActionId, the reinforcement learning algorithm will improve the model and improve performance of future rank + * calls. */ package com.azure.ai.personalizer.implementation; diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponse.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponse.java index 26d630eac3d54..ca2eb5a49dd99 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponse.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponse.java @@ -5,20 +5,31 @@ package com.azure.ai.personalizer.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; -/** Used to return an error to the client. */ +/** + * Used to return an error to the client. + */ @Fluent -public final class ErrorResponse { +public final class ErrorResponse implements JsonSerializable { /* * The error object. */ - @JsonProperty(value = "error", required = true) private PersonalizerError error; + /** + * Creates an instance of ErrorResponse class. + */ + public ErrorResponse() { + } + /** * Get the error property: The error object. - * + * * @return the error value. */ public PersonalizerError getError() { @@ -27,7 +38,7 @@ public PersonalizerError getError() { /** * Set the error property: The error object. - * + * * @param error the error value to set. * @return the ErrorResponse object itself. */ @@ -35,4 +46,41 @@ public ErrorResponse setError(PersonalizerError error) { this.error = error; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ErrorResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ErrorResponse 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 ErrorResponse. + */ + public static ErrorResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ErrorResponse deserializedErrorResponse = new ErrorResponse(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("error".equals(fieldName)) { + deserializedErrorResponse.error = PersonalizerError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedErrorResponse; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponseException.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponseException.java index b42b8a5f4c0e6..64fd27de07207 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponseException.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ErrorResponseException.java @@ -7,11 +7,13 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpResponse; -/** Exception thrown for an invalid response with ErrorResponse information. */ +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ public final class ErrorResponseException extends HttpResponseException { /** * Initializes a new instance of the ErrorResponseException class. - * + * * @param message the exception message or the response content if a message is not available. * @param response the HTTP response. */ @@ -21,7 +23,7 @@ public ErrorResponseException(String message, HttpResponse response) { /** * Initializes a new instance of the ErrorResponseException class. - * + * * @param message the exception message or the response content if a message is not available. * @param response the HTTP response. * @param value the deserialized response value. @@ -30,6 +32,9 @@ public ErrorResponseException(String message, HttpResponse response, ErrorRespon super(message, response, value); } + /** + * {@inheritDoc} + */ @Override public ErrorResponse getValue() { return (ErrorResponse) super.getValue(); diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationJobStatus.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationJobStatus.java index 0c207cbf8bc05..4ff54aa08816d 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationJobStatus.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationJobStatus.java @@ -5,46 +5,69 @@ package com.azure.ai.personalizer.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Defines values for EvaluationJobStatus. */ +/** + * The status of the job processing the evaluation. + */ public final class EvaluationJobStatus extends ExpandableStringEnum { - /** Static value completed for EvaluationJobStatus. */ + /** + * Static value completed for EvaluationJobStatus. + */ public static final EvaluationJobStatus COMPLETED = fromString("completed"); - /** Static value pending for EvaluationJobStatus. */ + /** + * Static value pending for EvaluationJobStatus. + */ public static final EvaluationJobStatus PENDING = fromString("pending"); - /** Static value failed for EvaluationJobStatus. */ + /** + * Static value failed for EvaluationJobStatus. + */ public static final EvaluationJobStatus FAILED = fromString("failed"); - /** Static value notSubmitted for EvaluationJobStatus. */ + /** + * Static value notSubmitted for EvaluationJobStatus. + */ public static final EvaluationJobStatus NOT_SUBMITTED = fromString("notSubmitted"); - /** Static value timeout for EvaluationJobStatus. */ + /** + * Static value timeout for EvaluationJobStatus. + */ public static final EvaluationJobStatus TIMEOUT = fromString("timeout"); - /** Static value optimalPolicyApplied for EvaluationJobStatus. */ + /** + * Static value optimalPolicyApplied for EvaluationJobStatus. + */ public static final EvaluationJobStatus OPTIMAL_POLICY_APPLIED = fromString("optimalPolicyApplied"); - /** Static value onlinePolicyRetained for EvaluationJobStatus. */ + /** + * Static value onlinePolicyRetained for EvaluationJobStatus. + */ public static final EvaluationJobStatus ONLINE_POLICY_RETAINED = fromString("onlinePolicyRetained"); + /** + * Creates a new instance of EvaluationJobStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvaluationJobStatus() { + } + /** * Creates or finds a EvaluationJobStatus from its string representation. - * + * * @param name a name to look for. * @return the corresponding EvaluationJobStatus. */ - @JsonCreator public static EvaluationJobStatus fromString(String name) { return fromString(name, EvaluationJobStatus.class); } /** * Gets known EvaluationJobStatus values. - * + * * @return known EvaluationJobStatus values. */ public static Collection values() { diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationType.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationType.java index 727a635099610..1e155f8830f79 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationType.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/EvaluationType.java @@ -5,31 +5,44 @@ package com.azure.ai.personalizer.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Defines values for EvaluationType. */ +/** + * Evaluation type (manual or through Automatic Optimization). + */ public final class EvaluationType extends ExpandableStringEnum { - /** Static value Manual for EvaluationType. */ + /** + * Static value Manual for EvaluationType. + */ public static final EvaluationType MANUAL = fromString("Manual"); - /** Static value Auto for EvaluationType. */ + /** + * Static value Auto for EvaluationType. + */ public static final EvaluationType AUTO = fromString("Auto"); + /** + * Creates a new instance of EvaluationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvaluationType() { + } + /** * Creates or finds a EvaluationType from its string representation. - * + * * @param name a name to look for. * @return the corresponding EvaluationType. */ - @JsonCreator public static EvaluationType fromString(String name) { return fromString(name, EvaluationType.class); } /** * Gets known EvaluationType values. - * + * * @return known EvaluationType values. */ public static Collection values() { diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/InternalError.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/InternalError.java index 1c4c55039a28a..68cdaef0e8311 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/InternalError.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/InternalError.java @@ -5,27 +5,36 @@ package com.azure.ai.personalizer.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; -/** An object containing more specific information than the parent object about the error. */ +/** + * An object containing more specific information than the parent object about the error. + */ @Fluent -public final class InternalError { +public final class InternalError implements JsonSerializable { /* * Detailed error code. */ - @JsonProperty(value = "code") private String code; /* - * An object containing more specific information than the parent object - * about the error. + * An object containing more specific information than the parent object about the error. */ - @JsonProperty(value = "innererror") private InternalError innererror; + /** + * Creates an instance of InternalError class. + */ + public InternalError() { + } + /** * Get the code property: Detailed error code. - * + * * @return the code value. */ public String getCode() { @@ -34,7 +43,7 @@ public String getCode() { /** * Set the code property: Detailed error code. - * + * * @param code the code value to set. * @return the InternalError object itself. */ @@ -46,7 +55,7 @@ public InternalError setCode(String code) { /** * Get the innererror property: An object containing more specific information than the parent object about the * error. - * + * * @return the innererror value. */ public InternalError getInnererror() { @@ -56,7 +65,7 @@ public InternalError getInnererror() { /** * Set the innererror property: An object containing more specific information than the parent object about the * error. - * + * * @param innererror the innererror value to set. * @return the InternalError object itself. */ @@ -64,4 +73,43 @@ public InternalError setInnererror(InternalError innererror) { this.innererror = innererror; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code); + jsonWriter.writeJsonField("innererror", this.innererror); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InternalError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InternalError 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 InternalError. + */ + public static InternalError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InternalError deserializedInternalError = new InternalError(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + deserializedInternalError.code = reader.getString(); + } else if ("innererror".equals(fieldName)) { + deserializedInternalError.innererror = InternalError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedInternalError; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/LearningMode.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/LearningMode.java index 415e31310320b..6cfa49477af4a 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/LearningMode.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/LearningMode.java @@ -5,34 +5,49 @@ package com.azure.ai.personalizer.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Defines values for LearningMode. */ +/** + * Learning Modes for Personalizer. + */ public final class LearningMode extends ExpandableStringEnum { - /** Static value Online for LearningMode. */ + /** + * Static value Online for LearningMode. + */ public static final LearningMode ONLINE = fromString("Online"); - /** Static value Apprentice for LearningMode. */ + /** + * Static value Apprentice for LearningMode. + */ public static final LearningMode APPRENTICE = fromString("Apprentice"); - /** Static value LoggingOnly for LearningMode. */ + /** + * Static value LoggingOnly for LearningMode. + */ public static final LearningMode LOGGING_ONLY = fromString("LoggingOnly"); + /** + * Creates a new instance of LearningMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public LearningMode() { + } + /** * Creates or finds a LearningMode from its string representation. - * + * * @param name a name to look for. * @return the corresponding LearningMode. */ - @JsonCreator public static LearningMode fromString(String name) { return fromString(name, LearningMode.class); } /** * Gets known LearningMode values. - * + * * @return known LearningMode values. */ public static Collection values() { diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerError.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerError.java index ddc1f34f74db8..d9158ffe58936 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerError.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerError.java @@ -1,48 +1,53 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.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; import java.util.List; -/** The error object. */ +/** + * The error object. + */ @Fluent -public final class PersonalizerError { +public final class PersonalizerError implements JsonSerializable { + /* * Error Codes returned by Personalizer */ - @JsonProperty(value = "code", required = true) private PersonalizerErrorCode code; /* * A message explaining the error reported by the service. */ - @JsonProperty(value = "message", required = true) private String message; /* * Error source element. */ - @JsonProperty(value = "target") private String target; /* - * An array of details about specific errors that led to this reported - * error. + * An array of details about specific errors that led to this reported error. */ - @JsonProperty(value = "details") private List details; /* - * An object containing more specific information than the parent object - * about the error. + * An object containing more specific information than the parent object about the error. */ - @JsonProperty(value = "innerError") private InternalError innerError; + /** + * Creates an instance of PersonalizerError class. + */ + public PersonalizerError() { + } + /** * Get the code property: Error Codes returned by Personalizer. * @@ -144,4 +149,52 @@ public PersonalizerError setInnerError(InternalError innerError) { this.innerError = innerError; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); + jsonWriter.writeStringField("message", this.message); + jsonWriter.writeStringField("target", this.target); + jsonWriter.writeArrayField("details", this.details, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("innerError", this.innerError); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerError 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 PersonalizerError. + */ + public static PersonalizerError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerError deserializedPersonalizerError = new PersonalizerError(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code".equals(fieldName)) { + deserializedPersonalizerError.code = PersonalizerErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + deserializedPersonalizerError.message = reader.getString(); + } else if ("target".equals(fieldName)) { + deserializedPersonalizerError.target = reader.getString(); + } else if ("details".equals(fieldName)) { + List details = reader.readArray(reader1 -> PersonalizerError.fromJson(reader1)); + deserializedPersonalizerError.details = details; + } else if ("innerError".equals(fieldName)) { + deserializedPersonalizerError.innerError = InternalError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedPersonalizerError; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerErrorCode.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerErrorCode.java index 0db5fc45fa482..e8ed2b6089370 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerErrorCode.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerErrorCode.java @@ -5,152 +5,246 @@ package com.azure.ai.personalizer.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Defines values for PersonalizerErrorCode. */ +/** + * Error Codes returned by Personalizer. + */ public final class PersonalizerErrorCode extends ExpandableStringEnum { - /** Static value BadRequest for PersonalizerErrorCode. */ + /** + * Request could not be understood by the server. + */ public static final PersonalizerErrorCode BAD_REQUEST = fromString("BadRequest"); - /** Static value InvalidServiceConfiguration for PersonalizerErrorCode. */ + /** + * Invalid service configuration. + */ public static final PersonalizerErrorCode INVALID_SERVICE_CONFIGURATION = fromString("InvalidServiceConfiguration"); - /** Static value InvalidLearningModeServiceConfiguration for PersonalizerErrorCode. */ - public static final PersonalizerErrorCode INVALID_LEARNING_MODE_SERVICE_CONFIGURATION = - fromString("InvalidLearningModeServiceConfiguration"); + /** + * Updating defaultReward, rewardWaitTime and rewardAggregation when changing learning mode from Online to + * Apprentice mode and vice versa is not allowed. Make the mode change and then change the additional settings with + * an additional API call. + */ + public static final PersonalizerErrorCode INVALID_LEARNING_MODE_SERVICE_CONFIGURATION + = fromString("InvalidLearningModeServiceConfiguration"); - /** Static value InvalidPolicyConfiguration for PersonalizerErrorCode. */ + /** + * Invalid policy configuration. + */ public static final PersonalizerErrorCode INVALID_POLICY_CONFIGURATION = fromString("InvalidPolicyConfiguration"); - /** Static value InvalidPolicyContract for PersonalizerErrorCode. */ + /** + * Invalid policy contract. + */ public static final PersonalizerErrorCode INVALID_POLICY_CONTRACT = fromString("InvalidPolicyContract"); - /** Static value InvalidEvaluationContract for PersonalizerErrorCode. */ + /** + * Invalid evaluation contract. + */ public static final PersonalizerErrorCode INVALID_EVALUATION_CONTRACT = fromString("InvalidEvaluationContract"); - /** Static value DuplicateCustomPolicyNames for PersonalizerErrorCode. */ + /** + * Custom policy names should be unique. + */ public static final PersonalizerErrorCode DUPLICATE_CUSTOM_POLICY_NAMES = fromString("DuplicateCustomPolicyNames"); - /** Static value NoLogsExistInDateRange for PersonalizerErrorCode. */ + /** + * No logs exist in date range. + */ public static final PersonalizerErrorCode NO_LOGS_EXIST_IN_DATE_RANGE = fromString("NoLogsExistInDateRange"); - /** Static value LogsSizeExceedAllowedLimit for PersonalizerErrorCode. */ + /** + * Total size of logs exceed allowed limit. + */ public static final PersonalizerErrorCode LOGS_SIZE_EXCEED_ALLOWED_LIMIT = fromString("LogsSizeExceedAllowedLimit"); - /** Static value InvalidRewardRequest for PersonalizerErrorCode. */ + /** + * Invalid reward request. + */ public static final PersonalizerErrorCode INVALID_REWARD_REQUEST = fromString("InvalidRewardRequest"); - /** Static value InvalidEventIdToActivate for PersonalizerErrorCode. */ + /** + * Invalid activate event request. + */ public static final PersonalizerErrorCode INVALID_EVENT_ID_TO_ACTIVATE = fromString("InvalidEventIdToActivate"); - /** Static value InvalidRankRequest for PersonalizerErrorCode. */ + /** + * Invalid request. + */ public static final PersonalizerErrorCode INVALID_RANK_REQUEST = fromString("InvalidRankRequest"); - /** Static value InvalidExportLogsRequest for PersonalizerErrorCode. */ + /** + * Invalid request. + */ public static final PersonalizerErrorCode INVALID_EXPORT_LOGS_REQUEST = fromString("InvalidExportLogsRequest"); - /** Static value InvalidRequest for PersonalizerErrorCode. */ + /** + * Invalid request. + */ public static final PersonalizerErrorCode INVALID_REQUEST = fromString("InvalidRequest"); - /** Static value InvalidContainer for PersonalizerErrorCode. */ + /** + * SAS Uri must be the Uri to a container that has write permissions. + */ public static final PersonalizerErrorCode INVALID_CONTAINER = fromString("InvalidContainer"); - /** Static value InvalidModelMetadata for PersonalizerErrorCode. */ + /** + * Invalid model metadata. + */ public static final PersonalizerErrorCode INVALID_MODEL_METADATA = fromString("InvalidModelMetadata"); - /** Static value ApprenticeModeNeverTurnedOn for PersonalizerErrorCode. */ - public static final PersonalizerErrorCode APPRENTICE_MODE_NEVER_TURNED_ON = - fromString("ApprenticeModeNeverTurnedOn"); + /** + * Apprentice mode never turned on. + */ + public static final PersonalizerErrorCode APPRENTICE_MODE_NEVER_TURNED_ON + = fromString("ApprenticeModeNeverTurnedOn"); - /** Static value MissingAppId for PersonalizerErrorCode. */ + /** + * AppId is missing in the header. + */ public static final PersonalizerErrorCode MISSING_APP_ID = fromString("MissingAppId"); - /** Static value InvalidRewardWaitTime for PersonalizerErrorCode. */ + /** + * Reward wait time should be either 10 minutes or 4 hours or 12 hours or 24 hours. + */ public static final PersonalizerErrorCode INVALID_REWARD_WAIT_TIME = fromString("InvalidRewardWaitTime"); - /** Static value InvalidLogRetentionDays for PersonalizerErrorCode. */ + /** + * Log Retention Days must be -1 to store indefinitely or must be at least reward wait time plus 1 day (rounded up). + */ public static final PersonalizerErrorCode INVALID_LOG_RETENTION_DAYS = fromString("InvalidLogRetentionDays"); - /** Static value InvalidMultiSlotApiAccess for PersonalizerErrorCode. */ + /** + * Multi-slot feature is currently disabled. Please follow multi-slot Personalizer documentation to update your loop + * settings to enable multi-slot functionality. + */ public static final PersonalizerErrorCode INVALID_MULTI_SLOT_API_ACCESS = fromString("InvalidMultiSlotApiAccess"); - /** Static value PayloadSizeExceeded for PersonalizerErrorCode. */ + /** + * Exceeds maximum allowed payload size. + */ public static final PersonalizerErrorCode PAYLOAD_SIZE_EXCEEDED = fromString("PayloadSizeExceeded"); - /** Static value InvalidModelImportSignature for PersonalizerErrorCode. */ - public static final PersonalizerErrorCode INVALID_MODEL_IMPORT_SIGNATURE = - fromString("InvalidModelImportSignature"); + /** + * Given model file is not signed or does not have a valid signature. + */ + public static final PersonalizerErrorCode INVALID_MODEL_IMPORT_SIGNATURE + = fromString("InvalidModelImportSignature"); - /** Static value InvalidModelImportFormat for PersonalizerErrorCode. */ + /** + * Given model file format is invalid. + */ public static final PersonalizerErrorCode INVALID_MODEL_IMPORT_FORMAT = fromString("InvalidModelImportFormat"); - /** Static value InvalidApiAccess for PersonalizerErrorCode. */ + /** + * Api is currently disabled for the instance. + */ public static final PersonalizerErrorCode INVALID_API_ACCESS = fromString("InvalidApiAccess"); - /** Static value ModelFileAccessDenied for PersonalizerErrorCode. */ + /** + * Key vault Key used for customer managed key cannot be accessed. + */ public static final PersonalizerErrorCode MODEL_FILE_ACCESS_DENIED = fromString("ModelFileAccessDenied"); - /** Static value ProblemTypeIncompatibleWithAutoOptimization for PersonalizerErrorCode. */ - public static final PersonalizerErrorCode PROBLEM_TYPE_INCOMPATIBLE_WITH_AUTO_OPTIMIZATION = - fromString("ProblemTypeIncompatibleWithAutoOptimization"); + /** + * Auto-optimization is not compatible with multi-slot personalization. + */ + public static final PersonalizerErrorCode PROBLEM_TYPE_INCOMPATIBLE_WITH_AUTO_OPTIMIZATION + = fromString("ProblemTypeIncompatibleWithAutoOptimization"); - /** Static value ResourceNotFound for PersonalizerErrorCode. */ + /** + * Requested resource does not exist on the server. + */ public static final PersonalizerErrorCode RESOURCE_NOT_FOUND = fromString("ResourceNotFound"); - /** Static value FrontEndNotFound for PersonalizerErrorCode. */ + /** + * Front end not found. + */ public static final PersonalizerErrorCode FRONT_END_NOT_FOUND = fromString("FrontEndNotFound"); - /** Static value EvaluationNotFound for PersonalizerErrorCode. */ + /** + * Offline Evaluation not found. + */ public static final PersonalizerErrorCode EVALUATION_NOT_FOUND = fromString("EvaluationNotFound"); - /** Static value LearningSettingsNotFound for PersonalizerErrorCode. */ + /** + * Learning Settings not found in evaluation. + */ public static final PersonalizerErrorCode LEARNING_SETTINGS_NOT_FOUND = fromString("LearningSettingsNotFound"); - /** Static value EvaluationModelNotFound for PersonalizerErrorCode. */ + /** + * Model not found in evaluation. + */ public static final PersonalizerErrorCode EVALUATION_MODEL_NOT_FOUND = fromString("EvaluationModelNotFound"); - /** Static value LogsPropertiesNotFound for PersonalizerErrorCode. */ + /** + * Log properties not found. + */ public static final PersonalizerErrorCode LOGS_PROPERTIES_NOT_FOUND = fromString("LogsPropertiesNotFound"); - /** Static value ModelRankingError for PersonalizerErrorCode. */ + /** + * Error while ranking actions using model. Please verify the learning settings are valid. + */ public static final PersonalizerErrorCode MODEL_RANKING_ERROR = fromString("ModelRankingError"); - /** Static value InternalServerError for PersonalizerErrorCode. */ + /** + * A generic error has occurred on the server. + */ public static final PersonalizerErrorCode INTERNAL_SERVER_ERROR = fromString("InternalServerError"); - /** Static value RankNullResponse for PersonalizerErrorCode. */ + /** + * Rank call returned null response. + */ public static final PersonalizerErrorCode RANK_NULL_RESPONSE = fromString("RankNullResponse"); - /** Static value UpdateConfigurationFailed for PersonalizerErrorCode. */ + /** + * Failed to update configuration. + */ public static final PersonalizerErrorCode UPDATE_CONFIGURATION_FAILED = fromString("UpdateConfigurationFailed"); - /** Static value ModelResetFailed for PersonalizerErrorCode. */ + /** + * Model reset failed. + */ public static final PersonalizerErrorCode MODEL_RESET_FAILED = fromString("ModelResetFailed"); - /** Static value ModelPublishFailed for PersonalizerErrorCode. */ + /** + * Model publish failed. + */ public static final PersonalizerErrorCode MODEL_PUBLISH_FAILED = fromString("ModelPublishFailed"); - /** Static value ModelMetadataUpdateFailed for PersonalizerErrorCode. */ + /** + * Model metadata update failed. + */ public static final PersonalizerErrorCode MODEL_METADATA_UPDATE_FAILED = fromString("ModelMetadataUpdateFailed"); - /** Static value OperationNotAllowed for PersonalizerErrorCode. */ + /** + * This operation is not allowed at this time. + */ public static final PersonalizerErrorCode OPERATION_NOT_ALLOWED = fromString("OperationNotAllowed"); + /** + * Creates a new instance of PersonalizerErrorCode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PersonalizerErrorCode() { + } + /** * Creates or finds a PersonalizerErrorCode from its string representation. - * + * * @param name a name to look for. * @return the corresponding PersonalizerErrorCode. */ - @JsonCreator public static PersonalizerErrorCode fromString(String name) { return fromString(name, PersonalizerErrorCode.class); } /** * Gets known PersonalizerErrorCode values. - * + * * @return known PersonalizerErrorCode values. */ public static Collection values() { diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotOptions.java index ad8ee6bc5ff1f..2c35b3a0289d7 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotOptions.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotOptions.java @@ -1,17 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.models; import com.azure.core.annotation.Fluent; import com.azure.core.util.BinaryData; -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; import java.util.List; -/** The PersonalizerRankMultiSlotOptions model. */ +/** + * The PersonalizerRankMultiSlotOptions model. + */ @Fluent -public final class PersonalizerRankMultiSlotOptions { +public final class PersonalizerRankMultiSlotOptions implements JsonSerializable { + /* * Features of the context used for Personalizer as a * dictionary of dictionaries. This is determined by your application, and @@ -20,59 +26,53 @@ public final class PersonalizerRankMultiSlotOptions { * Features should not include personally identifiable information (PII), * unique UserIDs, or precise timestamps. */ - @JsonProperty(value = "contextFeatures") private List contextFeatures; /* * The set of actions the Personalizer service can pick from. * The set should not contain more than 50 actions. * The order of the actions does not affect the rank result but the order - * should match the sequence your application would have used to display - * them. - * The first item in the array will be used as Baseline item in Offline - * Evaluations. + * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline Evaluations. */ - @JsonProperty(value = "actions", required = true) private List actions; /* * The set of slots the Personalizer service should select actions for. * The set should not contain more than 50 slots. */ - @JsonProperty(value = "slots", required = true) private List slots; /* * Optionally pass an eventId that uniquely identifies this Rank event. - * If null, the service generates a unique eventId. The eventId will be - * used for - * associating this request with its reward, as well as seeding the - * pseudo-random + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random * generator when making a Personalizer call. */ - @JsonProperty(value = "eventId") private String eventId; /* - * Send false if it is certain the rewardActionId in rank results will be - * shown to the user, therefore - * Personalizer will expect a Reward call, otherwise it will assign the - * default - * Reward to the event. Send true if it is possible the user will not see - * the action specified in the rank results, - * (e.g. because the page is rendering later, or the Rank results may be - * overridden by code further downstream). - * You must call the Activate Event API if the event output is shown to - * users, otherwise Rewards will be ignored. - */ - @JsonProperty(value = "deferActivation") + * Send false if it is certain the rewardActionId in rank results will be shown to the user, therefore + * Personalizer will expect a Reward call, otherwise it will assign the default + * Reward to the event. Send true if it is possible the user will not see the action specified in the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. + */ private Boolean deferActivation; /** - * Get the contextFeatures property: Features of the context used for Personalizer as a dictionary of dictionaries. - * This is determined by your application, and typically includes features about the current user, their device, - * profile information, aggregated data about time and date, etc. Features should not include personally - * identifiable information (PII), unique UserIDs, or precise timestamps. + * Creates an instance of PersonalizerRankMultiSlotOptions class. + */ + public PersonalizerRankMultiSlotOptions() { + } + + /** + * Get the contextFeatures property: Features of the context used for Personalizer as a + * dictionary of dictionaries. This is determined by your application, and + * typically includes features about the current user, their + * device, profile information, aggregated data about time and date, etc. + * Features should not include personally identifiable information (PII), + * unique UserIDs, or precise timestamps. * * @return the contextFeatures value. */ @@ -81,10 +81,12 @@ public List getContextFeatures() { } /** - * Set the contextFeatures property: Features of the context used for Personalizer as a dictionary of dictionaries. - * This is determined by your application, and typically includes features about the current user, their device, - * profile information, aggregated data about time and date, etc. Features should not include personally - * identifiable information (PII), unique UserIDs, or precise timestamps. + * Set the contextFeatures property: Features of the context used for Personalizer as a + * dictionary of dictionaries. This is determined by your application, and + * typically includes features about the current user, their + * device, profile information, aggregated data about time and date, etc. + * Features should not include personally identifiable information (PII), + * unique UserIDs, or precise timestamps. * * @param contextFeatures the contextFeatures value to set. * @return the PersonalizerRankMultiSlotOptions object itself. @@ -95,10 +97,11 @@ public PersonalizerRankMultiSlotOptions setContextFeatures(List cont } /** - * Get the actions property: The set of actions the Personalizer service can pick from. The set should not contain - * more than 50 actions. The order of the actions does not affect the rank result but the order should match the - * sequence your application would have used to display them. The first item in the array will be used as Baseline - * item in Offline Evaluations. + * Get the actions property: The set of actions the Personalizer service can pick from. + * The set should not contain more than 50 actions. + * The order of the actions does not affect the rank result but the order + * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline Evaluations. * * @return the actions value. */ @@ -107,10 +110,11 @@ public List getActions() { } /** - * Set the actions property: The set of actions the Personalizer service can pick from. The set should not contain - * more than 50 actions. The order of the actions does not affect the rank result but the order should match the - * sequence your application would have used to display them. The first item in the array will be used as Baseline - * item in Offline Evaluations. + * Set the actions property: The set of actions the Personalizer service can pick from. + * The set should not contain more than 50 actions. + * The order of the actions does not affect the rank result but the order + * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline Evaluations. * * @param actions the actions value to set. * @return the PersonalizerRankMultiSlotOptions object itself. @@ -121,8 +125,8 @@ public PersonalizerRankMultiSlotOptions setActions(List getSlots() { } /** - * Set the slots property: The set of slots the Personalizer service should select actions for. The set should not - * contain more than 50 slots. + * Set the slots property: The set of slots the Personalizer service should select actions for. + * The set should not contain more than 50 slots. * * @param slots the slots value to set. * @return the PersonalizerRankMultiSlotOptions object itself. @@ -143,9 +147,10 @@ public PersonalizerRankMultiSlotOptions setSlots(List s } /** - * Get the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. If null, the - * service generates a unique eventId. The eventId will be used for associating this request with its reward, as - * well as seeding the pseudo-random generator when making a Personalizer call. + * Get the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random + * generator when making a Personalizer call. * * @return the eventId value. */ @@ -154,9 +159,10 @@ public String getEventId() { } /** - * Set the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. If null, the - * service generates a unique eventId. The eventId will be used for associating this request with its reward, as - * well as seeding the pseudo-random generator when making a Personalizer call. + * Set the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random + * generator when making a Personalizer call. * * @param eventId the eventId value to set. * @return the PersonalizerRankMultiSlotOptions object itself. @@ -168,10 +174,11 @@ public PersonalizerRankMultiSlotOptions setEventId(String eventId) { /** * Get the deferActivation property: Send false if it is certain the rewardActionId in rank results will be shown to - * the user, therefore Personalizer will expect a Reward call, otherwise it will assign the default Reward to the - * event. Send true if it is possible the user will not see the action specified in the rank results, (e.g. because - * the page is rendering later, or the Rank results may be overridden by code further downstream). You must call the - * Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. + * the user, therefore + * Personalizer will expect a Reward call, otherwise it will assign the default + * Reward to the event. Send true if it is possible the user will not see the action specified in the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. * * @return the deferActivation value. */ @@ -181,10 +188,11 @@ public Boolean isDeferActivation() { /** * Set the deferActivation property: Send false if it is certain the rewardActionId in rank results will be shown to - * the user, therefore Personalizer will expect a Reward call, otherwise it will assign the default Reward to the - * event. Send true if it is possible the user will not see the action specified in the rank results, (e.g. because - * the page is rendering later, or the Rank results may be overridden by code further downstream). You must call the - * Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. + * the user, therefore + * Personalizer will expect a Reward call, otherwise it will assign the default + * Reward to the event. Send true if it is possible the user will not see the action specified in the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. * * @param deferActivation the deferActivation value to set. * @return the PersonalizerRankMultiSlotOptions object itself. @@ -193,4 +201,62 @@ public PersonalizerRankMultiSlotOptions setDeferActivation(Boolean deferActivati this.deferActivation = deferActivation; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("actions", this.actions, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("slots", this.slots, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("contextFeatures", this.contextFeatures, + (writer, element) -> element.writeTo(writer)); + jsonWriter.writeStringField("eventId", this.eventId); + jsonWriter.writeBooleanField("deferActivation", this.deferActivation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRankMultiSlotOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRankMultiSlotOptions 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 PersonalizerRankMultiSlotOptions. + */ + public static PersonalizerRankMultiSlotOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRankMultiSlotOptions deserializedPersonalizerRankMultiSlotOptions + = new PersonalizerRankMultiSlotOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("actions".equals(fieldName)) { + List actions + = reader.readArray(reader1 -> PersonalizerRankableAction.fromJson(reader1)); + deserializedPersonalizerRankMultiSlotOptions.actions = actions; + } else if ("slots".equals(fieldName)) { + List slots + = reader.readArray(reader1 -> PersonalizerSlotOptions.fromJson(reader1)); + deserializedPersonalizerRankMultiSlotOptions.slots = slots; + } else if ("contextFeatures".equals(fieldName)) { + List contextFeatures + = reader.readArray(reader1 -> (reader1.currentToken() == JsonToken.NULL) + ? null + : BinaryData.fromObject(reader1.readUntyped())); + deserializedPersonalizerRankMultiSlotOptions.contextFeatures = contextFeatures; + } else if ("eventId".equals(fieldName)) { + deserializedPersonalizerRankMultiSlotOptions.eventId = reader.getString(); + } else if ("deferActivation".equals(fieldName)) { + deserializedPersonalizerRankMultiSlotOptions.deferActivation + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + return deserializedPersonalizerRankMultiSlotOptions; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotResult.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotResult.java index 4c630a532f890..b6404ca748d5e 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotResult.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankMultiSlotResult.java @@ -5,29 +5,38 @@ package com.azure.ai.personalizer.models; import com.azure.core.annotation.Immutable; -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; import java.util.List; -/** The PersonalizerRankMultiSlotResult model. */ +/** + * The PersonalizerRankMultiSlotResult model. + */ @Immutable -public final class PersonalizerRankMultiSlotResult { +public final class PersonalizerRankMultiSlotResult implements JsonSerializable { /* - * Each slot has a corresponding rewardActionID which is the action ID - * recommended by Personalizer. + * Each slot has a corresponding rewardActionID which is the action ID recommended by Personalizer. */ - @JsonProperty(value = "slots", access = JsonProperty.Access.WRITE_ONLY) private List slots; /* * The eventId for the round trip from request to response. */ - @JsonProperty(value = "eventId", access = JsonProperty.Access.WRITE_ONLY) private String eventId; + /** + * Creates an instance of PersonalizerRankMultiSlotResult class. + */ + public PersonalizerRankMultiSlotResult() { + } + /** * Get the slots property: Each slot has a corresponding rewardActionID which is the action ID recommended by * Personalizer. - * + * * @return the slots value. */ public List getSlots() { @@ -36,10 +45,50 @@ public List getSlots() { /** * Get the eventId property: The eventId for the round trip from request to response. - * + * * @return the eventId value. */ public String getEventId() { return this.eventId; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRankMultiSlotResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRankMultiSlotResult 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 PersonalizerRankMultiSlotResult. + */ + public static PersonalizerRankMultiSlotResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRankMultiSlotResult deserializedPersonalizerRankMultiSlotResult + = new PersonalizerRankMultiSlotResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("slots".equals(fieldName)) { + List slots + = reader.readArray(reader1 -> PersonalizerSlotResult.fromJson(reader1)); + deserializedPersonalizerRankMultiSlotResult.slots = slots; + } else if ("eventId".equals(fieldName)) { + deserializedPersonalizerRankMultiSlotResult.eventId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPersonalizerRankMultiSlotResult; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankOptions.java index dfe91ee669bc1..dda08ac084dd7 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankOptions.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankOptions.java @@ -1,17 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.models; import com.azure.core.annotation.Fluent; import com.azure.core.util.BinaryData; -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; import java.util.List; -/** Request a set of actions to be ranked by the Personalizer service. */ +/** + * Request a set of actions to be ranked by the Personalizer service. + */ @Fluent -public final class PersonalizerRankOptions { +public final class PersonalizerRankOptions implements JsonSerializable { + /* * Features of the context used for Personalizer as a * dictionary of dictionaries. This is determined by your application, and @@ -20,60 +26,54 @@ public final class PersonalizerRankOptions { * Features should not include personally identifiable information (PII), * unique UserIDs, or precise timestamps. */ - @JsonProperty(value = "contextFeatures") private List contextFeatures; /* * The set of actions the Personalizer service can pick from. * The set should not contain more than 50 actions. * The order of the actions does not affect the rank result but the order - * should match the sequence your application would have used to display - * them. - * The first item in the array will be used as Baseline item in Offline - * Evaluations. + * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline Evaluations. */ - @JsonProperty(value = "actions", required = true) private List actions; /* * The set of action ids to exclude from ranking. - * Personalizer will consider the first non-excluded item in the array as - * the Baseline action when performing Offline Evaluations. + * Personalizer will consider the first non-excluded item in the array as the Baseline action when performing + * Offline Evaluations. */ - @JsonProperty(value = "excludedActions") private List excludedActions; /* * Optionally pass an eventId that uniquely identifies this Rank event. - * If null, the service generates a unique eventId. The eventId will be - * used for - * associating this request with its reward, as well as seeding the - * pseudo-random + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random * generator when making a Personalizer call. */ - @JsonProperty(value = "eventId") private String eventId; /* - * Send false if it is certain the rewardActionId in rank results will be - * shown to the user, therefore - * Personalizer will expect a Reward call, otherwise it will assign the - * default - * Reward to the event. Send true if it is possible the user will not see - * the action specified in the rank results, - * (e.g. because the page is rendering later, or the Rank results may be - * overridden by code further downstream). - * You must call the Activate Event API if the event output is shown to - * users, otherwise Rewards will be ignored. - */ - @JsonProperty(value = "deferActivation") + * Send false if it is certain the rewardActionId in rank results will be shown to the user, therefore + * Personalizer will expect a Reward call, otherwise it will assign the default + * Reward to the event. Send true if it is possible the user will not see the action specified in the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. + */ private Boolean deferActivation; /** - * Get the contextFeatures property: Features of the context used for Personalizer as a dictionary of dictionaries. - * This is determined by your application, and typically includes features about the current user, their device, - * profile information, aggregated data about time and date, etc. Features should not include personally - * identifiable information (PII), unique UserIDs, or precise timestamps. + * Creates an instance of PersonalizerRankOptions class. + */ + public PersonalizerRankOptions() { + } + + /** + * Get the contextFeatures property: Features of the context used for Personalizer as a + * dictionary of dictionaries. This is determined by your application, and + * typically includes features about the current user, their + * device, profile information, aggregated data about time and date, etc. + * Features should not include personally identifiable information (PII), + * unique UserIDs, or precise timestamps. * * @return the contextFeatures value. */ @@ -82,10 +82,12 @@ public List getContextFeatures() { } /** - * Set the contextFeatures property: Features of the context used for Personalizer as a dictionary of dictionaries. - * This is determined by your application, and typically includes features about the current user, their device, - * profile information, aggregated data about time and date, etc. Features should not include personally - * identifiable information (PII), unique UserIDs, or precise timestamps. + * Set the contextFeatures property: Features of the context used for Personalizer as a + * dictionary of dictionaries. This is determined by your application, and + * typically includes features about the current user, their + * device, profile information, aggregated data about time and date, etc. + * Features should not include personally identifiable information (PII), + * unique UserIDs, or precise timestamps. * * @param contextFeatures the contextFeatures value to set. * @return the PersonalizerRankOptions object itself. @@ -96,10 +98,11 @@ public PersonalizerRankOptions setContextFeatures(List contextFeatur } /** - * Get the actions property: The set of actions the Personalizer service can pick from. The set should not contain - * more than 50 actions. The order of the actions does not affect the rank result but the order should match the - * sequence your application would have used to display them. The first item in the array will be used as Baseline - * item in Offline Evaluations. + * Get the actions property: The set of actions the Personalizer service can pick from. + * The set should not contain more than 50 actions. + * The order of the actions does not affect the rank result but the order + * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline Evaluations. * * @return the actions value. */ @@ -108,10 +111,11 @@ public List getActions() { } /** - * Set the actions property: The set of actions the Personalizer service can pick from. The set should not contain - * more than 50 actions. The order of the actions does not affect the rank result but the order should match the - * sequence your application would have used to display them. The first item in the array will be used as Baseline - * item in Offline Evaluations. + * Set the actions property: The set of actions the Personalizer service can pick from. + * The set should not contain more than 50 actions. + * The order of the actions does not affect the rank result but the order + * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline Evaluations. * * @param actions the actions value to set. * @return the PersonalizerRankOptions object itself. @@ -122,8 +126,9 @@ public PersonalizerRankOptions setActions(List actio } /** - * Get the excludedActions property: The set of action ids to exclude from ranking. Personalizer will consider the - * first non-excluded item in the array as the Baseline action when performing Offline Evaluations. + * Get the excludedActions property: The set of action ids to exclude from ranking. + * Personalizer will consider the first non-excluded item in the array as the Baseline action when performing + * Offline Evaluations. * * @return the excludedActions value. */ @@ -132,8 +137,9 @@ public List getExcludedActions() { } /** - * Set the excludedActions property: The set of action ids to exclude from ranking. Personalizer will consider the - * first non-excluded item in the array as the Baseline action when performing Offline Evaluations. + * Set the excludedActions property: The set of action ids to exclude from ranking. + * Personalizer will consider the first non-excluded item in the array as the Baseline action when performing + * Offline Evaluations. * * @param excludedActions the excludedActions value to set. * @return the PersonalizerRankOptions object itself. @@ -144,9 +150,10 @@ public PersonalizerRankOptions setExcludedActions(List excludedActions) } /** - * Get the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. If null, the - * service generates a unique eventId. The eventId will be used for associating this request with its reward, as - * well as seeding the pseudo-random generator when making a Personalizer call. + * Get the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random + * generator when making a Personalizer call. * * @return the eventId value. */ @@ -155,9 +162,10 @@ public String getEventId() { } /** - * Set the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. If null, the - * service generates a unique eventId. The eventId will be used for associating this request with its reward, as - * well as seeding the pseudo-random generator when making a Personalizer call. + * Set the eventId property: Optionally pass an eventId that uniquely identifies this Rank event. + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random + * generator when making a Personalizer call. * * @param eventId the eventId value to set. * @return the PersonalizerRankOptions object itself. @@ -169,10 +177,11 @@ public PersonalizerRankOptions setEventId(String eventId) { /** * Get the deferActivation property: Send false if it is certain the rewardActionId in rank results will be shown to - * the user, therefore Personalizer will expect a Reward call, otherwise it will assign the default Reward to the - * event. Send true if it is possible the user will not see the action specified in the rank results, (e.g. because - * the page is rendering later, or the Rank results may be overridden by code further downstream). You must call the - * Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. + * the user, therefore + * Personalizer will expect a Reward call, otherwise it will assign the default + * Reward to the event. Send true if it is possible the user will not see the action specified in the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. * * @return the deferActivation value. */ @@ -182,10 +191,11 @@ public Boolean isDeferActivation() { /** * Set the deferActivation property: Send false if it is certain the rewardActionId in rank results will be shown to - * the user, therefore Personalizer will expect a Reward call, otherwise it will assign the default Reward to the - * event. Send true if it is possible the user will not see the action specified in the rank results, (e.g. because - * the page is rendering later, or the Rank results may be overridden by code further downstream). You must call the - * Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. + * the user, therefore + * Personalizer will expect a Reward call, otherwise it will assign the default + * Reward to the event. Send true if it is possible the user will not see the action specified in the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards will be ignored. * * @param deferActivation the deferActivation value to set. * @return the PersonalizerRankOptions object itself. @@ -194,4 +204,60 @@ public PersonalizerRankOptions setDeferActivation(Boolean deferActivation) { this.deferActivation = deferActivation; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("actions", this.actions, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("contextFeatures", this.contextFeatures, + (writer, element) -> element.writeTo(writer)); + jsonWriter.writeArrayField("excludedActions", this.excludedActions, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("eventId", this.eventId); + jsonWriter.writeBooleanField("deferActivation", this.deferActivation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRankOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRankOptions 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 PersonalizerRankOptions. + */ + public static PersonalizerRankOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRankOptions deserializedPersonalizerRankOptions = new PersonalizerRankOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("actions".equals(fieldName)) { + List actions + = reader.readArray(reader1 -> PersonalizerRankableAction.fromJson(reader1)); + deserializedPersonalizerRankOptions.actions = actions; + } else if ("contextFeatures".equals(fieldName)) { + List contextFeatures + = reader.readArray(reader1 -> (reader1.currentToken() == JsonToken.NULL) + ? null + : BinaryData.fromObject(reader1.readUntyped())); + deserializedPersonalizerRankOptions.contextFeatures = contextFeatures; + } else if ("excludedActions".equals(fieldName)) { + List excludedActions = reader.readArray(reader1 -> reader1.getString()); + deserializedPersonalizerRankOptions.excludedActions = excludedActions; + } else if ("eventId".equals(fieldName)) { + deserializedPersonalizerRankOptions.eventId = reader.getString(); + } else if ("deferActivation".equals(fieldName)) { + deserializedPersonalizerRankOptions.deferActivation = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + return deserializedPersonalizerRankOptions; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankResult.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankResult.java index 2956eff7e0e13..efff2a38d156a 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankResult.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankResult.java @@ -5,7 +5,11 @@ package com.azure.ai.personalizer.models; import com.azure.core.annotation.Immutable; -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; import java.util.List; /** @@ -13,31 +17,33 @@ * request. */ @Immutable -public final class PersonalizerRankResult { +public final class PersonalizerRankResult implements JsonSerializable { /* * The calculated ranking for the current request. */ - @JsonProperty(value = "ranking", access = JsonProperty.Access.WRITE_ONLY) private List ranking; /* * The eventId for the round trip from request to response. */ - @JsonProperty(value = "eventId", access = JsonProperty.Access.WRITE_ONLY) private String eventId; /* * The action chosen by the Personalizer service. - * This is the action your application should display, and for which to - * report the reward. + * This is the action your application should display, and for which to report the reward. * This might not be the first found in 'ranking'. */ - @JsonProperty(value = "rewardActionId", access = JsonProperty.Access.WRITE_ONLY) private String rewardActionId; + /** + * Creates an instance of PersonalizerRankResult class. + */ + public PersonalizerRankResult() { + } + /** * Get the ranking property: The calculated ranking for the current request. - * + * * @return the ranking value. */ public List getRanking() { @@ -46,7 +52,7 @@ public List getRanking() { /** * Get the eventId property: The eventId for the round trip from request to response. - * + * * @return the eventId value. */ public String getEventId() { @@ -54,12 +60,54 @@ public String getEventId() { } /** - * Get the rewardActionId property: The action chosen by the Personalizer service. This is the action your - * application should display, and for which to report the reward. This might not be the first found in 'ranking'. - * + * Get the rewardActionId property: The action chosen by the Personalizer service. + * This is the action your application should display, and for which to report the reward. + * This might not be the first found in 'ranking'. + * * @return the rewardActionId value. */ public String getRewardActionId() { return this.rewardActionId; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRankResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRankResult 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 PersonalizerRankResult. + */ + public static PersonalizerRankResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRankResult deserializedPersonalizerRankResult = new PersonalizerRankResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("ranking".equals(fieldName)) { + List ranking + = reader.readArray(reader1 -> PersonalizerRankedAction.fromJson(reader1)); + deserializedPersonalizerRankResult.ranking = ranking; + } else if ("eventId".equals(fieldName)) { + deserializedPersonalizerRankResult.eventId = reader.getString(); + } else if ("rewardActionId".equals(fieldName)) { + deserializedPersonalizerRankResult.rewardActionId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPersonalizerRankResult; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankableAction.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankableAction.java index 4ca934a50b6ec..ed27323f30197 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankableAction.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankableAction.java @@ -1,29 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.models; import com.azure.core.annotation.Fluent; import com.azure.core.util.BinaryData; -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; import java.util.List; -/** An action with its associated features used for ranking. */ +/** + * An action with its associated features used for ranking. + */ @Fluent -public final class PersonalizerRankableAction { +public final class PersonalizerRankableAction implements JsonSerializable { + /* * Id of the action. */ - @JsonProperty(value = "id", required = true) private String id; /* * List of dictionaries containing features. */ - @JsonProperty(value = "features", required = true) private List features; + /** + * Creates an instance of PersonalizerRankableAction class. + */ + public PersonalizerRankableAction() { + } + /** * Get the id property: Id of the action. * @@ -63,4 +73,45 @@ public PersonalizerRankableAction setFeatures(List features) { this.features = features; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeArrayField("features", this.features, (writer, element) -> element.writeTo(writer)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRankableAction from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRankableAction 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 PersonalizerRankableAction. + */ + public static PersonalizerRankableAction fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRankableAction deserializedPersonalizerRankableAction = new PersonalizerRankableAction(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + deserializedPersonalizerRankableAction.id = reader.getString(); + } else if ("features".equals(fieldName)) { + List features = reader.readArray(reader1 -> (reader1.currentToken() == JsonToken.NULL) + ? null + : BinaryData.fromObject(reader1.readUntyped())); + deserializedPersonalizerRankableAction.features = features; + } else { + reader.skipChildren(); + } + } + return deserializedPersonalizerRankableAction; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankedAction.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankedAction.java index 44e075368ec5e..9a268b70ed5f4 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankedAction.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRankedAction.java @@ -5,26 +5,36 @@ package com.azure.ai.personalizer.models; import com.azure.core.annotation.Immutable; -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; -/** A ranked action with its resulting probability. */ +/** + * A ranked action with its resulting probability. + */ @Immutable -public final class PersonalizerRankedAction { +public final class PersonalizerRankedAction implements JsonSerializable { /* * Id of the action */ - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /* * Probability of the action */ - @JsonProperty(value = "probability", access = JsonProperty.Access.WRITE_ONLY) private Float probability; + /** + * Creates an instance of PersonalizerRankedAction class. + */ + public PersonalizerRankedAction() { + } + /** * Get the id property: Id of the action. - * + * * @return the id value. */ public String getId() { @@ -33,10 +43,47 @@ public String getId() { /** * Get the probability property: Probability of the action. - * + * * @return the probability value. */ public Float getProbability() { return this.probability; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRankedAction from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRankedAction 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 PersonalizerRankedAction. + */ + public static PersonalizerRankedAction fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRankedAction deserializedPersonalizerRankedAction = new PersonalizerRankedAction(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedPersonalizerRankedAction.id = reader.getString(); + } else if ("probability".equals(fieldName)) { + deserializedPersonalizerRankedAction.probability = reader.getNullable(JsonReader::getFloat); + } else { + reader.skipChildren(); + } + } + + return deserializedPersonalizerRankedAction; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardMultiSlotOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardMultiSlotOptions.java index 0ba78cd137cc6..0fd985a68fbbf 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardMultiSlotOptions.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardMultiSlotOptions.java @@ -5,21 +5,32 @@ package com.azure.ai.personalizer.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; import java.util.List; -/** Reward given to a list of slots. */ +/** + * Reward given to a list of slots. + */ @Fluent -public final class PersonalizerRewardMultiSlotOptions { +public final class PersonalizerRewardMultiSlotOptions implements JsonSerializable { /* * List of SlotRewards */ - @JsonProperty(value = "reward", required = true) private List reward; + /** + * Creates an instance of PersonalizerRewardMultiSlotOptions class. + */ + public PersonalizerRewardMultiSlotOptions() { + } + /** * Get the reward property: List of SlotRewards. - * + * * @return the reward value. */ public List getReward() { @@ -28,7 +39,7 @@ public List getReward() { /** * Set the reward property: List of SlotRewards. - * + * * @param reward the reward value to set. * @return the PersonalizerRewardMultiSlotOptions object itself. */ @@ -36,4 +47,44 @@ public PersonalizerRewardMultiSlotOptions setReward(List this.reward = reward; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("reward", this.reward, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRewardMultiSlotOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRewardMultiSlotOptions 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 PersonalizerRewardMultiSlotOptions. + */ + public static PersonalizerRewardMultiSlotOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRewardMultiSlotOptions deserializedPersonalizerRewardMultiSlotOptions + = new PersonalizerRewardMultiSlotOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("reward".equals(fieldName)) { + List reward + = reader.readArray(reader1 -> PersonalizerSlotReward.fromJson(reader1)); + deserializedPersonalizerRewardMultiSlotOptions.reward = reward; + } else { + reader.skipChildren(); + } + } + + return deserializedPersonalizerRewardMultiSlotOptions; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardOptions.java index 881497a8f3985..7a05a7af4f2ad 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardOptions.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerRewardOptions.java @@ -5,22 +5,33 @@ package com.azure.ai.personalizer.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; -/** Reward given to a rank response. */ +/** + * Reward given to a rank response. + */ @Fluent -public final class PersonalizerRewardOptions { +public final class PersonalizerRewardOptions implements JsonSerializable { /* - * Reward to be assigned to an action. Value is a float calculated by your - * application, typically between 0 and 1, and must be between -1 and 1. + * Reward to be assigned to an action. Value is a float calculated by your application, typically between 0 and 1, + * and must be between -1 and 1. */ - @JsonProperty(value = "value", required = true) private float value; + /** + * Creates an instance of PersonalizerRewardOptions class. + */ + public PersonalizerRewardOptions() { + } + /** * Get the value property: Reward to be assigned to an action. Value is a float calculated by your application, * typically between 0 and 1, and must be between -1 and 1. - * + * * @return the value value. */ public float getValue() { @@ -30,7 +41,7 @@ public float getValue() { /** * Set the value property: Reward to be assigned to an action. Value is a float calculated by your application, * typically between 0 and 1, and must be between -1 and 1. - * + * * @param value the value value to set. * @return the PersonalizerRewardOptions object itself. */ @@ -38,4 +49,41 @@ public PersonalizerRewardOptions setValue(float value) { this.value = value; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFloatField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerRewardOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerRewardOptions 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 PersonalizerRewardOptions. + */ + public static PersonalizerRewardOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerRewardOptions deserializedPersonalizerRewardOptions = new PersonalizerRewardOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + deserializedPersonalizerRewardOptions.value = reader.getFloat(); + } else { + reader.skipChildren(); + } + } + + return deserializedPersonalizerRewardOptions; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotOptions.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotOptions.java index a8e5721c79bff..de67cb95674a9 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotOptions.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotOptions.java @@ -1,47 +1,53 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.models; import com.azure.core.annotation.Fluent; import com.azure.core.util.BinaryData; -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; import java.util.List; -/** A slot with it's associated features and list of excluded actions. */ +/** + * A slot with it's associated features and list of excluded actions. + */ @Fluent -public final class PersonalizerSlotOptions { +public final class PersonalizerSlotOptions implements JsonSerializable { + /* * Slot ID */ - @JsonProperty(value = "id", required = true) private String id; /* * List of dictionaries containing slot features. */ - @JsonProperty(value = "features") private List features; /* * List of excluded action Ids. */ - @JsonProperty(value = "excludedActions") private List excludedActions; /* * The 'baseline action' ID for the slot. - * The BaselineAction is the Id of the Action your application would use in - * that slot if Personalizer didn't exist. + * The BaselineAction is the Id of the Action your application would use in that slot if Personalizer didn't exist. * BaselineAction must be defined for every slot. * BaselineAction should never be part of ExcludedActions. - * Each slot must have a unique BaselineAction which corresponds to an an - * action from the event's Actions list. + * Each slot must have a unique BaselineAction which corresponds to an an action from the event's Actions list. */ - @JsonProperty(value = "baselineAction", required = true) private String baselineAction; + /** + * Creates an instance of PersonalizerSlotOptions class. + */ + public PersonalizerSlotOptions() { + } + /** * Get the id property: Slot ID. * @@ -103,10 +109,11 @@ public PersonalizerSlotOptions setExcludedActions(List excludedActions) } /** - * Get the baselineAction property: The 'baseline action' ID for the slot. The BaselineAction is the Id of the - * Action your application would use in that slot if Personalizer didn't exist. BaselineAction must be defined for - * every slot. BaselineAction should never be part of ExcludedActions. Each slot must have a unique BaselineAction - * which corresponds to an an action from the event's Actions list. + * Get the baselineAction property: The 'baseline action' ID for the slot. + * The BaselineAction is the Id of the Action your application would use in that slot if Personalizer didn't exist. + * BaselineAction must be defined for every slot. + * BaselineAction should never be part of ExcludedActions. + * Each slot must have a unique BaselineAction which corresponds to an an action from the event's Actions list. * * @return the baselineAction value. */ @@ -115,10 +122,11 @@ public String getBaselineAction() { } /** - * Set the baselineAction property: The 'baseline action' ID for the slot. The BaselineAction is the Id of the - * Action your application would use in that slot if Personalizer didn't exist. BaselineAction must be defined for - * every slot. BaselineAction should never be part of ExcludedActions. Each slot must have a unique BaselineAction - * which corresponds to an an action from the event's Actions list. + * Set the baselineAction property: The 'baseline action' ID for the slot. + * The BaselineAction is the Id of the Action your application would use in that slot if Personalizer didn't exist. + * BaselineAction must be defined for every slot. + * BaselineAction should never be part of ExcludedActions. + * Each slot must have a unique BaselineAction which corresponds to an an action from the event's Actions list. * * @param baselineAction the baselineAction value to set. * @return the PersonalizerSlotOptions object itself. @@ -127,4 +135,53 @@ public PersonalizerSlotOptions setBaselineAction(String baselineAction) { this.baselineAction = baselineAction; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("baselineAction", this.baselineAction); + jsonWriter.writeArrayField("features", this.features, (writer, element) -> element.writeTo(writer)); + jsonWriter.writeArrayField("excludedActions", this.excludedActions, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerSlotOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerSlotOptions 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 PersonalizerSlotOptions. + */ + public static PersonalizerSlotOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerSlotOptions deserializedPersonalizerSlotOptions = new PersonalizerSlotOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + deserializedPersonalizerSlotOptions.id = reader.getString(); + } else if ("baselineAction".equals(fieldName)) { + deserializedPersonalizerSlotOptions.baselineAction = reader.getString(); + } else if ("features".equals(fieldName)) { + List features = reader.readArray(reader1 -> (reader1.currentToken() == JsonToken.NULL) + ? null + : BinaryData.fromObject(reader1.readUntyped())); + deserializedPersonalizerSlotOptions.features = features; + } else if ("excludedActions".equals(fieldName)) { + List excludedActions = reader.readArray(reader1 -> reader1.getString()); + deserializedPersonalizerSlotOptions.excludedActions = excludedActions; + } else { + reader.skipChildren(); + } + } + return deserializedPersonalizerSlotOptions; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotResult.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotResult.java index 8eb4098388660..6ebe30848eed8 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotResult.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotResult.java @@ -1,27 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.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; -/** The PersonalizerSlotResult model. */ +/** + * The PersonalizerSlotResult model. + */ @Fluent -public final class PersonalizerSlotResult { +public final class PersonalizerSlotResult implements JsonSerializable { + /* * Id is the slot ID. */ - @JsonProperty(value = "id", required = true) private String id; /* * RewardActionID is the action ID recommended by Personalizer. */ - @JsonProperty(value = "rewardActionId", access = JsonProperty.Access.WRITE_ONLY) private String rewardActionId; + /** + * Creates an instance of PersonalizerSlotResult class. + */ + public PersonalizerSlotResult() { + } + /** * Get the id property: Id is the slot ID. * @@ -50,4 +60,41 @@ PersonalizerSlotResult setId(String id) { public String getRewardActionId() { return this.rewardActionId; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerSlotResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerSlotResult 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 PersonalizerSlotResult. + */ + public static PersonalizerSlotResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerSlotResult deserializedPersonalizerSlotResult = new PersonalizerSlotResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + deserializedPersonalizerSlotResult.id = reader.getString(); + } else if ("rewardActionId".equals(fieldName)) { + deserializedPersonalizerSlotResult.rewardActionId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedPersonalizerSlotResult; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotReward.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotReward.java index d266456901733..89172244e9b5a 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotReward.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PersonalizerSlotReward.java @@ -5,27 +5,36 @@ package com.azure.ai.personalizer.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; -/** The PersonalizerSlotReward model. */ +/** + * The PersonalizerSlotReward model. + */ @Fluent -public final class PersonalizerSlotReward { +public final class PersonalizerSlotReward implements JsonSerializable { /* * Slot id for which we are sending the reward. */ - @JsonProperty(value = "slotId", required = true) private String slotId; /* - * Reward to be assigned to slotId. Value should be between -1 and 1 - * inclusive. + * Reward to be assigned to slotId. Value should be between -1 and 1 inclusive. */ - @JsonProperty(value = "value", required = true) private float value; + /** + * Creates an instance of PersonalizerSlotReward class. + */ + public PersonalizerSlotReward() { + } + /** * Get the slotId property: Slot id for which we are sending the reward. - * + * * @return the slotId value. */ public String getSlotId() { @@ -34,7 +43,7 @@ public String getSlotId() { /** * Set the slotId property: Slot id for which we are sending the reward. - * + * * @param slotId the slotId value to set. * @return the PersonalizerSlotReward object itself. */ @@ -45,7 +54,7 @@ public PersonalizerSlotReward setSlotId(String slotId) { /** * Get the value property: Reward to be assigned to slotId. Value should be between -1 and 1 inclusive. - * + * * @return the value value. */ public float getValue() { @@ -54,7 +63,7 @@ public float getValue() { /** * Set the value property: Reward to be assigned to slotId. Value should be between -1 and 1 inclusive. - * + * * @param value the value value to set. * @return the PersonalizerSlotReward object itself. */ @@ -62,4 +71,44 @@ public PersonalizerSlotReward setValue(float value) { this.value = value; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("slotId", this.slotId); + jsonWriter.writeFloatField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersonalizerSlotReward from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersonalizerSlotReward 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 PersonalizerSlotReward. + */ + public static PersonalizerSlotReward fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersonalizerSlotReward deserializedPersonalizerSlotReward = new PersonalizerSlotReward(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("slotId".equals(fieldName)) { + deserializedPersonalizerSlotReward.slotId = reader.getString(); + } else if ("value".equals(fieldName)) { + deserializedPersonalizerSlotReward.value = reader.getFloat(); + } else { + reader.skipChildren(); + } + } + + return deserializedPersonalizerSlotReward; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PolicySource.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PolicySource.java index 00520efc802d5..677ce3f6fff7d 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PolicySource.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/PolicySource.java @@ -5,40 +5,59 @@ package com.azure.ai.personalizer.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Defines values for PolicySource. */ +/** + * The source of the Learning Settings. + */ public final class PolicySource extends ExpandableStringEnum { - /** Static value Online for PolicySource. */ + /** + * Static value Online for PolicySource. + */ public static final PolicySource ONLINE = fromString("Online"); - /** Static value Baseline for PolicySource. */ + /** + * Static value Baseline for PolicySource. + */ public static final PolicySource BASELINE = fromString("Baseline"); - /** Static value Random for PolicySource. */ + /** + * Static value Random for PolicySource. + */ public static final PolicySource RANDOM = fromString("Random"); - /** Static value Custom for PolicySource. */ + /** + * Static value Custom for PolicySource. + */ public static final PolicySource CUSTOM = fromString("Custom"); - /** Static value OfflineExperimentation for PolicySource. */ + /** + * Static value OfflineExperimentation for PolicySource. + */ public static final PolicySource OFFLINE_EXPERIMENTATION = fromString("OfflineExperimentation"); + /** + * Creates a new instance of PolicySource value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PolicySource() { + } + /** * Creates or finds a PolicySource from its string representation. - * + * * @param name a name to look for. * @return the corresponding PolicySource. */ - @JsonCreator public static PolicySource fromString(String name) { return fromString(name, PolicySource.class); } /** * Gets known PolicySource values. - * + * * @return known PolicySource values. */ public static Collection values() { diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ServiceStatus.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ServiceStatus.java index 7ab9450423567..ea85f61ea8da9 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ServiceStatus.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/ServiceStatus.java @@ -1,33 +1,42 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. - package com.azure.ai.personalizer.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; -/** The ServiceStatus model. */ +/** + * The ServiceStatus model. + */ @Fluent -class ServiceStatus { +class ServiceStatus implements JsonSerializable { + /* * The service property. */ - @JsonProperty(value = "service") private String service; /* * The apiStatus property. */ - @JsonProperty(value = "apiStatus") private String apiStatus; /* * The apiStatusMessage property. */ - @JsonProperty(value = "apiStatusMessage") private String apiStatusMessage; + /** + * Creates an instance of ServiceStatus class. + */ + ServiceStatus() { + } + /** * Get the service property: The service property. * @@ -87,4 +96,44 @@ public ServiceStatus setApiStatusMessage(String apiStatusMessage) { this.apiStatusMessage = apiStatusMessage; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("service", this.service); + jsonWriter.writeStringField("apiStatus", this.apiStatus); + jsonWriter.writeStringField("apiStatusMessage", this.apiStatusMessage); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ServiceStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ServiceStatus 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 ServiceStatus. + */ + public static ServiceStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ServiceStatus deserializedServiceStatus = new ServiceStatus(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("service".equals(fieldName)) { + deserializedServiceStatus.service = reader.getString(); + } else if ("apiStatus".equals(fieldName)) { + deserializedServiceStatus.apiStatus = reader.getString(); + } else if ("apiStatusMessage".equals(fieldName)) { + deserializedServiceStatus.apiStatusMessage = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedServiceStatus; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/package-info.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/package-info.java index 7813435bc5915..d67d232a87f7d 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/package-info.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/com/azure/ai/personalizer/models/package-info.java @@ -3,10 +3,11 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the data models for PersonalizerClientV1Preview3. Personalizer Service is an Azure Cognitive - * Service that makes it easy to target content and experiences without complex pre-analysis or cleanup of past data. - * Given a context and featurized content, the Personalizer Service returns which content item to show to users in - * rewardActionId. As rewards are sent in response to the use of rewardActionId, the reinforcement learning algorithm - * will improve the model and improve performance of future rank calls. + * Package containing the data models for PersonalizerClientV1Preview3. + * Personalizer Service is an Azure Cognitive Service that makes it easy to target content and experiences without + * complex pre-analysis or cleanup of past data. Given a context and featurized content, the Personalizer Service + * returns which content item to show to users in rewardActionId. As rewards are sent in response to the use of + * rewardActionId, the reinforcement learning algorithm will improve the model and improve performance of future rank + * calls. */ package com.azure.ai.personalizer.models; diff --git a/sdk/personalizer/azure-ai-personalizer/src/main/java/module-info.java b/sdk/personalizer/azure-ai-personalizer/src/main/java/module-info.java index aa4a854d9835b..296403ce34f6e 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/main/java/module-info.java +++ b/sdk/personalizer/azure-ai-personalizer/src/main/java/module-info.java @@ -8,7 +8,7 @@ exports com.azure.ai.personalizer.models; exports com.azure.ai.personalizer.administration.models; - opens com.azure.ai.personalizer to com.fasterxml.jackson.databind; - opens com.azure.ai.personalizer.administration.models to com.fasterxml.jackson.databind; - opens com.azure.ai.personalizer.models to com.fasterxml.jackson.databind, com.azure.core; + opens com.azure.ai.personalizer to com.azure.core; + opens com.azure.ai.personalizer.administration.models to com.azure.core; + opens com.azure.ai.personalizer.models to com.azure.core; } diff --git a/sdk/personalizer/azure-ai-personalizer/src/samples/java/com/azure/ai/personalizer/MultiSlotRankActionsAndRewardEvents.java b/sdk/personalizer/azure-ai-personalizer/src/samples/java/com/azure/ai/personalizer/MultiSlotRankActionsAndRewardEvents.java index 6c68b3397acf5..0f33b735cfd1c 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/samples/java/com/azure/ai/personalizer/MultiSlotRankActionsAndRewardEvents.java +++ b/sdk/personalizer/azure-ai-personalizer/src/samples/java/com/azure/ai/personalizer/MultiSlotRankActionsAndRewardEvents.java @@ -10,12 +10,16 @@ import com.azure.ai.personalizer.models.PersonalizerSlotResult; import com.azure.core.credential.AzureKeyCredential; import com.azure.core.util.BinaryData; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.function.Supplier; /** * Demonstrates the use of a Personalizer client to rank actions for multiple slots and reward the presented action. @@ -31,32 +35,26 @@ public class MultiSlotRankActionsAndRewardEvents { */ public static void main(final String[] args) throws IllegalArgumentException, NullPointerException { // Instantiate a client that will be used to call the service. - PersonalizerClient client = new PersonalizerClientBuilder() - .credential(new AzureKeyCredential("{key}")) + PersonalizerClient client = new PersonalizerClientBuilder().credential(new AzureKeyCredential("{key}")) .endpoint("https://{endpoint}.cognitiveservices.azure.com/") .buildClient(); - PersonalizerRankMultiSlotOptions rankOptions = new PersonalizerRankMultiSlotOptions() - .setActions(getActions()) + PersonalizerRankMultiSlotOptions rankOptions = new PersonalizerRankMultiSlotOptions().setActions(getActions()) .setContextFeatures(getContextFeatures()) .setSlots(getSlots()); System.out.println("Sending rank request"); PersonalizerRankMultiSlotResult result = client.rankMultiSlot(rankOptions); String eventId = rankOptions.getEventId(); - System.out.println(String.format( - "Rank returned response with event id %s and recommended the following:", - eventId)); + System.out.printf("Rank returned response with event id %s and recommended the following:%n", eventId); for (PersonalizerSlotResult slot : result.getSlots()) { - System.out.println(String.format( - "Action ${slotResponse.rewardActionId} for slot %s", - slot.getRewardActionId(), - slot.getId())); + System.out.printf("Action %s for slot %s%n", slot.getRewardActionId(), slot.getId()); } // The event response will be determined by how the user interacted with the action that was presented to them. - // Let us say that they like the action presented to them for the "Main Article" (first) slot. So we associate a reward of 1. + // Let us say that they like the action presented to them for the "Main Article" (first) slot. So we associate a + // reward of 1. System.out.println("Sending reward for event for the Main Article slot"); client.rewardMultiSlot(eventId, "Main Article", 1); System.out.println("Completed sending reward for event"); @@ -68,14 +66,11 @@ public static void main(final String[] args) throws IllegalArgumentException, Nu * @return the current context. */ private static List getContextFeatures() { - return new ArrayList() { - { - add(BinaryData.fromObject(new UserProfile().setProfileType("AnonymousUser").setLatLong("47.6,-122.1"))); - add(BinaryData.fromObject(new Environment().setDayOfMonth("28").setMonthOfYear("8").setWeather("Sunny"))); - add(BinaryData.fromObject(new Device().setMobile(true).setWindows(true))); - add(BinaryData.fromObject(new RecentActivity().setItemsInCart(3))); - } - }; + return Arrays.asList( + BinaryData.fromObject(new UserProfile().setProfileType("AnonymousUser").setLatLong("47.6,-122.1")), + BinaryData.fromObject(new Environment().setDayOfMonth("28").setMonthOfYear("8").setWeather("Sunny")), + BinaryData.fromObject(new Device().setMobile(true).setWindows(true)), + BinaryData.fromObject(new RecentActivity().setItemsInCart(3))); } /** @@ -85,21 +80,12 @@ private static List getContextFeatures() { */ private static List getActions() { ArrayList actions = new ArrayList<>(); - List newsFeatures = new ArrayList() { - { - add(BinaryData.fromObject(new FeatureMetadata().setFeatureType("News"))); - } - }; - List sportsFeatures = new ArrayList() { - { - add(BinaryData.fromObject(new FeatureMetadata().setFeatureType("Sports"))); - } - }; - List entertainmentFeatures = new ArrayList() { - { - add(BinaryData.fromObject(new FeatureMetadata().setFeatureType("Entertainment"))); - } - }; + List newsFeatures = Arrays.asList( + BinaryData.fromObject(new FeatureMetadata().setFeatureType("News"))); + List sportsFeatures = Arrays.asList( + BinaryData.fromObject(new FeatureMetadata().setFeatureType("Sports"))); + List entertainmentFeatures = Arrays.asList( + BinaryData.fromObject(new FeatureMetadata().setFeatureType("Entertainment"))); actions.add(new PersonalizerRankableAction().setId("NewsArticle").setFeatures(newsFeatures)); actions.add(new PersonalizerRankableAction().setId("SportsArticle").setFeatures(sportsFeatures)); @@ -113,210 +99,286 @@ private static List getActions() { * @return */ private static List getSlots() { - return new ArrayList() { - { - add(getSlot1()); - add(getSlot2()); - } - }; + return Arrays.asList(getSlot1(), getSlot2()); } private static PersonalizerSlotOptions getSlot1() { - ArrayList positionFeatures = new ArrayList() { - { - add(BinaryData.fromObject(new SlotPositionFeatures().setSize("Large").setPosition("Top Middle"))); - } - }; - - ArrayList excludedActions = new ArrayList() { - { - add("SportsArticle"); - add("EntertainmentArticle"); - } - }; - return new PersonalizerSlotOptions() - .setId("Main Article") + return new PersonalizerSlotOptions().setId("Main Article") .setBaselineAction("NewsArticle") - .setFeatures(positionFeatures) - .setExcludedActions(excludedActions); + .setFeatures(Arrays.asList( + BinaryData.fromObject(new SlotPositionFeatures().setSize("Large").setPosition("Top Middle")))) + .setExcludedActions(Arrays.asList("SportsArticle", "EntertainmentArticle")); } private static PersonalizerSlotOptions getSlot2() { - ArrayList positionFeatures = new ArrayList() { - { - add(BinaryData.fromObject(new SlotPositionFeatures().setSize("Small").setPosition("Bottom Right"))); - } - }; - ArrayList excludedActions = new ArrayList() { - { - add("EntertainmentArticle"); - } - }; - return new PersonalizerSlotOptions() - .setId("Side Bar") + return new PersonalizerSlotOptions().setId("Side Bar") .setBaselineAction("SportsArticle") - .setFeatures(positionFeatures) - .setExcludedActions(excludedActions); - } -} -class FeatureMetadata { - @JsonGetter - public String getFeatureType() { - return featureType; + .setFeatures(Arrays.asList( + BinaryData.fromObject(new SlotPositionFeatures().setSize("Small").setPosition("Bottom Right")))) + .setExcludedActions(Arrays.asList("EntertainmentArticle")); } - @JsonSetter - public FeatureMetadata setFeatureType(String featureType) { - this.featureType = featureType; - return this; - } + static T deserializationHelper(JsonReader jsonReader, Supplier createObject, + ReadValue readValue) throws IOException { + return jsonReader.readObject(reader -> { + T object = createObject.get(); - @JsonProperty - String featureType; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); -} + readValue.read(reader, fieldName, object); + } -class SlotPositionFeatures { - @JsonGetter - public String getSize() { - return size; + return object; + }); } - @JsonSetter - public SlotPositionFeatures setSize(String size) { - this.size = size; - return this; + private interface ReadValue { + void read(JsonReader reader, String fieldName, T object) throws IOException; } - @JsonGetter - public String getPosition() { - return position; - } + static class FeatureMetadata implements JsonSerializable { + String featureType; - @JsonSetter - public SlotPositionFeatures setPosition(String position) { - this.position = position; - return this; - } + public String getFeatureType() { + return featureType; + } - @JsonProperty - String size; - @JsonProperty - String position; -} + public FeatureMetadata setFeatureType(String featureType) { + this.featureType = featureType; + return this; + } -class UserProfile { - @JsonGetter - public String getProfileType() { - return profileType; - } + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("featureType", featureType) + .writeEndObject(); + } - @JsonSetter - public UserProfile setProfileType(String profileType) { - this.profileType = profileType; - return this; - } + public static FeatureMetadata fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, FeatureMetadata::new, (reader, fieldName, featureMetadata) -> { + if ("featureType".equals(fieldName)) { + featureMetadata.featureType = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } - @JsonGetter - public String getLatLong() { - return latLong; } - @JsonSetter - public UserProfile setLatLong(String latLong) { - this.latLong = latLong; - return this; - } + static class SlotPositionFeatures implements JsonSerializable { + String size; + String position; - @JsonProperty - String profileType; - @JsonProperty - String latLong; -} + public String getSize() { + return size; + } -class Environment { - @JsonGetter - public String getDayOfMonth() { - return dayOfMonth; - } + public SlotPositionFeatures setSize(String size) { + this.size = size; + return this; + } - @JsonSetter - public Environment setDayOfMonth(String dayOfMonth) { - this.dayOfMonth = dayOfMonth; - return this; - } + public String getPosition() { + return position; + } - @JsonGetter - public String getMonthOfYear() { - return monthOfYear; - } + public SlotPositionFeatures setPosition(String position) { + this.position = position; + return this; + } - @JsonSetter - public Environment setMonthOfYear(String monthOfYear) { - this.monthOfYear = monthOfYear; - return this; - } + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("size", size) + .writeStringField("position", position) + .writeEndObject(); + } - @JsonGetter - public String getWeather() { - return weather; + public static SlotPositionFeatures fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, SlotPositionFeatures::new, (reader, fieldName, features) -> { + if ("size".equals(fieldName)) { + features.size = reader.getString(); + } else if ("position".equals(fieldName)) { + features.position = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } - @JsonSetter - public Environment setWeather(String weather) { - this.weather = weather; - return this; - } + static class UserProfile implements JsonSerializable { + String profileType; + String latLong; - @JsonProperty - String dayOfMonth; - @JsonProperty - String monthOfYear; - @JsonProperty - String weather; -} + public String getProfileType() { + return profileType; + } -class Device { - @JsonGetter - public boolean isMobile() { - return isMobile; - } + public UserProfile setProfileType(String profileType) { + this.profileType = profileType; + return this; + } - @JsonSetter - public Device setMobile(boolean mobile) { - isMobile = mobile; - return this; - } + public String getLatLong() { + return latLong; + } - @JsonGetter - public boolean isWindows() { - return isWindows; - } + public UserProfile setLatLong(String latLong) { + this.latLong = latLong; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("profileType", profileType) + .writeStringField("latLong", latLong) + .writeEndObject(); + } - @JsonSetter - public Device setWindows(boolean windows) { - isWindows = windows; - return this; + public static UserProfile fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, UserProfile::new, (reader, fieldName, userProfile) -> { + if ("profileType".equals(fieldName)) { + userProfile.profileType = reader.getString(); + } else if ("latLong".equals(fieldName)) { + userProfile.latLong = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } - @JsonProperty - boolean isMobile; - @JsonProperty - boolean isWindows; -} + static class Environment implements JsonSerializable { + String dayOfMonth; + String monthOfYear; + String weather; -class RecentActivity { - @JsonGetter - public Integer getItemsInCart() { - return itemsInCart; + public String getDayOfMonth() { + return dayOfMonth; + } + + public Environment setDayOfMonth(String dayOfMonth) { + this.dayOfMonth = dayOfMonth; + return this; + } + + public String getMonthOfYear() { + return monthOfYear; + } + + public Environment setMonthOfYear(String monthOfYear) { + this.monthOfYear = monthOfYear; + return this; + } + + public String getWeather() { + return weather; + } + + public Environment setWeather(String weather) { + this.weather = weather; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("dayOfMonth", dayOfMonth) + .writeStringField("monthOfYear", monthOfYear) + .writeStringField("weather", weather) + .writeEndObject(); + } + + public static Environment fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, Environment::new, (reader, fieldName, environment) -> { + if ("dayOfMonth".equals(fieldName)) { + environment.dayOfMonth = reader.getString(); + } else if ("monthOfYear".equals(fieldName)) { + environment.monthOfYear = reader.getString(); + } else if ("weather".equals(fieldName)) { + environment.weather = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } - @JsonSetter - public RecentActivity setItemsInCart(Integer itemsInCart) { - this.itemsInCart = itemsInCart; - return this; + static class Device implements JsonSerializable { + boolean isMobile; + boolean isWindows; + + public boolean isMobile() { + return isMobile; + } + + public Device setMobile(boolean mobile) { + isMobile = mobile; + return this; + } + + public boolean isWindows() { + return isWindows; + } + + public Device setWindows(boolean windows) { + isWindows = windows; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeBooleanField("isMobile", isMobile) + .writeBooleanField("isWindows", isWindows) + .writeEndObject(); + } + + public static Device fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, Device::new, (reader, fieldName, device) -> { + if ("isMobile".equals(fieldName)) { + device.isMobile = reader.getBoolean(); + } else if ("isWindows".equals(fieldName)) { + device.isWindows = reader.getBoolean(); + } else { + reader.skipChildren(); + } + }); + } } - @JsonProperty - Integer itemsInCart; + static class RecentActivity implements JsonSerializable { + Integer itemsInCart; + + public Integer getItemsInCart() { + return itemsInCart; + } + + public RecentActivity setItemsInCart(Integer itemsInCart) { + this.itemsInCart = itemsInCart; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject().writeNumberField("itemsInCart", itemsInCart).writeEndObject(); + } + + public static RecentActivity fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, RecentActivity::new, (reader, fieldName, activity) -> { + if ("itemsInCart".equals(fieldName)) { + activity.itemsInCart = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + }); + } + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/TestUtils.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/TestUtils.java index f1cb835507fbe..57e5eb62609b2 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/TestUtils.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/TestUtils.java @@ -4,15 +4,21 @@ package com.azure.ai.personalizer; import com.azure.ai.personalizer.models.PersonalizerAudience; +import com.azure.ai.personalizer.testmodels.ReadValue; import com.azure.core.http.HttpClient; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; import com.azure.identity.AzureAuthorityHosts; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; import org.junit.jupiter.params.provider.Arguments; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Stream; import static com.azure.core.test.TestBase.AZURE_TEST_SERVICE_VERSIONS_VALUE_ALL; @@ -105,4 +111,32 @@ private static boolean shouldServiceVersionBeTested(PersonalizerServiceVersion s return Arrays.stream(configuredServiceVersionList).anyMatch(configuredServiceVersion -> serviceVersion.getVersion().equals(configuredServiceVersion.trim())); } + + /** + * Helper method for deserializing {@link JsonSerializable} instances that don't have constructor parameters. + * + * @param jsonReader The {@link JsonReader} being read. + * @param createObject The supplier that creates a new instance of the type being deserialized if the + * {@link JsonReader} isn't pointing to {@link JsonToken#NULL}. + * @param readValue The handler for reading each field in the JSON object. + * @return An instance of the type being deserialized, or null if the {@link JsonReader} was pointing to + * {@link JsonToken#NULL}. + * @param The type being deserialized. + * @throws IOException If an error occurs while reading the {@link JsonReader}. + */ + public static T deserializationHelper(JsonReader jsonReader, Supplier createObject, + ReadValue readValue) throws IOException { + return jsonReader.readObject(reader -> { + T object = createObject.get(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + readValue.read(reader, fieldName, object); + } + + return object; + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionCategory.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionCategory.java index d9428c63b76a1..a1b02d71dc402 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionCategory.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionCategory.java @@ -3,22 +3,40 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class ActionCategory implements JsonSerializable { + String mostWatchedByAge; -public class ActionCategory { - @JsonGetter public String getMostWatchedByAge() { return mostWatchedByAge; } - @JsonSetter public ActionCategory setMostWatchedByAge(String mostWatchedByAge) { this.mostWatchedByAge = mostWatchedByAge; return this; } - @JsonProperty - String mostWatchedByAge; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("mostWatchedByAge", mostWatchedByAge) + .writeEndObject(); + } + + public static ActionCategory fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, ActionCategory::new, (reader, fieldName, actionCategory) -> { + if ("mostWatchedByAge".equals(fieldName)) { + actionCategory.mostWatchedByAge = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionFeatures.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionFeatures.java index 93e131ad0e8f2..b3d0d5f483048 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionFeatures.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ActionFeatures.java @@ -3,48 +3,66 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class ActionFeatures implements JsonSerializable { + String videoType; + Integer videoLength; + String director; -public class ActionFeatures { - @JsonGetter public String getVideoType() { return videoType; } - @JsonSetter public ActionFeatures setVideoType(String videoType) { this.videoType = videoType; return this; } - @JsonGetter public Integer getVideoLength() { return videoLength; } - @JsonSetter public ActionFeatures setVideoLength(Integer videoLength) { this.videoLength = videoLength; return this; } - @JsonGetter public String getDirector() { return director; } - @JsonSetter public ActionFeatures setDirector(String director) { this.director = director; return this; } - @JsonProperty - String videoType; - @JsonProperty - Integer videoLength; - @JsonProperty - String director; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("videoType", videoType) + .writeNumberField("videoLength", videoLength) + .writeStringField("director", director) + .writeEndObject(); + } + + public static ActionFeatures fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, ActionFeatures::new, (reader, fieldName, actionFeatures) -> { + if ("videoType".equals(fieldName)) { + actionFeatures.videoType = reader.getString(); + } else if ("videoLength".equals(fieldName)) { + actionFeatures.videoLength = reader.getNullable(JsonReader::getInt); + } else if ("director".equals(fieldName)) { + actionFeatures.director = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Context.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Context.java index 5c1ddef65fe23..355b82fe431a4 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Context.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Context.java @@ -3,22 +3,40 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; -public class Context { - @JsonGetter - public CurrentFeatures getFeatures() { +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class Context implements JsonSerializable { + CurrentFeatures currentFeatures; + + public CurrentFeatures getCurrentFeatures() { return currentFeatures; } - @JsonSetter public Context setCurrentFeatures(CurrentFeatures currentFeatures) { this.currentFeatures = currentFeatures; return this; } - @JsonProperty - CurrentFeatures currentFeatures; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeJsonField("currentFeatures", currentFeatures) + .writeEndObject(); + } + + public static Context fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, Context::new, (reader, fieldName, context) -> { + if ("currentFeatures".equals(fieldName)) { + context.currentFeatures = CurrentFeatures.fromJson(reader); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/CurrentFeatures.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/CurrentFeatures.java index 583af157e9734..24636b19dea0f 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/CurrentFeatures.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/CurrentFeatures.java @@ -3,36 +3,53 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class CurrentFeatures implements JsonSerializable { + private String day; + private String weather; -public class CurrentFeatures { - @JsonGetter public String getDay() { return day; } - @JsonSetter public CurrentFeatures setDay(String day) { this.day = day; return this; } - @JsonGetter public String getWeather() { return weather; } - @JsonSetter public CurrentFeatures setWeather(String weather) { this.weather = weather; return this; } - @JsonProperty - private String day; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("day", day) + .writeStringField("weather", weather) + .writeEndObject(); + } - @JsonProperty - private String weather; + public static CurrentFeatures fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, CurrentFeatures::new, (reader, fieldName, currentFeatures) -> { + if ("day".equals(fieldName)) { + currentFeatures.day = reader.getString(); + } else if ("weather".equals(fieldName)) { + currentFeatures.weather = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Device.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Device.java index 7f43464e66a15..fa3c19e932fc5 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Device.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Device.java @@ -3,39 +3,53 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonSetter; - -// Not sure why but the ordering of serialization changes between Java 8 and 17 -// Using azure-json will fix this as it strongly enforces order. -@JsonPropertyOrder({"isMobile", "isWindows", "windows", "mobile"}) -public class Device { - @JsonGetter +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class Device implements JsonSerializable { + boolean isMobile; + boolean isWindows; + public boolean isMobile() { return isMobile; } - @JsonSetter public Device setMobile(boolean mobile) { isMobile = mobile; return this; } - @JsonGetter public boolean isWindows() { return isWindows; } - @JsonSetter public Device setWindows(boolean windows) { isWindows = windows; return this; } - @JsonProperty - boolean isMobile; - @JsonProperty - boolean isWindows; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeBooleanField("isMobile", isMobile) + .writeBooleanField("isWindows", isWindows) + .writeEndObject(); + } + + public static Device fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, Device::new, (reader, fieldName, device) -> { + if ("isMobile".equals(fieldName)) { + device.isMobile = reader.getBoolean(); + } else if ("isWindows".equals(fieldName)) { + device.isWindows = reader.getBoolean(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Environment.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Environment.java index bb401e8d20ec3..53abfb0fceb0b 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Environment.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/Environment.java @@ -3,48 +3,66 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class Environment implements JsonSerializable { + String dayOfMonth; + String monthOfYear; + String weather; -public class Environment { - @JsonGetter public String getDayOfMonth() { return dayOfMonth; } - @JsonSetter public Environment setDayOfMonth(String dayOfMonth) { this.dayOfMonth = dayOfMonth; return this; } - @JsonGetter public String getMonthOfYear() { return monthOfYear; } - @JsonSetter public Environment setMonthOfYear(String monthOfYear) { this.monthOfYear = monthOfYear; return this; } - @JsonGetter public String getWeather() { return weather; } - @JsonSetter public Environment setWeather(String weather) { this.weather = weather; return this; } - @JsonProperty - String dayOfMonth; - @JsonProperty - String monthOfYear; - @JsonProperty - String weather; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("dayOfMonth", dayOfMonth) + .writeStringField("monthOfYear", monthOfYear) + .writeStringField("weather", weather) + .writeEndObject(); + } + + public static Environment fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, Environment::new, (reader, fieldName, environment) -> { + if ("dayOfMonth".equals(fieldName)) { + environment.dayOfMonth = reader.getString(); + } else if ("monthOfYear".equals(fieldName)) { + environment.monthOfYear = reader.getString(); + } else if ("weather".equals(fieldName)) { + environment.weather = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/FeatureMetadata.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/FeatureMetadata.java index f7edae0c7bd66..ffd8e5acb8ed7 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/FeatureMetadata.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/FeatureMetadata.java @@ -3,22 +3,40 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class FeatureMetadata implements JsonSerializable { + String featureType; -public class FeatureMetadata { - @JsonGetter public String getFeatureType() { return featureType; } - @JsonSetter public FeatureMetadata setFeatureType(String featureType) { this.featureType = featureType; return this; } - @JsonProperty - String featureType; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("featureType", featureType) + .writeEndObject(); + } + + public static FeatureMetadata fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, FeatureMetadata::new, (reader, fieldName, featureMetadata) -> { + if ("featureType".equals(fieldName)) { + featureMetadata.featureType = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ReadValue.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ReadValue.java new file mode 100644 index 0000000000000..7f8ab09c3d6c7 --- /dev/null +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/ReadValue.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.personalizer.testmodels; + +import com.azure.json.JsonReader; + +import java.io.IOException; + +/** + * Functional interface that aids in simplifying deserialization. + * + * @param The type being deserialized. + */ +public interface ReadValue { + /** + * Reads a value from the {@link JsonReader} into the {@code object}. + * + * @param reader The {@link JsonReader} being read. + * @param fieldName The current field name. + * @param object The current object being deserialized. + * @throws IOException If an error occurs while reading the {@link JsonReader}. + */ + void read(JsonReader reader, String fieldName, T object) throws IOException; +} diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/RecentActivity.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/RecentActivity.java index f17d62f10262f..eee40cabac738 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/RecentActivity.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/RecentActivity.java @@ -3,22 +3,40 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class RecentActivity implements JsonSerializable { + Integer itemsInCart; -public class RecentActivity { - @JsonGetter public Integer getItemsInCart() { return itemsInCart; } - @JsonSetter public RecentActivity setItemsInCart(Integer itemsInCart) { this.itemsInCart = itemsInCart; return this; } - @JsonProperty - Integer itemsInCart; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeNumberField("itemsInCart", itemsInCart) + .writeEndObject(); + } + + public static RecentActivity fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, RecentActivity::new, (reader, fieldName, recentActivity) -> { + if ("itemsInCart".equals(fieldName)) { + recentActivity.itemsInCart = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/SlotPositionFeatures.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/SlotPositionFeatures.java index 957498ca091a4..0faaf17b00e18 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/SlotPositionFeatures.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/SlotPositionFeatures.java @@ -3,35 +3,53 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class SlotPositionFeatures implements JsonSerializable { + String size; + String position; -public class SlotPositionFeatures { - @JsonGetter public String getSize() { return size; } - @JsonSetter public SlotPositionFeatures setSize(String size) { this.size = size; return this; } - @JsonGetter public String getPosition() { return position; } - @JsonSetter public SlotPositionFeatures setPosition(String position) { this.position = position; return this; } - @JsonProperty - String size; - @JsonProperty - String position; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("size", size) + .writeStringField("position", position) + .writeEndObject(); + } + + public static SlotPositionFeatures fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, SlotPositionFeatures::new, (reader, fieldName, features) -> { + if ("size".equals(fieldName)) { + features.size = reader.getString(); + } else if ("position".equals(fieldName)) { + features.position = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserFeatures.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserFeatures.java index 7eff64105a315..f64beb7467061 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserFeatures.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserFeatures.java @@ -3,61 +3,79 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class UserFeatures implements JsonSerializable { + private boolean isPayingUser; + private String favoriteGenre; + private double hoursOnSite; + private String lastWatchedType; -public class UserFeatures { - @JsonGetter public boolean isPayingUser() { return isPayingUser; } - @JsonSetter public UserFeatures setPayingUser(boolean payingUser) { isPayingUser = payingUser; return this; } - @JsonGetter public String getFavoriteGenre() { return favoriteGenre; } - @JsonSetter public UserFeatures setFavoriteGenre(String favoriteGenre) { this.favoriteGenre = favoriteGenre; return this; } - @JsonGetter public double getHoursOnSite() { return hoursOnSite; } - @JsonSetter public UserFeatures setHoursOnSite(double hoursOnSite) { this.hoursOnSite = hoursOnSite; return this; } - @JsonGetter public String getLastWatchedType() { return lastWatchedType; } - @JsonSetter public UserFeatures setLastWatchedType(String lastWatchedType) { this.lastWatchedType = lastWatchedType; return this; } - @JsonProperty - private boolean isPayingUser; - @JsonProperty - private String favoriteGenre; - @JsonProperty - private double hoursOnSite; - @JsonProperty - private String lastWatchedType; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeBooleanField("isPayingUser", isPayingUser) + .writeStringField("favoriteGenre", favoriteGenre) + .writeDoubleField("hoursOnSite", hoursOnSite) + .writeStringField("lastWatchedType", lastWatchedType) + .writeEndObject(); + } + + public static UserFeatures fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, UserFeatures::new, (reader, fieldName, userFeatures) -> { + if ("isPayingUser".equals(fieldName)) { + userFeatures.isPayingUser = reader.getBoolean(); + } else if ("favoriteGenre".equals(fieldName)) { + userFeatures.favoriteGenre = reader.getString(); + } else if ("hoursOnSite".equals(fieldName)) { + userFeatures.hoursOnSite = reader.getDouble(); + } else if ("lastWatchedType".equals(fieldName)) { + userFeatures.lastWatchedType = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserProfile.java b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserProfile.java index 0e83ea9061e46..7aed29718c60b 100644 --- a/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserProfile.java +++ b/sdk/personalizer/azure-ai-personalizer/src/test/java/com/azure/ai/personalizer/testmodels/UserProfile.java @@ -3,35 +3,53 @@ package com.azure.ai.personalizer.testmodels; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; + +import java.io.IOException; + +import static com.azure.ai.personalizer.TestUtils.deserializationHelper; + +public class UserProfile implements JsonSerializable { + String profileType; + String latLong; -public class UserProfile { - @JsonGetter public String getProfileType() { return profileType; } - @JsonSetter public UserProfile setProfileType(String profileType) { this.profileType = profileType; return this; } - @JsonGetter public String getLatLong() { return latLong; } - @JsonSetter public UserProfile setLatLong(String latLong) { this.latLong = latLong; return this; } - @JsonProperty - String profileType; - @JsonProperty - String latLong; + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return jsonWriter.writeStartObject() + .writeStringField("profileType", profileType) + .writeStringField("latLong", latLong) + .writeEndObject(); + } + + public static UserProfile fromJson(JsonReader jsonReader) throws IOException { + return deserializationHelper(jsonReader, UserProfile::new, (reader, fieldName, userProfile) -> { + if ("profileType".equals(fieldName)) { + userProfile.profileType = reader.getString(); + } else if ("latLong".equals(fieldName)) { + userProfile.latLong = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/sdk/personalizer/azure-ai-personalizer/swagger/README.md b/sdk/personalizer/azure-ai-personalizer/swagger/README.md index a49fecd3ad2af..c992d29dee34c 100644 --- a/sdk/personalizer/azure-ai-personalizer/swagger/README.md +++ b/sdk/personalizer/azure-ai-personalizer/swagger/README.md @@ -19,7 +19,7 @@ autorest ```yaml input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/cognitiveservices/data-plane/Personalizer/preview/v1.1-preview.3/Personalizer.json java: true -use: '@autorest/java@4.1.17' +use: '@autorest/java@4.1.39' output-folder: ..\ generate-client-as-impl: true namespace: com.azure.ai.personalizer @@ -121,3 +121,50 @@ directive: to: PersonalizerSlotReward - generate-samples: true ``` + +### Replace Uri with Url + +```yaml +directive: +- from: swagger-document + where: $.definitions + transform: > + $.PersonalizerServiceProperties.properties.logMirrorSasUri["x-ms-client-name"] = "logMirrorSasUrl"; +``` + +### Rename enableOfflineExperimentation to offlineExperimentationEnabled + +```yaml +directive: +- from: swagger-document + where: $.definitions + transform: > + $.PersonalizerEvaluationOptions.properties.enableOfflineExperimentation["x-ms-client-name"] = "offlineExperimentationEnabled"; +``` + +### Fix for ApiVersion in parameterized host + +```yaml +directive: +- from: swagger-document + where: $["x-ms-parameterized-host"] + transform: > + $.hostTemplate = "{Endpoint}/personalizer/{ApiVersion}"; + $.parameters.push({ + "name": "ApiVersion", + "description": "Supported Cognitive Services API version.", + "x-ms-parameter-location": "client", + "required": true, + "type": "string", + "in": "path", + "x-ms-skip-url-encoding": true + }); +``` + +```yaml +directive: +- from: swagger-document + where: $ + transform: > + delete $.basePath; +``` diff --git a/sdk/personalizer/azure-ai-personalizer/swagger/src/main/java/PersonalizerCustomization.java b/sdk/personalizer/azure-ai-personalizer/swagger/src/main/java/PersonalizerCustomization.java index 144bb69d459b4..c87a7bec622c3 100644 --- a/sdk/personalizer/azure-ai-personalizer/swagger/src/main/java/PersonalizerCustomization.java +++ b/sdk/personalizer/azure-ai-personalizer/swagger/src/main/java/PersonalizerCustomization.java @@ -2,15 +2,13 @@ // Licensed under the MIT License. import com.azure.autorest.customization.Customization; -import com.azure.autorest.customization.JavadocCustomization; import com.azure.autorest.customization.LibraryCustomization; +import com.azure.autorest.customization.PackageCustomization; +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.nodeTypes.NodeWithModifiers; import org.slf4j.Logger; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Contains customizations for Azure Personalizer swagger code generation. */ @@ -18,147 +16,87 @@ public class PersonalizerCustomization extends Customization { @Override public void customize(LibraryCustomization libraryCustomization, Logger logger) { - // Following classes are not intended for consumption by external callers. But we cannot do that since the - // current autorest configuration only allows for two packages (and not three). Since these are with the - // models package but still need to be accessible from the administration.models package, we have to make them - // public. Once issue https://github.com/Azure/autorest.java/issues/1647 is fixed, we can have these in the - // implementation package and hidden from the customer. -// Arrays.asList("ErrorResponse", "ErrorResponseException", -// "InternalError", "PersonalizerError", "PersonalizerErrorCode", -// "ServiceStatus") - Arrays.asList("ServiceStatus") - .forEach(className -> { - libraryCustomization - .getClass("com.azure.ai.personalizer.models", className) - .setModifier(0); // 0 -> package-private - }); + PackageCustomization adminModels = libraryCustomization.getPackage("com.azure.ai.personalizer.administration.models"); + PackageCustomization models = libraryCustomization.getPackage("com.azure.ai.personalizer.models"); + useBinaryDataForRankApis(models); + hideMethods(adminModels, models); + returnBaseClassTypesForMethodReturnValues(adminModels); + hideClasses(adminModels, models); + } + private void useBinaryDataForRankApis(PackageCustomization models) { + customizeToUseBinaryData(models, "PersonalizerRankableAction", "features"); + customizeToUseBinaryData(models, "PersonalizerSlotOptions", "features"); - // Same comment as line 21 above applies here as well. -// Arrays.asList("EvaluationsCreateHeaders", "PersonalizerPolicyReferenceOptions") -// .forEach(className -> { -// libraryCustomization -// .getClass("com.azure.ai.personalizer.administration.models", className) -// .setModifier(0); // 0 -> package-private -// }); - - useBinaryDataForRankApis(libraryCustomization, logger); - renameLogMirrorSasUriProperty(libraryCustomization, logger); - hideMethods(libraryCustomization, logger); - renameOfflineExperimentationProperties(libraryCustomization, logger); - returnBaseClassTypesForMethodReturnValues(libraryCustomization, logger); - hideClasses(libraryCustomization, logger); + customizeToUseBinaryData(models, "PersonalizerRankMultiSlotOptions", "contextFeatures"); + customizeToUseBinaryData(models, "PersonalizerRankOptions", "contextFeatures"); } - private void useBinaryDataForRankApis(LibraryCustomization libraryCustomization, Logger logger) { - Arrays.asList("PersonalizerRankableAction", "PersonalizerRankMultiSlotOptions", "PersonalizerRankOptions", "PersonalizerSlotOptions") - .forEach(className -> { - String fileName = "src/main/java/com/azure/ai/personalizer/models/" + className + ".java"; - libraryCustomization - .getClass("com.azure.ai.personalizer.models", className) - .addImports("com.azure.core.util.BinaryData"); - libraryCustomization.getRawEditor() - .searchText(fileName, "List") - .forEach(range -> { - libraryCustomization - .getRawEditor() - .replace(fileName, range.getStart(), range.getEnd(), "List"); - }); + private static void customizeToUseBinaryData(PackageCustomization models, String className, String fieldName) { + models.getClass(className).customizeAst(ast -> { + ast.addImport("com.azure.core.util.BinaryData"); + ast.getClassByName(className).ifPresent(clazz -> { + clazz.getFieldByName(fieldName).get().getVariable(0).setType("List"); + clazz.getMethodsByName("get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)) + .forEach(method -> method.setType("List")); + clazz.getMethodsByName("set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)) + .forEach(method -> method.getParameter(0).setType("List")); + + MethodDeclaration toJson = clazz.getMethodsByName("toJson").get(0); + toJson.setBody(StaticJavaParser.parseBlock(toJson.getBody().get().toString() + .replace("(writer, element) -> writer.writeUntyped(element)", + "(writer, element) -> element.writeTo(writer)"))); + + MethodDeclaration fromJson = clazz.getMethodsByName("fromJson").get(0); + String fromJsonToReplace = "List " + fieldName + " = reader.readArray(reader1 -> reader1.readUntyped());"; + String fromJsonReplacement = "List " + fieldName + " = reader.readArray(reader1 -> " + + "(reader1.currentToken() == JsonToken.NULL) ? null : BinaryData.fromObject(reader1.readUntyped()));"; + fromJson.setBody(StaticJavaParser.parseBlock(fromJson.getBody().get().toString() + .replace(fromJsonToReplace, fromJsonReplacement))); }); + }); } - private void renameLogMirrorSasUriProperty(LibraryCustomization libraryCustomization, Logger logger) { - logger.info("Renaming logMirrorSasUri property"); - // renaming the model property - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerServiceProperties") - .getProperty("logMirrorSasUri") - .rename("logMirrorSasUrl"); - - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerServiceProperties") - .getMethod("setLogMirrorSasUrl") - .replaceParameters("String logMirrorSasUrl") - .replaceBody("this.logMirrorSasUrl = logMirrorSasUrl;return this;"); - - JavadocCustomization getMethodJavaDoc = libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerServiceProperties") - .getMethod("getLogMirrorSasUrl") - .getJavadoc(); - getMethodJavaDoc.setDescription(getMethodJavaDoc.getDescription().replace("Uri", "Url")); - getMethodJavaDoc.setReturn(getMethodJavaDoc.getReturn().replace("Uri", "Url")); - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerServiceProperties") - .getMethod("getLogMirrorSasUrl") - .getJavadoc() - .replace(getMethodJavaDoc); - - JavadocCustomization setMethodJavaDoc = libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerServiceProperties") - .getMethod("setLogMirrorSasUrl") - .getJavadoc(); - setMethodJavaDoc.setDescription(getMethodJavaDoc.getDescription().replace("Uri", "Url")); - setMethodJavaDoc.setParam("logMirrorSasUrl", setMethodJavaDoc.getParams().get("logMirrorSasUri").replace("Uri", "Url")); - setMethodJavaDoc.removeParam("logMirrorSasUri"); - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerServiceProperties") - .getMethod("getLogMirrorSasUrl") - .getJavadoc() - .replace(getMethodJavaDoc); - } - - private void hideMethods(LibraryCustomization libraryCustomization, Logger logger) { - Map> adminModelsMap = new HashMap>(); - adminModelsMap.put("PersonalizerPolicyResultSummary", Arrays.asList("setNonZeroProbability")); - adminModelsMap.put("PersonalizerEvaluation", Arrays.asList("setEvaluationType", "getJobId", "setPolicyResults", "setFeatureImportance", "setOptimalPolicy", "setCreationTime")); - adminModelsMap.forEach((className, methodNames) -> makeMethodPrivate(libraryCustomization, "com.azure.ai.personalizer.administration.models", className, methodNames, logger)); + private void hideMethods(PackageCustomization adminModels, PackageCustomization models) { + makeMethodPrivate(adminModels, "PersonalizerPolicyResultSummary", "setNonZeroProbability"); + makeMethodPrivate(adminModels, "PersonalizerEvaluation", "setEvaluationType", "getJobId", "setPolicyResults", + "setFeatureImportance", "setOptimalPolicy", "setCreationTime"); - Map> modelsMap = new HashMap>(); - modelsMap.put("PersonalizerSlotResult", Arrays.asList("setId")); - modelsMap.put("PersonalizerError", Arrays.asList("setCode", "setMessage", "setTarget", "setDetails")); - modelsMap.forEach((className, methodNames) -> makeMethodPrivate(libraryCustomization, "com.azure.ai.personalizer.models", className, methodNames, logger)); + makeMethodPrivate(models, "PersonalizerSlotResult", "setId"); + makeMethodPrivate(models, "PersonalizerError", "setCode", "setMessage", "setTarget", "setDetails"); } - private void makeMethodPrivate(LibraryCustomization libraryCustomization, String packageName, String className, List methodNames, Logger logger) { - methodNames.forEach(methodName -> { - libraryCustomization - .getClass(packageName, className) - .getMethod(methodName) - .setModifier(0); - }); + private void makeMethodPrivate(PackageCustomization customization, String className, String... methodNames) { + customization.getClass(className).customizeAst(ast -> ast.getClassByName(className).ifPresent(clazz -> { + for (String methodName : methodNames) { + clazz.getMethodsByName(methodName).forEach(NodeWithModifiers::setModifiers); + } + })); } - private void renameOfflineExperimentationProperties(LibraryCustomization libraryCustomization, Logger logger) { - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerEvaluationOptions") - .getMethod("isEnableOfflineExperimentation") - .rename("isOfflineExperimentationEnabled"); + private void returnBaseClassTypesForMethodReturnValues(PackageCustomization adminModels) { + adminModels.getClass("PersonalizerPolicyResult") + .customizeAst(ast -> ast.getClassByName("PersonalizerPolicyResult") + .ifPresent(clazz -> clazz.getMethodsByName("getTotalSummary") + .forEach(method -> method.setType("PersonalizerPolicyResultSummary")))); - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerEvaluationOptions") - .getMethod("setEnableOfflineExperimentation") - .rename("setOfflineExperimentationEnabled"); + adminModels.getClass("PersonalizerLogProperties") + .customizeAst(ast -> ast.getClassByName("PersonalizerLogProperties") + .ifPresent(clazz -> clazz.getMethodsByName("getDateRange") + .forEach(method -> method.setType("PersonalizerDateRange")))); } - private void returnBaseClassTypesForMethodReturnValues(LibraryCustomization libraryCustomization, Logger logger) { - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerPolicyResult") - .getMethod("getTotalSummary") - .setReturnType("PersonalizerPolicyResultSummary", "returnValue"); + private void hideClasses(PackageCustomization adminModels, PackageCustomization models) { + makeClassAndConstructorPackagePrivate(adminModels, "PersonalizerPolicyResultTotalSummary"); + makeClassAndConstructorPackagePrivate(adminModels, "PersonalizerLogPropertiesDateRange"); - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerLogProperties") - .getMethod("getDateRange") - .setReturnType("PersonalizerDateRange", "returnValue"); + makeClassAndConstructorPackagePrivate(models, "ServiceStatus"); } - private void hideClasses(LibraryCustomization libraryCustomization, Logger logger) { - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerPolicyResultTotalSummary") - .setModifier(0); - - libraryCustomization - .getClass("com.azure.ai.personalizer.administration.models", "PersonalizerLogPropertiesDateRange") - .setModifier(0); + private static void makeClassAndConstructorPackagePrivate(PackageCustomization customization, String className) { + customization.getClass(className).customizeAst(ast -> ast.getClassByName(className).ifPresent(clazz -> { + clazz.setModifiers(); + clazz.getDefaultConstructor().get().setModifiers(); + })); } } diff --git a/sdk/search/azure-search-documents/pom.xml b/sdk/search/azure-search-documents/pom.xml index 88c267339bc26..bb475757c04f3 100644 --- a/sdk/search/azure-search-documents/pom.xml +++ b/sdk/search/azure-search-documents/pom.xml @@ -106,7 +106,7 @@ com.azure azure-ai-openai - 1.0.0-beta.11 + 1.0.0-beta.12 test diff --git a/sdk/translation/azure-ai-translation-document/pom.xml b/sdk/translation/azure-ai-translation-document/pom.xml index 576468ab1a457..8a5ef4620f95c 100644 --- a/sdk/translation/azure-ai-translation-document/pom.xml +++ b/sdk/translation/azure-ai-translation-document/pom.xml @@ -47,6 +47,11 @@ Code generated by Microsoft (R) TypeSpec Code Generator. + + com.azure + azure-json + 1.3.0 + com.azure azure-core diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/BatchRequest.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/BatchRequest.java index 4bba4cb0052eb..924ce8537b5cd 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/BatchRequest.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/BatchRequest.java @@ -5,35 +5,35 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; -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; import java.util.List; /** * Definition for the input batch translation request. */ @Fluent -public final class BatchRequest { +public final class BatchRequest implements JsonSerializable { /* * Source of the input documents */ @Generated - @JsonProperty(value = "source") private final SourceInput source; /* * Location of the destination for the output */ @Generated - @JsonProperty(value = "targets") private final List targets; /* * Storage type of the input documents source string */ @Generated - @JsonProperty(value = "storageType") private StorageInputType storageType; /** @@ -43,9 +43,7 @@ public final class BatchRequest { * @param targets the targets value to set. */ @Generated - @JsonCreator - public BatchRequest(@JsonProperty(value = "source") SourceInput source, - @JsonProperty(value = "targets") List targets) { + public BatchRequest(SourceInput source, List targets) { this.source = source; this.targets = targets; } @@ -91,4 +89,51 @@ public BatchRequest setStorageType(StorageInputType storageType) { this.storageType = storageType; return this; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("source", this.source); + jsonWriter.writeArrayField("targets", this.targets, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("storageType", this.storageType == null ? null : this.storageType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BatchRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BatchRequest 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 BatchRequest. + */ + @Generated + public static BatchRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SourceInput source = null; + List targets = null; + StorageInputType storageType = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("source".equals(fieldName)) { + source = SourceInput.fromJson(reader); + } else if ("targets".equals(fieldName)) { + targets = reader.readArray(reader1 -> TargetInput.fromJson(reader1)); + } else if ("storageType".equals(fieldName)) { + storageType = StorageInputType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + BatchRequest deserializedBatchRequest = new BatchRequest(source, targets); + deserializedBatchRequest.storageType = storageType; + return deserializedBatchRequest; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentFilter.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentFilter.java index 8c528b76b0f25..b383cbfd521ab 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentFilter.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentFilter.java @@ -5,13 +5,17 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -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; /** * Document filter. */ @Fluent -public final class DocumentFilter { +public final class DocumentFilter implements JsonSerializable { /* * A case-sensitive prefix string to filter documents in the source path for @@ -20,7 +24,6 @@ public final class DocumentFilter { * to restrict sub folders for translation. */ @Generated - @JsonProperty(value = "prefix") private String prefix; /* @@ -29,7 +32,6 @@ public final class DocumentFilter { * This is most often use for file extensions */ @Generated - @JsonProperty(value = "suffix") private String suffix; /** @@ -92,4 +94,43 @@ public DocumentFilter setSuffix(String suffix) { this.suffix = suffix; return this; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prefix", this.prefix); + jsonWriter.writeStringField("suffix", this.suffix); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentFilter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentFilter 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 DocumentFilter. + */ + @Generated + public static DocumentFilter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DocumentFilter deserializedDocumentFilter = new DocumentFilter(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("prefix".equals(fieldName)) { + deserializedDocumentFilter.prefix = reader.getString(); + } else if ("suffix".equals(fieldName)) { + deserializedDocumentFilter.suffix = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedDocumentFilter; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentStatus.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentStatus.java index 043332f85da8d..a53ba0468a49b 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentStatus.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/DocumentStatus.java @@ -5,56 +5,55 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +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 java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; /** * Document Status Response. */ @Immutable -public final class DocumentStatus { +public final class DocumentStatus implements JsonSerializable { /* * Location of the document or folder */ @Generated - @JsonProperty(value = "path") private String path; /* * Location of the source document */ @Generated - @JsonProperty(value = "sourcePath") private final String sourcePath; /* * Operation created date time */ @Generated - @JsonProperty(value = "createdDateTimeUtc") private final OffsetDateTime createdDateTimeUtc; /* * Date time in which the operation's status has been updated */ @Generated - @JsonProperty(value = "lastActionDateTimeUtc") private final OffsetDateTime lastActionDateTimeUtc; /* * List of possible statuses for job or document */ @Generated - @JsonProperty(value = "status") private final Status status; /* * To language */ @Generated - @JsonProperty(value = "to") private final String to; /* @@ -62,28 +61,24 @@ public final class DocumentStatus { * inner error with more descriptive details. */ @Generated - @JsonProperty(value = "error") private TranslationError error; /* * Progress of the translation if available */ @Generated - @JsonProperty(value = "progress") private final double progress; /* * Document Id */ @Generated - @JsonProperty(value = "id") private final String id; /* * Character charged by the API */ @Generated - @JsonProperty(value = "characterCharged") private Integer characterCharged; /** @@ -98,12 +93,8 @@ public final class DocumentStatus { * @param id the id value to set. */ @Generated - @JsonCreator - private DocumentStatus(@JsonProperty(value = "sourcePath") String sourcePath, - @JsonProperty(value = "createdDateTimeUtc") OffsetDateTime createdDateTimeUtc, - @JsonProperty(value = "lastActionDateTimeUtc") OffsetDateTime lastActionDateTimeUtc, - @JsonProperty(value = "status") Status status, @JsonProperty(value = "to") String to, - @JsonProperty(value = "progress") double progress, @JsonProperty(value = "id") String id) { + private DocumentStatus(String sourcePath, OffsetDateTime createdDateTimeUtc, OffsetDateTime lastActionDateTimeUtc, + Status status, String to, double progress, String id) { this.sourcePath = sourcePath; this.createdDateTimeUtc = createdDateTimeUtc; this.lastActionDateTimeUtc = lastActionDateTimeUtc; @@ -213,4 +204,90 @@ public String getId() { public Integer getCharacterCharged() { return this.characterCharged; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("sourcePath", this.sourcePath); + jsonWriter.writeStringField("createdDateTimeUtc", + this.createdDateTimeUtc == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTimeUtc)); + jsonWriter.writeStringField("lastActionDateTimeUtc", + this.lastActionDateTimeUtc == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastActionDateTimeUtc)); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("to", this.to); + jsonWriter.writeDoubleField("progress", this.progress); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("path", this.path); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeNumberField("characterCharged", this.characterCharged); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentStatus 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 DocumentStatus. + */ + @Generated + public static DocumentStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String sourcePath = null; + OffsetDateTime createdDateTimeUtc = null; + OffsetDateTime lastActionDateTimeUtc = null; + Status status = null; + String to = null; + double progress = 0.0; + String id = null; + String path = null; + TranslationError error = null; + Integer characterCharged = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("sourcePath".equals(fieldName)) { + sourcePath = reader.getString(); + } else if ("createdDateTimeUtc".equals(fieldName)) { + createdDateTimeUtc = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("lastActionDateTimeUtc".equals(fieldName)) { + lastActionDateTimeUtc = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("status".equals(fieldName)) { + status = Status.fromString(reader.getString()); + } else if ("to".equals(fieldName)) { + to = reader.getString(); + } else if ("progress".equals(fieldName)) { + progress = reader.getDouble(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("path".equals(fieldName)) { + path = reader.getString(); + } else if ("error".equals(fieldName)) { + error = TranslationError.fromJson(reader); + } else if ("characterCharged".equals(fieldName)) { + characterCharged = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + DocumentStatus deserializedDocumentStatus + = new DocumentStatus(sourcePath, createdDateTimeUtc, lastActionDateTimeUtc, status, to, progress, id); + deserializedDocumentStatus.path = path; + deserializedDocumentStatus.error = error; + deserializedDocumentStatus.characterCharged = characterCharged; + return deserializedDocumentStatus; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormat.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormat.java index 0e0c06e21f783..1cfef04c8bb7a 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormat.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormat.java @@ -5,56 +5,53 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -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; import java.util.List; /** * File Format. */ @Immutable -public final class FileFormat { +public final class FileFormat implements JsonSerializable { /* * Name of the format */ @Generated - @JsonProperty(value = "format") private final String format; /* * Supported file extension for this format */ @Generated - @JsonProperty(value = "fileExtensions") private final List fileExtensions; /* * Supported Content-Types for this format */ @Generated - @JsonProperty(value = "contentTypes") private final List contentTypes; /* * Default version if none is specified */ @Generated - @JsonProperty(value = "defaultVersion") private String defaultVersion; /* * Supported Version */ @Generated - @JsonProperty(value = "versions") private List versions; /* * Supported Type for this format */ @Generated - @JsonProperty(value = "type") private String type; /** @@ -65,10 +62,7 @@ public final class FileFormat { * @param contentTypes the contentTypes value to set. */ @Generated - @JsonCreator - private FileFormat(@JsonProperty(value = "format") String format, - @JsonProperty(value = "fileExtensions") List fileExtensions, - @JsonProperty(value = "contentTypes") List contentTypes) { + private FileFormat(String format, List fileExtensions, List contentTypes) { this.format = format; this.fileExtensions = fileExtensions; this.contentTypes = contentTypes; @@ -133,4 +127,66 @@ public List getVersions() { public String getType() { return this.type; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("format", this.format); + jsonWriter.writeArrayField("fileExtensions", this.fileExtensions, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("contentTypes", this.contentTypes, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("defaultVersion", this.defaultVersion); + jsonWriter.writeArrayField("versions", this.versions, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileFormat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileFormat 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 FileFormat. + */ + @Generated + public static FileFormat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String format = null; + List fileExtensions = null; + List contentTypes = null; + String defaultVersion = null; + List versions = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("format".equals(fieldName)) { + format = reader.getString(); + } else if ("fileExtensions".equals(fieldName)) { + fileExtensions = reader.readArray(reader1 -> reader1.getString()); + } else if ("contentTypes".equals(fieldName)) { + contentTypes = reader.readArray(reader1 -> reader1.getString()); + } else if ("defaultVersion".equals(fieldName)) { + defaultVersion = reader.getString(); + } else if ("versions".equals(fieldName)) { + versions = reader.readArray(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + FileFormat deserializedFileFormat = new FileFormat(format, fileExtensions, contentTypes); + deserializedFileFormat.defaultVersion = defaultVersion; + deserializedFileFormat.versions = versions; + deserializedFileFormat.type = type; + return deserializedFileFormat; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormatType.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormatType.java index b7799d1adc314..3bd5723c13064 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormatType.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/FileFormatType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -42,7 +41,6 @@ public FileFormatType() { * @return the corresponding FileFormatType. */ @Generated - @JsonCreator public static FileFormatType fromString(String name) { return fromString(name, FileFormatType.class); } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Glossary.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Glossary.java index 4ff2bc90b0cbd..c7eeee453b447 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Glossary.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Glossary.java @@ -5,14 +5,17 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; -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; /** * Glossary / translation memory for the request. */ @Fluent -public final class Glossary { +public final class Glossary implements JsonSerializable { /* * Location of the glossary. @@ -23,28 +26,24 @@ public final class Glossary { * language pair is not present in the glossary, it will not be applied */ @Generated - @JsonProperty(value = "glossaryUrl") private final String glossaryUrl; /* * Format */ @Generated - @JsonProperty(value = "format") private final String format; /* * Optional Version. If not specified, default is used. */ @Generated - @JsonProperty(value = "version") private String version; /* * Storage Source */ @Generated - @JsonProperty(value = "storageSource") private StorageSource storageSource; /** @@ -54,9 +53,7 @@ public final class Glossary { * @param format the format value to set. */ @Generated - @JsonCreator - public Glossary(@JsonProperty(value = "glossaryUrl") String glossaryUrl, - @JsonProperty(value = "format") String format) { + public Glossary(String glossaryUrl, String format) { this.glossaryUrl = glossaryUrl; this.format = format; } @@ -129,4 +126,56 @@ public Glossary setStorageSource(StorageSource storageSource) { this.storageSource = storageSource; return this; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("glossaryUrl", this.glossaryUrl); + jsonWriter.writeStringField("format", this.format); + jsonWriter.writeStringField("version", this.version); + jsonWriter.writeStringField("storageSource", this.storageSource == null ? null : this.storageSource.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Glossary from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Glossary 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 Glossary. + */ + @Generated + public static Glossary fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String glossaryUrl = null; + String format = null; + String version = null; + StorageSource storageSource = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("glossaryUrl".equals(fieldName)) { + glossaryUrl = reader.getString(); + } else if ("format".equals(fieldName)) { + format = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("storageSource".equals(fieldName)) { + storageSource = StorageSource.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Glossary deserializedGlossary = new Glossary(glossaryUrl, format); + deserializedGlossary.version = version; + deserializedGlossary.storageSource = storageSource; + return deserializedGlossary; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/InnerTranslationError.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/InnerTranslationError.java index 395583e428bf4..4d55aadfdab32 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/InnerTranslationError.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/InnerTranslationError.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -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; /** * New Inner Error format which conforms to Cognitive Services API Guidelines @@ -17,20 +20,18 @@ * details(key value pair), inner error(this can be nested). */ @Immutable -public final class InnerTranslationError { +public final class InnerTranslationError implements JsonSerializable { /* * Gets code error string. */ @Generated - @JsonProperty(value = "code") private final String code; /* * Gets high level error message. */ @Generated - @JsonProperty(value = "message") private final String message; /* @@ -39,7 +40,6 @@ public final class InnerTranslationError { * "document id" in case of invalid document. */ @Generated - @JsonProperty(value = "target", access = JsonProperty.Access.WRITE_ONLY) private String target; /* @@ -52,7 +52,6 @@ public final class InnerTranslationError { * details(key value pair), inner error(this can be nested). */ @Generated - @JsonProperty(value = "innerError") private InnerTranslationError innerError; /** @@ -62,9 +61,7 @@ public final class InnerTranslationError { * @param message the message value to set. */ @Generated - @JsonCreator - private InnerTranslationError(@JsonProperty(value = "code") String code, - @JsonProperty(value = "message") String message) { + private InnerTranslationError(String code, String message) { this.code = code; this.message = message; } @@ -115,4 +112,55 @@ public String getTarget() { public InnerTranslationError getInnerError() { return this.innerError; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code); + jsonWriter.writeStringField("message", this.message); + jsonWriter.writeJsonField("innerError", this.innerError); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerTranslationError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerTranslationError 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 InnerTranslationError. + */ + @Generated + public static InnerTranslationError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String code = null; + String message = null; + String target = null; + InnerTranslationError innerError = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code".equals(fieldName)) { + code = reader.getString(); + } else if ("message".equals(fieldName)) { + message = reader.getString(); + } else if ("target".equals(fieldName)) { + target = reader.getString(); + } else if ("innerError".equals(fieldName)) { + innerError = InnerTranslationError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + InnerTranslationError deserializedInnerTranslationError = new InnerTranslationError(code, message); + deserializedInnerTranslationError.target = target; + deserializedInnerTranslationError.innerError = innerError; + return deserializedInnerTranslationError; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SourceInput.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SourceInput.java index da4bb7e4c994f..d9dc722b5fc86 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SourceInput.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SourceInput.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; -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; /** * Source of the input documents. */ @Fluent -public final class SourceInput { +public final class SourceInput implements JsonSerializable { /* * Location of the folder / container or single file with your documents */ @Generated - @JsonProperty(value = "sourceUrl") private final String sourceUrl; /* * Document filter */ @Generated - @JsonProperty(value = "filter") private DocumentFilter filter; /* @@ -33,14 +34,12 @@ public final class SourceInput { * If none is specified, we will perform auto detect on the document */ @Generated - @JsonProperty(value = "language") private String language; /* * Storage Source */ @Generated - @JsonProperty(value = "storageSource") private StorageSource storageSource; /** @@ -49,8 +48,7 @@ public final class SourceInput { * @param sourceUrl the sourceUrl value to set. */ @Generated - @JsonCreator - public SourceInput(@JsonProperty(value = "sourceUrl") String sourceUrl) { + public SourceInput(String sourceUrl) { this.sourceUrl = sourceUrl; } @@ -131,4 +129,57 @@ public SourceInput setStorageSource(StorageSource storageSource) { this.storageSource = storageSource; return this; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("sourceUrl", this.sourceUrl); + jsonWriter.writeJsonField("filter", this.filter); + jsonWriter.writeStringField("language", this.language); + jsonWriter.writeStringField("storageSource", this.storageSource == null ? null : this.storageSource.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SourceInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SourceInput 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 SourceInput. + */ + @Generated + public static SourceInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String sourceUrl = null; + DocumentFilter filter = null; + String language = null; + StorageSource storageSource = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("sourceUrl".equals(fieldName)) { + sourceUrl = reader.getString(); + } else if ("filter".equals(fieldName)) { + filter = DocumentFilter.fromJson(reader); + } else if ("language".equals(fieldName)) { + language = reader.getString(); + } else if ("storageSource".equals(fieldName)) { + storageSource = StorageSource.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + SourceInput deserializedSourceInput = new SourceInput(sourceUrl); + deserializedSourceInput.filter = filter; + deserializedSourceInput.language = language; + deserializedSourceInput.storageSource = storageSource; + return deserializedSourceInput; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StartTranslationDetails.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StartTranslationDetails.java index acf6bd7bdceee..6b803a999255c 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StartTranslationDetails.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StartTranslationDetails.java @@ -5,21 +5,23 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -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; import java.util.List; /** * Translation job submission batch request. */ @Immutable -public final class StartTranslationDetails { +public final class StartTranslationDetails implements JsonSerializable { /* * The input list of documents or folders containing documents */ @Generated - @JsonProperty(value = "inputs") private final List inputs; /** @@ -28,8 +30,7 @@ public final class StartTranslationDetails { * @param inputs the inputs value to set. */ @Generated - @JsonCreator - public StartTranslationDetails(@JsonProperty(value = "inputs") List inputs) { + public StartTranslationDetails(List inputs) { this.inputs = inputs; } @@ -42,4 +43,41 @@ public StartTranslationDetails(@JsonProperty(value = "inputs") List getInputs() { return this.inputs; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("inputs", this.inputs, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StartTranslationDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StartTranslationDetails 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 StartTranslationDetails. + */ + @Generated + public static StartTranslationDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List inputs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("inputs".equals(fieldName)) { + inputs = reader.readArray(reader1 -> BatchRequest.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new StartTranslationDetails(inputs); + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Status.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Status.java index 265bc4f25004c..5d8231a165b1f 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Status.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/Status.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -72,7 +71,6 @@ public Status() { * @return the corresponding Status. */ @Generated - @JsonCreator public static Status fromString(String name) { return fromString(name, Status.class); } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StatusSummary.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StatusSummary.java index 8ee1f0f84bcf0..9cda4af83b0ad 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StatusSummary.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StatusSummary.java @@ -5,62 +5,58 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -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; /** * Status Summary. */ @Immutable -public final class StatusSummary { +public final class StatusSummary implements JsonSerializable { /* * Total count */ @Generated - @JsonProperty(value = "total") private final int total; /* * Failed count */ @Generated - @JsonProperty(value = "failed") private final int failed; /* * Number of Success */ @Generated - @JsonProperty(value = "success") private final int success; /* * Number of in progress */ @Generated - @JsonProperty(value = "inProgress") private final int inProgress; /* * Count of not yet started */ @Generated - @JsonProperty(value = "notYetStarted") private final int notYetStarted; /* * Number of cancelled */ @Generated - @JsonProperty(value = "cancelled") private final int cancelled; /* * Total characters charged by the API */ @Generated - @JsonProperty(value = "totalCharacterCharged") private final long totalCharacterCharged; /** @@ -75,11 +71,8 @@ public final class StatusSummary { * @param totalCharacterCharged the totalCharacterCharged value to set. */ @Generated - @JsonCreator - private StatusSummary(@JsonProperty(value = "total") int total, @JsonProperty(value = "failed") int failed, - @JsonProperty(value = "success") int success, @JsonProperty(value = "inProgress") int inProgress, - @JsonProperty(value = "notYetStarted") int notYetStarted, @JsonProperty(value = "cancelled") int cancelled, - @JsonProperty(value = "totalCharacterCharged") long totalCharacterCharged) { + private StatusSummary(int total, int failed, int success, int inProgress, int notYetStarted, int cancelled, + long totalCharacterCharged) { this.total = total; this.failed = failed; this.success = success; @@ -158,4 +151,66 @@ public int getCancelled() { public long getTotalCharacterCharged() { return this.totalCharacterCharged; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("total", this.total); + jsonWriter.writeIntField("failed", this.failed); + jsonWriter.writeIntField("success", this.success); + jsonWriter.writeIntField("inProgress", this.inProgress); + jsonWriter.writeIntField("notYetStarted", this.notYetStarted); + jsonWriter.writeIntField("cancelled", this.cancelled); + jsonWriter.writeLongField("totalCharacterCharged", this.totalCharacterCharged); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StatusSummary from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StatusSummary 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 StatusSummary. + */ + @Generated + public static StatusSummary fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int total = 0; + int failed = 0; + int success = 0; + int inProgress = 0; + int notYetStarted = 0; + int cancelled = 0; + long totalCharacterCharged = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("total".equals(fieldName)) { + total = reader.getInt(); + } else if ("failed".equals(fieldName)) { + failed = reader.getInt(); + } else if ("success".equals(fieldName)) { + success = reader.getInt(); + } else if ("inProgress".equals(fieldName)) { + inProgress = reader.getInt(); + } else if ("notYetStarted".equals(fieldName)) { + notYetStarted = reader.getInt(); + } else if ("cancelled".equals(fieldName)) { + cancelled = reader.getInt(); + } else if ("totalCharacterCharged".equals(fieldName)) { + totalCharacterCharged = reader.getLong(); + } else { + reader.skipChildren(); + } + } + return new StatusSummary(total, failed, success, inProgress, notYetStarted, cancelled, + totalCharacterCharged); + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageInputType.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageInputType.java index 5b64022da1a73..d70a941d7fc2e 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageInputType.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageInputType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -42,7 +41,6 @@ public StorageInputType() { * @return the corresponding StorageInputType. */ @Generated - @JsonCreator public static StorageInputType fromString(String name) { return fromString(name, StorageInputType.class); } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageSource.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageSource.java index fd7594355d9fa..5309dc7d4acbe 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageSource.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/StorageSource.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -36,7 +35,6 @@ public StorageSource() { * @return the corresponding StorageSource. */ @Generated - @JsonCreator public static StorageSource fromString(String name) { return fromString(name, StorageSource.class); } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SupportedFileFormats.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SupportedFileFormats.java index 9cbea04bacfed..a905fea5363c0 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SupportedFileFormats.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/SupportedFileFormats.java @@ -5,21 +5,23 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -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; import java.util.List; /** * List of supported file formats. */ @Immutable -public final class SupportedFileFormats { +public final class SupportedFileFormats implements JsonSerializable { /* * list of objects */ @Generated - @JsonProperty(value = "value") private final List value; /** @@ -28,8 +30,7 @@ public final class SupportedFileFormats { * @param value the value value to set. */ @Generated - @JsonCreator - private SupportedFileFormats(@JsonProperty(value = "value") List value) { + private SupportedFileFormats(List value) { this.value = value; } @@ -42,4 +43,41 @@ private SupportedFileFormats(@JsonProperty(value = "value") List val public List getValue() { return this.value; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SupportedFileFormats from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SupportedFileFormats 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 SupportedFileFormats. + */ + @Generated + public static SupportedFileFormats fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("value".equals(fieldName)) { + value = reader.readArray(reader1 -> FileFormat.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new SupportedFileFormats(value); + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TargetInput.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TargetInput.java index 30b57494c9915..14a8e5e16f96f 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TargetInput.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TargetInput.java @@ -5,49 +5,47 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; -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; import java.util.List; /** * Destination for the finished translated documents. */ @Fluent -public final class TargetInput { +public final class TargetInput implements JsonSerializable { /* * Location of the folder / container with your documents */ @Generated - @JsonProperty(value = "targetUrl") private final String targetUrl; /* * Category / custom system for translation request */ @Generated - @JsonProperty(value = "category") private String category; /* * Target Language */ @Generated - @JsonProperty(value = "language") private final String language; /* * List of Glossary */ @Generated - @JsonProperty(value = "glossaries") private List glossaries; /* * Storage Source */ @Generated - @JsonProperty(value = "storageSource") private StorageSource storageSource; /** @@ -57,9 +55,7 @@ public final class TargetInput { * @param language the language value to set. */ @Generated - @JsonCreator - public TargetInput(@JsonProperty(value = "targetUrl") String targetUrl, - @JsonProperty(value = "language") String language) { + public TargetInput(String targetUrl, String language) { this.targetUrl = targetUrl; this.language = language; } @@ -149,4 +145,61 @@ public TargetInput setStorageSource(StorageSource storageSource) { this.storageSource = storageSource; return this; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetUrl", this.targetUrl); + jsonWriter.writeStringField("language", this.language); + jsonWriter.writeStringField("category", this.category); + jsonWriter.writeArrayField("glossaries", this.glossaries, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("storageSource", this.storageSource == null ? null : this.storageSource.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TargetInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TargetInput 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 TargetInput. + */ + @Generated + public static TargetInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String targetUrl = null; + String language = null; + String category = null; + List glossaries = null; + StorageSource storageSource = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("targetUrl".equals(fieldName)) { + targetUrl = reader.getString(); + } else if ("language".equals(fieldName)) { + language = reader.getString(); + } else if ("category".equals(fieldName)) { + category = reader.getString(); + } else if ("glossaries".equals(fieldName)) { + glossaries = reader.readArray(reader1 -> Glossary.fromJson(reader1)); + } else if ("storageSource".equals(fieldName)) { + storageSource = StorageSource.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + TargetInput deserializedTargetInput = new TargetInput(targetUrl, language); + deserializedTargetInput.category = category; + deserializedTargetInput.glossaries = glossaries; + deserializedTargetInput.storageSource = storageSource; + return deserializedTargetInput; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationError.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationError.java index aa7f453e4dab6..6b3c40a66c2c3 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationError.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationError.java @@ -5,28 +5,29 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -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; /** * This contains an outer error with error code, message, details, target and an * inner error with more descriptive details. */ @Immutable -public final class TranslationError { +public final class TranslationError implements JsonSerializable { /* * Enums containing high level error codes. */ @Generated - @JsonProperty(value = "code") private final TranslationErrorCode code; /* * Gets high level error message. */ @Generated - @JsonProperty(value = "message") private final String message; /* @@ -35,7 +36,6 @@ public final class TranslationError { * "document id" in case of invalid document. */ @Generated - @JsonProperty(value = "target", access = JsonProperty.Access.WRITE_ONLY) private String target; /* @@ -48,7 +48,6 @@ public final class TranslationError { * details(key value pair), inner error(this can be nested). */ @Generated - @JsonProperty(value = "innerError") private InnerTranslationError innerError; /** @@ -58,9 +57,7 @@ public final class TranslationError { * @param message the message value to set. */ @Generated - @JsonCreator - private TranslationError(@JsonProperty(value = "code") TranslationErrorCode code, - @JsonProperty(value = "message") String message) { + private TranslationError(TranslationErrorCode code, String message) { this.code = code; this.message = message; } @@ -111,4 +108,55 @@ public String getTarget() { public InnerTranslationError getInnerError() { return this.innerError; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); + jsonWriter.writeStringField("message", this.message); + jsonWriter.writeJsonField("innerError", this.innerError); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TranslationError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslationError 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 TranslationError. + */ + @Generated + public static TranslationError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TranslationErrorCode code = null; + String message = null; + String target = null; + InnerTranslationError innerError = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code".equals(fieldName)) { + code = TranslationErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + message = reader.getString(); + } else if ("target".equals(fieldName)) { + target = reader.getString(); + } else if ("innerError".equals(fieldName)) { + innerError = InnerTranslationError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + TranslationError deserializedTranslationError = new TranslationError(code, message); + deserializedTranslationError.target = target; + deserializedTranslationError.innerError = innerError; + return deserializedTranslationError; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationErrorCode.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationErrorCode.java index 6aca687460086..43a2d2e65790d 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationErrorCode.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationErrorCode.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -72,7 +71,6 @@ public TranslationErrorCode() { * @return the corresponding TranslationErrorCode. */ @Generated - @JsonCreator public static TranslationErrorCode fromString(String name) { return fromString(name, TranslationErrorCode.class); } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationStatus.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationStatus.java index 5deff67c98f34..7e4657ca7a3bf 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationStatus.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/models/TranslationStatus.java @@ -5,42 +5,43 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +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 java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; /** * Translation job status response. */ @Immutable -public final class TranslationStatus { +public final class TranslationStatus implements JsonSerializable { /* * Id of the operation. */ @Generated - @JsonProperty(value = "id") private final String id; /* * Operation created date time */ @Generated - @JsonProperty(value = "createdDateTimeUtc") private final OffsetDateTime createdDateTimeUtc; /* * Date time in which the operation's status has been updated */ @Generated - @JsonProperty(value = "lastActionDateTimeUtc") private final OffsetDateTime lastActionDateTimeUtc; /* * List of possible statuses for job or document */ @Generated - @JsonProperty(value = "status") private final Status status; /* @@ -48,14 +49,12 @@ public final class TranslationStatus { * inner error with more descriptive details. */ @Generated - @JsonProperty(value = "error") private TranslationError error; /* * Status Summary */ @Generated - @JsonProperty(value = "summary") private final StatusSummary summary; /** @@ -68,11 +67,8 @@ public final class TranslationStatus { * @param summary the summary value to set. */ @Generated - @JsonCreator - private TranslationStatus(@JsonProperty(value = "id") String id, - @JsonProperty(value = "createdDateTimeUtc") OffsetDateTime createdDateTimeUtc, - @JsonProperty(value = "lastActionDateTimeUtc") OffsetDateTime lastActionDateTimeUtc, - @JsonProperty(value = "status") Status status, @JsonProperty(value = "summary") StatusSummary summary) { + private TranslationStatus(String id, OffsetDateTime createdDateTimeUtc, OffsetDateTime lastActionDateTimeUtc, + Status status, StatusSummary summary) { this.id = id; this.createdDateTimeUtc = createdDateTimeUtc; this.lastActionDateTimeUtc = lastActionDateTimeUtc; @@ -140,4 +136,72 @@ public TranslationError getError() { public StatusSummary getSummary() { return this.summary; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("createdDateTimeUtc", + this.createdDateTimeUtc == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTimeUtc)); + jsonWriter.writeStringField("lastActionDateTimeUtc", + this.lastActionDateTimeUtc == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastActionDateTimeUtc)); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("summary", this.summary); + jsonWriter.writeJsonField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TranslationStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslationStatus 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 TranslationStatus. + */ + @Generated + public static TranslationStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdDateTimeUtc = null; + OffsetDateTime lastActionDateTimeUtc = null; + Status status = null; + StatusSummary summary = null; + TranslationError error = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("createdDateTimeUtc".equals(fieldName)) { + createdDateTimeUtc = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("lastActionDateTimeUtc".equals(fieldName)) { + lastActionDateTimeUtc = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("status".equals(fieldName)) { + status = Status.fromString(reader.getString()); + } else if ("summary".equals(fieldName)) { + summary = StatusSummary.fromJson(reader); + } else if ("error".equals(fieldName)) { + error = TranslationError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + TranslationStatus deserializedTranslationStatus + = new TranslationStatus(id, createdDateTimeUtc, lastActionDateTimeUtc, status, summary); + deserializedTranslationStatus.error = error; + return deserializedTranslationStatus; + }); + } } diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/module-info.java b/sdk/translation/azure-ai-translation-document/src/main/java/module-info.java index 8c729629b0136..298aa758544c5 100644 --- a/sdk/translation/azure-ai-translation-document/src/main/java/module-info.java +++ b/sdk/translation/azure-ai-translation-document/src/main/java/module-info.java @@ -8,5 +8,5 @@ exports com.azure.ai.translation.document; exports com.azure.ai.translation.document.models; - opens com.azure.ai.translation.document.models to com.azure.core, com.fasterxml.jackson.databind; + opens com.azure.ai.translation.document.models to com.azure.core; } diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/CancelACurrentlyProcessingOrQueuedTranslation.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/CancelACurrentlyProcessingOrQueuedTranslation.java new file mode 100644 index 0000000000000..2dfca6b0b2773 --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/CancelACurrentlyProcessingOrQueuedTranslation.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.TranslationStatus; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class CancelACurrentlyProcessingOrQueuedTranslation { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.canceltranslation.cancelacurrentlyprocessingorqueuedtranslation + TranslationStatus response + = documentTranslationClient.cancelTranslation("727BF148-F327-47A0-9481-ABAE6362F11E"); + // END:com.azure.ai.translation.document.generated.canceltranslation.cancelacurrentlyprocessingorqueuedtranslation + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsAListOfBatchRequestsSubmittedAndTheStatusForEachRequest.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsAListOfBatchRequestsSubmittedAndTheStatusForEachRequest.java new file mode 100644 index 0000000000000..17703e5ba71fe --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsAListOfBatchRequestsSubmittedAndTheStatusForEachRequest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.TranslationStatus; +import com.azure.core.http.rest.PagedIterable; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class ReturnsAListOfBatchRequestsSubmittedAndTheStatusForEachRequest { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.gettranslationsstatus.returnsalistofbatchrequestssubmittedandthestatusforeachrequest + PagedIterable response = documentTranslationClient.getTranslationsStatus(1, 0, + Arrays.asList("273622bd-835c-4946-9798-fd8f19f6bbf2"), Arrays.asList("Succeeded"), + OffsetDateTime.parse("2021-03-23T07:03:38.0136316Z"), OffsetDateTime.parse("2021-03-25T07:03:38.0136316Z"), + Arrays.asList("CreatedDateTime asc")); + // END:com.azure.ai.translation.document.generated.gettranslationsstatus.returnsalistofbatchrequestssubmittedandthestatusforeachrequest + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsAListOfSupportedDocumentFormats.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsAListOfSupportedDocumentFormats.java new file mode 100644 index 0000000000000..e579b82fab200 --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsAListOfSupportedDocumentFormats.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.FileFormatType; +import com.azure.ai.translation.document.models.SupportedFileFormats; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ReturnsAListOfSupportedDocumentFormats { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.getsupportedformats.returnsalistofsupporteddocumentformats + SupportedFileFormats response = documentTranslationClient.getSupportedFormats(FileFormatType.DOCUMENT); + // END:com.azure.ai.translation.document.generated.getsupportedformats.returnsalistofsupporteddocumentformats + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusForABatchDocumentTranslationRequest.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusForABatchDocumentTranslationRequest.java new file mode 100644 index 0000000000000..070552b2ffdb7 --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusForABatchDocumentTranslationRequest.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.TranslationStatus; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ReturnsTheStatusForABatchDocumentTranslationRequest { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.gettranslationstatus.returnsthestatusforabatchdocumenttranslationrequest + TranslationStatus response + = documentTranslationClient.getTranslationStatus("727BF148-F327-47A0-9481-ABAE6362F11E"); + // END:com.azure.ai.translation.document.generated.gettranslationstatus.returnsthestatusforabatchdocumenttranslationrequest + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusForAllDocumentsInABatchDocumentTranslationRequest.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusForAllDocumentsInABatchDocumentTranslationRequest.java new file mode 100644 index 0000000000000..c8637b9dc71af --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusForAllDocumentsInABatchDocumentTranslationRequest.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.DocumentStatus; +import com.azure.core.http.rest.PagedIterable; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class ReturnsTheStatusForAllDocumentsInABatchDocumentTranslationRequest { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.getdocumentsstatus.returnsthestatusforalldocumentsinabatchdocumenttranslationrequest + PagedIterable response + = documentTranslationClient.getDocumentsStatus("727BF148-F327-47A0-9481-ABAE6362F11E", 2, 0, + Arrays.asList("273622bd-835c-4946-9798-fd8f19f6bbf2", "511b6a66-a6f8-4640-83e1-48c325e9fa29"), + Arrays.asList("Succeeded"), OffsetDateTime.parse("2021-03-23T07:03:38.0136316Z"), + OffsetDateTime.parse("2021-03-25T07:03:38.0136316Z"), Arrays.asList("CreatedDateTimeUtc asc")); + // END:com.azure.ai.translation.document.generated.getdocumentsstatus.returnsthestatusforalldocumentsinabatchdocumenttranslationrequest + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusOfASingleDocumentInABatchTranslationRequest.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusOfASingleDocumentInABatchTranslationRequest.java new file mode 100644 index 0000000000000..f04860453c6df --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/ReturnsTheStatusOfASingleDocumentInABatchTranslationRequest.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.DocumentStatus; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ReturnsTheStatusOfASingleDocumentInABatchTranslationRequest { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.getdocumentstatus.returnsthestatusofasingledocumentinabatchtranslationrequest + DocumentStatus response = documentTranslationClient.getDocumentStatus("727BF148-F327-47A0-9481-ABAE6362F11E", + "727BF148-F327-47A0-9481-ABAE6362F12F"); + // END:com.azure.ai.translation.document.generated.getdocumentstatus.returnsthestatusofasingledocumentinabatchtranslationrequest + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/SubmitADocumentTranslationRequestToTheDocumentTranslationService.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/SubmitADocumentTranslationRequestToTheDocumentTranslationService.java new file mode 100644 index 0000000000000..f7046d16bb08a --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/SubmitADocumentTranslationRequestToTheDocumentTranslationService.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.DocumentTranslationClient; +import com.azure.ai.translation.document.DocumentTranslationClientBuilder; +import com.azure.ai.translation.document.models.BatchRequest; +import com.azure.ai.translation.document.models.DocumentFilter; +import com.azure.ai.translation.document.models.Glossary; +import com.azure.ai.translation.document.models.SourceInput; +import com.azure.ai.translation.document.models.StartTranslationDetails; +import com.azure.ai.translation.document.models.StorageInputType; +import com.azure.ai.translation.document.models.StorageSource; +import com.azure.ai.translation.document.models.TargetInput; +import com.azure.ai.translation.document.models.TranslationStatus; +import com.azure.core.util.polling.SyncPoller; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +public class SubmitADocumentTranslationRequestToTheDocumentTranslationService { + public static void main(String[] args) { + DocumentTranslationClient documentTranslationClient + = new DocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.starttranslation.submitadocumenttranslationrequesttothedocumenttranslationservice + SyncPoller response + = documentTranslationClient + .beginStartTranslation( + new StartTranslationDetails( + Arrays + .asList(new BatchRequest( + new SourceInput("https://myblob.blob.core.windows.net/sourceContainer") + .setFilter(new DocumentFilter().setPrefix("pre").setSuffix(".txt")) + .setLanguage("en") + .setStorageSource(StorageSource.AZURE_BLOB), + Arrays.asList( + new TargetInput("https://myblob.blob.core.windows.net/destinationContainer1", "fr") + .setCategory("general") + .setGlossaries(Arrays.asList(new Glossary( + "https://myblob.blob.core.windows.net/myglossary/en_fr_glossary.xlf", + "XLIFF").setStorageSource(StorageSource.AZURE_BLOB))) + .setStorageSource(StorageSource.AZURE_BLOB), + new TargetInput("https://myblob.blob.core.windows.net/destinationContainer2", "es") + .setCategory("general") + .setStorageSource(StorageSource.AZURE_BLOB))) + .setStorageType(StorageInputType.FOLDER)))); + // END:com.azure.ai.translation.document.generated.starttranslation.submitadocumenttranslationrequesttothedocumenttranslationservice + } +} diff --git a/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/TranslateASingleDocument.java b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/TranslateASingleDocument.java new file mode 100644 index 0000000000000..cda930d884d6b --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/src/samples/java/com/azure/ai/translation/document/generated/TranslateASingleDocument.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.document.generated; + +import com.azure.ai.translation.document.SingleDocumentTranslationClient; +import com.azure.ai.translation.document.SingleDocumentTranslationClientBuilder; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class TranslateASingleDocument { + public static void main(String[] args) { + SingleDocumentTranslationClient singleDocumentTranslationClient + = new SingleDocumentTranslationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.document.generated.documenttranslate.translateasingledocument + BinaryData response = singleDocumentTranslationClient.documentTranslate("es", null, "en", null, null); + // END:com.azure.ai.translation.document.generated.documenttranslate.translateasingledocument + } +} diff --git a/sdk/translation/azure-ai-translation-document/tsp-location.yaml b/sdk/translation/azure-ai-translation-document/tsp-location.yaml index 7690921cc02fb..0bfd6682e8541 100644 --- a/sdk/translation/azure-ai-translation-document/tsp-location.yaml +++ b/sdk/translation/azure-ai-translation-document/tsp-location.yaml @@ -1,3 +1,3 @@ directory: specification/translation/Azure.AI.DocumentTranslation -commit: 4bf64653380a8582fa070b62ae46b86f2455932e +commit: 08dcb2d13f39910ceab6c50bd08d7d5c12f99bf2 repo: Azure/azure-rest-api-specs