Skip to content

Commit

Permalink
CodeGen from PR 3383 in test-repo-billy/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 12d12592e186a02f280c2f6a28d663d6d96e5aa2 into 152d42215263aa8bd9e2d635120581fff0d14608
  • Loading branch information
SDKAuto committed Oct 29, 2024
1 parent 5a36dcb commit 2b35003
Show file tree
Hide file tree
Showing 27 changed files with 758 additions and 36 deletions.
132 changes: 129 additions & 3 deletions sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,140 @@

## 1.1.0-beta.1 (Unreleased)

### Breaking Changes

#### `models.AddOrUpdateTextBlocklistItemsResult` was not changed
#### `models.AnalyzeImageOutputType` was not changed
#### `implementation.BlocklistClientImpl` was not changed
#### `BlocklistAsyncClient` was not changed
#### `models.AnalyzeTextResult` was not changed
#### `models.TextBlocklistMatch` was not changed
#### `models.AnalyzeImageOptions` was not changed
#### `implementation.ContentSafetyClientImpl$ContentSafetyClientService` was modified* `analyzeImage(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `analyzeTextSync(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `analyzeText(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `analyzeImageSync(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed

#### `models.TextBlocklistItem` was not changed
#### `models.RemoveTextBlocklistItemsOptions` was not changed
#### `implementation.ContentSafetyClientImpl` was not changed
#### `models.AnalyzeTextOutputType` was not changed
#### `implementation.BlocklistClientImpl$BlocklistClientService` was modified* `addOrUpdateBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `removeBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `addOrUpdateBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `removeBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed

#### `models.TextBlocklist` was not changed
#### `models.ImageCategory` was not changed
#### `models.AnalyzeTextOptions` was modified* `getText()` was removed

#### `ContentSafetyAsyncClient` was not changed
#### `ContentSafetyClient` was not changed
#### `implementation.JsonMergePatchHelper$TextBlocklistAccessor` was not changed
#### `models.ImageCategoriesAnalysis` was not changed
#### `models.AnalyzeImageResult` was not changed
#### `models.TextCategory` was not changed
#### `BlocklistClientBuilder` was not changed
#### `models.AddOrUpdateTextBlocklistItemsOptions` was not changed
#### `ContentSafetyClientBuilder` was not changed
#### `implementation.JsonMergePatchHelper` was not changed
#### `ContentSafetyServiceVersion` was not changed
#### `models.ContentSafetyImageData` was not changed
#### `models.TextCategoriesAnalysis` was not changed
#### `BlocklistClient` was not changed
### Features Added

### Breaking Changes
#### `models.AddOrUpdateTextBlocklistItemsResult` was modified

### Bugs Fixed
* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

### Other Changes
#### `BlocklistAsyncClient` was modified

* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added

#### `models.AnalyzeTextResult` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.TextBlocklistMatch` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AnalyzeImageOptions` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `implementation.ContentSafetyClientImpl$ContentSafetyClientService` was modified

