Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest 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.AddBlockItemsOptions;
import com.azure.ai.contentsafety.models.AddBlockItemsResult;
import com.azure.ai.contentsafety.models.TextBlockItemInfo;
import com.azure.core.credential.KeyCredential;
import com.azure.core.util.Configuration;
import java.util.Arrays;

public class AddBlockItemsToTextBlocklist {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.addblockitems.addblockitemstotextblocklist
AddBlockItemsResult response =
contentSafetyClient.addBlockItems(
"TestBlocklist",
new AddBlockItemsOptions(
Arrays.asList(new TextBlockItemInfo("hate").setDescription("Hate word"))));
// END:com.azure.ai.contentsafety.generated.addblockitems.addblockitemstotextblocklist
}
}
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) AutoRest 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.ImageData;
import com.azure.core.credential.KeyCredential;
import com.azure.core.util.Configuration;

public class AnalyzeImage {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.analyzeimage.analyzeimage
AnalyzeImageResult response =
contentSafetyClient.analyzeImage(
new AnalyzeImageOptions(new ImageData().setContent("Y29udGVudDE=".getBytes())));
// END:com.azure.ai.contentsafety.generated.analyzeimage.analyzeimage
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest 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.credential.KeyCredential;
import com.azure.core.util.Configuration;

public class AnalyzeText {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.analyzetext.analyzetext
AnalyzeTextResult response = contentSafetyClient.analyzeText(new AnalyzeTextOptions("This is text example"));
// END:com.azure.ai.contentsafety.generated.analyzetext.analyzetext
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.ai.contentsafety.generated;

import com.azure.ai.contentsafety.ContentSafetyClient;
import com.azure.ai.contentsafety.ContentSafetyClientBuilder;
import com.azure.core.credential.KeyCredential;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Configuration;

public class CreateOrUpdateTextBlocklist {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.createorupdatetextblocklist.createorupdatetextblocklist
BinaryData resource = BinaryData.fromString("{\"description\":\"Test Blocklist\"}");
RequestOptions requestOptions = new RequestOptions();
Response<BinaryData> response =
contentSafetyClient.createOrUpdateTextBlocklistWithResponse("TestBlocklist", resource, requestOptions);
// END:com.azure.ai.contentsafety.generated.createorupdatetextblocklist.createorupdatetextblocklist
}
}
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) AutoRest Code Generator.

package com.azure.ai.contentsafety.generated;

import com.azure.ai.contentsafety.ContentSafetyClient;
import com.azure.ai.contentsafety.ContentSafetyClientBuilder;
import com.azure.core.credential.KeyCredential;
import com.azure.core.util.Configuration;

public class DeleteTextBlocklistByBlocklistName {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.deletetextblocklist.deletetextblocklistbyblocklistname
contentSafetyClient.deleteTextBlocklist("TestBlocklist");
// END:com.azure.ai.contentsafety.generated.deletetextblocklist.deletetextblocklistbyblocklistname
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest 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.TextBlockItem;
import com.azure.core.credential.KeyCredential;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Configuration;

public class GetAllBlockItemsByBlocklistName {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.listtextblocklistitems.getallblockitemsbyblocklistname
PagedIterable<TextBlockItem> response = contentSafetyClient.listTextBlocklistItems("TestBlocklist", null, null);
// END:com.azure.ai.contentsafety.generated.listtextblocklistitems.getallblockitemsbyblocklistname
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest 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.TextBlocklist;
import com.azure.core.credential.KeyCredential;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Configuration;

public class GetAllTextBlocklists {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.listtextblocklists.getalltextblocklists
PagedIterable<TextBlocklist> response = contentSafetyClient.listTextBlocklists();
// END:com.azure.ai.contentsafety.generated.listtextblocklists.getalltextblocklists
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest 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.TextBlockItem;
import com.azure.core.credential.KeyCredential;
import com.azure.core.util.Configuration;

public class GetBlockItemByBlocklistNameAndBlockItemId {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.gettextblocklistitem.getblockitembyblocklistnameandblockitemid
TextBlockItem response =
contentSafetyClient.getTextBlocklistItem("TestBlocklist", "9511969e-f1e3-4604-9127-05ee16c509ec");
// END:com.azure.ai.contentsafety.generated.gettextblocklistitem.getblockitembyblocklistnameandblockitemid
}
}
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) AutoRest 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.TextBlocklist;
import com.azure.core.credential.KeyCredential;
import com.azure.core.util.Configuration;

public class GetTextBlocklistByBlocklistName {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.gettextblocklist.gettextblocklistbyblocklistname
TextBlocklist response = contentSafetyClient.getTextBlocklist("TestBlocklist");
// END:com.azure.ai.contentsafety.generated.gettextblocklist.gettextblocklistbyblocklistname
}
}
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) AutoRest 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.RemoveBlockItemsOptions;
import com.azure.core.credential.KeyCredential;
import com.azure.core.util.Configuration;
import java.util.Arrays;

