diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/api/Azure.AI.ContentSafety.netstandard2.0.cs b/sdk/contentsafety/Azure.AI.ContentSafety/api/Azure.AI.ContentSafety.netstandard2.0.cs index 1895532af5cd..eb7f3ba6d6fd 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/api/Azure.AI.ContentSafety.netstandard2.0.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/api/Azure.AI.ContentSafety.netstandard2.0.cs @@ -1,67 +1,101 @@ namespace Azure.AI.ContentSafety { - public partial class AddBlockItemsOptions + public partial class AddOrUpdateTextBlocklistItemsOptions { - public AddBlockItemsOptions(System.Collections.Generic.IEnumerable blockItems) { } - public System.Collections.Generic.IList BlockItems { get { throw null; } } + public AddOrUpdateTextBlocklistItemsOptions(System.Collections.Generic.IEnumerable blocklistItems) { } + public System.Collections.Generic.IList BlocklistItems { get { throw null; } } } - public partial class AddBlockItemsResult + public partial class AddOrUpdateTextBlocklistItemsResult { - internal AddBlockItemsResult() { } - public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } + internal AddOrUpdateTextBlocklistItemsResult() { } + public System.Collections.Generic.IReadOnlyList BlocklistItems { get { throw null; } } } public static partial class AIContentSafetyModelFactory { - public static Azure.AI.ContentSafety.AddBlockItemsResult AddBlockItemsResult(System.Collections.Generic.IEnumerable value = null) { throw null; } - public static Azure.AI.ContentSafety.AnalyzeImageResult AnalyzeImageResult(Azure.AI.ContentSafety.ImageAnalyzeSeverityResult hateResult = null, Azure.AI.ContentSafety.ImageAnalyzeSeverityResult selfHarmResult = null, Azure.AI.ContentSafety.ImageAnalyzeSeverityResult sexualResult = null, Azure.AI.ContentSafety.ImageAnalyzeSeverityResult violenceResult = null) { throw null; } - public static Azure.AI.ContentSafety.AnalyzeTextResult AnalyzeTextResult(System.Collections.Generic.IEnumerable blocklistsMatchResults = null, Azure.AI.ContentSafety.TextAnalyzeSeverityResult hateResult = null, Azure.AI.ContentSafety.TextAnalyzeSeverityResult selfHarmResult = null, Azure.AI.ContentSafety.TextAnalyzeSeverityResult sexualResult = null, Azure.AI.ContentSafety.TextAnalyzeSeverityResult violenceResult = null) { throw null; } - public static Azure.AI.ContentSafety.ImageAnalyzeSeverityResult ImageAnalyzeSeverityResult(Azure.AI.ContentSafety.ImageCategory category = default(Azure.AI.ContentSafety.ImageCategory), int severity = 0) { throw null; } - public static Azure.AI.ContentSafety.TextAnalyzeSeverityResult TextAnalyzeSeverityResult(Azure.AI.ContentSafety.TextCategory category = default(Azure.AI.ContentSafety.TextCategory), int severity = 0) { throw null; } - public static Azure.AI.ContentSafety.TextBlockItem TextBlockItem(string blockItemId = null, string description = null, string text = null) { throw null; } + public static Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsResult AddOrUpdateTextBlocklistItemsResult(System.Collections.Generic.IEnumerable blocklistItems = null) { throw null; } + public static Azure.AI.ContentSafety.AnalyzeImageResult AnalyzeImageResult(System.Collections.Generic.IEnumerable categoriesAnalysis = null) { throw null; } + public static Azure.AI.ContentSafety.AnalyzeTextResult AnalyzeTextResult(System.Collections.Generic.IEnumerable blocklistsMatch = null, System.Collections.Generic.IEnumerable categoriesAnalysis = null) { throw null; } + public static Azure.AI.ContentSafety.ImageCategoriesAnalysis ImageCategoriesAnalysis(Azure.AI.ContentSafety.ImageCategory category = default(Azure.AI.ContentSafety.ImageCategory), int? severity = default(int?)) { throw null; } public static Azure.AI.ContentSafety.TextBlocklist TextBlocklist(string blocklistName = null, string description = null) { throw null; } - public static Azure.AI.ContentSafety.TextBlocklistMatchResult TextBlocklistMatchResult(string blocklistName = null, string blockItemId = null, string blockItemText = null, int offset = 0, int length = 0) { throw null; } + public static Azure.AI.ContentSafety.TextBlocklistItem TextBlocklistItem(string blocklistItemId = null, string description = null, string text = null) { throw null; } + public static Azure.AI.ContentSafety.TextBlocklistMatch TextBlocklistMatch(string blocklistName = null, string blocklistItemId = null, string blocklistItemText = null) { throw null; } + public static Azure.AI.ContentSafety.TextCategoriesAnalysis TextCategoriesAnalysis(Azure.AI.ContentSafety.TextCategory category = default(Azure.AI.ContentSafety.TextCategory), int? severity = default(int?)) { throw null; } } public partial class AnalyzeImageOptions { public AnalyzeImageOptions(Azure.AI.ContentSafety.ContentSafetyImageData image) { } public System.Collections.Generic.IList Categories { get { throw null; } } public Azure.AI.ContentSafety.ContentSafetyImageData Image { get { throw null; } } + public Azure.AI.ContentSafety.AnalyzeImageOutputType? OutputType { get { throw null; } set { } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AnalyzeImageOutputType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AnalyzeImageOutputType(string value) { throw null; } + public static Azure.AI.ContentSafety.AnalyzeImageOutputType EightSeverityLevels { get { throw null; } } + public static Azure.AI.ContentSafety.AnalyzeImageOutputType FourSeverityLevels { get { throw null; } } + public bool Equals(Azure.AI.ContentSafety.AnalyzeImageOutputType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.ContentSafety.AnalyzeImageOutputType left, Azure.AI.ContentSafety.AnalyzeImageOutputType right) { throw null; } + public static implicit operator Azure.AI.ContentSafety.AnalyzeImageOutputType (string value) { throw null; } + public static bool operator !=(Azure.AI.ContentSafety.AnalyzeImageOutputType left, Azure.AI.ContentSafety.AnalyzeImageOutputType right) { throw null; } + public override string ToString() { throw null; } } public partial class AnalyzeImageResult { internal AnalyzeImageResult() { } - public Azure.AI.ContentSafety.ImageAnalyzeSeverityResult HateResult { get { throw null; } } - public Azure.AI.ContentSafety.ImageAnalyzeSeverityResult SelfHarmResult { get { throw null; } } - public Azure.AI.ContentSafety.ImageAnalyzeSeverityResult SexualResult { get { throw null; } } - public Azure.AI.ContentSafety.ImageAnalyzeSeverityResult ViolenceResult { get { throw null; } } + public System.Collections.Generic.IReadOnlyList CategoriesAnalysis { get { throw null; } } } public partial class AnalyzeTextOptions { public AnalyzeTextOptions(string text) { } public System.Collections.Generic.IList BlocklistNames { get { throw null; } } - public bool? BreakByBlocklists { get { throw null; } set { } } public System.Collections.Generic.IList Categories { get { throw null; } } + public bool? HaltOnBlocklistHit { get { throw null; } set { } } + public Azure.AI.ContentSafety.AnalyzeTextOutputType? OutputType { get { throw null; } set { } } public string Text { get { throw null; } } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AnalyzeTextOutputType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AnalyzeTextOutputType(string value) { throw null; } + public static Azure.AI.ContentSafety.AnalyzeTextOutputType EightSeverityLevels { get { throw null; } } + public static Azure.AI.ContentSafety.AnalyzeTextOutputType FourSeverityLevels { get { throw null; } } + public bool Equals(Azure.AI.ContentSafety.AnalyzeTextOutputType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.ContentSafety.AnalyzeTextOutputType left, Azure.AI.ContentSafety.AnalyzeTextOutputType right) { throw null; } + public static implicit operator Azure.AI.ContentSafety.AnalyzeTextOutputType (string value) { throw null; } + public static bool operator !=(Azure.AI.ContentSafety.AnalyzeTextOutputType left, Azure.AI.ContentSafety.AnalyzeTextOutputType right) { throw null; } + public override string ToString() { throw null; } + } public partial class AnalyzeTextResult { internal AnalyzeTextResult() { } - public System.Collections.Generic.IReadOnlyList BlocklistsMatchResults { get { throw null; } } - public Azure.AI.ContentSafety.TextAnalyzeSeverityResult HateResult { get { throw null; } } - public Azure.AI.ContentSafety.TextAnalyzeSeverityResult SelfHarmResult { get { throw null; } } - public Azure.AI.ContentSafety.TextAnalyzeSeverityResult SexualResult { get { throw null; } } - public Azure.AI.ContentSafety.TextAnalyzeSeverityResult ViolenceResult { get { throw null; } } + public System.Collections.Generic.IReadOnlyList BlocklistsMatch { get { throw null; } } + public System.Collections.Generic.IReadOnlyList CategoriesAnalysis { get { throw null; } } } public partial class ContentSafetyClient { protected ContentSafetyClient() { } public ContentSafetyClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } public ContentSafetyClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.ContentSafety.ContentSafetyClientOptions options) { } + public ContentSafetyClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { } + public ContentSafetyClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.AI.ContentSafety.ContentSafetyClientOptions options) { } public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } - public virtual Azure.Response AddBlockItems(string blocklistName, Azure.AI.ContentSafety.AddBlockItemsOptions addBlockItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response AddBlockItems(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task> AddBlockItemsAsync(string blocklistName, Azure.AI.ContentSafety.AddBlockItemsOptions addBlockItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task AddBlockItemsAsync(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response AddOrUpdateBlocklistItems(string blocklistName, Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response AddOrUpdateBlocklistItems(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> AddOrUpdateBlocklistItemsAsync(string blocklistName, Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task AddOrUpdateBlocklistItemsAsync(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response AnalyzeImage(Azure.AI.ContentSafety.AnalyzeImageOptions body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response AnalyzeImage(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual System.Threading.Tasks.Task> AnalyzeImageAsync(Azure.AI.ContentSafety.AnalyzeImageOptions body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -78,29 +112,29 @@ public ContentSafetyClient(System.Uri endpoint, Azure.AzureKeyCredential credent public virtual Azure.Response GetTextBlocklist(string blocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetTextBlocklistAsync(string blocklistName, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetTextBlocklistAsync(string blocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetTextBlocklistItem(string blocklistName, string blockItemId, Azure.RequestContext context) { throw null; } - public virtual Azure.Response GetTextBlocklistItem(string blocklistName, string blockItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task GetTextBlocklistItemAsync(string blocklistName, string blockItemId, Azure.RequestContext context) { throw null; } - public virtual System.Threading.Tasks.Task> GetTextBlocklistItemAsync(string blocklistName, string blockItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTextBlocklistItem(string blocklistName, string blocklistItemId, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTextBlocklistItem(string blocklistName, string blocklistItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTextBlocklistItemAsync(string blocklistName, string blocklistItemId, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTextBlocklistItemAsync(string blocklistName, string blocklistItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetTextBlocklistItems(string blocklistName, int? maxCount, int? skip, int? maxpagesize, Azure.RequestContext context) { throw null; } - public virtual Azure.Pageable GetTextBlocklistItems(string blocklistName, int? maxCount = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetTextBlocklistItems(string blocklistName, int? maxCount = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetTextBlocklistItemsAsync(string blocklistName, int? maxCount, int? skip, int? maxpagesize, Azure.RequestContext context) { throw null; } - public virtual Azure.AsyncPageable GetTextBlocklistItemsAsync(string blocklistName, int? maxCount = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTextBlocklistItemsAsync(string blocklistName, int? maxCount = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetTextBlocklists(Azure.RequestContext context) { throw null; } public virtual Azure.Pageable GetTextBlocklists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetTextBlocklistsAsync(Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetTextBlocklistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response RemoveBlockItems(string blocklistName, Azure.AI.ContentSafety.RemoveBlockItemsOptions removeBlockItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response RemoveBlockItems(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task RemoveBlockItemsAsync(string blocklistName, Azure.AI.ContentSafety.RemoveBlockItemsOptions removeBlockItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task RemoveBlockItemsAsync(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response RemoveBlocklistItems(string blocklistName, Azure.AI.ContentSafety.RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveBlocklistItems(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task RemoveBlocklistItemsAsync(string blocklistName, Azure.AI.ContentSafety.RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task RemoveBlocklistItemsAsync(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } } public partial class ContentSafetyClientOptions : Azure.Core.ClientOptions { - public ContentSafetyClientOptions(Azure.AI.ContentSafety.ContentSafetyClientOptions.ServiceVersion version = Azure.AI.ContentSafety.ContentSafetyClientOptions.ServiceVersion.V2023_04_30_Preview) { } + public ContentSafetyClientOptions(Azure.AI.ContentSafety.ContentSafetyClientOptions.ServiceVersion version = Azure.AI.ContentSafety.ContentSafetyClientOptions.ServiceVersion.V2023_10_01) { } public enum ServiceVersion { - V2023_04_30_Preview = 1, + V2023_10_01 = 1, } } public partial class ContentSafetyImageData @@ -109,11 +143,11 @@ public ContentSafetyImageData() { } public System.Uri BlobUrl { get { throw null; } set { } } public System.BinaryData Content { get { throw null; } set { } } } - public partial class ImageAnalyzeSeverityResult + public partial class ImageCategoriesAnalysis { - internal ImageAnalyzeSeverityResult() { } + internal ImageCategoriesAnalysis() { } public Azure.AI.ContentSafety.ImageCategory Category { get { throw null; } } - public int Severity { get { throw null; } } + public int? Severity { get { throw null; } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ImageCategory : System.IEquatable @@ -135,44 +169,36 @@ internal ImageAnalyzeSeverityResult() { } public static bool operator !=(Azure.AI.ContentSafety.ImageCategory left, Azure.AI.ContentSafety.ImageCategory right) { throw null; } public override string ToString() { throw null; } } - public partial class RemoveBlockItemsOptions - { - public RemoveBlockItemsOptions(System.Collections.Generic.IEnumerable blockItemIds) { } - public System.Collections.Generic.IList BlockItemIds { get { throw null; } } - } - public partial class TextAnalyzeSeverityResult + public partial class RemoveTextBlocklistItemsOptions { - internal TextAnalyzeSeverityResult() { } - public Azure.AI.ContentSafety.TextCategory Category { get { throw null; } } - public int Severity { get { throw null; } } + public RemoveTextBlocklistItemsOptions(System.Collections.Generic.IEnumerable blocklistItemIds) { } + public System.Collections.Generic.IList BlocklistItemIds { get { throw null; } } } - public partial class TextBlockItem + public partial class TextBlocklist { - internal TextBlockItem() { } - public string BlockItemId { get { throw null; } } + internal TextBlocklist() { } + public string BlocklistName { get { throw null; } } public string Description { get { throw null; } } - public string Text { get { throw null; } } } - public partial class TextBlockItemInfo + public partial class TextBlocklistItem { - public TextBlockItemInfo(string text) { } + public TextBlocklistItem(string text) { } + public string BlocklistItemId { get { throw null; } } public string Description { get { throw null; } set { } } - public string Text { get { throw null; } } + public string Text { get { throw null; } set { } } } - public partial class TextBlocklist + public partial class TextBlocklistMatch { - internal TextBlocklist() { } + internal TextBlocklistMatch() { } + public string BlocklistItemId { get { throw null; } } + public string BlocklistItemText { get { throw null; } } public string BlocklistName { get { throw null; } } - public string Description { get { throw null; } } } - public partial class TextBlocklistMatchResult + public partial class TextCategoriesAnalysis { - internal TextBlocklistMatchResult() { } - public string BlockItemId { get { throw null; } } - public string BlockItemText { get { throw null; } } - public string BlocklistName { get { throw null; } } - public int Length { get { throw null; } } - public int Offset { get { throw null; } } + internal TextCategoriesAnalysis() { } + public Azure.AI.ContentSafety.TextCategory Category { get { throw null; } } + public int? Severity { get { throw null; } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TextCategory : System.IEquatable @@ -199,6 +225,7 @@ namespace Microsoft.Extensions.Azure { public static partial class AIContentSafetyClientBuilderExtensions { + public static Azure.Core.Extensions.IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, System.Uri endpoint) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; } public static Azure.Core.Extensions.IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } public static Azure.Core.Extensions.IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyClientBuilderExtensions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyClientBuilderExtensions.cs index 6c63c13fe6e8..ec710a447be3 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyClientBuilderExtensions.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyClientBuilderExtensions.cs @@ -28,6 +28,18 @@ public static IAzureClientBuilder((options) => new ContentSafetyClient(endpoint, credential, options)); } + /// Registers a instance. + /// The builder to register with. + /// + /// Supported Cognitive Services endpoints (protocol and hostname, for example: + /// https://<resource-name>.cognitiveservices.azure.com). + /// + public static IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new ContentSafetyClient(endpoint, cred, options)); + } + /// Registers a instance. /// The builder to register with. /// The configuration values. diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs index a66c6f5b7b82..1a5c6397021c 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs @@ -15,72 +15,67 @@ namespace Azure.AI.ContentSafety public static partial class AIContentSafetyModelFactory { /// Initializes a new instance of AnalyzeTextResult. - /// The details of blocklist match. - /// Analysis result for Hate category. - /// Analysis result for SelfHarm category. - /// Analysis result for Sexual category. - /// Analysis result for Violence category. + /// The blocklist match details. + /// Analysis result for categories. /// A new instance for mocking. - public static AnalyzeTextResult AnalyzeTextResult(IEnumerable blocklistsMatchResults = null, TextAnalyzeSeverityResult hateResult = null, TextAnalyzeSeverityResult selfHarmResult = null, TextAnalyzeSeverityResult sexualResult = null, TextAnalyzeSeverityResult violenceResult = null) + public static AnalyzeTextResult AnalyzeTextResult(IEnumerable blocklistsMatch = null, IEnumerable categoriesAnalysis = null) { - blocklistsMatchResults ??= new List(); + blocklistsMatch ??= new List(); + categoriesAnalysis ??= new List(); - return new AnalyzeTextResult(blocklistsMatchResults?.ToList(), hateResult, selfHarmResult, sexualResult, violenceResult); + return new AnalyzeTextResult(blocklistsMatch?.ToList(), categoriesAnalysis?.ToList()); } - /// Initializes a new instance of TextBlocklistMatchResult. - /// The name of matched blocklist. - /// The id of matched item. - /// The content of matched item. - /// The character offset of matched text in original input. - /// The length of matched text in original input. - /// , or is null. - /// A new instance for mocking. - public static TextBlocklistMatchResult TextBlocklistMatchResult(string blocklistName = null, string blockItemId = null, string blockItemText = null, int offset = default, int length = default) + /// Initializes a new instance of TextBlocklistMatch. + /// The name of the matched blocklist. + /// The ID of the matched item. + /// The content of the matched item. + /// , or is null. + /// A new instance for mocking. + public static TextBlocklistMatch TextBlocklistMatch(string blocklistName = null, string blocklistItemId = null, string blocklistItemText = null) { if (blocklistName == null) { throw new ArgumentNullException(nameof(blocklistName)); } - if (blockItemId == null) + if (blocklistItemId == null) { - throw new ArgumentNullException(nameof(blockItemId)); + throw new ArgumentNullException(nameof(blocklistItemId)); } - if (blockItemText == null) + if (blocklistItemText == null) { - throw new ArgumentNullException(nameof(blockItemText)); + throw new ArgumentNullException(nameof(blocklistItemText)); } - return new TextBlocklistMatchResult(blocklistName, blockItemId, blockItemText, offset, length); + return new TextBlocklistMatch(blocklistName, blocklistItemId, blocklistItemText); } - /// Initializes a new instance of TextAnalyzeSeverityResult. - /// The text category. - /// The higher the severity of input content, the larger this value is. The values could be: 0,2,4,6. - /// A new instance for mocking. - public static TextAnalyzeSeverityResult TextAnalyzeSeverityResult(TextCategory category = default, int severity = default) + /// Initializes a new instance of TextCategoriesAnalysis. + /// The text analysis category. + /// The value increases with the severity of the input content. The value of this field is determined by the outputType specified in the request. If 'FourSeverityLevels' or 'EightSeverityLevels' is chosen, this field will be included in the output. + /// A new instance for mocking. + public static TextCategoriesAnalysis TextCategoriesAnalysis(TextCategory category = default, int? severity = null) { - return new TextAnalyzeSeverityResult(category, severity); + return new TextCategoriesAnalysis(category, severity); } /// Initializes a new instance of AnalyzeImageResult. - /// Analysis result for Hate category. - /// Analysis result for SelfHarm category. - /// Analysis result for Sexual category. - /// Analysis result for Violence category. + /// Analysis result for categories. /// A new instance for mocking. - public static AnalyzeImageResult AnalyzeImageResult(ImageAnalyzeSeverityResult hateResult = null, ImageAnalyzeSeverityResult selfHarmResult = null, ImageAnalyzeSeverityResult sexualResult = null, ImageAnalyzeSeverityResult violenceResult = null) + public static AnalyzeImageResult AnalyzeImageResult(IEnumerable categoriesAnalysis = null) { - return new AnalyzeImageResult(hateResult, selfHarmResult, sexualResult, violenceResult); + categoriesAnalysis ??= new List(); + + return new AnalyzeImageResult(categoriesAnalysis?.ToList()); } - /// Initializes a new instance of ImageAnalyzeSeverityResult. - /// The image category. - /// The higher the severity of input content, the larger this value, currently its value could be: 0,2,4,6. - /// A new instance for mocking. - public static ImageAnalyzeSeverityResult ImageAnalyzeSeverityResult(ImageCategory category = default, int severity = default) + /// Initializes a new instance of ImageCategoriesAnalysis. + /// The image analysis category. + /// The value increases with the severity of the input content. The value of this field is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’ or ‘EightSeverity Levels’, and the output value can be 0, 2, 4, 6 or 0, 1, 2, 3, 4, 5, 6, or 7. + /// A new instance for mocking. + public static ImageCategoriesAnalysis ImageCategoriesAnalysis(ImageCategory category = default, int? severity = null) { - return new ImageAnalyzeSeverityResult(category, severity); + return new ImageCategoriesAnalysis(category, severity); } /// Initializes a new instance of TextBlocklist. @@ -92,24 +87,24 @@ public static TextBlocklist TextBlocklist(string blocklistName = null, string de return new TextBlocklist(blocklistName, description); } - /// Initializes a new instance of AddBlockItemsResult. - /// Array of blockItems added. - /// A new instance for mocking. - public static AddBlockItemsResult AddBlockItemsResult(IEnumerable value = null) + /// Initializes a new instance of TextBlocklistItem. + /// The service will generate a BlocklistItemId, which will be a UUID. + /// BlocklistItem description. + /// BlocklistItem content. + /// A new instance for mocking. + public static TextBlocklistItem TextBlocklistItem(string blocklistItemId = null, string description = null, string text = null) { - value ??= new List(); - - return new AddBlockItemsResult(value?.ToList()); + return new TextBlocklistItem(blocklistItemId, description, text); } - /// Initializes a new instance of TextBlockItem. - /// Block Item Id. It will be uuid. - /// Block item description. - /// Block item content. - /// A new instance for mocking. - public static TextBlockItem TextBlockItem(string blockItemId = null, string description = null, string text = null) + /// Initializes a new instance of AddOrUpdateTextBlocklistItemsResult. + /// Array of blocklistItems have been added. + /// A new instance for mocking. + public static AddOrUpdateTextBlocklistItemsResult AddOrUpdateTextBlocklistItemsResult(IEnumerable blocklistItems = null) { - return new TextBlockItem(blockItemId, description, text); + blocklistItems ??= new List(); + + return new AddOrUpdateTextBlocklistItemsResult(blocklistItems?.ToList()); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.cs deleted file mode 100644 index 1cf626e27a0e..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - /// The request of adding blockItems to text blocklist. - public partial class AddBlockItemsOptions - { - /// Initializes a new instance of AddBlockItemsOptions. - /// Array of blockItemInfo to add. - /// is null. - public AddBlockItemsOptions(IEnumerable blockItems) - { - Argument.AssertNotNull(blockItems, nameof(blockItems)); - - BlockItems = blockItems.ToList(); - } - - /// Initializes a new instance of AddBlockItemsOptions. - /// Array of blockItemInfo to add. - internal AddBlockItemsOptions(IList blockItems) - { - BlockItems = blockItems; - } - - /// Array of blockItemInfo to add. - public IList BlockItems { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.cs deleted file mode 100644 index cdcc2c531e98..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - /// The response of adding blockItems to text blocklist. - public partial class AddBlockItemsResult - { - /// Initializes a new instance of AddBlockItemsResult. - internal AddBlockItemsResult() - { - Value = new ChangeTrackingList(); - } - - /// Initializes a new instance of AddBlockItemsResult. - /// Array of blockItems added. - internal AddBlockItemsResult(IReadOnlyList value) - { - Value = value; - } - - /// Array of blockItems added. - public IReadOnlyList Value { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.Serialization.cs similarity index 81% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.Serialization.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.Serialization.cs index e524744c252d..8bb14d8e8fce 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.Serialization.cs @@ -10,14 +10,14 @@ namespace Azure.AI.ContentSafety { - public partial class AddBlockItemsOptions : IUtf8JsonSerializable + public partial class AddOrUpdateTextBlocklistItemsOptions : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); - writer.WritePropertyName("blockItems"u8); + writer.WritePropertyName("blocklistItems"u8); writer.WriteStartArray(); - foreach (var item in BlockItems) + foreach (var item in BlocklistItems) { writer.WriteObjectValue(item); } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.cs new file mode 100644 index 000000000000..6f31c72cb365 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.ContentSafety +{ + /// The request to add blocklistItems to a text blocklist. + public partial class AddOrUpdateTextBlocklistItemsOptions + { + /// Initializes a new instance of AddOrUpdateTextBlocklistItemsOptions. + /// Array of blocklistItems to add. + /// is null. + public AddOrUpdateTextBlocklistItemsOptions(IEnumerable blocklistItems) + { + Argument.AssertNotNull(blocklistItems, nameof(blocklistItems)); + + BlocklistItems = blocklistItems.ToList(); + } + + /// Initializes a new instance of AddOrUpdateTextBlocklistItemsOptions. + /// Array of blocklistItems to add. + internal AddOrUpdateTextBlocklistItemsOptions(IList blocklistItems) + { + BlocklistItems = blocklistItems; + } + + /// Array of blocklistItems to add. + public IList BlocklistItems { get; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.Serialization.cs similarity index 52% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.Serialization.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.Serialization.cs index 2cc2e19f8267..8c28ed7b7ea4 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.Serialization.cs @@ -8,45 +8,40 @@ using System.Collections.Generic; using System.Text.Json; using Azure; -using Azure.Core; namespace Azure.AI.ContentSafety { - public partial class AddBlockItemsResult + public partial class AddOrUpdateTextBlocklistItemsResult { - internal static AddBlockItemsResult DeserializeAddBlockItemsResult(JsonElement element) + internal static AddOrUpdateTextBlocklistItemsResult DeserializeAddOrUpdateTextBlocklistItemsResult(JsonElement element) { if (element.ValueKind == JsonValueKind.Null) { return null; } - Optional> value = default; + IReadOnlyList blocklistItems = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (property.NameEquals("blocklistItems"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TextBlockItem.DeserializeTextBlockItem(item)); + array.Add(TextBlocklistItem.DeserializeTextBlocklistItem(item)); } - value = array; + blocklistItems = array; continue; } } - return new AddBlockItemsResult(Optional.ToList(value)); + return new AddOrUpdateTextBlocklistItemsResult(blocklistItems); } /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static AddBlockItemsResult FromResponse(Response response) + internal static AddOrUpdateTextBlocklistItemsResult FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeAddBlockItemsResult(document.RootElement); + return DeserializeAddOrUpdateTextBlocklistItemsResult(document.RootElement); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.cs new file mode 100644 index 000000000000..514f81c362a6 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.ContentSafety +{ + /// The response of adding blocklistItems to the text blocklist. + public partial class AddOrUpdateTextBlocklistItemsResult + { + /// Initializes a new instance of AddOrUpdateTextBlocklistItemsResult. + /// Array of blocklistItems have been added. + /// is null. + internal AddOrUpdateTextBlocklistItemsResult(IEnumerable blocklistItems) + { + Argument.AssertNotNull(blocklistItems, nameof(blocklistItems)); + + BlocklistItems = blocklistItems.ToList(); + } + + /// Initializes a new instance of AddOrUpdateTextBlocklistItemsResult. + /// Array of blocklistItems have been added. + internal AddOrUpdateTextBlocklistItemsResult(IReadOnlyList blocklistItems) + { + BlocklistItems = blocklistItems; + } + + /// Array of blocklistItems have been added. + public IReadOnlyList BlocklistItems { get; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.Serialization.cs index 0b09ca42ffa6..257e8ce31a12 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.Serialization.cs @@ -27,6 +27,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } + if (Optional.IsDefined(OutputType)) + { + writer.WritePropertyName("outputType"u8); + writer.WriteStringValue(OutputType.Value.ToString()); + } writer.WriteEndObject(); } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.cs index 228bc2bb7f30..4af5f8656a3d 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOptions.cs @@ -11,7 +11,7 @@ namespace Azure.AI.ContentSafety { - /// The analysis request of the image. + /// The image analysis request. public partial class AnalyzeImageOptions { /// Initializes a new instance of AnalyzeImageOptions. @@ -27,16 +27,20 @@ public AnalyzeImageOptions(ContentSafetyImageData image) /// Initializes a new instance of AnalyzeImageOptions. /// The image needs to be analyzed. - /// The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be returned. - internal AnalyzeImageOptions(ContentSafetyImageData image, IList categories) + /// The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned. + /// This refers to the type of image analysis output. If no value is assigned, the default value will be "FourSeverityLevels". + internal AnalyzeImageOptions(ContentSafetyImageData image, IList categories, AnalyzeImageOutputType? outputType) { Image = image; Categories = categories; + OutputType = outputType; } /// The image needs to be analyzed. public ContentSafetyImageData Image { get; } - /// The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be returned. + /// The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned. public IList Categories { get; } + /// This refers to the type of image analysis output. If no value is assigned, the default value will be "FourSeverityLevels". + public AnalyzeImageOutputType? OutputType { get; set; } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOutputType.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOutputType.cs new file mode 100644 index 000000000000..64575a26dd58 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOutputType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.ContentSafety +{ + /// The type of image analysis output. + public readonly partial struct AnalyzeImageOutputType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AnalyzeImageOutputType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FourSeverityLevelsValue = "FourSeverityLevels"; + private const string EightSeverityLevelsValue = "EightSeverityLevels"; + + /// Output severities in four levels, the value could be 0,2,4,6. + public static AnalyzeImageOutputType FourSeverityLevels { get; } = new AnalyzeImageOutputType(FourSeverityLevelsValue); + /// Output severities in eight levels, the value could be 0,1,2,3,4,5,6,7. + public static AnalyzeImageOutputType EightSeverityLevels { get; } = new AnalyzeImageOutputType(EightSeverityLevelsValue); + /// Determines if two values are the same. + public static bool operator ==(AnalyzeImageOutputType left, AnalyzeImageOutputType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AnalyzeImageOutputType left, AnalyzeImageOutputType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AnalyzeImageOutputType(string value) => new AnalyzeImageOutputType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AnalyzeImageOutputType other && Equals(other); + /// + public bool Equals(AnalyzeImageOutputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.Serialization.cs index aaf7dd21ab38..fbbf35d2cfa0 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.Serialization.cs @@ -5,9 +5,9 @@ #nullable disable +using System.Collections.Generic; using System.Text.Json; using Azure; -using Azure.Core; namespace Azure.AI.ContentSafety { @@ -19,50 +19,21 @@ internal static AnalyzeImageResult DeserializeAnalyzeImageResult(JsonElement ele { return null; } - Optional hateResult = default; - Optional selfHarmResult = default; - Optional sexualResult = default; - Optional violenceResult = default; + IReadOnlyList categoriesAnalysis = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("hateResult"u8)) + if (property.NameEquals("categoriesAnalysis"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - continue; + array.Add(ImageCategoriesAnalysis.DeserializeImageCategoriesAnalysis(item)); } - hateResult = ImageAnalyzeSeverityResult.DeserializeImageAnalyzeSeverityResult(property.Value); - continue; - } - if (property.NameEquals("selfHarmResult"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - selfHarmResult = ImageAnalyzeSeverityResult.DeserializeImageAnalyzeSeverityResult(property.Value); - continue; - } - if (property.NameEquals("sexualResult"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - sexualResult = ImageAnalyzeSeverityResult.DeserializeImageAnalyzeSeverityResult(property.Value); - continue; - } - if (property.NameEquals("violenceResult"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - violenceResult = ImageAnalyzeSeverityResult.DeserializeImageAnalyzeSeverityResult(property.Value); + categoriesAnalysis = array; continue; } } - return new AnalyzeImageResult(hateResult.Value, selfHarmResult.Value, sexualResult.Value, violenceResult.Value); + return new AnalyzeImageResult(categoriesAnalysis); } /// Deserializes the model from a raw response. diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.cs index 45b67ca068c7..30b10804740c 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageResult.cs @@ -5,36 +5,34 @@ #nullable disable +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + namespace Azure.AI.ContentSafety { - /// The analysis response of the image. + /// The image analysis response. public partial class AnalyzeImageResult { /// Initializes a new instance of AnalyzeImageResult. - internal AnalyzeImageResult() + /// Analysis result for categories. + /// is null. + internal AnalyzeImageResult(IEnumerable categoriesAnalysis) { + Argument.AssertNotNull(categoriesAnalysis, nameof(categoriesAnalysis)); + + CategoriesAnalysis = categoriesAnalysis.ToList(); } /// Initializes a new instance of AnalyzeImageResult. - /// Analysis result for Hate category. - /// Analysis result for SelfHarm category. - /// Analysis result for Sexual category. - /// Analysis result for Violence category. - internal AnalyzeImageResult(ImageAnalyzeSeverityResult hateResult, ImageAnalyzeSeverityResult selfHarmResult, ImageAnalyzeSeverityResult sexualResult, ImageAnalyzeSeverityResult violenceResult) + /// Analysis result for categories. + internal AnalyzeImageResult(IReadOnlyList categoriesAnalysis) { - HateResult = hateResult; - SelfHarmResult = selfHarmResult; - SexualResult = sexualResult; - ViolenceResult = violenceResult; + CategoriesAnalysis = categoriesAnalysis; } - /// Analysis result for Hate category. - public ImageAnalyzeSeverityResult HateResult { get; } - /// Analysis result for SelfHarm category. - public ImageAnalyzeSeverityResult SelfHarmResult { get; } - /// Analysis result for Sexual category. - public ImageAnalyzeSeverityResult SexualResult { get; } - /// Analysis result for Violence category. - public ImageAnalyzeSeverityResult ViolenceResult { get; } + /// Analysis result for categories. + public IReadOnlyList CategoriesAnalysis { get; } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.Serialization.cs index 91c37f38eb2f..226104604056 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.Serialization.cs @@ -37,10 +37,15 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - if (Optional.IsDefined(BreakByBlocklists)) + if (Optional.IsDefined(HaltOnBlocklistHit)) { - writer.WritePropertyName("breakByBlocklists"u8); - writer.WriteBooleanValue(BreakByBlocklists.Value); + writer.WritePropertyName("haltOnBlocklistHit"u8); + writer.WriteBooleanValue(HaltOnBlocklistHit.Value); + } + if (Optional.IsDefined(OutputType)) + { + writer.WritePropertyName("outputType"u8); + writer.WriteStringValue(OutputType.Value.ToString()); } writer.WriteEndObject(); } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.cs index 73ffda9748cc..d53108a70e26 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOptions.cs @@ -11,11 +11,11 @@ namespace Azure.AI.ContentSafety { - /// The analysis request of the text. + /// The text analysis request. public partial class AnalyzeTextOptions { /// Initializes a new instance of AnalyzeTextOptions. - /// The text needs to be scanned. We support at most 1000 characters (unicode code points) in text of one request. + /// The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request. /// is null. public AnalyzeTextOptions(string text) { @@ -27,25 +27,29 @@ public AnalyzeTextOptions(string text) } /// Initializes a new instance of AnalyzeTextOptions. - /// The text needs to be scanned. We support at most 1000 characters (unicode code points) in text of one request. - /// The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be returned. + /// The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request. + /// The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned. /// The names of blocklists. - /// When set to true, further analyses of harmful content will not be performed in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether or not blocklists are hit. - internal AnalyzeTextOptions(string text, IList categories, IList blocklistNames, bool? breakByBlocklists) + /// When set to true, further analyses of harmful content will not be performed in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether or not blocklists are hit. + /// This refers to the type of text analysis output. If no value is assigned, the default value will be "FourSeverityLevels". + internal AnalyzeTextOptions(string text, IList categories, IList blocklistNames, bool? haltOnBlocklistHit, AnalyzeTextOutputType? outputType) { Text = text; Categories = categories; BlocklistNames = blocklistNames; - BreakByBlocklists = breakByBlocklists; + HaltOnBlocklistHit = haltOnBlocklistHit; + OutputType = outputType; } - /// The text needs to be scanned. We support at most 1000 characters (unicode code points) in text of one request. + /// The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request. public string Text { get; } - /// The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be returned. + /// The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned. public IList Categories { get; } /// The names of blocklists. public IList BlocklistNames { get; } /// When set to true, further analyses of harmful content will not be performed in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether or not blocklists are hit. - public bool? BreakByBlocklists { get; set; } + public bool? HaltOnBlocklistHit { get; set; } + /// This refers to the type of text analysis output. If no value is assigned, the default value will be "FourSeverityLevels". + public AnalyzeTextOutputType? OutputType { get; set; } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOutputType.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOutputType.cs new file mode 100644 index 000000000000..e546d8938467 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOutputType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.ContentSafety +{ + /// The type of text analysis output. + public readonly partial struct AnalyzeTextOutputType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AnalyzeTextOutputType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FourSeverityLevelsValue = "FourSeverityLevels"; + private const string EightSeverityLevelsValue = "EightSeverityLevels"; + + /// Output severities in four levels, the value could be 0,2,4,6. + public static AnalyzeTextOutputType FourSeverityLevels { get; } = new AnalyzeTextOutputType(FourSeverityLevelsValue); + /// Output severities in eight levels, the value could be 0,1,2,3,4,5,6,7. + public static AnalyzeTextOutputType EightSeverityLevels { get; } = new AnalyzeTextOutputType(EightSeverityLevelsValue); + /// Determines if two values are the same. + public static bool operator ==(AnalyzeTextOutputType left, AnalyzeTextOutputType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AnalyzeTextOutputType left, AnalyzeTextOutputType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AnalyzeTextOutputType(string value) => new AnalyzeTextOutputType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AnalyzeTextOutputType other && Equals(other); + /// + public bool Equals(AnalyzeTextOutputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.Serialization.cs index 8256e6e78157..7c12bf024cdc 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.Serialization.cs @@ -20,65 +20,36 @@ internal static AnalyzeTextResult DeserializeAnalyzeTextResult(JsonElement eleme { return null; } - Optional> blocklistsMatchResults = default; - Optional hateResult = default; - Optional selfHarmResult = default; - Optional sexualResult = default; - Optional violenceResult = default; + Optional> blocklistsMatch = default; + IReadOnlyList categoriesAnalysis = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("blocklistsMatchResults"u8)) + if (property.NameEquals("blocklistsMatch"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TextBlocklistMatchResult.DeserializeTextBlocklistMatchResult(item)); + array.Add(TextBlocklistMatch.DeserializeTextBlocklistMatch(item)); } - blocklistsMatchResults = array; + blocklistsMatch = array; continue; } - if (property.NameEquals("hateResult"u8)) + if (property.NameEquals("categoriesAnalysis"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - hateResult = TextAnalyzeSeverityResult.DeserializeTextAnalyzeSeverityResult(property.Value); - continue; - } - if (property.NameEquals("selfHarmResult"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - selfHarmResult = TextAnalyzeSeverityResult.DeserializeTextAnalyzeSeverityResult(property.Value); - continue; - } - if (property.NameEquals("sexualResult"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - sexualResult = TextAnalyzeSeverityResult.DeserializeTextAnalyzeSeverityResult(property.Value); - continue; - } - if (property.NameEquals("violenceResult"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - continue; + array.Add(TextCategoriesAnalysis.DeserializeTextCategoriesAnalysis(item)); } - violenceResult = TextAnalyzeSeverityResult.DeserializeTextAnalyzeSeverityResult(property.Value); + categoriesAnalysis = array; continue; } } - return new AnalyzeTextResult(Optional.ToList(blocklistsMatchResults), hateResult.Value, selfHarmResult.Value, sexualResult.Value, violenceResult.Value); + return new AnalyzeTextResult(Optional.ToList(blocklistsMatch), categoriesAnalysis); } /// Deserializes the model from a raw response. diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.cs index 125ca8a7f6ee..4fd9c0e0e813 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextResult.cs @@ -5,44 +5,39 @@ #nullable disable +using System; using System.Collections.Generic; +using System.Linq; using Azure.Core; namespace Azure.AI.ContentSafety { - /// The analysis response of the text. + /// The text analysis response. public partial class AnalyzeTextResult { /// Initializes a new instance of AnalyzeTextResult. - internal AnalyzeTextResult() + /// Analysis result for categories. + /// is null. + internal AnalyzeTextResult(IEnumerable categoriesAnalysis) { - BlocklistsMatchResults = new ChangeTrackingList(); + Argument.AssertNotNull(categoriesAnalysis, nameof(categoriesAnalysis)); + + BlocklistsMatch = new ChangeTrackingList(); + CategoriesAnalysis = categoriesAnalysis.ToList(); } /// Initializes a new instance of AnalyzeTextResult. - /// The details of blocklist match. - /// Analysis result for Hate category. - /// Analysis result for SelfHarm category. - /// Analysis result for Sexual category. - /// Analysis result for Violence category. - internal AnalyzeTextResult(IReadOnlyList blocklistsMatchResults, TextAnalyzeSeverityResult hateResult, TextAnalyzeSeverityResult selfHarmResult, TextAnalyzeSeverityResult sexualResult, TextAnalyzeSeverityResult violenceResult) + /// The blocklist match details. + /// Analysis result for categories. + internal AnalyzeTextResult(IReadOnlyList blocklistsMatch, IReadOnlyList categoriesAnalysis) { - BlocklistsMatchResults = blocklistsMatchResults; - HateResult = hateResult; - SelfHarmResult = selfHarmResult; - SexualResult = sexualResult; - ViolenceResult = violenceResult; + BlocklistsMatch = blocklistsMatch; + CategoriesAnalysis = categoriesAnalysis; } - /// The details of blocklist match. - public IReadOnlyList BlocklistsMatchResults { get; } - /// Analysis result for Hate category. - public TextAnalyzeSeverityResult HateResult { get; } - /// Analysis result for SelfHarm category. - public TextAnalyzeSeverityResult SelfHarmResult { get; } - /// Analysis result for Sexual category. - public TextAnalyzeSeverityResult SexualResult { get; } - /// Analysis result for Violence category. - public TextAnalyzeSeverityResult ViolenceResult { get; } + /// The blocklist match details. + public IReadOnlyList BlocklistsMatch { get; } + /// Analysis result for categories. + public IReadOnlyList CategoriesAnalysis { get; } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs index 44e41bd84a12..32011b71111e 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs @@ -21,6 +21,8 @@ public partial class ContentSafetyClient { private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; @@ -47,6 +49,17 @@ protected ContentSafetyClient() { } + /// Initializes a new instance of ContentSafetyClient. + /// + /// Supported Cognitive Services endpoints (protocol and hostname, for example: + /// https://<resource-name>.cognitiveservices.azure.com). + /// + /// A credential used to authenticate to an Azure Service. + /// or is null. + public ContentSafetyClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new ContentSafetyClientOptions()) + { + } + /// Initializes a new instance of ContentSafetyClient. /// /// Supported Cognitive Services endpoints (protocol and hostname, for example: @@ -68,11 +81,32 @@ public ContentSafetyClient(Uri endpoint, AzureKeyCredential credential, ContentS _apiVersion = options.Version; } + /// Initializes a new instance of ContentSafetyClient. + /// + /// Supported Cognitive Services endpoints (protocol and hostname, for example: + /// https://<resource-name>.cognitiveservices.azure.com). + /// + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public ContentSafetyClient(Uri endpoint, TokenCredential credential, ContentSafetyClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new ContentSafetyClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + /// Analyze Text. - /// The request of text analysis. + /// The text analysis request. /// The cancellation token to use. /// is null. - /// A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, Sexual, Violence. + /// A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence. /// public virtual async Task> AnalyzeTextAsync(AnalyzeTextOptions body, CancellationToken cancellationToken = default) { @@ -85,10 +119,10 @@ public virtual async Task> AnalyzeTextAsync(AnalyzeT } /// Analyze Text. - /// The request of text analysis. + /// The text analysis request. /// The cancellation token to use. /// is null. - /// A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, Sexual, Violence. + /// A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence. /// public virtual Response AnalyzeText(AnalyzeTextOptions body, CancellationToken cancellationToken = default) { @@ -179,10 +213,10 @@ public virtual Response AnalyzeText(RequestContent content, RequestContext conte } /// Analyze Image. - /// The analysis request of the image. + /// The image analysis request. /// The cancellation token to use. /// is null. - /// A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, Sexual, Violence. + /// A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence. /// public virtual async Task> AnalyzeImageAsync(AnalyzeImageOptions body, CancellationToken cancellationToken = default) { @@ -195,10 +229,10 @@ public virtual async Task> AnalyzeImageAsync(Analyz } /// Analyze Image. - /// The analysis request of the image. + /// The image analysis request. /// The cancellation token to use. /// is null. - /// A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, Sexual, Violence. + /// A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence. /// public virtual Response AnalyzeImage(AnalyzeImageOptions body, CancellationToken cancellationToken = default) { @@ -546,46 +580,46 @@ public virtual Response DeleteTextBlocklist(string blocklistName, RequestContext } } - /// Add BlockItems To Text Blocklist. + /// Add or update BlocklistItems To Text Blocklist. /// Text blocklist name. - /// The request of adding blockItems to text blocklist. + /// The request to add blocklistItems to a text blocklist. /// The cancellation token to use. - /// or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - /// Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - /// - public virtual async Task> AddBlockItemsAsync(string blocklistName, AddBlockItemsOptions addBlockItemsOptions, CancellationToken cancellationToken = default) + /// Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one request. + /// + public virtual async Task> AddOrUpdateBlocklistItemsAsync(string blocklistName, AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(addBlockItemsOptions, nameof(addBlockItemsOptions)); + Argument.AssertNotNull(addOrUpdateTextBlocklistItemsOptions, nameof(addOrUpdateTextBlocklistItemsOptions)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = addBlockItemsOptions.ToRequestContent(); - Response response = await AddBlockItemsAsync(blocklistName, content, context).ConfigureAwait(false); - return Response.FromValue(AddBlockItemsResult.FromResponse(response), response); + using RequestContent content = addOrUpdateTextBlocklistItemsOptions.ToRequestContent(); + Response response = await AddOrUpdateBlocklistItemsAsync(blocklistName, content, context).ConfigureAwait(false); + return Response.FromValue(AddOrUpdateTextBlocklistItemsResult.FromResponse(response), response); } - /// Add BlockItems To Text Blocklist. + /// Add or update BlocklistItems To Text Blocklist. /// Text blocklist name. - /// The request of adding blockItems to text blocklist. + /// The request to add blocklistItems to a text blocklist. /// The cancellation token to use. - /// or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - /// Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - /// - public virtual Response AddBlockItems(string blocklistName, AddBlockItemsOptions addBlockItemsOptions, CancellationToken cancellationToken = default) + /// Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one request. + /// + public virtual Response AddOrUpdateBlocklistItems(string blocklistName, AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(addBlockItemsOptions, nameof(addBlockItemsOptions)); + Argument.AssertNotNull(addOrUpdateTextBlocklistItemsOptions, nameof(addOrUpdateTextBlocklistItemsOptions)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = addBlockItemsOptions.ToRequestContent(); - Response response = AddBlockItems(blocklistName, content, context); - return Response.FromValue(AddBlockItemsResult.FromResponse(response), response); + using RequestContent content = addOrUpdateTextBlocklistItemsOptions.ToRequestContent(); + Response response = AddOrUpdateBlocklistItems(blocklistName, content, context); + return Response.FromValue(AddOrUpdateTextBlocklistItemsResult.FromResponse(response), response); } /// - /// [Protocol Method] Add BlockItems To Text Blocklist + /// [Protocol Method] Add or update BlocklistItems To Text Blocklist /// /// /// @@ -594,7 +628,7 @@ public virtual Response AddBlockItems(string blocklistName, /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -606,17 +640,17 @@ public virtual Response AddBlockItems(string blocklistName, /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task AddBlockItemsAsync(string blocklistName, RequestContent content, RequestContext context = null) + /// + public virtual async Task AddOrUpdateBlocklistItemsAsync(string blocklistName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.AddBlockItems"); + using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.AddOrUpdateBlocklistItems"); scope.Start(); try { - using HttpMessage message = CreateAddBlockItemsRequest(blocklistName, content, context); + using HttpMessage message = CreateAddOrUpdateBlocklistItemsRequest(blocklistName, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -627,7 +661,7 @@ public virtual async Task AddBlockItemsAsync(string blocklistName, Req } /// - /// [Protocol Method] Add BlockItems To Text Blocklist + /// [Protocol Method] Add or update BlocklistItems To Text Blocklist /// /// /// @@ -636,7 +670,7 @@ public virtual async Task AddBlockItemsAsync(string blocklistName, Req /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -648,17 +682,17 @@ public virtual async Task AddBlockItemsAsync(string blocklistName, Req /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response AddBlockItems(string blocklistName, RequestContent content, RequestContext context = null) + /// + public virtual Response AddOrUpdateBlocklistItems(string blocklistName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.AddBlockItems"); + using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.AddOrUpdateBlocklistItems"); scope.Start(); try { - using HttpMessage message = CreateAddBlockItemsRequest(blocklistName, content, context); + using HttpMessage message = CreateAddOrUpdateBlocklistItemsRequest(blocklistName, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -668,46 +702,46 @@ public virtual Response AddBlockItems(string blocklistName, RequestContent conte } } - /// Remove BlockItems From Text Blocklist. + /// Remove BlocklistItems From Text Blocklist. /// Text blocklist name. - /// The request of removing blockItems from text blocklist. + /// The request to remove blocklistItems from a text blocklist. /// The cancellation token to use. - /// or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - /// Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - /// - public virtual async Task RemoveBlockItemsAsync(string blocklistName, RemoveBlockItemsOptions removeBlockItemsOptions, CancellationToken cancellationToken = default) + /// Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + /// + public virtual async Task RemoveBlocklistItemsAsync(string blocklistName, RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(removeBlockItemsOptions, nameof(removeBlockItemsOptions)); + Argument.AssertNotNull(removeTextBlocklistItemsOptions, nameof(removeTextBlocklistItemsOptions)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = removeBlockItemsOptions.ToRequestContent(); - Response response = await RemoveBlockItemsAsync(blocklistName, content, context).ConfigureAwait(false); + using RequestContent content = removeTextBlocklistItemsOptions.ToRequestContent(); + Response response = await RemoveBlocklistItemsAsync(blocklistName, content, context).ConfigureAwait(false); return response; } - /// Remove BlockItems From Text Blocklist. + /// Remove BlocklistItems From Text Blocklist. /// Text blocklist name. - /// The request of removing blockItems from text blocklist. + /// The request to remove blocklistItems from a text blocklist. /// The cancellation token to use. - /// or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - /// Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - /// - public virtual Response RemoveBlockItems(string blocklistName, RemoveBlockItemsOptions removeBlockItemsOptions, CancellationToken cancellationToken = default) + /// Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + /// + public virtual Response RemoveBlocklistItems(string blocklistName, RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(removeBlockItemsOptions, nameof(removeBlockItemsOptions)); + Argument.AssertNotNull(removeTextBlocklistItemsOptions, nameof(removeTextBlocklistItemsOptions)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = removeBlockItemsOptions.ToRequestContent(); - Response response = RemoveBlockItems(blocklistName, content, context); + using RequestContent content = removeTextBlocklistItemsOptions.ToRequestContent(); + Response response = RemoveBlocklistItems(blocklistName, content, context); return response; } /// - /// [Protocol Method] Remove BlockItems From Text Blocklist + /// [Protocol Method] Remove BlocklistItems From Text Blocklist /// /// /// @@ -716,7 +750,7 @@ public virtual Response RemoveBlockItems(string blocklistName, RemoveBlockItemsO /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -728,17 +762,17 @@ public virtual Response RemoveBlockItems(string blocklistName, RemoveBlockItemsO /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task RemoveBlockItemsAsync(string blocklistName, RequestContent content, RequestContext context = null) + /// + public virtual async Task RemoveBlocklistItemsAsync(string blocklistName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.RemoveBlockItems"); + using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.RemoveBlocklistItems"); scope.Start(); try { - using HttpMessage message = CreateRemoveBlockItemsRequest(blocklistName, content, context); + using HttpMessage message = CreateRemoveBlocklistItemsRequest(blocklistName, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -749,7 +783,7 @@ public virtual async Task RemoveBlockItemsAsync(string blocklistName, } /// - /// [Protocol Method] Remove BlockItems From Text Blocklist + /// [Protocol Method] Remove BlocklistItems From Text Blocklist /// /// /// @@ -758,7 +792,7 @@ public virtual async Task RemoveBlockItemsAsync(string blocklistName, /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -770,17 +804,17 @@ public virtual async Task RemoveBlockItemsAsync(string blocklistName, /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response RemoveBlockItems(string blocklistName, RequestContent content, RequestContext context = null) + /// + public virtual Response RemoveBlocklistItems(string blocklistName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.RemoveBlockItems"); + using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.RemoveBlocklistItems"); scope.Start(); try { - using HttpMessage message = CreateRemoveBlockItemsRequest(blocklistName, content, context); + using HttpMessage message = CreateRemoveBlocklistItemsRequest(blocklistName, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -790,44 +824,44 @@ public virtual Response RemoveBlockItems(string blocklistName, RequestContent co } } - /// Get BlockItem By blocklistName And blockItemId. + /// Get BlocklistItem By blocklistName And blocklistItemId. /// Text blocklist name. - /// Block Item Id. It will be uuid. + /// The service will generate a BlocklistItemId, which will be a UUID. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Get blockItem By blockItemId from a text blocklist. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. /// - public virtual async Task> GetTextBlocklistItemAsync(string blocklistName, string blockItemId, CancellationToken cancellationToken = default) + public virtual async Task> GetTextBlocklistItemAsync(string blocklistName, string blocklistItemId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetTextBlocklistItemAsync(blocklistName, blockItemId, context).ConfigureAwait(false); - return Response.FromValue(TextBlockItem.FromResponse(response), response); + Response response = await GetTextBlocklistItemAsync(blocklistName, blocklistItemId, context).ConfigureAwait(false); + return Response.FromValue(TextBlocklistItem.FromResponse(response), response); } - /// Get BlockItem By blocklistName And blockItemId. + /// Get BlocklistItem By blocklistName And blocklistItemId. /// Text blocklist name. - /// Block Item Id. It will be uuid. + /// The service will generate a BlocklistItemId, which will be a UUID. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Get blockItem By blockItemId from a text blocklist. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. /// - public virtual Response GetTextBlocklistItem(string blocklistName, string blockItemId, CancellationToken cancellationToken = default) + public virtual Response GetTextBlocklistItem(string blocklistName, string blocklistItemId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetTextBlocklistItem(blocklistName, blockItemId, context); - return Response.FromValue(TextBlockItem.FromResponse(response), response); + Response response = GetTextBlocklistItem(blocklistName, blocklistItemId, context); + return Response.FromValue(TextBlocklistItem.FromResponse(response), response); } /// - /// [Protocol Method] Get BlockItem By blocklistName And blockItemId + /// [Protocol Method] Get BlocklistItem By blocklistName And blocklistItemId /// /// /// @@ -842,23 +876,23 @@ public virtual Response GetTextBlocklistItem(string blocklistName /// /// /// Text blocklist name. - /// Block Item Id. It will be uuid. + /// The service will generate a BlocklistItemId, which will be a UUID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. /// - public virtual async Task GetTextBlocklistItemAsync(string blocklistName, string blockItemId, RequestContext context) + public virtual async Task GetTextBlocklistItemAsync(string blocklistName, string blocklistItemId, RequestContext context) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.GetTextBlocklistItem"); scope.Start(); try { - using HttpMessage message = CreateGetTextBlocklistItemRequest(blocklistName, blockItemId, context); + using HttpMessage message = CreateGetTextBlocklistItemRequest(blocklistName, blocklistItemId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -869,7 +903,7 @@ public virtual async Task GetTextBlocklistItemAsync(string blocklistNa } /// - /// [Protocol Method] Get BlockItem By blocklistName And blockItemId + /// [Protocol Method] Get BlocklistItem By blocklistName And blocklistItemId /// /// /// @@ -884,23 +918,23 @@ public virtual async Task GetTextBlocklistItemAsync(string blocklistNa /// /// /// Text blocklist name. - /// Block Item Id. It will be uuid. + /// The service will generate a BlocklistItemId, which will be a UUID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. /// - public virtual Response GetTextBlocklistItem(string blocklistName, string blockItemId, RequestContext context) + public virtual Response GetTextBlocklistItem(string blocklistName, string blocklistItemId, RequestContext context) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.GetTextBlocklistItem"); scope.Start(); try { - using HttpMessage message = CreateGetTextBlocklistItemRequest(blocklistName, blockItemId, context); + using HttpMessage message = CreateGetTextBlocklistItemRequest(blocklistName, blocklistItemId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -986,7 +1020,7 @@ public virtual Pageable GetTextBlocklists(RequestContext context) return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklists", "value", "nextLink", context); } - /// Get All BlockItems By blocklistName. + /// Get All BlocklistItems By blocklistName. /// Text blocklist name. /// The number of result items to return. /// The number of result items to skip. @@ -994,19 +1028,19 @@ public virtual Pageable GetTextBlocklists(RequestContext context) /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - /// Get all blockItems in a text blocklist. + /// Get all blocklistItems in a text blocklist. /// - public virtual AsyncPageable GetTextBlocklistItemsAsync(string blocklistName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + public virtual AsyncPageable GetTextBlocklistItemsAsync(string blocklistName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistItemsRequest(blocklistName, maxCount, skip, maxpagesize, context); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistItemsNextPageRequest(nextLink, blocklistName, maxCount, skip, maxpagesize, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, TextBlockItem.DeserializeTextBlockItem, ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklistItems", "value", "nextLink", context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, TextBlocklistItem.DeserializeTextBlocklistItem, ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklistItems", "value", "nextLink", context); } - /// Get All BlockItems By blocklistName. + /// Get All BlocklistItems By blocklistName. /// Text blocklist name. /// The number of result items to return. /// The number of result items to skip. @@ -1014,20 +1048,20 @@ public virtual AsyncPageable GetTextBlocklistItemsAsync(string bl /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - /// Get all blockItems in a text blocklist. + /// Get all blocklistItems in a text blocklist. /// - public virtual Pageable GetTextBlocklistItems(string blocklistName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + public virtual Pageable GetTextBlocklistItems(string blocklistName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistItemsRequest(blocklistName, maxCount, skip, maxpagesize, context); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistItemsNextPageRequest(nextLink, blocklistName, maxCount, skip, maxpagesize, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, TextBlockItem.DeserializeTextBlockItem, ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklistItems", "value", "nextLink", context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, TextBlocklistItem.DeserializeTextBlocklistItem, ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklistItems", "value", "nextLink", context); } /// - /// [Protocol Method] Get All BlockItems By blocklistName + /// [Protocol Method] Get All BlocklistItems By blocklistName /// /// /// @@ -1061,7 +1095,7 @@ public virtual AsyncPageable GetTextBlocklistItemsAsync(string block } /// - /// [Protocol Method] Get All BlockItems By blocklistName + /// [Protocol Method] Get All BlocklistItems By blocklistName /// /// /// @@ -1193,7 +1227,7 @@ internal HttpMessage CreateGetTextBlocklistsRequest(RequestContext context) return message; } - internal HttpMessage CreateAddBlockItemsRequest(string blocklistName, RequestContent content, RequestContext context) + internal HttpMessage CreateAddOrUpdateBlocklistItemsRequest(string blocklistName, RequestContent content, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1203,7 +1237,7 @@ internal HttpMessage CreateAddBlockItemsRequest(string blocklistName, RequestCon uri.AppendRaw("/contentsafety", false); uri.AppendPath("/text/blocklists/", false); uri.AppendPath(blocklistName, true); - uri.AppendPath(":addBlockItems", false); + uri.AppendPath(":addOrUpdateBlocklistItems", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1212,7 +1246,7 @@ internal HttpMessage CreateAddBlockItemsRequest(string blocklistName, RequestCon return message; } - internal HttpMessage CreateRemoveBlockItemsRequest(string blocklistName, RequestContent content, RequestContext context) + internal HttpMessage CreateRemoveBlocklistItemsRequest(string blocklistName, RequestContent content, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier204); var request = message.Request; @@ -1222,7 +1256,7 @@ internal HttpMessage CreateRemoveBlockItemsRequest(string blocklistName, Request uri.AppendRaw("/contentsafety", false); uri.AppendPath("/text/blocklists/", false); uri.AppendPath(blocklistName, true); - uri.AppendPath(":removeBlockItems", false); + uri.AppendPath(":removeBlocklistItems", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1231,7 +1265,7 @@ internal HttpMessage CreateRemoveBlockItemsRequest(string blocklistName, Request return message; } - internal HttpMessage CreateGetTextBlocklistItemRequest(string blocklistName, string blockItemId, RequestContext context) + internal HttpMessage CreateGetTextBlocklistItemRequest(string blocklistName, string blocklistItemId, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1241,8 +1275,8 @@ internal HttpMessage CreateGetTextBlocklistItemRequest(string blocklistName, str uri.AppendRaw("/contentsafety", false); uri.AppendPath("/text/blocklists/", false); uri.AppendPath(blocklistName, true); - uri.AppendPath("/blockItems/", false); - uri.AppendPath(blockItemId, true); + uri.AppendPath("/blocklistItems/", false); + uri.AppendPath(blocklistItemId, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1259,7 +1293,7 @@ internal HttpMessage CreateGetTextBlocklistItemsRequest(string blocklistName, in uri.AppendRaw("/contentsafety", false); uri.AppendPath("/text/blocklists/", false); uri.AppendPath(blocklistName, true); - uri.AppendPath("/blockItems", false); + uri.AppendPath("/blocklistItems", false); uri.AppendQuery("api-version", _apiVersion, true); if (maxCount != null) { diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClientOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClientOptions.cs index 8f6285c3198e..df89b0c9a524 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClientOptions.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClientOptions.cs @@ -13,13 +13,13 @@ namespace Azure.AI.ContentSafety /// Client options for ContentSafetyClient. public partial class ContentSafetyClientOptions : ClientOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V2023_04_30_Preview; + private const ServiceVersion LatestVersion = ServiceVersion.V2023_10_01; /// The version of the service to use. public enum ServiceVersion { - /// Service version "2023-04-30-preview". - V2023_04_30_Preview = 1, + /// Service version "2023-10-01". + V2023_10_01 = 1, } internal string Version { get; } @@ -29,7 +29,7 @@ public ContentSafetyClientOptions(ServiceVersion version = LatestVersion) { Version = version switch { - ServiceVersion.V2023_04_30_Preview => "2023-04-30-preview", + ServiceVersion.V2023_10_01 => "2023-10-01", _ => throw new NotSupportedException() }; } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.cs index 5bcf3028b84f..bb7a0d0ebd6d 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.cs @@ -9,7 +9,7 @@ namespace Azure.AI.ContentSafety { - /// The content or blob url of image, could be base64 encoding bytes or blob url. If both are given, the request will be refused. The maximum size of image is 2048 pixels * 2048 pixels, no larger than 4MB at the same time. The minimum size of image is 50 pixels * 50 pixels. + /// The image can be either base64 encoded bytes or a blob URL. You can choose only one of these options. If both are provided, the request will be refused. The maximum image size is 2048 x 2048 pixels and should not exceed 4 MB, while the minimum image size is 50 x 50 pixels. public partial class ContentSafetyImageData { /// Initializes a new instance of ContentSafetyImageData. @@ -18,8 +18,8 @@ public ContentSafetyImageData() } /// Initializes a new instance of ContentSafetyImageData. - /// Base64 encoding of image. - /// The blob url of image. + /// The Base64 encoding of the image. + /// The blob url of the image. internal ContentSafetyImageData(BinaryData content, Uri blobUrl) { Content = content; @@ -27,7 +27,7 @@ internal ContentSafetyImageData(BinaryData content, Uri blobUrl) } /// - /// Base64 encoding of image. + /// The Base64 encoding of the image. /// /// To assign a byte[] to this property use . /// The byte[] will be serialized to a Base64 encoded string. @@ -43,7 +43,7 @@ internal ContentSafetyImageData(BinaryData content, Uri blobUrl) /// /// public BinaryData Content { get; set; } - /// The blob url of image. + /// The blob url of the image. public Uri BlobUrl { get; set; } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/ContentSafetyClient.xml b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/ContentSafetyClient.xml index 66d75df37e28..30ca4e4ff6ef 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/ContentSafetyClient.xml +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/ContentSafetyClient.xml @@ -22,7 +22,8 @@ AnalyzeTextOptions body = new AnalyzeTextOptions("") { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; Response response = await client.AnalyzeTextAsync(body); ]]> @@ -48,7 +49,8 @@ AnalyzeTextOptions body = new AnalyzeTextOptions("") { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; Response response = client.AnalyzeText(body); ]]> @@ -68,7 +70,7 @@ using RequestContent content = RequestContent.Create(new Response response = await client.AnalyzeTextAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); ]]> This sample shows how to call AnalyzeTextAsync with all request content and parse the result. " }, - breakByBlocklists = true, + haltOnBlocklistHit = true, + outputType = "FourSeverityLevels", }); Response response = await client.AnalyzeTextAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blocklistName").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemText").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("offset").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("length").ToString()); -Console.WriteLine(result.GetProperty("hateResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("hateResult").GetProperty("severity").ToString()); -Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("severity").ToString()); -Console.WriteLine(result.GetProperty("sexualResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("sexualResult").GetProperty("severity").ToString()); -Console.WriteLine(result.GetProperty("violenceResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("violenceResult").GetProperty("severity").ToString()); +Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistName").ToString()); +Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemText").ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").ToString()); ]]> @@ -122,7 +117,7 @@ using RequestContent content = RequestContent.Create(new Response response = client.AnalyzeText(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); ]]> This sample shows how to call AnalyzeText with all request content and parse the result. " }, - breakByBlocklists = true, + haltOnBlocklistHit = true, + outputType = "FourSeverityLevels", }); Response response = client.AnalyzeText(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blocklistName").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemText").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("offset").ToString()); -Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("length").ToString()); -Console.WriteLine(result.GetProperty("hateResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("hateResult").GetProperty("severity").ToString()); -Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("severity").ToString()); -Console.WriteLine(result.GetProperty("sexualResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("sexualResult").GetProperty("severity").ToString()); -Console.WriteLine(result.GetProperty("violenceResult").GetProperty("category").ToString()); -Console.WriteLine(result.GetProperty("violenceResult").GetProperty("severity").ToString()); +Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistName").ToString()); +Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemText").ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").ToString()); ]]> @@ -185,6 +173,7 @@ AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; Response response = await client.AnalyzeImageAsync(body); ]]> @@ -213,6 +202,7 @@ AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; Response response = client.AnalyzeImage(body); ]]> @@ -232,7 +222,7 @@ using RequestContent content = RequestContent.Create(new Response response = await client.AnalyzeImageAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); ]]> This sample shows how to call AnalyzeImageAsync with all request content and parse the result. @@ -280,7 +265,7 @@ using RequestContent content = RequestContent.Create(new Response response = client.AnalyzeImage(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); ]]> This sample shows how to call AnalyzeImage with all request content and parse the result. @@ -519,69 +499,69 @@ Response response = client.DeleteTextBlocklist(""); Console.WriteLine(response.Status); ]]> - + -This sample shows how to call AddBlockItemsAsync. +This sample shows how to call AddOrUpdateBlocklistItemsAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] +AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { - new TextBlockItemInfo("") + new TextBlocklistItem("") }); -Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", addOrUpdateTextBlocklistItemsOptions); ]]> -This sample shows how to call AddBlockItemsAsync with all parameters. +This sample shows how to call AddOrUpdateBlocklistItemsAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] +AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { - new TextBlockItemInfo("") + new TextBlocklistItem("") { Description = "", } }); -Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", addOrUpdateTextBlocklistItemsOptions); ]]> - + -This sample shows how to call AddBlockItems. +This sample shows how to call AddOrUpdateBlocklistItems. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] +AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { - new TextBlockItemInfo("") + new TextBlocklistItem("") }); -Response response = client.AddBlockItems("", addBlockItemsOptions); +Response response = client.AddOrUpdateBlocklistItems("", addOrUpdateTextBlocklistItemsOptions); ]]> -This sample shows how to call AddBlockItems with all parameters. +This sample shows how to call AddOrUpdateBlocklistItems with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] +AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { - new TextBlockItemInfo("") + new TextBlocklistItem("") { Description = "", } }); -Response response = client.AddBlockItems("", addBlockItemsOptions); +Response response = client.AddOrUpdateBlocklistItems("", addOrUpdateTextBlocklistItemsOptions); ]]> - + -This sample shows how to call AddBlockItemsAsync and parse the result. +This sample shows how to call AddOrUpdateBlocklistItemsAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -589,7 +569,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -597,12 +577,13 @@ using RequestContent content = RequestContent.Create(new } }, }); -Response response = await client.AddBlockItemsAsync("", content); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); ]]> -This sample shows how to call AddBlockItemsAsync with all parameters and request content and parse the result. +This sample shows how to call AddOrUpdateBlocklistItemsAsync with all parameters and request content and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -610,7 +591,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -619,17 +600,17 @@ using RequestContent content = RequestContent.Create(new } }, }); -Response response = await client.AddBlockItemsAsync("", content); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("value")[0].GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString()); -Console.WriteLine(result.GetProperty("value")[0].GetProperty("text").ToString()); +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()); ]]> - + -This sample shows how to call AddBlockItems and parse the result. +This sample shows how to call AddOrUpdateBlocklistItems and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -637,7 +618,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -645,12 +626,13 @@ using RequestContent content = RequestContent.Create(new } }, }); -Response response = client.AddBlockItems("", content); +Response response = client.AddOrUpdateBlocklistItems("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); ]]> -This sample shows how to call AddBlockItems with all parameters and request content and parse the result. +This sample shows how to call AddOrUpdateBlocklistItems with all parameters and request content and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -658,7 +640,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -667,59 +649,59 @@ using RequestContent content = RequestContent.Create(new } }, }); -Response response = client.AddBlockItems("", content); +Response response = client.AddOrUpdateBlocklistItems("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("value")[0].GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString()); -Console.WriteLine(result.GetProperty("value")[0].GetProperty("text").ToString()); +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()); ]]> - + -This sample shows how to call RemoveBlockItemsAsync. +This sample shows how to call RemoveBlocklistItemsAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = await client.RemoveBlockItemsAsync("", removeBlockItemsOptions); +RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = await client.RemoveBlocklistItemsAsync("", removeTextBlocklistItemsOptions); ]]> -This sample shows how to call RemoveBlockItemsAsync with all parameters. +This sample shows how to call RemoveBlocklistItemsAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = await client.RemoveBlockItemsAsync("", removeBlockItemsOptions); +RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = await client.RemoveBlocklistItemsAsync("", removeTextBlocklistItemsOptions); ]]> - + -This sample shows how to call RemoveBlockItems. +This sample shows how to call RemoveBlocklistItems. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = client.RemoveBlockItems("", removeBlockItemsOptions); +RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = client.RemoveBlocklistItems("", removeTextBlocklistItemsOptions); ]]> -This sample shows how to call RemoveBlockItems with all parameters. +This sample shows how to call RemoveBlocklistItems with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = client.RemoveBlockItems("", removeBlockItemsOptions); +RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = client.RemoveBlocklistItems("", removeTextBlocklistItemsOptions); ]]> - + -This sample shows how to call RemoveBlockItemsAsync. +This sample shows how to call RemoveBlocklistItemsAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -727,16 +709,16 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { - "" + "" }, }); -Response response = await client.RemoveBlockItemsAsync("", content); +Response response = await client.RemoveBlocklistItemsAsync("", content); Console.WriteLine(response.Status); ]]> -This sample shows how to call RemoveBlockItemsAsync with all parameters and request content. +This sample shows how to call RemoveBlocklistItemsAsync with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -744,19 +726,19 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { - "" + "" }, }); -Response response = await client.RemoveBlockItemsAsync("", content); +Response response = await client.RemoveBlocklistItemsAsync("", content); Console.WriteLine(response.Status); ]]> - + -This sample shows how to call RemoveBlockItems. +This sample shows how to call RemoveBlocklistItems. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -764,16 +746,16 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { - "" + "" }, }); -Response response = client.RemoveBlockItems("", content); +Response response = client.RemoveBlocklistItems("", content); Console.WriteLine(response.Status); ]]> -This sample shows how to call RemoveBlockItems with all parameters and request content. +This sample shows how to call RemoveBlocklistItems with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -781,12 +763,12 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { - "" + "" }, }); -Response response = client.RemoveBlockItems("", content); +Response response = client.RemoveBlocklistItems("", content); Console.WriteLine(response.Status); ]]> @@ -799,7 +781,7 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = await client.GetTextBlocklistItemAsync("", ""); +Response response = await client.GetTextBlocklistItemAsync("", ""); ]]> This sample shows how to call GetTextBlocklistItemAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = await client.GetTextBlocklistItemAsync("", ""); +Response response = await client.GetTextBlocklistItemAsync("", ""); ]]> @@ -818,7 +800,7 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = client.GetTextBlocklistItem("", ""); +Response response = client.GetTextBlocklistItem("", ""); ]]> This sample shows how to call GetTextBlocklistItem with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = client.GetTextBlocklistItem("", ""); +Response response = client.GetTextBlocklistItem("", ""); ]]> @@ -837,10 +819,10 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = await client.GetTextBlocklistItemAsync("", "", null); +Response response = await client.GetTextBlocklistItemAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); ]]> This sample shows how to call GetTextBlocklistItemAsync with all parameters and parse the result. @@ -849,10 +831,10 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = await client.GetTextBlocklistItemAsync("", "", null); +Response response = await client.GetTextBlocklistItemAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); ]]> @@ -865,10 +847,10 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = client.GetTextBlocklistItem("", "", null); +Response response = client.GetTextBlocklistItem("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); ]]> This sample shows how to call GetTextBlocklistItem with all parameters and parse the result. @@ -877,10 +859,10 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -Response response = client.GetTextBlocklistItem("", "", null); +Response response = client.GetTextBlocklistItem("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); ]]> @@ -995,7 +977,7 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("")) +await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("")) { } ]]> @@ -1005,7 +987,7 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) { } ]]> @@ -1018,7 +1000,7 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -foreach (TextBlockItem item in client.GetTextBlocklistItems("")) +foreach (TextBlocklistItem item in client.GetTextBlocklistItems("")) { } ]]> @@ -1028,7 +1010,7 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -foreach (TextBlockItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +foreach (TextBlocklistItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) { } ]]> @@ -1044,7 +1026,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } ]]> @@ -1057,7 +1039,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -1074,7 +1056,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); foreach (BinaryData item in client.GetTextBlocklistItems("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } ]]> @@ -1087,7 +1069,7 @@ ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); foreach (BinaryData item in client.GetTextBlocklistItems("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.cs deleted file mode 100644 index 9af75fe1da78..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.ContentSafety -{ - /// Image analysis result. - public partial class ImageAnalyzeSeverityResult - { - /// Initializes a new instance of ImageAnalyzeSeverityResult. - /// The image category. - /// The higher the severity of input content, the larger this value, currently its value could be: 0,2,4,6. - internal ImageAnalyzeSeverityResult(ImageCategory category, int severity) - { - Category = category; - Severity = severity; - } - - /// The image category. - public ImageCategory Category { get; } - /// The higher the severity of input content, the larger this value, currently its value could be: 0,2,4,6. - public int Severity { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.Serialization.cs similarity index 64% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.Serialization.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.Serialization.cs index 3ef3955610bb..660e1d41b96e 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.Serialization.cs @@ -7,19 +7,20 @@ using System.Text.Json; using Azure; +using Azure.Core; namespace Azure.AI.ContentSafety { - public partial class ImageAnalyzeSeverityResult + public partial class ImageCategoriesAnalysis { - internal static ImageAnalyzeSeverityResult DeserializeImageAnalyzeSeverityResult(JsonElement element) + internal static ImageCategoriesAnalysis DeserializeImageCategoriesAnalysis(JsonElement element) { if (element.ValueKind == JsonValueKind.Null) { return null; } ImageCategory category = default; - int severity = default; + Optional severity = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("category"u8)) @@ -29,19 +30,23 @@ internal static ImageAnalyzeSeverityResult DeserializeImageAnalyzeSeverityResult } if (property.NameEquals("severity"u8)) { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } severity = property.Value.GetInt32(); continue; } } - return new ImageAnalyzeSeverityResult(category, severity); + return new ImageCategoriesAnalysis(category, Optional.ToNullable(severity)); } /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static ImageAnalyzeSeverityResult FromResponse(Response response) + internal static ImageCategoriesAnalysis FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeImageAnalyzeSeverityResult(document.RootElement); + return DeserializeImageCategoriesAnalysis(document.RootElement); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.cs new file mode 100644 index 000000000000..d24933194774 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.ContentSafety +{ + /// Image analysis result. + public partial class ImageCategoriesAnalysis + { + /// Initializes a new instance of ImageCategoriesAnalysis. + /// The image analysis category. + internal ImageCategoriesAnalysis(ImageCategory category) + { + Category = category; + } + + /// Initializes a new instance of ImageCategoriesAnalysis. + /// The image analysis category. + /// The value increases with the severity of the input content. The value of this field is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’ or ‘EightSeverity Levels’, and the output value can be 0, 2, 4, 6 or 0, 1, 2, 3, 4, 5, 6, or 7. + internal ImageCategoriesAnalysis(ImageCategory category, int? severity) + { + Category = category; + Severity = severity; + } + + /// The image analysis category. + public ImageCategory Category { get; } + /// The value increases with the severity of the input content. The value of this field is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’ or ‘EightSeverity Levels’, and the output value can be 0, 2, 4, 6 or 0, 1, 2, 3, 4, 5, 6, or 7. + public int? Severity { get; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.cs deleted file mode 100644 index d8759e8db58e..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - /// The request of removing blockItems from text blocklist. - public partial class RemoveBlockItemsOptions - { - /// Initializes a new instance of RemoveBlockItemsOptions. - /// Array of blockItemIds to remove. - /// is null. - public RemoveBlockItemsOptions(IEnumerable blockItemIds) - { - Argument.AssertNotNull(blockItemIds, nameof(blockItemIds)); - - BlockItemIds = blockItemIds.ToList(); - } - - /// Initializes a new instance of RemoveBlockItemsOptions. - /// Array of blockItemIds to remove. - internal RemoveBlockItemsOptions(IList blockItemIds) - { - BlockItemIds = blockItemIds; - } - - /// Array of blockItemIds to remove. - public IList BlockItemIds { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.Serialization.cs similarity index 81% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.Serialization.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.Serialization.cs index d1df71a0dbe1..d7e0822600f4 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.Serialization.cs @@ -10,14 +10,14 @@ namespace Azure.AI.ContentSafety { - public partial class RemoveBlockItemsOptions : IUtf8JsonSerializable + public partial class RemoveTextBlocklistItemsOptions : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); - writer.WritePropertyName("blockItemIds"u8); + writer.WritePropertyName("blocklistItemIds"u8); writer.WriteStartArray(); - foreach (var item in BlockItemIds) + foreach (var item in BlocklistItemIds) { writer.WriteStringValue(item); } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.cs new file mode 100644 index 000000000000..aee2f49a0630 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.ContentSafety +{ + /// The request to remove blocklistItems from a text blocklist. + public partial class RemoveTextBlocklistItemsOptions + { + /// Initializes a new instance of RemoveTextBlocklistItemsOptions. + /// Array of blocklistItemIds to remove. + /// is null. + public RemoveTextBlocklistItemsOptions(IEnumerable blocklistItemIds) + { + Argument.AssertNotNull(blocklistItemIds, nameof(blocklistItemIds)); + + BlocklistItemIds = blocklistItemIds.ToList(); + } + + /// Initializes a new instance of RemoveTextBlocklistItemsOptions. + /// Array of blocklistItemIds to remove. + internal RemoveTextBlocklistItemsOptions(IList blocklistItemIds) + { + BlocklistItemIds = blocklistItemIds; + } + + /// Array of blocklistItemIds to remove. + public IList BlocklistItemIds { get; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.cs deleted file mode 100644 index b77d1561e74d..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.ContentSafety -{ - /// Text analysis result. - public partial class TextAnalyzeSeverityResult - { - /// Initializes a new instance of TextAnalyzeSeverityResult. - /// The text category. - /// The higher the severity of input content, the larger this value is. The values could be: 0,2,4,6. - internal TextAnalyzeSeverityResult(TextCategory category, int severity) - { - Category = category; - Severity = severity; - } - - /// The text category. - public TextCategory Category { get; } - /// The higher the severity of input content, the larger this value is. The values could be: 0,2,4,6. - public int Severity { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.cs deleted file mode 100644 index 23ac2522a815..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - /// Item in TextBlocklist. - public partial class TextBlockItem - { - /// Initializes a new instance of TextBlockItem. - /// Block Item Id. It will be uuid. - /// Block item content. - /// or is null. - internal TextBlockItem(string blockItemId, string text) - { - Argument.AssertNotNull(blockItemId, nameof(blockItemId)); - Argument.AssertNotNull(text, nameof(text)); - - BlockItemId = blockItemId; - Text = text; - } - - /// Initializes a new instance of TextBlockItem. - /// Block Item Id. It will be uuid. - /// Block item description. - /// Block item content. - internal TextBlockItem(string blockItemId, string description, string text) - { - BlockItemId = blockItemId; - Description = description; - Text = text; - } - - /// Block Item Id. It will be uuid. - public string BlockItemId { get; } - /// Block item description. - public string Description { get; } - /// Block item content. - public string Text { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.Serialization.cs deleted file mode 100644 index 0f78b5dc1d76..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.Serialization.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - public partial class TextBlockItemInfo : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - writer.WriteEndObject(); - } - - /// Convert into a Utf8JsonRequestContent. - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.cs deleted file mode 100644 index f983f67dbbee..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - /// Block item info in text blocklist. - public partial class TextBlockItemInfo - { - /// Initializes a new instance of TextBlockItemInfo. - /// Block item content. - /// is null. - public TextBlockItemInfo(string text) - { - Argument.AssertNotNull(text, nameof(text)); - - Text = text; - } - - /// Initializes a new instance of TextBlockItemInfo. - /// Block item description. - /// Block item content. - internal TextBlockItemInfo(string description, string text) - { - Description = description; - Text = text; - } - - /// Block item description. - public string Description { get; set; } - /// Block item content. - public string Text { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.Serialization.cs new file mode 100644 index 000000000000..504576f9431a --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.Serialization.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.ContentSafety +{ + public partial class TextBlocklistItem : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WriteEndObject(); + } + + internal static TextBlocklistItem DeserializeTextBlocklistItem(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string blocklistItemId = default; + Optional description = default; + string text = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("blocklistItemId"u8)) + { + blocklistItemId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + } + return new TextBlocklistItem(blocklistItemId, description.Value, text); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TextBlocklistItem FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTextBlocklistItem(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.cs new file mode 100644 index 000000000000..8adb067fc6e6 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.ContentSafety +{ + /// Item in a TextBlocklist. + public partial class TextBlocklistItem + { + /// Initializes a new instance of TextBlocklistItem. + /// BlocklistItem content. + /// is null. + public TextBlocklistItem(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of TextBlocklistItem. + /// The service will generate a BlocklistItemId, which will be a UUID. + /// BlocklistItem description. + /// BlocklistItem content. + internal TextBlocklistItem(string blocklistItemId, string description, string text) + { + BlocklistItemId = blocklistItemId; + Description = description; + Text = text; + } + + /// The service will generate a BlocklistItemId, which will be a UUID. + public string BlocklistItemId { get; } + /// BlocklistItem description. + public string Description { get; set; } + /// BlocklistItem content. + public string Text { get; set; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.Serialization.cs similarity index 50% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.Serialization.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.Serialization.cs index a29aa1d978f6..1825b88170d7 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.Serialization.cs @@ -7,48 +7,47 @@ using System.Text.Json; using Azure; -using Azure.Core; namespace Azure.AI.ContentSafety { - public partial class TextBlockItem + public partial class TextBlocklistMatch { - internal static TextBlockItem DeserializeTextBlockItem(JsonElement element) + internal static TextBlocklistMatch DeserializeTextBlocklistMatch(JsonElement element) { if (element.ValueKind == JsonValueKind.Null) { return null; } - string blockItemId = default; - Optional description = default; - string text = default; + string blocklistName = default; + string blocklistItemId = default; + string blocklistItemText = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("blockItemId"u8)) + if (property.NameEquals("blocklistName"u8)) { - blockItemId = property.Value.GetString(); + blocklistName = property.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (property.NameEquals("blocklistItemId"u8)) { - description = property.Value.GetString(); + blocklistItemId = property.Value.GetString(); continue; } - if (property.NameEquals("text"u8)) + if (property.NameEquals("blocklistItemText"u8)) { - text = property.Value.GetString(); + blocklistItemText = property.Value.GetString(); continue; } } - return new TextBlockItem(blockItemId, description.Value, text); + return new TextBlocklistMatch(blocklistName, blocklistItemId, blocklistItemText); } /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static TextBlockItem FromResponse(Response response) + internal static TextBlocklistMatch FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeTextBlockItem(document.RootElement); + return DeserializeTextBlocklistMatch(document.RootElement); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.cs new file mode 100644 index 000000000000..8e915edf31db --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.ContentSafety +{ + /// The result of blocklist match. + public partial class TextBlocklistMatch + { + /// Initializes a new instance of TextBlocklistMatch. + /// The name of the matched blocklist. + /// The ID of the matched item. + /// The content of the matched item. + /// , or is null. + internal TextBlocklistMatch(string blocklistName, string blocklistItemId, string blocklistItemText) + { + Argument.AssertNotNull(blocklistName, nameof(blocklistName)); + Argument.AssertNotNull(blocklistItemId, nameof(blocklistItemId)); + Argument.AssertNotNull(blocklistItemText, nameof(blocklistItemText)); + + BlocklistName = blocklistName; + BlocklistItemId = blocklistItemId; + BlocklistItemText = blocklistItemText; + } + + /// The name of the matched blocklist. + public string BlocklistName { get; } + /// The ID of the matched item. + public string BlocklistItemId { get; } + /// The content of the matched item. + public string BlocklistItemText { get; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.Serialization.cs deleted file mode 100644 index ee1b83025ee1..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.Serialization.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure; - -namespace Azure.AI.ContentSafety -{ - public partial class TextBlocklistMatchResult - { - internal static TextBlocklistMatchResult DeserializeTextBlocklistMatchResult(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string blocklistName = default; - string blockItemId = default; - string blockItemText = default; - int offset = default; - int length = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("blocklistName"u8)) - { - blocklistName = property.Value.GetString(); - continue; - } - if (property.NameEquals("blockItemId"u8)) - { - blockItemId = property.Value.GetString(); - continue; - } - if (property.NameEquals("blockItemText"u8)) - { - blockItemText = property.Value.GetString(); - continue; - } - if (property.NameEquals("offset"u8)) - { - offset = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("length"u8)) - { - length = property.Value.GetInt32(); - continue; - } - } - return new TextBlocklistMatchResult(blocklistName, blockItemId, blockItemText, offset, length); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static TextBlocklistMatchResult FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeTextBlocklistMatchResult(document.RootElement); - } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.cs deleted file mode 100644 index b4fc2ead623b..000000000000 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using Azure.Core; - -namespace Azure.AI.ContentSafety -{ - /// The result of blocklist match. - public partial class TextBlocklistMatchResult - { - /// Initializes a new instance of TextBlocklistMatchResult. - /// The name of matched blocklist. - /// The id of matched item. - /// The content of matched item. - /// The character offset of matched text in original input. - /// The length of matched text in original input. - /// , or is null. - internal TextBlocklistMatchResult(string blocklistName, string blockItemId, string blockItemText, int offset, int length) - { - Argument.AssertNotNull(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(blockItemId, nameof(blockItemId)); - Argument.AssertNotNull(blockItemText, nameof(blockItemText)); - - BlocklistName = blocklistName; - BlockItemId = blockItemId; - BlockItemText = blockItemText; - Offset = offset; - Length = length; - } - - /// The name of matched blocklist. - public string BlocklistName { get; } - /// The id of matched item. - public string BlockItemId { get; } - /// The content of matched item. - public string BlockItemText { get; } - /// The character offset of matched text in original input. - public int Offset { get; } - /// The length of matched text in original input. - public int Length { get; } - } -} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.Serialization.cs similarity index 65% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.Serialization.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.Serialization.cs index 8ef10094604e..590d2ecd780a 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.Serialization.cs @@ -7,19 +7,20 @@ using System.Text.Json; using Azure; +using Azure.Core; namespace Azure.AI.ContentSafety { - public partial class TextAnalyzeSeverityResult + public partial class TextCategoriesAnalysis { - internal static TextAnalyzeSeverityResult DeserializeTextAnalyzeSeverityResult(JsonElement element) + internal static TextCategoriesAnalysis DeserializeTextCategoriesAnalysis(JsonElement element) { if (element.ValueKind == JsonValueKind.Null) { return null; } TextCategory category = default; - int severity = default; + Optional severity = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("category"u8)) @@ -29,19 +30,23 @@ internal static TextAnalyzeSeverityResult DeserializeTextAnalyzeSeverityResult(J } if (property.NameEquals("severity"u8)) { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } severity = property.Value.GetInt32(); continue; } } - return new TextAnalyzeSeverityResult(category, severity); + return new TextCategoriesAnalysis(category, Optional.ToNullable(severity)); } /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static TextAnalyzeSeverityResult FromResponse(Response response) + internal static TextCategoriesAnalysis FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeTextAnalyzeSeverityResult(document.RootElement); + return DeserializeTextCategoriesAnalysis(document.RootElement); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.cs new file mode 100644 index 000000000000..02f8048bf43b --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.ContentSafety +{ + /// Text analysis result. + public partial class TextCategoriesAnalysis + { + /// Initializes a new instance of TextCategoriesAnalysis. + /// The text analysis category. + internal TextCategoriesAnalysis(TextCategory category) + { + Category = category; + } + + /// Initializes a new instance of TextCategoriesAnalysis. + /// The text analysis category. + /// The value increases with the severity of the input content. The value of this field is determined by the outputType specified in the request. If 'FourSeverityLevels' or 'EightSeverityLevels' is chosen, this field will be included in the output. + internal TextCategoriesAnalysis(TextCategory category, int? severity) + { + Category = category; + Severity = severity; + } + + /// The text analysis category. + public TextCategory Category { get; } + /// The value increases with the severity of the input content. The value of this field is determined by the outputType specified in the request. If 'FourSeverityLevels' or 'EightSeverityLevels' is chosen, this field will be included in the output. + public int? Severity { get; } + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_ContentSafetyClient.cs b/sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_ContentSafetyClient.cs index 8615f5e3496a..14281208f174 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_ContentSafetyClient.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_ContentSafetyClient.cs @@ -33,7 +33,7 @@ public void Example_AnalyzeText_ShortVersion() Response response = client.AnalyzeText(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); } [Test] @@ -51,7 +51,7 @@ public async Task Example_AnalyzeText_ShortVersion_Async() Response response = await client.AnalyzeTextAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); } [Test] @@ -97,24 +97,17 @@ public void Example_AnalyzeText_AllParameters() { "" }, - breakByBlocklists = true, + haltOnBlocklistHit = true, + outputType = "FourSeverityLevels", }); Response response = client.AnalyzeText(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemText").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("offset").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("length").ToString()); - Console.WriteLine(result.GetProperty("hateResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("hateResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("severity").ToString()); + Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemText").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").ToString()); } [Test] @@ -136,24 +129,17 @@ public async Task Example_AnalyzeText_AllParameters_Async() { "" }, - breakByBlocklists = true, + haltOnBlocklistHit = true, + outputType = "FourSeverityLevels", }); Response response = await client.AnalyzeTextAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("blockItemText").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("offset").ToString()); - Console.WriteLine(result.GetProperty("blocklistsMatchResults")[0].GetProperty("length").ToString()); - Console.WriteLine(result.GetProperty("hateResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("hateResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("severity").ToString()); + Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistsMatch")[0].GetProperty("blocklistItemText").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").ToString()); } [Test] @@ -168,7 +154,8 @@ public void Example_AnalyzeText_AllParameters_Convenience() { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; Response response = client.AnalyzeText(body); } @@ -185,7 +172,8 @@ public async Task Example_AnalyzeText_AllParameters_Convenience_Async() { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; Response response = await client.AnalyzeTextAsync(body); } @@ -205,7 +193,7 @@ public void Example_AnalyzeImage_ShortVersion() Response response = client.AnalyzeImage(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); } [Test] @@ -223,7 +211,7 @@ public async Task Example_AnalyzeImage_ShortVersion_Async() Response response = await client.AnalyzeImageAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); } [Test] @@ -269,18 +257,13 @@ public void Example_AnalyzeImage_AllParameters() { "Hate" }, + outputType = "FourSeverityLevels", }); Response response = client.AnalyzeImage(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("hateResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("hateResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("severity").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").ToString()); } [Test] @@ -302,18 +285,13 @@ public async Task Example_AnalyzeImage_AllParameters_Async() { "Hate" }, + outputType = "FourSeverityLevels", }); Response response = await client.AnalyzeImageAsync(content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("hateResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("hateResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("selfHarmResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("sexualResult").GetProperty("severity").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("category").ToString()); - Console.WriteLine(result.GetProperty("violenceResult").GetProperty("severity").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); + Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").ToString()); } [Test] @@ -331,6 +309,7 @@ public void Example_AnalyzeImage_AllParameters_Convenience() }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; Response response = client.AnalyzeImage(body); } @@ -350,6 +329,7 @@ public async Task Example_AnalyzeImage_AllParameters_Convenience_Async() }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; Response response = await client.AnalyzeImageAsync(body); } @@ -586,7 +566,7 @@ public async Task Example_DeleteTextBlocklist_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_ShortVersion() + public void Example_AddOrUpdateBlocklistItems_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -594,7 +574,7 @@ public void Example_AddBlockItems_ShortVersion() using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -602,15 +582,16 @@ public void Example_AddBlockItems_ShortVersion() } }, }); - Response response = client.AddBlockItems("", content); + Response response = client.AddOrUpdateBlocklistItems("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_ShortVersion_Async() + public async Task Example_AddOrUpdateBlocklistItems_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -618,7 +599,7 @@ public async Task Example_AddBlockItems_ShortVersion_Async() using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -626,45 +607,46 @@ public async Task Example_AddBlockItems_ShortVersion_Async() } }, }); - Response response = await client.AddBlockItemsAsync("", content); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_ShortVersion_Convenience() + public void Example_AddOrUpdateBlocklistItems_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] + AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { -new TextBlockItemInfo("") +new TextBlocklistItem("") }); - Response response = client.AddBlockItems("", addBlockItemsOptions); + Response response = client.AddOrUpdateBlocklistItems("", addOrUpdateTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_ShortVersion_Convenience_Async() + public async Task Example_AddOrUpdateBlocklistItems_ShortVersion_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] + AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { -new TextBlockItemInfo("") +new TextBlocklistItem("") }); - Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", addOrUpdateTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_AllParameters() + public void Example_AddOrUpdateBlocklistItems_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -672,7 +654,7 @@ public void Example_AddBlockItems_AllParameters() using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -681,17 +663,17 @@ public void Example_AddBlockItems_AllParameters() } }, }); - Response response = client.AddBlockItems("", content); + Response response = client.AddOrUpdateBlocklistItems("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("value")[0].GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString()); - Console.WriteLine(result.GetProperty("value")[0].GetProperty("text").ToString()); + 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()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_AllParameters_Async() + public async Task Example_AddOrUpdateBlocklistItems_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -699,7 +681,7 @@ public async Task Example_AddBlockItems_AllParameters_Async() using RequestContent content = RequestContent.Create(new { - blockItems = new object[] + blocklistItems = new object[] { new { @@ -708,53 +690,53 @@ public async Task Example_AddBlockItems_AllParameters_Async() } }, }); - Response response = await client.AddBlockItemsAsync("", content); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("value")[0].GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString()); - Console.WriteLine(result.GetProperty("value")[0].GetProperty("text").ToString()); + 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()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_AllParameters_Convenience() + public void Example_AddOrUpdateBlocklistItems_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] + AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { -new TextBlockItemInfo("") +new TextBlocklistItem("") { Description = "", } }); - Response response = client.AddBlockItems("", addBlockItemsOptions); + Response response = client.AddOrUpdateBlocklistItems("", addOrUpdateTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_AllParameters_Convenience_Async() + public async Task Example_AddOrUpdateBlocklistItems_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] + AddOrUpdateTextBlocklistItemsOptions addOrUpdateTextBlocklistItemsOptions = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] { -new TextBlockItemInfo("") +new TextBlocklistItem("") { Description = "", } }); - Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", addOrUpdateTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_ShortVersion() + public void Example_RemoveBlocklistItems_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -762,19 +744,19 @@ public void Example_RemoveBlockItems_ShortVersion() using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { -"" +"" }, }); - Response response = client.RemoveBlockItems("", content); + Response response = client.RemoveBlocklistItems("", content); Console.WriteLine(response.Status); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_ShortVersion_Async() + public async Task Example_RemoveBlocklistItems_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -782,43 +764,43 @@ public async Task Example_RemoveBlockItems_ShortVersion_Async() using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { -"" +"" }, }); - Response response = await client.RemoveBlockItemsAsync("", content); + Response response = await client.RemoveBlocklistItemsAsync("", content); Console.WriteLine(response.Status); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_ShortVersion_Convenience() + public void Example_RemoveBlocklistItems_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); - Response response = client.RemoveBlockItems("", removeBlockItemsOptions); + RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = client.RemoveBlocklistItems("", removeTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_ShortVersion_Convenience_Async() + public async Task Example_RemoveBlocklistItems_ShortVersion_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); - Response response = await client.RemoveBlockItemsAsync("", removeBlockItemsOptions); + RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = await client.RemoveBlocklistItemsAsync("", removeTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_AllParameters() + public void Example_RemoveBlocklistItems_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -826,19 +808,19 @@ public void Example_RemoveBlockItems_AllParameters() using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { -"" +"" }, }); - Response response = client.RemoveBlockItems("", content); + Response response = client.RemoveBlocklistItems("", content); Console.WriteLine(response.Status); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_AllParameters_Async() + public async Task Example_RemoveBlocklistItems_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); @@ -846,38 +828,38 @@ public async Task Example_RemoveBlockItems_AllParameters_Async() using RequestContent content = RequestContent.Create(new { - blockItemIds = new object[] + blocklistItemIds = new object[] { -"" +"" }, }); - Response response = await client.RemoveBlockItemsAsync("", content); + Response response = await client.RemoveBlocklistItemsAsync("", content); Console.WriteLine(response.Status); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_AllParameters_Convenience() + public void Example_RemoveBlocklistItems_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); - Response response = client.RemoveBlockItems("", removeBlockItemsOptions); + RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = client.RemoveBlocklistItems("", removeTextBlocklistItemsOptions); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_AllParameters_Convenience_Async() + public async Task Example_RemoveBlocklistItems_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); - Response response = await client.RemoveBlockItemsAsync("", removeBlockItemsOptions); + RemoveTextBlocklistItemsOptions removeTextBlocklistItemsOptions = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = await client.RemoveBlocklistItemsAsync("", removeTextBlocklistItemsOptions); } [Test] @@ -888,10 +870,10 @@ public void Example_GetTextBlocklistItem_ShortVersion() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = client.GetTextBlocklistItem("", "", null); + Response response = client.GetTextBlocklistItem("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -903,10 +885,10 @@ public async Task Example_GetTextBlocklistItem_ShortVersion_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = await client.GetTextBlocklistItemAsync("", "", null); + Response response = await client.GetTextBlocklistItemAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -918,7 +900,7 @@ public void Example_GetTextBlocklistItem_ShortVersion_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = client.GetTextBlocklistItem("", ""); + Response response = client.GetTextBlocklistItem("", ""); } [Test] @@ -929,7 +911,7 @@ public async Task Example_GetTextBlocklistItem_ShortVersion_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = await client.GetTextBlocklistItemAsync("", ""); + Response response = await client.GetTextBlocklistItemAsync("", ""); } [Test] @@ -940,10 +922,10 @@ public void Example_GetTextBlocklistItem_AllParameters() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = client.GetTextBlocklistItem("", "", null); + Response response = client.GetTextBlocklistItem("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -956,10 +938,10 @@ public async Task Example_GetTextBlocklistItem_AllParameters_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = await client.GetTextBlocklistItemAsync("", "", null); + Response response = await client.GetTextBlocklistItemAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -972,7 +954,7 @@ public void Example_GetTextBlocklistItem_AllParameters_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = client.GetTextBlocklistItem("", ""); + Response response = client.GetTextBlocklistItem("", ""); } [Test] @@ -983,7 +965,7 @@ public async Task Example_GetTextBlocklistItem_AllParameters_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - Response response = await client.GetTextBlocklistItemAsync("", ""); + Response response = await client.GetTextBlocklistItemAsync("", ""); } [Test] @@ -1111,7 +1093,7 @@ public void Example_GetTextBlocklistItems_ShortVersion() foreach (BinaryData item in client.GetTextBlocklistItems("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } } @@ -1127,7 +1109,7 @@ public async Task Example_GetTextBlocklistItems_ShortVersion_Async() await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } } @@ -1140,7 +1122,7 @@ public void Example_GetTextBlocklistItems_ShortVersion_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - foreach (TextBlockItem item in client.GetTextBlocklistItems("")) + foreach (TextBlocklistItem item in client.GetTextBlocklistItems("")) { } } @@ -1153,7 +1135,7 @@ public async Task Example_GetTextBlocklistItems_ShortVersion_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("")) + await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("")) { } } @@ -1169,7 +1151,7 @@ public void Example_GetTextBlocklistItems_AllParameters() foreach (BinaryData item in client.GetTextBlocklistItems("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -1186,7 +1168,7 @@ public async Task Example_GetTextBlocklistItems_AllParameters_Async() await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); Console.WriteLine(result.GetProperty("description").ToString()); Console.WriteLine(result.GetProperty("text").ToString()); } @@ -1200,7 +1182,7 @@ public void Example_GetTextBlocklistItems_AllParameters_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - foreach (TextBlockItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + foreach (TextBlocklistItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) { } } @@ -1213,7 +1195,7 @@ public async Task Example_GetTextBlocklistItems_AllParameters_Convenience_Async( AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) { } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml b/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml index 2f023a7a4f40..5ca6a7f5a1ee 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml +++ b/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml @@ -1,3 +1,5 @@ +commit: 1e4276e43ef274ccf739c9d45eafd5c5a3bb970b +additionalDirectories: [] directory: specification/cognitiveservices/ContentSafety -commit: 17c41d0c4a96294bf563b009c9c72093963b529f -repo: Azure/azure-rest-api-specs \ No newline at end of file +repo: Azure/azure-rest-api-specs +