From 494192d707558a885a5199effafed39c6dfdec94 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 21 Nov 2023 04:16:12 +0000 Subject: [PATCH] CodeGen from PR 26353 in Azure/azure-rest-api-specs Merge 343a71abdf0ab4502ac3e03d8da65a1e78da98fe into c8d98ad576b439cf4377d8d17122d2e9e831ff9e --- .../Azure.AI.ContentSafety.netstandard2.0.cs | 232 ++-- .../AIContentSafetyClientBuilderExtensions.cs | 55 +- .../Generated/AIContentSafetyModelFactory.cs | 113 +- .../src/Generated/AddBlockItemsOptions.cs | 38 - .../src/Generated/AddBlockItemsResult.cs | 32 - ...extBlocklistItemsOptions.Serialization.cs} | 6 +- .../AddOrUpdateTextBlocklistItemsOptions.cs | 38 + ...TextBlocklistItemsResult.Serialization.cs} | 25 +- .../AddOrUpdateTextBlocklistItemsResult.cs | 38 + .../AnalyzeImageOptions.Serialization.cs | 5 + .../src/Generated/AnalyzeImageOptions.cs | 12 +- .../src/Generated/AnalyzeImageOutputType.cs | 48 + .../AnalyzeImageResult.Serialization.cs | 45 +- .../src/Generated/AnalyzeImageResult.cs | 36 +- .../AnalyzeTextOptions.Serialization.cs | 11 +- .../src/Generated/AnalyzeTextOptions.cs | 24 +- .../src/Generated/AnalyzeTextOutputType.cs | 51 + .../AnalyzeTextResult.Serialization.cs | 53 +- .../src/Generated/AnalyzeTextResult.cs | 43 +- ...s => AzureAIContentSafetyClientOptions.cs} | 16 +- .../src/Generated/BlocklistClient.cs | 1107 +++++++++++++++++ .../src/Generated/ContentSafetyClient.cs | 1107 ++--------------- .../ContentSafetyImageData.Serialization.cs | 4 +- .../src/Generated/ContentSafetyImageData.cs | 16 +- .../src/Generated/Docs/BlocklistClient.xml | 787 ++++++++++++ .../Generated/Docs/ContentSafetyClient.xml | 896 +------------ .../Generated/ImageAnalyzeSeverityResult.cs | 27 - ... ImageCategoriesAnalysis.Serialization.cs} | 17 +- .../src/Generated/ImageCategoriesAnalysis.cs | 34 + .../src/Generated/RemoveBlockItemsOptions.cs | 38 - ...extBlocklistItemsOptions.Serialization.cs} | 6 +- .../RemoveTextBlocklistItemsOptions.cs | 38 + .../Generated/TextAnalyzeSeverityResult.cs | 27 - .../src/Generated/TextBlockItem.cs | 47 - .../TextBlockItemInfo.Serialization.cs | 36 - .../src/Generated/TextBlockItemInfo.cs | 40 - .../src/Generated/TextBlocklist.cs | 18 +- .../TextBlocklistItem.Serialization.cs | 75 ++ .../src/Generated/TextBlocklistItem.cs | 44 + ...cs => TextBlocklistMatch.Serialization.cs} | 29 +- .../src/Generated/TextBlocklistMatch.cs | 39 + .../TextBlocklistMatchResult.Serialization.cs | 65 - .../src/Generated/TextBlocklistMatchResult.cs | 47 - ...> TextCategoriesAnalysis.Serialization.cs} | 17 +- .../src/Generated/TextCategoriesAnalysis.cs | 34 + .../Samples/Samples_BlocklistClient.cs | 887 +++++++++++++ .../Samples/Samples_ContentSafetyClient.cs | 980 +-------------- .../Azure.AI.ContentSafety/tsp-location.yaml | 6 +- 48 files changed, 3805 insertions(+), 3584 deletions(-) delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsOptions.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddBlockItemsResult.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{AddBlockItemsOptions.Serialization.cs => AddOrUpdateTextBlocklistItemsOptions.Serialization.cs} (81%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsOptions.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{AddBlockItemsResult.Serialization.cs => AddOrUpdateTextBlocklistItemsResult.Serialization.cs} (52%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AddOrUpdateTextBlocklistItemsResult.cs create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOutputType.cs create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeTextOutputType.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{ContentSafetyClientOptions.cs => AzureAIContentSafetyClientOptions.cs} (53%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/BlocklistClient.cs create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/BlocklistClient.xml delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageAnalyzeSeverityResult.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{ImageAnalyzeSeverityResult.Serialization.cs => ImageCategoriesAnalysis.Serialization.cs} (64%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ImageCategoriesAnalysis.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveBlockItemsOptions.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{RemoveBlockItemsOptions.Serialization.cs => RemoveTextBlocklistItemsOptions.Serialization.cs} (81%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/RemoveTextBlocklistItemsOptions.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextAnalyzeSeverityResult.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItem.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.Serialization.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlockItemInfo.cs create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.Serialization.cs create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistItem.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{TextBlockItem.Serialization.cs => TextBlocklistMatch.Serialization.cs} (50%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatch.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.Serialization.cs delete mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklistMatchResult.cs rename sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/{TextAnalyzeSeverityResult.Serialization.cs => TextCategoriesAnalysis.Serialization.cs} (65%) create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextCategoriesAnalysis.cs create mode 100644 sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_BlocklistClient.cs 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..c9dabdece35a 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,119 +1,161 @@ 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.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.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 name = null, string description = null) { 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 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 AzureAIContentSafetyClientOptions : Azure.Core.ClientOptions + { + public AzureAIContentSafetyClientOptions(Azure.AI.ContentSafety.AzureAIContentSafetyClientOptions.ServiceVersion version = Azure.AI.ContentSafety.AzureAIContentSafetyClientOptions.ServiceVersion.V2023_10_01) { } + public enum ServiceVersion + { + V2023_10_01 = 1, + } + } + public partial class BlocklistClient + { + protected BlocklistClient() { } + public BlocklistClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public BlocklistClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.ContentSafety.AzureAIContentSafetyClientOptions options) { } + public BlocklistClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { } + public BlocklistClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.AI.ContentSafety.AzureAIContentSafetyClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response AddOrUpdateBlocklistItems(string name, Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response AddOrUpdateBlocklistItems(string name, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> AddOrUpdateBlocklistItemsAsync(string name, Azure.AI.ContentSafety.AddOrUpdateTextBlocklistItemsOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task AddOrUpdateBlocklistItemsAsync(string name, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response CreateOrUpdateTextBlocklist(string name, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task CreateOrUpdateTextBlocklistAsync(string name, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response DeleteTextBlocklist(string name, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task DeleteTextBlocklistAsync(string name, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response GetTextBlocklist(string name, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTextBlocklist(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTextBlocklistAsync(string name, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTextBlocklistAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTextBlocklistItem(string name, string blocklistItemId, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTextBlocklistItem(string name, string blocklistItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTextBlocklistItemAsync(string name, string blocklistItemId, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTextBlocklistItemAsync(string name, string blocklistItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetTextBlocklistItems(string name, int? maxCount, int? skip, int? maxpagesize, Azure.RequestContext context) { throw null; } + public virtual Azure.Pageable GetTextBlocklistItems(string name, 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 name, int? maxCount, int? skip, int? maxpagesize, Azure.RequestContext context) { throw null; } + public virtual Azure.AsyncPageable GetTextBlocklistItemsAsync(string name, 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 RemoveBlocklistItems(string name, Azure.AI.ContentSafety.RemoveTextBlocklistItemsOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveBlocklistItems(string name, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task RemoveBlocklistItemsAsync(string name, Azure.AI.ContentSafety.RemoveTextBlocklistItemsOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task RemoveBlocklistItemsAsync(string name, Azure.Core.RequestContent content, Azure.RequestContext context = null) { 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.AzureKeyCredential credential, Azure.AI.ContentSafety.AzureAIContentSafetyClientOptions options) { } + public ContentSafetyClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { } + public ContentSafetyClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.AI.ContentSafety.AzureAIContentSafetyClientOptions 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 AnalyzeImage(Azure.AI.ContentSafety.AnalyzeImageOptions body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response AnalyzeImage(Azure.AI.ContentSafety.AnalyzeImageOptions options, 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; } + public virtual System.Threading.Tasks.Task> AnalyzeImageAsync(Azure.AI.ContentSafety.AnalyzeImageOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task AnalyzeImageAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual Azure.Response AnalyzeText(Azure.AI.ContentSafety.AnalyzeTextOptions body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response AnalyzeText(Azure.AI.ContentSafety.AnalyzeTextOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response AnalyzeText(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task> AnalyzeTextAsync(Azure.AI.ContentSafety.AnalyzeTextOptions body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AnalyzeTextAsync(Azure.AI.ContentSafety.AnalyzeTextOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task AnalyzeTextAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual Azure.Response CreateOrUpdateTextBlocklist(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task CreateOrUpdateTextBlocklistAsync(string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual Azure.Response DeleteTextBlocklist(string blocklistName, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task DeleteTextBlocklistAsync(string blocklistName, Azure.RequestContext context = null) { throw null; } - public virtual Azure.Response GetTextBlocklist(string blocklistName, Azure.RequestContext context) { throw null; } - 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.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.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.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 partial class ContentSafetyClientOptions : Azure.Core.ClientOptions - { - public ContentSafetyClientOptions(Azure.AI.ContentSafety.ContentSafetyClientOptions.ServiceVersion version = Azure.AI.ContentSafety.ContentSafetyClientOptions.ServiceVersion.V2023_04_30_Preview) { } - public enum ServiceVersion - { - V2023_04_30_Preview = 1, - } } public partial class ContentSafetyImageData { public ContentSafetyImageData() { } - public System.Uri BlobUrl { get { throw null; } set { } } + public System.Uri BlobUri { 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 +177,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 Description { get { throw null; } } - public string Text { get { throw null; } } + public string Name { 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,7 +233,11 @@ namespace Microsoft.Extensions.Azure { public static partial class AIContentSafetyClientBuilderExtensions { - 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; } + public static Azure.Core.Extensions.IAzureClientBuilder AddBlocklistClient(this TBuilder builder, System.Uri endpoint) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddBlocklistClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddBlocklistClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + 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..00bb5ced0c18 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyClientBuilderExtensions.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyClientBuilderExtensions.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Azure { - /// Extension methods to add to client builder. + /// Extension methods to add , to client builder. public static partial class AIContentSafetyClientBuilderExtensions { /// Registers a instance. @@ -22,19 +22,64 @@ public static partial class AIContentSafetyClientBuilderExtensions /// https://<resource-name>.cognitiveservices.azure.com). /// /// A credential used to authenticate to an Azure Service. - public static IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + public static IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) where TBuilder : IAzureClientFactoryBuilder { - return builder.RegisterClientFactory((options) => new ContentSafetyClient(endpoint, credential, options)); + return builder.RegisterClientFactory((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. + /// + /// Supported Cognitive Services endpoints (protocol and hostname, for example: + /// https://<resource-name>.cognitiveservices.azure.com). + /// + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddBlocklistClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new BlocklistClient(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 AddBlocklistClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new BlocklistClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + /// Registers a instance. + /// The builder to register with. /// The configuration values. - public static IAzureClientBuilder AddContentSafetyClient(this TBuilder builder, TConfiguration configuration) + public static IAzureClientBuilder AddBlocklistClient(this TBuilder builder, TConfiguration configuration) where TBuilder : IAzureClientFactoryBuilderWithConfiguration { - return builder.RegisterClientFactory(configuration); + return builder.RegisterClientFactory(configuration); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs index a66c6f5b7b82..ce958046f199 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AIContentSafetyModelFactory.cs @@ -15,101 +15,96 @@ 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 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 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’, and the output value can be 0, 2, 4, 6. + /// 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. - /// Text blocklist name. - /// Text blocklist description. - /// A new instance for mocking. - public static TextBlocklist TextBlocklist(string blocklistName = null, string description = 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) { - return new TextBlocklist(blocklistName, description); + return new TextBlocklistItem(blocklistItemId, description, text); } - /// 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 AddOrUpdateTextBlocklistItemsResult. + /// Array of blocklistItems have been added. + /// A new instance for mocking. + public static AddOrUpdateTextBlocklistItemsResult AddOrUpdateTextBlocklistItemsResult(IEnumerable blocklistItems = null) { - value ??= new List(); + blocklistItems ??= new List(); - return new AddBlockItemsResult(value?.ToList()); + return new AddOrUpdateTextBlocklistItemsResult(blocklistItems?.ToList()); } - /// 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 TextBlocklist. + /// Text blocklist name. + /// Text blocklist description. + /// A new instance for mocking. + public static TextBlocklist TextBlocklist(string name = null, string description = null) { - return new TextBlockItem(blockItemId, description, text); + return new TextBlocklist(name, description); } } } 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..fc67790de41f --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AnalyzeImageOutputType.cs @@ -0,0 +1,48 @@ +// 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"; + + /// Output severities in four levels, the value could be 0,2,4,6. + public static AnalyzeImageOutputType FourSeverityLevels { get; } = new AnalyzeImageOutputType(FourSeverityLevelsValue); + /// 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/ContentSafetyClientOptions.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AzureAIContentSafetyClientOptions.cs similarity index 53% rename from sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClientOptions.cs rename to sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AzureAIContentSafetyClientOptions.cs index 8f6285c3198e..7f1eea547425 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClientOptions.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/AzureAIContentSafetyClientOptions.cs @@ -10,26 +10,26 @@ namespace Azure.AI.ContentSafety { - /// Client options for ContentSafetyClient. - public partial class ContentSafetyClientOptions : ClientOptions + /// Client options for Azure.AI.ContentSafety library clients. + public partial class AzureAIContentSafetyClientOptions : 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; } - /// Initializes new instance of ContentSafetyClientOptions. - public ContentSafetyClientOptions(ServiceVersion version = LatestVersion) + /// Initializes new instance of AzureAIContentSafetyClientOptions. + public AzureAIContentSafetyClientOptions(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/BlocklistClient.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/BlocklistClient.cs new file mode 100644 index 000000000000..ff2780af6b42 --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/BlocklistClient.cs @@ -0,0 +1,1107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.ContentSafety +{ + // Data plane generated client. + /// The Blocklist service client. + public partial class BlocklistClient + { + 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; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of BlocklistClient for mocking. + protected BlocklistClient() + { + } + + /// Initializes a new instance of BlocklistClient. + /// + /// 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 BlocklistClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AzureAIContentSafetyClientOptions()) + { + } + + /// Initializes a new instance of BlocklistClient. + /// + /// 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 BlocklistClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureAIContentSafetyClientOptions()) + { + } + + /// Initializes a new instance of BlocklistClient. + /// + /// 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 BlocklistClient(Uri endpoint, AzureKeyCredential credential, AzureAIContentSafetyClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureAIContentSafetyClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Initializes a new instance of BlocklistClient. + /// + /// 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 BlocklistClient(Uri endpoint, TokenCredential credential, AzureAIContentSafetyClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureAIContentSafetyClientOptions(); + + 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; + } + + /// Add or update BlocklistItems To Text Blocklist. + /// Text blocklist name. + /// Options for adding or updating blocklist items. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// 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 name, AddOrUpdateTextBlocklistItemsOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(options, nameof(options)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = options.ToRequestContent(); + Response response = await AddOrUpdateBlocklistItemsAsync(name, content, context).ConfigureAwait(false); + return Response.FromValue(AddOrUpdateTextBlocklistItemsResult.FromResponse(response), response); + } + + /// Add or update BlocklistItems To Text Blocklist. + /// Text blocklist name. + /// Options for adding or updating blocklist items. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// 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 name, AddOrUpdateTextBlocklistItemsOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(options, nameof(options)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = options.ToRequestContent(); + Response response = AddOrUpdateBlocklistItems(name, content, context); + return Response.FromValue(AddOrUpdateTextBlocklistItemsResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Add or update BlocklistItems To Text Blocklist + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// 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 AddOrUpdateBlocklistItemsAsync(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.AddOrUpdateBlocklistItems"); + scope.Start(); + try + { + using HttpMessage message = CreateAddOrUpdateBlocklistItemsRequest(name, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add or update BlocklistItems To Text Blocklist + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// 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 AddOrUpdateBlocklistItems(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.AddOrUpdateBlocklistItems"); + scope.Start(); + try + { + using HttpMessage message = CreateAddOrUpdateBlocklistItemsRequest(name, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create Or Update Text Blocklist + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Text blocklist name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// 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 CreateOrUpdateTextBlocklistAsync(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.CreateOrUpdateTextBlocklist"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTextBlocklistRequest(name, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create Or Update Text Blocklist + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Text blocklist name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// 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 CreateOrUpdateTextBlocklist(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.CreateOrUpdateTextBlocklist"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTextBlocklistRequest(name, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete Text Blocklist By blocklistName + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Text blocklist name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// 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 DeleteTextBlocklistAsync(string name, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.DeleteTextBlocklist"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTextBlocklistRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete Text Blocklist By blocklistName + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Text blocklist name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// 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 DeleteTextBlocklist(string name, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.DeleteTextBlocklist"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTextBlocklistRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get Text Blocklist By blocklistName. + /// Text blocklist name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Returns text blocklist details. + /// + public virtual async Task> GetTextBlocklistAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTextBlocklistAsync(name, context).ConfigureAwait(false); + return Response.FromValue(TextBlocklist.FromResponse(response), response); + } + + /// Get Text Blocklist By blocklistName. + /// Text blocklist name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Returns text blocklist details. + /// + public virtual Response GetTextBlocklist(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTextBlocklist(name, context); + return Response.FromValue(TextBlocklist.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get Text Blocklist By blocklistName + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// 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 GetTextBlocklistAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.GetTextBlocklist"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTextBlocklistRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get Text Blocklist By blocklistName + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// 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 GetTextBlocklist(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.GetTextBlocklist"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTextBlocklistRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get BlocklistItem By blocklistName And blocklistItemId. + /// Text blocklist name. + /// 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 blocklistItem by blocklistName and blocklistItemId from a text blocklist. + /// + public virtual async Task> GetTextBlocklistItemAsync(string name, string blocklistItemId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTextBlocklistItemAsync(name, blocklistItemId, context).ConfigureAwait(false); + return Response.FromValue(TextBlocklistItem.FromResponse(response), response); + } + + /// Get BlocklistItem By blocklistName And blocklistItemId. + /// Text blocklist name. + /// 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 blocklistItem by blocklistName and blocklistItemId from a text blocklist. + /// + public virtual Response GetTextBlocklistItem(string name, string blocklistItemId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTextBlocklistItem(name, blocklistItemId, context); + return Response.FromValue(TextBlocklistItem.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get BlocklistItem By blocklistName And blocklistItemId + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// 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. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTextBlocklistItemAsync(string name, string blocklistItemId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.GetTextBlocklistItem"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTextBlocklistItemRequest(name, blocklistItemId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get BlocklistItem By blocklistName And blocklistItemId + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// 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. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTextBlocklistItem(string name, string blocklistItemId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(blocklistItemId, nameof(blocklistItemId)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.GetTextBlocklistItem"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTextBlocklistItemRequest(name, blocklistItemId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Remove BlocklistItems From Text Blocklist. + /// Text blocklist name. + /// Options for removing blocklist items. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + /// + public virtual async Task RemoveBlocklistItemsAsync(string name, RemoveTextBlocklistItemsOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(options, nameof(options)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = options.ToRequestContent(); + Response response = await RemoveBlocklistItemsAsync(name, content, context).ConfigureAwait(false); + return response; + } + + /// Remove BlocklistItems From Text Blocklist. + /// Text blocklist name. + /// Options for removing blocklist items. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + /// + public virtual Response RemoveBlocklistItems(string name, RemoveTextBlocklistItemsOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(options, nameof(options)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = options.ToRequestContent(); + Response response = RemoveBlocklistItems(name, content, context); + return response; + } + + /// + /// [Protocol Method] Remove BlocklistItems From Text Blocklist + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// 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 RemoveBlocklistItemsAsync(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.RemoveBlocklistItems"); + scope.Start(); + try + { + using HttpMessage message = CreateRemoveBlocklistItemsRequest(name, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Remove BlocklistItems From Text Blocklist + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// 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 RemoveBlocklistItems(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BlocklistClient.RemoveBlocklistItems"); + scope.Start(); + try + { + using HttpMessage message = CreateRemoveBlocklistItemsRequest(name, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get All BlocklistItems By blocklistName. + /// Text blocklist name. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get all blocklistItems in a text blocklist. + /// + public virtual AsyncPageable GetTextBlocklistItemsAsync(string name, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistItemsRequest(name, maxCount, skip, maxpagesize, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistItemsNextPageRequest(nextLink, name, maxCount, skip, maxpagesize, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, TextBlocklistItem.DeserializeTextBlocklistItem, ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklistItems", "value", "nextLink", context); + } + + /// Get All BlocklistItems By blocklistName. + /// Text blocklist name. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get all blocklistItems in a text blocklist. + /// + public virtual Pageable GetTextBlocklistItems(string name, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistItemsRequest(name, maxCount, skip, maxpagesize, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistItemsNextPageRequest(nextLink, name, maxCount, skip, maxpagesize, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, TextBlocklistItem.DeserializeTextBlocklistItem, ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklistItems", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get All BlocklistItems By blocklistName + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTextBlocklistItemsAsync(string name, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistItemsRequest(name, maxCount, skip, maxpagesize, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistItemsNextPageRequest(nextLink, name, maxCount, skip, maxpagesize, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklistItems", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get All BlocklistItems By blocklistName + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Text blocklist name. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTextBlocklistItems(string name, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistItemsRequest(name, maxCount, skip, maxpagesize, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistItemsNextPageRequest(nextLink, name, maxCount, skip, maxpagesize, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklistItems", "value", "nextLink", context); + } + + /// Get All Text Blocklists. + /// The cancellation token to use. + /// Get all text blocklists details. + /// + public virtual AsyncPageable GetTextBlocklistsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, TextBlocklist.DeserializeTextBlocklist, ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklists", "value", "nextLink", context); + } + + /// Get All Text Blocklists. + /// The cancellation token to use. + /// Get all text blocklists details. + /// + public virtual Pageable GetTextBlocklists(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, TextBlocklist.DeserializeTextBlocklist, ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklists", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get All Text Blocklists + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTextBlocklistsAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklists", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get All Text Blocklists + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTextBlocklists(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BlocklistClient.GetTextBlocklists", "value", "nextLink", context); + } + + internal HttpMessage CreateAddOrUpdateBlocklistItemsRequest(string name, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendPath(":addOrUpdateBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateTextBlocklistRequest(string name, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTextBlocklistRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTextBlocklistRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTextBlocklistItemRequest(string name, string blocklistItemId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendPath("/blocklistItems/", false); + uri.AppendPath(blocklistItemId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTextBlocklistItemsRequest(string name, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendPath("/blocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTextBlocklistsRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateRemoveBlocklistItemsRequest(string name, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text/blocklists/", false); + uri.AppendPath(name, true); + uri.AppendPath(":removeBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetTextBlocklistItemsNextPageRequest(string nextLink, string name, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTextBlocklistsNextPageRequest(string nextLink, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs index 44e41bd84a12..2ab1c0b46516 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyClient.cs @@ -8,7 +8,6 @@ using System; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; using Azure; using Azure.Core; using Azure.Core.Pipeline; @@ -21,6 +20,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; @@ -43,7 +44,18 @@ protected ContentSafetyClient() /// /// A credential used to authenticate to an Azure Service. /// or is null. - public ContentSafetyClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new ContentSafetyClientOptions()) + public ContentSafetyClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AzureAIContentSafetyClientOptions()) + { + } + + /// 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 AzureAIContentSafetyClientOptions()) { } @@ -55,11 +67,11 @@ protected ContentSafetyClient() /// A credential used to authenticate to an Azure Service. /// The options for configuring the client. /// or is null. - public ContentSafetyClient(Uri endpoint, AzureKeyCredential credential, ContentSafetyClientOptions options) + public ContentSafetyClient(Uri endpoint, AzureKeyCredential credential, AzureAIContentSafetyClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); - options ??= new ContentSafetyClientOptions(); + options ??= new AzureAIContentSafetyClientOptions(); ClientDiagnostics = new ClientDiagnostics(options, true); _keyCredential = credential; @@ -68,34 +80,55 @@ 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, AzureAIContentSafetyClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureAIContentSafetyClientOptions(); + + 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. + /// is null. + /// 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) + public virtual async Task> AnalyzeTextAsync(AnalyzeTextOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(options, nameof(options)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = body.ToRequestContent(); + using RequestContent content = options.ToRequestContent(); Response response = await AnalyzeTextAsync(content, context).ConfigureAwait(false); return Response.FromValue(AnalyzeTextResult.FromResponse(response), response); } /// 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. + /// is null. + /// 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) + public virtual Response AnalyzeText(AnalyzeTextOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(options, nameof(options)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = body.ToRequestContent(); + using RequestContent content = options.ToRequestContent(); Response response = AnalyzeText(content, context); return Response.FromValue(AnalyzeTextResult.FromResponse(response), response); } @@ -179,33 +212,33 @@ 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. + /// is null. + /// 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) + public virtual async Task> AnalyzeImageAsync(AnalyzeImageOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(options, nameof(options)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = body.ToRequestContent(); + using RequestContent content = options.ToRequestContent(); Response response = await AnalyzeImageAsync(content, context).ConfigureAwait(false); return Response.FromValue(AnalyzeImageResult.FromResponse(response), response); } /// 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. + /// is null. + /// 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) + public virtual Response AnalyzeImage(AnalyzeImageOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(options, nameof(options)); RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = body.ToRequestContent(); + using RequestContent content = options.ToRequestContent(); Response response = AnalyzeImage(content, context); return Response.FromValue(AnalyzeImageResult.FromResponse(response), response); } @@ -288,830 +321,24 @@ public virtual Response AnalyzeImage(RequestContent content, RequestContext cont } } - /// Get Text Blocklist By blocklistName. - /// Text blocklist name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Returns text blocklist details. - /// - public virtual async Task> GetTextBlocklistAsync(string blocklistName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetTextBlocklistAsync(blocklistName, context).ConfigureAwait(false); - return Response.FromValue(TextBlocklist.FromResponse(response), response); - } - - /// Get Text Blocklist By blocklistName. - /// Text blocklist name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Returns text blocklist details. - /// - public virtual Response GetTextBlocklist(string blocklistName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetTextBlocklist(blocklistName, context); - return Response.FromValue(TextBlocklist.FromResponse(response), response); - } - - /// - /// [Protocol Method] Get Text Blocklist By blocklistName - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// 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 GetTextBlocklistAsync(string blocklistName, RequestContext context) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.GetTextBlocklist"); - scope.Start(); - try - { - using HttpMessage message = CreateGetTextBlocklistRequest(blocklistName, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Get Text Blocklist By blocklistName - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// 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 GetTextBlocklist(string blocklistName, RequestContext context) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.GetTextBlocklist"); - scope.Start(); - try - { - using HttpMessage message = CreateGetTextBlocklistRequest(blocklistName, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Create Or Update Text Blocklist - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Text blocklist name. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// 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 CreateOrUpdateTextBlocklistAsync(string blocklistName, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.CreateOrUpdateTextBlocklist"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateOrUpdateTextBlocklistRequest(blocklistName, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Create Or Update Text Blocklist - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Text blocklist name. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// 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 CreateOrUpdateTextBlocklist(string blocklistName, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.CreateOrUpdateTextBlocklist"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateOrUpdateTextBlocklistRequest(blocklistName, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method - /// - /// [Protocol Method] Delete Text Blocklist By blocklistName - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Text blocklist name. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// 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 DeleteTextBlocklistAsync(string blocklistName, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.DeleteTextBlocklist"); - scope.Start(); - try - { - using HttpMessage message = CreateDeleteTextBlocklistRequest(blocklistName, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method - /// - /// [Protocol Method] Delete Text Blocklist By blocklistName - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Text blocklist name. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// 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 DeleteTextBlocklist(string blocklistName, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.DeleteTextBlocklist"); - scope.Start(); - try - { - using HttpMessage message = CreateDeleteTextBlocklistRequest(blocklistName, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Add BlockItems To Text Blocklist. - /// Text blocklist name. - /// The request of adding blockItems to text blocklist. - /// The cancellation token to use. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(addBlockItemsOptions, nameof(addBlockItemsOptions)); - - 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); - } - - /// Add BlockItems To Text Blocklist. - /// Text blocklist name. - /// The request of adding blockItems to text blocklist. - /// The cancellation token to use. - /// 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) + internal HttpMessage CreateAnalyzeTextRequest(RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(addBlockItemsOptions, nameof(addBlockItemsOptions)); - - RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = addBlockItemsOptions.ToRequestContent(); - Response response = AddBlockItems(blocklistName, content, context); - return Response.FromValue(AddBlockItemsResult.FromResponse(response), response); + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/contentsafety", false); + uri.AppendPath("/text:analyze", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; } - /// - /// [Protocol Method] Add BlockItems To Text Blocklist - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.AddBlockItems"); - scope.Start(); - try - { - using HttpMessage message = CreateAddBlockItemsRequest(blocklistName, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Add BlockItems To Text Blocklist - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.AddBlockItems"); - scope.Start(); - try - { - using HttpMessage message = CreateAddBlockItemsRequest(blocklistName, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Remove BlockItems From Text Blocklist. - /// Text blocklist name. - /// The request of removing blockItems from text blocklist. - /// The cancellation token to use. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(removeBlockItemsOptions, nameof(removeBlockItemsOptions)); - - RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = removeBlockItemsOptions.ToRequestContent(); - Response response = await RemoveBlockItemsAsync(blocklistName, content, context).ConfigureAwait(false); - return response; - } - - /// Remove BlockItems From Text Blocklist. - /// Text blocklist name. - /// The request of removing blockItems from text blocklist. - /// The cancellation token to use. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(removeBlockItemsOptions, nameof(removeBlockItemsOptions)); - - RequestContext context = FromCancellationToken(cancellationToken); - using RequestContent content = removeBlockItemsOptions.ToRequestContent(); - Response response = RemoveBlockItems(blocklistName, content, context); - return response; - } - - /// - /// [Protocol Method] Remove BlockItems From Text Blocklist - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.RemoveBlockItems"); - scope.Start(); - try - { - using HttpMessage message = CreateRemoveBlockItemsRequest(blocklistName, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Remove BlockItems From Text Blocklist - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// 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) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.RemoveBlockItems"); - scope.Start(); - try - { - using HttpMessage message = CreateRemoveBlockItemsRequest(blocklistName, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get BlockItem By blocklistName And blockItemId. - /// Text blocklist name. - /// Block Item Id. It will be 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. - /// - public virtual async Task> GetTextBlocklistItemAsync(string blocklistName, string blockItemId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetTextBlocklistItemAsync(blocklistName, blockItemId, context).ConfigureAwait(false); - return Response.FromValue(TextBlockItem.FromResponse(response), response); - } - - /// Get BlockItem By blocklistName And blockItemId. - /// Text blocklist name. - /// Block Item Id. It will be 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. - /// - public virtual Response GetTextBlocklistItem(string blocklistName, string blockItemId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetTextBlocklistItem(blocklistName, blockItemId, context); - return Response.FromValue(TextBlockItem.FromResponse(response), response); - } - - /// - /// [Protocol Method] Get BlockItem By blocklistName And blockItemId - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// Block Item Id. It will be 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. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task GetTextBlocklistItemAsync(string blocklistName, string blockItemId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.GetTextBlocklistItem"); - scope.Start(); - try - { - using HttpMessage message = CreateGetTextBlocklistItemRequest(blocklistName, blockItemId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Get BlockItem By blocklistName And blockItemId - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// Block Item Id. It will be 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. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response GetTextBlocklistItem(string blocklistName, string blockItemId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - Argument.AssertNotNullOrEmpty(blockItemId, nameof(blockItemId)); - - using var scope = ClientDiagnostics.CreateScope("ContentSafetyClient.GetTextBlocklistItem"); - scope.Start(); - try - { - using HttpMessage message = CreateGetTextBlocklistItemRequest(blocklistName, blockItemId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get All Text Blocklists. - /// The cancellation token to use. - /// Get all text blocklists details. - /// - public virtual AsyncPageable GetTextBlocklistsAsync(CancellationToken cancellationToken = default) - { - RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, TextBlocklist.DeserializeTextBlocklist, ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklists", "value", "nextLink", context); - } - - /// Get All Text Blocklists. - /// The cancellation token to use. - /// Get all text blocklists details. - /// - public virtual Pageable GetTextBlocklists(CancellationToken cancellationToken = default) - { - RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, TextBlocklist.DeserializeTextBlocklist, ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklists", "value", "nextLink", context); - } - - /// - /// [Protocol Method] Get All Text Blocklists - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetTextBlocklistsAsync(RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklists", "value", "nextLink", context); - } - - /// - /// [Protocol Method] Get All Text Blocklists - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetTextBlocklists(RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTextBlocklistsRequest(context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTextBlocklistsNextPageRequest(nextLink, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklists", "value", "nextLink", context); - } - - /// Get All BlockItems By blocklistName. - /// Text blocklist name. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// 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. - /// - 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); - } - - /// Get All BlockItems By blocklistName. - /// Text blocklist name. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// 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. - /// - 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); - } - - /// - /// [Protocol Method] Get All BlockItems By blocklistName - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetTextBlocklistItemsAsync(string blocklistName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - 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, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklistItems", "value", "nextLink", context); - } - - /// - /// [Protocol Method] Get All BlockItems By blocklistName - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Text blocklist name. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetTextBlocklistItems(string blocklistName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - Argument.AssertNotNullOrEmpty(blocklistName, nameof(blocklistName)); - - 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, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ContentSafetyClient.GetTextBlocklistItems", "value", "nextLink", context); - } - - internal HttpMessage CreateAnalyzeTextRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text:analyze", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateAnalyzeImageRequest(RequestContent content, RequestContext context) + internal HttpMessage CreateAnalyzeImageRequest(RequestContent content, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1128,184 +355,6 @@ internal HttpMessage CreateAnalyzeImageRequest(RequestContent content, RequestCo return message; } - internal HttpMessage CreateGetTextBlocklistRequest(string blocklistName, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateOrUpdateTextBlocklistRequest(string blocklistName, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200201); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/merge-patch+json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateDeleteTextBlocklistRequest(string blocklistName, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetTextBlocklistsRequest(RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateAddBlockItemsRequest(string blocklistName, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendPath(":addBlockItems", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateRemoveBlockItemsRequest(string blocklistName, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendPath(":removeBlockItems", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetTextBlocklistItemRequest(string blocklistName, string blockItemId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendPath("/blockItems/", false); - uri.AppendPath(blockItemId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetTextBlocklistItemsRequest(string blocklistName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendPath("/text/blocklists/", false); - uri.AppendPath(blocklistName, true); - uri.AppendPath("/blockItems", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (maxCount != null) - { - uri.AppendQuery("top", maxCount.Value, true); - } - if (skip != null) - { - uri.AppendQuery("skip", skip.Value, true); - } - if (maxpagesize != null) - { - uri.AppendQuery("maxpagesize", maxpagesize.Value, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetTextBlocklistsNextPageRequest(string nextLink, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetTextBlocklistItemsNextPageRequest(string nextLink, string blocklistName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/contentsafety", false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - private static RequestContext DefaultRequestContext = new RequestContext(); internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) { @@ -1319,9 +368,5 @@ internal static RequestContext FromCancellationToken(CancellationToken cancellat private static ResponseClassifier _responseClassifier200; private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); - private static ResponseClassifier _responseClassifier200201; - private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); - private static ResponseClassifier _responseClassifier204; - private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.Serialization.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.Serialization.cs index cc1640cbb19d..c2073b8b3f0d 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.Serialization.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.Serialization.cs @@ -20,10 +20,10 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("content"u8); writer.WriteBase64StringValue(Content.ToArray(), "D"); } - if (Optional.IsDefined(BlobUrl)) + if (Optional.IsDefined(BlobUri)) { writer.WritePropertyName("blobUrl"u8); - writer.WriteStringValue(BlobUrl.AbsoluteUri); + writer.WriteStringValue(BlobUri.AbsoluteUri); } writer.WriteEndObject(); } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/ContentSafetyImageData.cs index 5bcf3028b84f..63ea749d6100 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,16 +18,16 @@ public ContentSafetyImageData() } /// Initializes a new instance of ContentSafetyImageData. - /// Base64 encoding of image. - /// The blob url of image. - internal ContentSafetyImageData(BinaryData content, Uri blobUrl) + /// The Base64 encoding of the image. + /// The blob url of the image. + internal ContentSafetyImageData(BinaryData content, Uri blobUri) { Content = content; - BlobUrl = blobUrl; + BlobUri = blobUri; } /// - /// 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. - public Uri BlobUrl { get; set; } + /// The blob url of the image. + public Uri BlobUri { get; set; } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/BlocklistClient.xml b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/BlocklistClient.xml new file mode 100644 index 000000000000..2867b96ccc3b --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/BlocklistClient.xml @@ -0,0 +1,787 @@ + + + + + +This sample shows how to call AddOrUpdateBlocklistItemsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] +{ + new TextBlocklistItem("") +}); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", options); +]]> +This sample shows how to call AddOrUpdateBlocklistItemsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] +{ + new TextBlocklistItem("") + { + Description = "", + } +}); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", options); +]]> + + + +This sample shows how to call AddOrUpdateBlocklistItems. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] +{ + new TextBlocklistItem("") +}); +Response response = client.AddOrUpdateBlocklistItems("", options); +]]> +This sample shows how to call AddOrUpdateBlocklistItems with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] +{ + new TextBlocklistItem("") + { + Description = "", + } +}); +Response response = client.AddOrUpdateBlocklistItems("", options); +]]> + + + +This sample shows how to call AddOrUpdateBlocklistItemsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItems = new object[] + { + new + { + text = "", + } + }, +}); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); +]]> +This sample shows how to call AddOrUpdateBlocklistItemsAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItems = new object[] + { + new + { + description = "", + text = "", + } + }, +}); +Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); +]]> + + + +This sample shows how to call AddOrUpdateBlocklistItems and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItems = new object[] + { + new + { + text = "", + } + }, +}); +Response response = client.AddOrUpdateBlocklistItems("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); +]]> +This sample shows how to call AddOrUpdateBlocklistItems with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItems = new object[] + { + new + { + description = "", + text = "", + } + }, +}); +Response response = client.AddOrUpdateBlocklistItems("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTextBlocklistAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistName = "", +}); +Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +]]> +This sample shows how to call CreateOrUpdateTextBlocklistAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistName = "", + description = "", +}); +Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTextBlocklist and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistName = "", +}); +Response response = client.CreateOrUpdateTextBlocklist("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +]]> +This sample shows how to call CreateOrUpdateTextBlocklist with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistName = "", + description = "", +}); +Response response = client.CreateOrUpdateTextBlocklist("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +]]> + + + +This sample shows how to call DeleteTextBlocklistAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.DeleteTextBlocklistAsync(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteTextBlocklistAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.DeleteTextBlocklistAsync(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTextBlocklist. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.DeleteTextBlocklist(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteTextBlocklist with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.DeleteTextBlocklist(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetTextBlocklistAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistAsync(""); +]]> +This sample shows how to call GetTextBlocklistAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistAsync(""); +]]> + + + +This sample shows how to call GetTextBlocklist. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklist(""); +]]> +This sample shows how to call GetTextBlocklist with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklist(""); +]]> + + + +This sample shows how to call GetTextBlocklistAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +]]> +This sample shows how to call GetTextBlocklistAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +]]> + + + +This sample shows how to call GetTextBlocklist and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklist("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +]]> +This sample shows how to call GetTextBlocklist with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklist("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +]]> + + + +This sample shows how to call GetTextBlocklistItemAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistItemAsync("", ""); +]]> +This sample shows how to call GetTextBlocklistItemAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistItemAsync("", ""); +]]> + + + +This sample shows how to call GetTextBlocklistItem. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklistItem("", ""); +]]> +This sample shows how to call GetTextBlocklistItem with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklistItem("", ""); +]]> + + + +This sample shows how to call GetTextBlocklistItemAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistItemAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +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. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = await client.GetTextBlocklistItemAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("text").ToString()); +]]> + + + +This sample shows how to call GetTextBlocklistItem and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklistItem("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +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. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +Response response = client.GetTextBlocklistItem("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("text").ToString()); +]]> + + + +This sample shows how to call RemoveBlocklistItemsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = await client.RemoveBlocklistItemsAsync("", options); +]]> +This sample shows how to call RemoveBlocklistItemsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = await client.RemoveBlocklistItemsAsync("", options); +]]> + + + +This sample shows how to call RemoveBlocklistItems. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = client.RemoveBlocklistItems("", options); +]]> +This sample shows how to call RemoveBlocklistItems with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); +Response response = client.RemoveBlocklistItems("", options); +]]> + + + +This sample shows how to call RemoveBlocklistItemsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItemIds = new object[] + { + "" + }, +}); +Response response = await client.RemoveBlocklistItemsAsync("", content); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call RemoveBlocklistItemsAsync with all parameters and request content. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItemIds = new object[] + { + "" + }, +}); +Response response = await client.RemoveBlocklistItemsAsync("", content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call RemoveBlocklistItems. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItemIds = new object[] + { + "" + }, +}); +Response response = client.RemoveBlocklistItems("", content); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call RemoveBlocklistItems with all parameters and request content. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + blocklistItemIds = new object[] + { + "" + }, +}); +Response response = client.RemoveBlocklistItems("", content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetTextBlocklistItemsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("")) +{ +} +]]> +This sample shows how to call GetTextBlocklistItemsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetTextBlocklistItems. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (TextBlocklistItem item in client.GetTextBlocklistItems("")) +{ +} +]]> +This sample shows how to call GetTextBlocklistItems with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (TextBlocklistItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetTextBlocklistItemsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); +} +]]> +This sample shows how to call GetTextBlocklistItemsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", 1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); +} +]]> + + + +This sample shows how to call GetTextBlocklistItems and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (BinaryData item in client.GetTextBlocklistItems("", null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); +} +]]> +This sample shows how to call GetTextBlocklistItems with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (BinaryData item in client.GetTextBlocklistItems("", 1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); +} +]]> + + + +This sample shows how to call GetTextBlocklistsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) +{ +} +]]> +This sample shows how to call GetTextBlocklistsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) +{ +} +]]> + + + +This sample shows how to call GetTextBlocklists. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (TextBlocklist item in client.GetTextBlocklists()) +{ +} +]]> +This sample shows how to call GetTextBlocklists with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (TextBlocklist item in client.GetTextBlocklists()) +{ +} +]]> + + + +This sample shows how to call GetTextBlocklistsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); +} +]]> +This sample shows how to call GetTextBlocklistsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); +} +]]> + + + +This sample shows how to call GetTextBlocklists and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (BinaryData item in client.GetTextBlocklists(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); +} +]]> +This sample shows how to call GetTextBlocklists with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BlocklistClient client = new BlocklistClient(endpoint, credential); + +foreach (BinaryData item in client.GetTextBlocklists(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); +} +]]> + + + \ No newline at end of file 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..6d3c083a5dbc 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/ContentSafetyClient.xml +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/Docs/ContentSafetyClient.xml @@ -9,8 +9,8 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeTextOptions body = new AnalyzeTextOptions(""); -Response response = await client.AnalyzeTextAsync(body); +AnalyzeTextOptions options = new AnalyzeTextOptions(""); +Response response = await client.AnalyzeTextAsync(options); ]]> This sample shows how to call AnalyzeTextAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeTextOptions body = new AnalyzeTextOptions("") +AnalyzeTextOptions options = new AnalyzeTextOptions("") { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; -Response response = await client.AnalyzeTextAsync(body); +Response response = await client.AnalyzeTextAsync(options); ]]> @@ -35,8 +36,8 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeTextOptions body = new AnalyzeTextOptions(""); -Response response = client.AnalyzeText(body); +AnalyzeTextOptions options = new AnalyzeTextOptions(""); +Response response = client.AnalyzeText(options); ]]> This sample shows how to call AnalyzeText with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeTextOptions body = new AnalyzeTextOptions("") +AnalyzeTextOptions options = new AnalyzeTextOptions("") { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; -Response response = client.AnalyzeText(body); +Response response = client.AnalyzeText(options); ]]> @@ -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()); ]]> @@ -169,8 +157,8 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData()); -Response response = await client.AnalyzeImageAsync(body); +AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData()); +Response response = await client.AnalyzeImageAsync(options); ]]> This sample shows how to call AnalyzeImageAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData +AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData { Content = BinaryData.FromObjectAsJson(new object()), - BlobUrl = new Uri("http://localhost:3000"), + BlobUri = new Uri("http://localhost:3000"), }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; -Response response = await client.AnalyzeImageAsync(body); +Response response = await client.AnalyzeImageAsync(options); ]]> @@ -197,8 +186,8 @@ Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData()); -Response response = client.AnalyzeImage(body); +AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData()); +Response response = client.AnalyzeImage(options); ]]> This sample shows how to call AnalyzeImage with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); -AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData +AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData { Content = BinaryData.FromObjectAsJson(new object()), - BlobUrl = new Uri("http://localhost:3000"), + BlobUri = new Uri("http://localhost:3000"), }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; -Response response = client.AnalyzeImage(body); +Response response = client.AnalyzeImage(options); ]]> @@ -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. - - - -This sample shows how to call GetTextBlocklistAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.GetTextBlocklistAsync(""); -]]> -This sample shows how to call GetTextBlocklistAsync with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.GetTextBlocklistAsync(""); -]]> - - - -This sample shows how to call GetTextBlocklist. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.GetTextBlocklist(""); -]]> -This sample shows how to call GetTextBlocklist with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.GetTextBlocklist(""); -]]> - - - -This sample shows how to call GetTextBlocklistAsync and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.GetTextBlocklistAsync("", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -]]> -This sample shows how to call GetTextBlocklistAsync with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.GetTextBlocklistAsync("", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -Console.WriteLine(result.GetProperty("description").ToString()); -]]> - - - -This sample shows how to call GetTextBlocklist and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.GetTextBlocklist("", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -]]> -This sample shows how to call GetTextBlocklist with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.GetTextBlocklist("", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -Console.WriteLine(result.GetProperty("description").ToString()); -]]> - - - -This sample shows how to call CreateOrUpdateTextBlocklistAsync and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blocklistName = "", -}); -Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -]]> -This sample shows how to call CreateOrUpdateTextBlocklistAsync with all parameters and request content and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blocklistName = "", - description = "", -}); -Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -Console.WriteLine(result.GetProperty("description").ToString()); -]]> - - - -This sample shows how to call CreateOrUpdateTextBlocklist and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blocklistName = "", -}); -Response response = client.CreateOrUpdateTextBlocklist("", content); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -]]> -This sample shows how to call CreateOrUpdateTextBlocklist with all parameters and request content and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blocklistName = "", - description = "", -}); -Response response = client.CreateOrUpdateTextBlocklist("", content); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blocklistName").ToString()); -Console.WriteLine(result.GetProperty("description").ToString()); -]]> - - - -This sample shows how to call DeleteTextBlocklistAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.DeleteTextBlocklistAsync(""); - -Console.WriteLine(response.Status); -]]> -This sample shows how to call DeleteTextBlocklistAsync with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.DeleteTextBlocklistAsync(""); - -Console.WriteLine(response.Status); -]]> - - - -This sample shows how to call DeleteTextBlocklist. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.DeleteTextBlocklist(""); - -Console.WriteLine(response.Status); -]]> -This sample shows how to call DeleteTextBlocklist with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.DeleteTextBlocklist(""); - -Console.WriteLine(response.Status); -]]> - - - -This sample shows how to call AddBlockItemsAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] -{ - new TextBlockItemInfo("") -}); -Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); -]]> -This sample shows how to call AddBlockItemsAsync with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] -{ - new TextBlockItemInfo("") - { - Description = "", - } -}); -Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); -]]> - - - -This sample shows how to call AddBlockItems. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] -{ - new TextBlockItemInfo("") -}); -Response response = client.AddBlockItems("", addBlockItemsOptions); -]]> -This sample shows how to call AddBlockItems with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] -{ - new TextBlockItemInfo("") - { - Description = "", - } -}); -Response response = client.AddBlockItems("", addBlockItemsOptions); -]]> - - - -This sample shows how to call AddBlockItemsAsync and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItems = new object[] - { - new - { - text = "", - } - }, -}); -Response response = await client.AddBlockItemsAsync("", content); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); -]]> -This sample shows how to call AddBlockItemsAsync with all parameters and request content and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItems = new object[] - { - new - { - description = "", - text = "", - } - }, -}); -Response response = await client.AddBlockItemsAsync("", 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()); -]]> - - - -This sample shows how to call AddBlockItems and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItems = new object[] - { - new - { - text = "", - } - }, -}); -Response response = client.AddBlockItems("", content); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); -]]> -This sample shows how to call AddBlockItems with all parameters and request content and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItems = new object[] - { - new - { - description = "", - text = "", - } - }, -}); -Response response = client.AddBlockItems("", 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()); -]]> - - - -This sample shows how to call RemoveBlockItemsAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = await client.RemoveBlockItemsAsync("", removeBlockItemsOptions); -]]> -This sample shows how to call RemoveBlockItemsAsync 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); -]]> - - - -This sample shows how to call RemoveBlockItems. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = client.RemoveBlockItems("", removeBlockItemsOptions); -]]> -This sample shows how to call RemoveBlockItems with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -RemoveBlockItemsOptions removeBlockItemsOptions = new RemoveBlockItemsOptions(new string[] { "" }); -Response response = client.RemoveBlockItems("", removeBlockItemsOptions); -]]> - - - -This sample shows how to call RemoveBlockItemsAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItemIds = new object[] - { - "" - }, -}); -Response response = await client.RemoveBlockItemsAsync("", content); - -Console.WriteLine(response.Status); -]]> -This sample shows how to call RemoveBlockItemsAsync with all parameters and request content. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItemIds = new object[] - { - "" - }, -}); -Response response = await client.RemoveBlockItemsAsync("", content); - -Console.WriteLine(response.Status); -]]> - - - -This sample shows how to call RemoveBlockItems. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItemIds = new object[] - { - "" - }, -}); -Response response = client.RemoveBlockItems("", content); - -Console.WriteLine(response.Status); -]]> -This sample shows how to call RemoveBlockItems with all parameters and request content. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new -{ - blockItemIds = new object[] - { - "" - }, -}); -Response response = client.RemoveBlockItems("", content); - -Console.WriteLine(response.Status); -]]> - - - -This sample shows how to call GetTextBlocklistItemAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -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("", ""); -]]> - - - -This sample shows how to call GetTextBlocklistItem. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -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("", ""); -]]> - - - -This sample shows how to call GetTextBlocklistItemAsync and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.GetTextBlocklistItemAsync("", "", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("text").ToString()); -]]> -This sample shows how to call GetTextBlocklistItemAsync with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = await client.GetTextBlocklistItemAsync("", "", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("description").ToString()); -Console.WriteLine(result.GetProperty("text").ToString()); -]]> - - - -This sample shows how to call GetTextBlocklistItem and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.GetTextBlocklistItem("", "", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("text").ToString()); -]]> -This sample shows how to call GetTextBlocklistItem with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -Response response = client.GetTextBlocklistItem("", "", null); - -JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("blockItemId").ToString()); -Console.WriteLine(result.GetProperty("description").ToString()); -Console.WriteLine(result.GetProperty("text").ToString()); -]]> - - - -This sample shows how to call GetTextBlocklistsAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) -{ -} -]]> -This sample shows how to call GetTextBlocklistsAsync with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) -{ -} -]]> - - - -This sample shows how to call GetTextBlocklists. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -foreach (TextBlocklist item in client.GetTextBlocklists()) -{ -} -]]> -This sample shows how to call GetTextBlocklists with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -foreach (TextBlocklist item in client.GetTextBlocklists()) -{ -} -]]> - - - -This sample shows how to call GetTextBlocklistsAsync and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); -} -]]> -This sample shows how to call GetTextBlocklistsAsync with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); -} -]]> - - - -This sample shows how to call GetTextBlocklists and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -foreach (BinaryData item in client.GetTextBlocklists(null)) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); -} -]]> -This sample shows how to call GetTextBlocklists with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -foreach (BinaryData item in client.GetTextBlocklists(null)) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); -} -]]> - - - -This sample shows how to call GetTextBlocklistItemsAsync. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("")) -{ -} -]]> -This sample shows how to call GetTextBlocklistItemsAsync with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) -{ -} -]]> - - - -This sample shows how to call GetTextBlocklistItems. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -foreach (TextBlockItem item in client.GetTextBlocklistItems("")) -{ -} -]]> -This sample shows how to call GetTextBlocklistItems with all parameters. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - -foreach (TextBlockItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) -{ -} -]]> - - - -This sample shows how to call GetTextBlocklistItemsAsync and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -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("text").ToString()); -} -]]> -This sample shows how to call GetTextBlocklistItemsAsync with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -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("description").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); -} -]]> - - - -This sample shows how to call GetTextBlocklistItems and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -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("text").ToString()); -} -]]> -This sample shows how to call GetTextBlocklistItems with all parameters and parse the result. -"); -AzureKeyCredential credential = new AzureKeyCredential(""); -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("description").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); -} +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("category").ToString()); +Console.WriteLine(result.GetProperty("categoriesAnalysis")[0].GetProperty("severity").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..b1d5e3f37f94 --- /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’, and the output value can be 0, 2, 4, 6. + 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’, and the output value can be 0, 2, 4, 6. + 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/TextBlocklist.cs b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklist.cs index c2261aee3d68..aa71ec28a4c5 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklist.cs +++ b/sdk/contentsafety/Azure.AI.ContentSafety/src/Generated/TextBlocklist.cs @@ -14,26 +14,26 @@ namespace Azure.AI.ContentSafety public partial class TextBlocklist { /// Initializes a new instance of TextBlocklist. - /// Text blocklist name. - /// is null. - internal TextBlocklist(string blocklistName) + /// Text blocklist name. + /// is null. + internal TextBlocklist(string name) { - Argument.AssertNotNull(blocklistName, nameof(blocklistName)); + Argument.AssertNotNull(name, nameof(name)); - BlocklistName = blocklistName; + Name = name; } /// Initializes a new instance of TextBlocklist. - /// Text blocklist name. + /// Text blocklist name. /// Text blocklist description. - internal TextBlocklist(string blocklistName, string description) + internal TextBlocklist(string name, string description) { - BlocklistName = blocklistName; + Name = name; Description = description; } /// Text blocklist name. - public string BlocklistName { get; } + public string Name { get; } /// Text blocklist description. public string Description { 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..8580e853205e --- /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 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 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 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/tests/Generated/Samples/Samples_BlocklistClient.cs b/sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_BlocklistClient.cs new file mode 100644 index 000000000000..bb0089bf550f --- /dev/null +++ b/sdk/contentsafety/Azure.AI.ContentSafety/tests/Generated/Samples/Samples_BlocklistClient.cs @@ -0,0 +1,887 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.AI.ContentSafety; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.ContentSafety.Samples +{ + public partial class Samples_BlocklistClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AddOrUpdateBlocklistItems_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItems = new object[] + { +new +{ +text = "", +} + }, + }); + Response response = client.AddOrUpdateBlocklistItems("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AddOrUpdateBlocklistItems_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItems = new object[] + { +new +{ +text = "", +} + }, + }); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AddOrUpdateBlocklistItems_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] + { +new TextBlocklistItem("") + }); + Response response = client.AddOrUpdateBlocklistItems("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AddOrUpdateBlocklistItems_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] + { +new TextBlocklistItem("") + }); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AddOrUpdateBlocklistItems_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItems = new object[] + { +new +{ +description = "", +text = "", +} + }, + }); + Response response = client.AddOrUpdateBlocklistItems("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AddOrUpdateBlocklistItems_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItems = new object[] + { +new +{ +description = "", +text = "", +} + }, + }); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("blocklistItems")[0].GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AddOrUpdateBlocklistItems_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] + { +new TextBlocklistItem("") +{ +Description = "", +} + }); + Response response = client.AddOrUpdateBlocklistItems("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AddOrUpdateBlocklistItems_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + AddOrUpdateTextBlocklistItemsOptions options = new AddOrUpdateTextBlocklistItemsOptions(new TextBlocklistItem[] + { +new TextBlocklistItem("") +{ +Description = "", +} + }); + Response response = await client.AddOrUpdateBlocklistItemsAsync("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_CreateOrUpdateTextBlocklist_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistName = "", + }); + Response response = client.CreateOrUpdateTextBlocklist("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_CreateOrUpdateTextBlocklist_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistName = "", + }); + Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_CreateOrUpdateTextBlocklist_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistName = "", + description = "", + }); + Response response = client.CreateOrUpdateTextBlocklist("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_CreateOrUpdateTextBlocklist_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistName = "", + description = "", + }); + Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeleteTextBlocklist_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.DeleteTextBlocklist(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeleteTextBlocklist_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.DeleteTextBlocklistAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeleteTextBlocklist_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.DeleteTextBlocklist(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeleteTextBlocklist_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.DeleteTextBlocklistAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklist_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklist("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklist_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklist_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklist(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklist_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklist_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklist("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklist_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklist_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklist(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklist_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItem_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklistItem("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItem_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistItemAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItem_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklistItem("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItem_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistItemAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItem_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklistItem("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItem_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistItemAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItem_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = client.GetTextBlocklistItem("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItem_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + Response response = await client.GetTextBlocklistItemAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RemoveBlocklistItems_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItemIds = new object[] + { +"" + }, + }); + Response response = client.RemoveBlocklistItems("", content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RemoveBlocklistItems_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItemIds = new object[] + { +"" + }, + }); + Response response = await client.RemoveBlocklistItemsAsync("", content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RemoveBlocklistItems_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = client.RemoveBlocklistItems("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RemoveBlocklistItems_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = await client.RemoveBlocklistItemsAsync("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RemoveBlocklistItems_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItemIds = new object[] + { +"" + }, + }); + Response response = client.RemoveBlocklistItems("", content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RemoveBlocklistItems_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + blocklistItemIds = new object[] + { +"" + }, + }); + Response response = await client.RemoveBlocklistItemsAsync("", content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RemoveBlocklistItems_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = client.RemoveBlocklistItems("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RemoveBlocklistItems_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + RemoveTextBlocklistItemsOptions options = new RemoveTextBlocklistItemsOptions(new string[] { "" }); + Response response = await client.RemoveBlocklistItemsAsync("", options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItems_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (BinaryData item in client.GetTextBlocklistItems("", null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItems_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItems_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (TextBlocklistItem item in client.GetTextBlocklistItems("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItems_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItems_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (BinaryData item in client.GetTextBlocklistItems("", 1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItems_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTextBlocklistItemsAsync("", 1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistItemId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("text").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklistItems_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (TextBlocklistItem item in client.GetTextBlocklistItems("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklistItems_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (TextBlocklistItem item in client.GetTextBlocklistItemsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklists_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (BinaryData item in client.GetTextBlocklists(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklists_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklists_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (TextBlocklist item in client.GetTextBlocklists()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklists_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklists_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (BinaryData item in client.GetTextBlocklists(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklists_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("blocklistName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_GetTextBlocklists_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + foreach (TextBlocklist item in client.GetTextBlocklists()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetTextBlocklists_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BlocklistClient client = new BlocklistClient(endpoint, credential); + + await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) + { + } + } + } +} 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..9ec06152d669 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] @@ -62,8 +62,8 @@ public void Example_AnalyzeText_ShortVersion_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeTextOptions body = new AnalyzeTextOptions(""); - Response response = client.AnalyzeText(body); + AnalyzeTextOptions options = new AnalyzeTextOptions(""); + Response response = client.AnalyzeText(options); } [Test] @@ -74,8 +74,8 @@ public async Task Example_AnalyzeText_ShortVersion_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeTextOptions body = new AnalyzeTextOptions(""); - Response response = await client.AnalyzeTextAsync(body); + AnalyzeTextOptions options = new AnalyzeTextOptions(""); + Response response = await client.AnalyzeTextAsync(options); } [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] @@ -164,13 +150,14 @@ public void Example_AnalyzeText_AllParameters_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeTextOptions body = new AnalyzeTextOptions("") + AnalyzeTextOptions options = new AnalyzeTextOptions("") { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; - Response response = client.AnalyzeText(body); + Response response = client.AnalyzeText(options); } [Test] @@ -181,13 +168,14 @@ public async Task Example_AnalyzeText_AllParameters_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeTextOptions body = new AnalyzeTextOptions("") + AnalyzeTextOptions options = new AnalyzeTextOptions("") { Categories = { TextCategory.Hate }, BlocklistNames = { "" }, - BreakByBlocklists = true, + HaltOnBlocklistHit = true, + OutputType = AnalyzeTextOutputType.FourSeverityLevels, }; - Response response = await client.AnalyzeTextAsync(body); + Response response = await client.AnalyzeTextAsync(options); } [Test] @@ -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] @@ -234,8 +222,8 @@ public void Example_AnalyzeImage_ShortVersion_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData()); - Response response = client.AnalyzeImage(body); + AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData()); + Response response = client.AnalyzeImage(options); } [Test] @@ -246,8 +234,8 @@ public async Task Example_AnalyzeImage_ShortVersion_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData()); - Response response = await client.AnalyzeImageAsync(body); + AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData()); + Response response = await client.AnalyzeImageAsync(options); } [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] @@ -324,15 +302,16 @@ public void Example_AnalyzeImage_AllParameters_Convenience() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData + AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData { Content = BinaryData.FromObjectAsJson(new object()), - BlobUrl = new Uri("http://localhost:3000"), + BlobUri = new Uri("http://localhost:3000"), }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; - Response response = client.AnalyzeImage(body); + Response response = client.AnalyzeImage(options); } [Test] @@ -343,879 +322,16 @@ public async Task Example_AnalyzeImage_AllParameters_Convenience_Async() AzureKeyCredential credential = new AzureKeyCredential(""); ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - AnalyzeImageOptions body = new AnalyzeImageOptions(new ContentSafetyImageData + AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData { Content = BinaryData.FromObjectAsJson(new object()), - BlobUrl = new Uri("http://localhost:3000"), + BlobUri = new Uri("http://localhost:3000"), }) { Categories = { ImageCategory.Hate }, + OutputType = AnalyzeImageOutputType.FourSeverityLevels, }; - Response response = await client.AnalyzeImageAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklist_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklist("", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklist_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistAsync("", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklist_ShortVersion_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklist(""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklist_ShortVersion_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistAsync(""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklist_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklist("", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklist_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistAsync("", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklist_AllParameters_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklist(""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklist_AllParameters_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistAsync(""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_CreateOrUpdateTextBlocklist_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blocklistName = "", - }); - Response response = client.CreateOrUpdateTextBlocklist("", content); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_CreateOrUpdateTextBlocklist_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blocklistName = "", - }); - Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_CreateOrUpdateTextBlocklist_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blocklistName = "", - description = "", - }); - Response response = client.CreateOrUpdateTextBlocklist("", content); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_CreateOrUpdateTextBlocklist_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blocklistName = "", - description = "", - }); - Response response = await client.CreateOrUpdateTextBlocklistAsync("", content); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_DeleteTextBlocklist_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.DeleteTextBlocklist(""); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_DeleteTextBlocklist_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.DeleteTextBlocklistAsync(""); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_DeleteTextBlocklist_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.DeleteTextBlocklist(""); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_DeleteTextBlocklist_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.DeleteTextBlocklistAsync(""); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItems = new object[] - { -new -{ -text = "", -} - }, - }); - Response response = client.AddBlockItems("", content); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItems = new object[] - { -new -{ -text = "", -} - }, - }); - Response response = await client.AddBlockItemsAsync("", content); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_ShortVersion_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] - { -new TextBlockItemInfo("") - }); - Response response = client.AddBlockItems("", addBlockItemsOptions); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_ShortVersion_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] - { -new TextBlockItemInfo("") - }); - Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItems = new object[] - { -new -{ -description = "", -text = "", -} - }, - }); - Response response = client.AddBlockItems("", 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()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItems = new object[] - { -new -{ -description = "", -text = "", -} - }, - }); - Response response = await client.AddBlockItemsAsync("", 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()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_AddBlockItems_AllParameters_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] - { -new TextBlockItemInfo("") -{ -Description = "", -} - }); - Response response = client.AddBlockItems("", addBlockItemsOptions); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_AddBlockItems_AllParameters_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - AddBlockItemsOptions addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[] - { -new TextBlockItemInfo("") -{ -Description = "", -} - }); - Response response = await client.AddBlockItemsAsync("", addBlockItemsOptions); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItemIds = new object[] - { -"" - }, - }); - Response response = client.RemoveBlockItems("", content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItemIds = new object[] - { -"" - }, - }); - Response response = await client.RemoveBlockItemsAsync("", content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_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); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_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); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItemIds = new object[] - { -"" - }, - }); - Response response = client.RemoveBlockItems("", content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - using RequestContent content = RequestContent.Create(new - { - blockItemIds = new object[] - { -"" - }, - }); - Response response = await client.RemoveBlockItemsAsync("", content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_RemoveBlockItems_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); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_RemoveBlockItems_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); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItem_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklistItem("", "", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItem_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistItemAsync("", "", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItem_ShortVersion_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklistItem("", ""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItem_ShortVersion_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistItemAsync("", ""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItem_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklistItem("", "", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItem_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistItemAsync("", "", null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("blockItemId").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItem_AllParameters_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = client.GetTextBlocklistItem("", ""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItem_AllParameters_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - Response response = await client.GetTextBlocklistItemAsync("", ""); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklists_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - foreach (BinaryData item in client.GetTextBlocklists(null)) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklists_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklists_ShortVersion_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - foreach (TextBlocklist item in client.GetTextBlocklists()) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklists_ShortVersion_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklists_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - foreach (BinaryData item in client.GetTextBlocklists(null)) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklists_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - await foreach (BinaryData item in client.GetTextBlocklistsAsync(null)) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("blocklistName").ToString()); - Console.WriteLine(result.GetProperty("description").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklists_AllParameters_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - foreach (TextBlocklist item in client.GetTextBlocklists()) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklists_AllParameters_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - await foreach (TextBlocklist item in client.GetTextBlocklistsAsync()) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItems_ShortVersion() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - 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("text").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItems_ShortVersion_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - 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("text").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItems_ShortVersion_Convenience() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - foreach (TextBlockItem item in client.GetTextBlocklistItems("")) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItems_ShortVersion_Convenience_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - ContentSafetyClient client = new ContentSafetyClient(endpoint, credential); - - await foreach (TextBlockItem item in client.GetTextBlocklistItemsAsync("")) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItems_AllParameters() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - 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("description").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItems_AllParameters_Async() - { - Uri endpoint = new Uri(""); - AzureKeyCredential credential = new AzureKeyCredential(""); - 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("description").ToString()); - Console.WriteLine(result.GetProperty("text").ToString()); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_GetTextBlocklistItems_AllParameters_Convenience() - { - 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)) - { - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetTextBlocklistItems_AllParameters_Convenience_Async() - { - 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)) - { - } + Response response = await client.AnalyzeImageAsync(options); } } } diff --git a/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml b/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml index 2f023a7a4f40..6ddfd99744b2 100644 --- a/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml +++ b/sdk/contentsafety/Azure.AI.ContentSafety/tsp-location.yaml @@ -1,3 +1,5 @@ +additionalDirectories: [] +repo: Azure/azure-rest-api-specs +commit: 4539708e7024bad1fcf4854bb1d852f856e2813a directory: specification/cognitiveservices/ContentSafety -commit: 17c41d0c4a96294bf563b009c9c72093963b529f -repo: Azure/azure-rest-api-specs \ No newline at end of file +