public class RemoveBlockItemsFromTextBlocklist {
public static void main(String[] args) {
ContentSafetyClient contentSafetyClient =
new ContentSafetyClientBuilder()
.credential(new KeyCredential(Configuration.getGlobalConfiguration().get("API_KEY")))
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
.buildClient();
// BEGIN:com.azure.ai.contentsafety.generated.removeblockitems.removeblockitemsfromtextblocklist
contentSafetyClient.removeBlockItems(
"TestBlocklist", new RemoveBlockItemsOptions(Arrays.asList("9511969e-f1e3-4604-9127-05ee16c509ec")));
// END:com.azure.ai.contentsafety.generated.removeblockitems.removeblockitemsfromtextblocklist
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +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.contentsafety.generated;

import com.azure.ai.contentsafety.models.AddBlockItemsOptions;
import com.azure.ai.contentsafety.models.AddBlockItemsResult;
import com.azure.ai.contentsafety.models.TextBlockItem;
import com.azure.ai.contentsafety.models.TextBlockItemInfo;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@Disabled
public final class AddBlockItemsToTextBlocklistTests extends ContentSafetyClientTestBase {
@Test
@Disabled
public void testAddBlockItemsToTextBlocklistTests() {
// method invocation
AddBlockItemsResult response =
contentSafetyClient.addBlockItems(
"TestBlocklist",
new AddBlockItemsOptions(
Arrays.asList(new TextBlockItemInfo("hate").setDescription("Hate word"))));

// response assertion
Assertions.assertNotNull(response);
// verify property "value"
List<TextBlockItem> responseValue = response.getValue();
TextBlockItem responseValueFirstItem = responseValue.iterator().next();
Assertions.assertNotNull(responseValueFirstItem);
Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", responseValueFirstItem.getBlockItemId());
Assertions.assertEquals("Hate word", responseValueFirstItem.getDescription());
Assertions.assertEquals("hate", responseValueFirstItem.getText());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.ai.contentsafety.generated;

import com.azure.ai.contentsafety.models.AnalyzeImageOptions;
import com.azure.ai.contentsafety.models.AnalyzeImageResult;
import com.azure.ai.contentsafety.models.ImageAnalyzeSeverityResult;
import com.azure.ai.contentsafety.models.ImageCategory;
import com.azure.ai.contentsafety.models.ImageData;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@Disabled
public final class AnalyzeImageTests extends ContentSafetyClientTestBase {
@Test
@Disabled
public void testAnalyzeImageTests() {
// method invocation
AnalyzeImageResult response =
contentSafetyClient.analyzeImage(
new AnalyzeImageOptions(new ImageData().setContent("Y29udGVudDE=".getBytes())));

// response assertion
Assertions.assertNotNull(response);
// verify property "hateResult"
ImageAnalyzeSeverityResult responseHateResult = response.getHateResult();
Assertions.assertNotNull(responseHateResult);
Assertions.assertEquals(ImageCategory.HATE, responseHateResult.getCategory());
Assertions.assertEquals(0, responseHateResult.getSeverity());
// verify property "selfHarmResult"
ImageAnalyzeSeverityResult responseSelfHarmResult = response.getSelfHarmResult();
Assertions.assertNotNull(responseSelfHarmResult);
Assertions.assertEquals(ImageCategory.HATE, responseSelfHarmResult.getCategory());
Assertions.assertEquals(0, responseSelfHarmResult.getSeverity());
// verify property "sexualResult"
ImageAnalyzeSeverityResult responseSexualResult = response.getSexualResult();
Assertions.assertNotNull(responseSexualResult);
Assertions.assertEquals(ImageCategory.HATE, responseSexualResult.getCategory());
Assertions.assertEquals(0, responseSexualResult.getSeverity());
// verify property "violenceResult"
ImageAnalyzeSeverityResult responseViolenceResult = response.getViolenceResult();
Assertions.assertNotNull(responseViolenceResult);
Assertions.assertEquals(ImageCategory.HATE, responseViolenceResult.getCategory());
Assertions.assertEquals(2, responseViolenceResult.getSeverity());
}
}
Loading