* `analyzeImageSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `analyzeText(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `analyzeTextSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `analyzeImage(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added

#### `models.TextBlocklistItem` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `models.RemoveTextBlocklistItemsOptions` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `implementation.BlocklistClientImpl$BlocklistClientService` was modified

* `addOrUpdateBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `addOrUpdateBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `removeBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `removeBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added

#### `models.TextBlocklist` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AnalyzeTextOptions` was modified

* `getText2()` was added
* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `implementation.JsonMergePatchHelper$TextBlocklistAccessor` was modified

* `isJsonMergePatch(models.TextBlocklist)` was added

#### `models.ImageCategoriesAnalysis` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AnalyzeImageResult` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AddOrUpdateTextBlocklistItemsOptions` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `models.ContentSafetyImageData` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.TextCategoriesAnalysis` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `BlocklistClient` was modified

* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added

## 1.0.7 (2024-09-27)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class ContentSafetyAsyncClient {
* <pre>
* {@code
* {
* text: String (Required)
* text2: String (Required)
* categories (Optional): [
* String(Hate/SelfHarm/Sexual/Violence) (Optional)
* ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class ContentSafetyClient {
* <pre>
* {@code
* {
* text: String (Required)
* text2: String (Required)
* categories (Optional): [
* String(Hate/SelfHarm/Sexual/Violence) (Optional)
* ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public Response<BinaryData> analyzeImageWithResponse(BinaryData options, Request
* <pre>
* {@code
* {
* text: String (Required)
* text2: String (Required)
* categories (Optional): [
* String(Hate/SelfHarm/Sexual/Violence) (Optional)
* ]
Expand Down Expand Up @@ -374,7 +374,7 @@ public Mono<Response<BinaryData>> analyzeTextWithResponseAsync(BinaryData option
* <pre>
* {@code
* {
* text: String (Required)
* text2: String (Required)
* categories (Optional): [
* String(Hate/SelfHarm/Sexual/Violence) (Optional)
* ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
@Fluent
public final class AnalyzeTextOptions implements JsonSerializable<AnalyzeTextOptions> {

/*
* The text to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one
* request.
*/
@Generated
private final String text;

/*
* The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories
* will be returned.
Expand Down Expand Up @@ -55,22 +48,11 @@ public final class AnalyzeTextOptions implements JsonSerializable<AnalyzeTextOpt
/**
* Creates an instance of AnalyzeTextOptions class.
*
* @param text the text value to set.
*/
@Generated
public AnalyzeTextOptions(String text) {
this.text = text;
}

/**
* Get the text property: The text to be analyzed. We support a maximum of 10k Unicode characters (Unicode code
* points) in the text of one request.
*
* @return the text value.
* @param text2 the text2 value to set.
*/
@Generated
public String getText() {
return this.text;
public AnalyzeTextOptions(String text2) {
this.text2 = text2;
}

/**
Expand Down Expand Up @@ -176,7 +158,7 @@ public AnalyzeTextOptions setOutputType(AnalyzeTextOutputType outputType) {
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("text", this.text);
jsonWriter.writeStringField("text2", this.text2);
jsonWriter.writeArrayField("categories", this.categories,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
jsonWriter.writeArrayField("blocklistNames", this.blocklistNames,
Expand All @@ -198,16 +180,16 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
@Generated
public static AnalyzeTextOptions fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
String text = null;
String text2 = null;
List<TextCategory> categories = null;
List<String> blocklistNames = null;
Boolean haltOnBlocklistHit = null;
AnalyzeTextOutputType outputType = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("text".equals(fieldName)) {
text = reader.getString();
if ("text2".equals(fieldName)) {
text2 = reader.getString();
} else if ("categories".equals(fieldName)) {
categories = reader.readArray(reader1 -> TextCategory.fromString(reader1.getString()));
} else if ("blocklistNames".equals(fieldName)) {
Expand All @@ -220,12 +202,30 @@ public static AnalyzeTextOptions fromJson(JsonReader jsonReader) throws IOExcept
reader.skipChildren();
}
}
AnalyzeTextOptions deserializedAnalyzeTextOptions = new AnalyzeTextOptions(text);
AnalyzeTextOptions deserializedAnalyzeTextOptions = new AnalyzeTextOptions(text2);
deserializedAnalyzeTextOptions.categories = categories;
deserializedAnalyzeTextOptions.blocklistNames = blocklistNames;
deserializedAnalyzeTextOptions.haltOnBlocklistHit = haltOnBlocklistHit;
deserializedAnalyzeTextOptions.outputType = outputType;
return deserializedAnalyzeTextOptions;
});
}

/*
* The text to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one
* request.
*/
@Generated
private final String text2;

/**
* Get the text2 property: The text to be analyzed. We support a maximum of 10k Unicode characters (Unicode code
* points) in the text of one request.
*
* @return the text2 value.
*/
@Generated
public String getText2() {
return this.text2;
}
}
Original file line number Diff line number Diff line change
@@ -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.contentsafety.generated;

import com.azure.ai.contentsafety.BlocklistClient;
import com.azure.ai.contentsafety.BlocklistClientBuilder;
import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions;
import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult;
import com.azure.ai.contentsafety.models.TextBlocklistItem;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;
import java.util.Arrays;

public class AddOrUpdateBlocklistItemsToTextBlocklist {
public static void main(String[] args) {
BlocklistClient blocklistClient
= new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.addorupdateblocklistitems.addorupdateblocklistitemstotextblocklist
AddOrUpdateTextBlocklistItemsResult response
= blocklistClient.addOrUpdateBlocklistItems("TestBlocklist", new AddOrUpdateTextBlocklistItemsOptions(
Arrays.asList(new TextBlocklistItem("hate").setDescription("Hate word"))));
// END:com.azure.ai.contentsafety.generated.addorupdateblocklistitems.addorupdateblocklistitemstotextblocklist
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.ai.contentsafety.generated;

import com.azure.ai.contentsafety.ContentSafetyClient;
import com.azure.ai.contentsafety.ContentSafetyClientBuilder;
import com.azure.ai.contentsafety.models.AnalyzeImageOptions;
import com.azure.ai.contentsafety.models.AnalyzeImageResult;
import com.azure.ai.contentsafety.models.ContentSafetyImageData;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;

public class AnalyzeImage {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient
= new ContentSafetyClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.analyzeimage.analyzeimage
AnalyzeImageResult response = contentSafetyClient
.analyzeImage(new AnalyzeImageOptions(new ContentSafetyImageData().setContent("Y29udGVudDE=".getBytes())));
// END:com.azure.ai.contentsafety.generated.analyzeimage.analyzeimage
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.ai.contentsafety.generated;

import com.azure.ai.contentsafety.ContentSafetyClient;
import com.azure.ai.contentsafety.ContentSafetyClientBuilder;
import com.azure.ai.contentsafety.models.AnalyzeTextOptions;
import com.azure.ai.contentsafety.models.AnalyzeTextResult;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;

public class AnalyzeText {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient
= new ContentSafetyClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.analyzetext.analyzetext
AnalyzeTextResult response = contentSafetyClient.analyzeText(new AnalyzeTextOptions(null));
// END:com.azure.ai.contentsafety.generated.analyzetext.analyzetext
}
}
Original file line number Diff line number Diff line change
@@ -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.contentsafety.generated;

import com.azure.ai.contentsafety.BlocklistClient;
import com.azure.ai.contentsafety.BlocklistClientBuilder;
import com.azure.ai.contentsafety.models.TextBlocklist;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;

public class CreateOrUpdateTextBlocklist {
public static void main(String[] args) {
BlocklistClient blocklistClient
= new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.createorupdatetextblocklist.createorupdatetextblocklist
TextBlocklist response = blocklistClient.createOrUpdateTextBlocklist("TestBlocklist", null);
// END:com.azure.ai.contentsafety.generated.createorupdatetextblocklist.createorupdatetextblocklist
}
}
Loading

0 comments on commit 2b35003

Please sign in to comment.