Share via


BlocklistClient.AddOrUpdateBlocklistItems Method

Definition

Overloads

AddOrUpdateBlocklistItems(String, AddOrUpdateTextBlocklistItemsOptions, CancellationToken)

Add or update BlocklistItems To Text Blocklist.

AddOrUpdateBlocklistItems(String, RequestContent, RequestContext)

[Protocol Method] Add or update BlocklistItems To Text Blocklist

AddOrUpdateBlocklistItems(String, AddOrUpdateTextBlocklistItemsOptions, CancellationToken)

Source:
BlocklistClient.cs

Add or update BlocklistItems To Text Blocklist.

public virtual Azure.Response<Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsResult> AddOrUpdateBlocklistItems (string name, Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member AddOrUpdateBlocklistItems : string * Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions * System.Threading.CancellationToken -> Azure.Response<Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsResult>
override this.AddOrUpdateBlocklistItems : string * Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions * System.Threading.CancellationToken -> Azure.Response<Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsResult>
Public Overridable Function AddOrUpdateBlocklistItems (name As String, options As AddOrUpdateTextBlocklistItemsOptions, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AddOrUpdateTextBlocklistItemsResult)

Parameters

name
String

Text blocklist name.

options
AddOrUpdateTextBlocklistItemsOptions

Options for adding or updating blocklist items.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

name or options is null.

name is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call AddOrUpdateBlocklistItems.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
BlocklistClient client = new BlocklistClient(endpoint, credential);

AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[]
{
    new TextBlocklistItem("<text>")
});
Response<AddOrUpdateTextBlocklistItemsResult> response = client.AddOrUpdateBlocklistItems("<Name>", options);

This sample shows how to call AddOrUpdateBlocklistItems with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
BlocklistClient client = new BlocklistClient(endpoint, credential);

AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[]
{
    new TextBlocklistItem("<text>")
    {
        Description = "<description>",
    }
});
Response<AddOrUpdateTextBlocklistItemsResult> response = client.AddOrUpdateBlocklistItems("<Name>", options);

Remarks

Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one request.

Applies to

AddOrUpdateBlocklistItems(String, RequestContent, RequestContext)

Source:
BlocklistClient.cs

[Protocol Method] Add or update BlocklistItems To Text Blocklist

public virtual Azure.Response AddOrUpdateBlocklistItems (string name, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member AddOrUpdateBlocklistItems : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.AddOrUpdateBlocklistItems : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function AddOrUpdateBlocklistItems (name As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response

Parameters

name
String

Text blocklist name.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

name or content is null.

name is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call AddOrUpdateBlocklistItems and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
BlocklistClient client = new BlocklistClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    blocklistItems = new object[]
    {
        new
        {
            text = "<text>",
        }
    },
});
Response response = client.AddOrUpdateBlocklistItems("<Name>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString());
Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString());

This sample shows how to call AddOrUpdateBlocklistItems with all parameters and request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
BlocklistClient client = new BlocklistClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    blocklistItems = new object[]
    {
        new
        {
            description = "<description>",
            text = "<text>",
        }
    },
});
Response response = client.AddOrUpdateBlocklistItems("<Name>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString());
Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString());

Applies to