diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/Azure.HealthDataAIServices.Deid.sln b/sdk/deid/Azure.HealthDataAIServices.Deid/Azure.HealthDataAIServices.Deid.sln new file mode 100644 index 000000000000..c467ed04a12b --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/Azure.HealthDataAIServices.Deid.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.HealthDataAIServices.Deid", "src\Azure.HealthDataAIServices.Deid.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.HealthDataAIServices.Deid.Tests", "tests\Azure.HealthDataAIServices.Deid.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/CHANGELOG.md b/sdk/deid/Azure.HealthDataAIServices.Deid/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/Directory.Build.props b/sdk/deid/Azure.HealthDataAIServices.Deid/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/README.md b/sdk/deid/Azure.HealthDataAIServices.Deid/README.md new file mode 100644 index 000000000000..6eb617b6e80e --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/README.md @@ -0,0 +1,86 @@ +# Azure.HealthDataAIServices.Deid client library for .NET + +Azure.HealthDataAIServices.Deid is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/deid/Azure.HealthDataAIServices.Deid/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.HealthDataAIServices.Deid --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/deid/Azure.HealthDataAIServices.Deid/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/deid/Azure.HealthDataAIServices.Deid/README.png) diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Azure.HealthDataAIServices.Deid.csproj b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Azure.HealthDataAIServices.Deid.csproj new file mode 100644 index 000000000000..ad98fb3bda41 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Azure.HealthDataAIServices.Deid.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.HealthDataAIServices.Deid client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.HealthDataAIServices.Deid for Azure Data Plane + 1.0.0-beta.1 + Azure.HealthDataAIServices.Deid + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidRequest.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidRequest.Serialization.cs new file mode 100644 index 000000000000..5fec6dbd13ed --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidRequest.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class DeidRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeidRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("inputText"u8); + writer.WriteStringValue(InputText); + writer.WritePropertyName("dataType"u8); + writer.WriteStringValue(DataType.ToString()); + writer.WritePropertyName("operation"u8); + writer.WriteStringValue(Operation.ToString()); + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"u8); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + if (Optional.IsDefined(RedactionFormat)) + { + writer.WritePropertyName("redactionFormat"u8); + writer.WriteStringValue(RedactionFormat); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeidRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeidRequest)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeidRequest(document.RootElement, options); + } + + internal static DeidRequest DeserializeDeidRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string inputText = default; + DocumentDataType dataType = default; + OperationType operation = default; + StringIndexType? stringIndexType = default; + string redactionFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("inputText"u8)) + { + inputText = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataType"u8)) + { + dataType = new DocumentDataType(property.Value.GetString()); + continue; + } + if (property.NameEquals("operation"u8)) + { + operation = new OperationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("stringIndexType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stringIndexType = new StringIndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("redactionFormat"u8)) + { + redactionFormat = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DeidRequest( + inputText, + dataType, + operation, + stringIndexType, + redactionFormat, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DeidRequest)} does not support '{options.Format}' format."); + } + } + + DeidRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeidRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeidRequest)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DeidRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDeidRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidRequest.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidRequest.cs new file mode 100644 index 000000000000..d3b245ddde8e --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidRequest.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Request for synchronous DeID operation. + public partial class DeidRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Input text to deidentify. + /// Data type of the input. + /// Operation to perform on the input. + /// is null. + public DeidRequest(string inputText, DocumentDataType dataType, OperationType operation) + { + if (inputText == null) + { + throw new ArgumentNullException(nameof(inputText)); + } + + InputText = inputText; + DataType = dataType; + Operation = operation; + } + + /// Initializes a new instance of . + /// Input text to deidentify. + /// Data type of the input. + /// Operation to perform on the input. + /// Requested Encoding of the tag response indices. + /// Format of the redacted output. Only valid when OperationType is Redact. + /// Keeps track of any properties unknown to the library. + internal DeidRequest(string inputText, DocumentDataType dataType, OperationType operation, StringIndexType? stringIndexType, string redactionFormat, IDictionary serializedAdditionalRawData) + { + InputText = inputText; + DataType = dataType; + Operation = operation; + StringIndexType = stringIndexType; + RedactionFormat = redactionFormat; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DeidRequest() + { + } + + /// Input text to deidentify. + public string InputText { get; } + /// Data type of the input. + public DocumentDataType DataType { get; } + /// Operation to perform on the input. + public OperationType Operation { get; } + /// Requested Encoding of the tag response indices. + public StringIndexType? StringIndexType { get; set; } + /// Format of the redacted output. Only valid when OperationType is Redact. + public string RedactionFormat { get; set; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidResponse.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidResponse.Serialization.cs new file mode 100644 index 000000000000..633f24bc122c --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidResponse.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class DeidResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeidResponse)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(OutputText)) + { + writer.WritePropertyName("outputText"u8); + writer.WriteStringValue(OutputText); + } + if (Optional.IsDefined(TaggerResult)) + { + writer.WritePropertyName("taggerResult"u8); + writer.WriteObjectValue(TaggerResult); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeidResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeidResponse)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeidResponse(document.RootElement, options); + } + + internal static DeidResponse DeserializeDeidResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string outputText = default; + PhiTaggerResult taggerResult = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("outputText"u8)) + { + outputText = property.Value.GetString(); + continue; + } + if (property.NameEquals("taggerResult"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + taggerResult = PhiTaggerResult.DeserializePhiTaggerResult(property.Value, options); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DeidResponse(outputText, taggerResult, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DeidResponse)} does not support '{options.Format}' format."); + } + } + + DeidResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeidResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeidResponse)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DeidResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDeidResponse(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidResponse.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidResponse.cs new file mode 100644 index 000000000000..b498ce63ed71 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidResponse.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Response for synchronous DeID operation. + public partial class DeidResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal DeidResponse() + { + } + + /// Initializes a new instance of . + /// Output text after deidentification. Not available for Tag Operation. + /// Result of the tag operation. Only available for Tag Operation. + /// Keeps track of any properties unknown to the library. + internal DeidResponse(string outputText, PhiTaggerResult taggerResult, IDictionary serializedAdditionalRawData) + { + OutputText = outputText; + TaggerResult = taggerResult; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Output text after deidentification. Not available for Tag Operation. + public string OutputText { get; } + /// Result of the tag operation. Only available for Tag Operation. + public PhiTaggerResult TaggerResult { get; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidentificationClient.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidentificationClient.cs new file mode 100644 index 000000000000..7b0ee0873581 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidentificationClient.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.HealthDataAIServices.Deid +{ + // Data plane generated client. + /// The Deidentification service client. + public partial class DeidentificationClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://deid.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// 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 DeidentificationClient for mocking. + protected DeidentificationClient() + { + } + + /// Initializes a new instance of DeidentificationClient. + /// Uri of your Deid Service. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public DeidentificationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new DeidentificationClientOptions()) + { + } + + /// Initializes a new instance of DeidentificationClient. + /// Uri of your Deid Service. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public DeidentificationClient(Uri endpoint, TokenCredential credential, DeidentificationClientOptions options) + { + if (endpoint == null) + { + throw new ArgumentNullException(nameof(endpoint)); + } + if (credential == null) + { + throw new ArgumentNullException(nameof(credential)); + } + options ??= new DeidentificationClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of Jobs. + /// The API version to use for this operation. + /// is null. + public virtual Jobs GetJobsClient(string apiVersion = "2024-01-31-preview") + { + if (apiVersion == null) + { + throw new ArgumentNullException(nameof(apiVersion)); + } + + return new Jobs(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Realtime. + /// The API version to use for this operation. + /// is null. + public virtual Realtime GetRealtimeClient(string apiVersion = "2024-01-31-preview") + { + if (apiVersion == null) + { + throw new ArgumentNullException(nameof(apiVersion)); + } + + return new Realtime(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidentificationClientOptions.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidentificationClientOptions.cs new file mode 100644 index 000000000000..bb15ecc341d8 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DeidentificationClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Client options for DeidentificationClient. + public partial class DeidentificationClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_01_31_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-01-31-preview". + V2024_01_31_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of DeidentificationClientOptions. + public DeidentificationClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_01_31_Preview => "2024-01-31-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Docs/Jobs.xml b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Docs/Jobs.xml new file mode 100644 index 000000000000..b00fd0e475f0 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Docs/Jobs.xml @@ -0,0 +1,841 @@ + + + + + +This sample shows how to call GetJobAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.GetJobAsync(""); +]]> +This sample shows how to call GetJobAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.GetJobAsync(""); +]]> + + + +This sample shows how to call GetJob. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.GetJob(""); +]]> +This sample shows how to call GetJob with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.GetJob(""); +]]> + + + +This sample shows how to call GetJobAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.GetJobAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +]]> +This sample shows how to call GetJobAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.GetJobAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("redactionFormat").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("startedAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +]]> + + + +This sample shows how to call GetJob and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.GetJob("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +]]> +This sample shows how to call GetJob with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.GetJob("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("redactionFormat").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("startedAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +]]> + + + +This sample shows how to call CancelAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.CancelAsync(""); +]]> +This sample shows how to call CancelAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.CancelAsync(""); +]]> + + + +This sample shows how to call Cancel. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.Cancel(""); +]]> +This sample shows how to call Cancel with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.Cancel(""); +]]> + + + +This sample shows how to call CancelAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.CancelAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +]]> +This sample shows how to call CancelAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.CancelAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("redactionFormat").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("startedAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +]]> + + + +This sample shows how to call Cancel and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.Cancel("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +]]> +This sample shows how to call Cancel with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.Cancel("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("redactionFormat").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("startedAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.DeleteAsync(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = await client.DeleteAsync(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.Delete(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call Delete with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Response response = client.Delete(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetJobsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (Job item in client.GetJobsAsync()) +{ +} +]]> +This sample shows how to call GetJobsAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (Job item in client.GetJobsAsync(maxpagesize: 1234, continuationToken: "")) +{ +} +]]> + + + +This sample shows how to call GetJobs. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (Job item in client.GetJobs()) +{ +} +]]> +This sample shows how to call GetJobs with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (Job item in client.GetJobs(maxpagesize: 1234, continuationToken: "")) +{ +} +]]> + + + +This sample shows how to call GetJobsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (BinaryData item in client.GetJobsAsync(null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); +} +]]> +This sample shows how to call GetJobsAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (BinaryData item in client.GetJobsAsync(1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +} +]]> + + + +This sample shows how to call GetJobs and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (BinaryData item in client.GetJobs(null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); +} +]]> +This sample shows how to call GetJobs with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (BinaryData item in client.GetJobs(1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +} +]]> + + + +This sample shows how to call GetFilesAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (File item in client.GetFilesAsync("")) +{ +} +]]> +This sample shows how to call GetFilesAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (File item in client.GetFilesAsync("", maxpagesize: 1234, continuationToken: "")) +{ +} +]]> + + + +This sample shows how to call GetFiles. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (File item in client.GetFiles("")) +{ +} +]]> +This sample shows how to call GetFiles with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (File item in client.GetFiles("", maxpagesize: 1234, continuationToken: "")) +{ +} +]]> + + + +This sample shows how to call GetFilesAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (BinaryData item in client.GetFilesAsync("", null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); +} +]]> +This sample shows how to call GetFilesAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +await foreach (BinaryData item in client.GetFilesAsync("", 1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); +} +]]> + + + +This sample shows how to call GetFiles and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (BinaryData item in client.GetFiles("", null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); +} +]]> +This sample shows how to call GetFiles with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +foreach (BinaryData item in client.GetFiles("", 1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); +} +]]> + + + +This sample shows how to call CreateAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), ""), new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact); +Operation operation = await client.CreateAsync(WaitUntil.Completed, "", resource); +Job responseData = operation.Value; +]]> +This sample shows how to call CreateAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), "") +{ + Extensions = { "" }, +}, new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact) +{ + RedactionFormat = "", +}; +Operation operation = await client.CreateAsync(WaitUntil.Completed, "", resource); +Job responseData = operation.Value; +]]> + + + +This sample shows how to call Create. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), ""), new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact); +Operation operation = client.Create(WaitUntil.Completed, "", resource); +Job responseData = operation.Value; +]]> +This sample shows how to call Create with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), "") +{ + Extensions = { "" }, +}, new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact) +{ + RedactionFormat = "", +}; +Operation operation = client.Create(WaitUntil.Completed, "", resource); +Job responseData = operation.Value; +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", +}); +Operation operation = await client.CreateAsync(WaitUntil.Completed, "", content); +BinaryData responseData = operation.Value; + +JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +]]> +This sample shows how to call CreateAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + extensions = new object[] + { + "" + }, + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", + redactionFormat = "", +}); +Operation operation = await client.CreateAsync(WaitUntil.Completed, "", content); +BinaryData responseData = operation.Value; + +JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("redactionFormat").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("startedAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", +}); +Operation operation = client.Create(WaitUntil.Completed, "", content); +BinaryData responseData = operation.Value; + +JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +]]> +This sample shows how to call Create with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + extensions = new object[] + { + "" + }, + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", + redactionFormat = "", +}); +Operation operation = client.Create(WaitUntil.Completed, "", content); +BinaryData responseData = operation.Value; + +JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); +Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); +Console.WriteLine(result.GetProperty("dataType").ToString()); +Console.WriteLine(result.GetProperty("operation").ToString()); +Console.WriteLine(result.GetProperty("redactionFormat").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("startedAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); +Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Docs/Realtime.xml b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Docs/Realtime.xml new file mode 100644 index 000000000000..4c62be2f34a7 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Docs/Realtime.xml @@ -0,0 +1,149 @@ + + + + + +This sample shows how to call DeidAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact); +Response response = await client.DeidAsync(options); +]]> +This sample shows how to call DeidAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact) +{ + StringIndexType = StringIndexType.TextElementV8, + RedactionFormat = "", +}; +Response response = await client.DeidAsync(options); +]]> + + + +This sample shows how to call Deid. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact); +Response response = client.Deid(options); +]]> +This sample shows how to call Deid with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact) +{ + StringIndexType = StringIndexType.TextElementV8, + RedactionFormat = "", +}; +Response response = client.Deid(options); +]]> + + + +This sample shows how to call DeidAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputText = "", + dataType = "Unknown", + operation = "Redact", +}); +Response response = await client.DeidAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call DeidAsync with all request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputText = "", + dataType = "Unknown", + operation = "Redact", + stringIndexType = "TextElement_v8", + redactionFormat = "", +}); +Response response = await client.DeidAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("outputText").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("category").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("stringIndexType").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("path").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("checksum").ToString()); +]]> + + + +This sample shows how to call Deid and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputText = "", + dataType = "Unknown", + operation = "Redact", +}); +Response response = client.Deid(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call Deid with all request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputText = "", + dataType = "Unknown", + operation = "Redact", + stringIndexType = "TextElement_v8", + redactionFormat = "", +}); +Response response = client.Deid(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("outputText").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("category").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("stringIndexType").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("path").ToString()); +Console.WriteLine(result.GetProperty("taggerResult").GetProperty("checksum").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DocumentDataType.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DocumentDataType.cs new file mode 100644 index 000000000000..a26e3d326235 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/DocumentDataType.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.HealthDataAIServices.Deid +{ + /// Enum of supported Data Types. + public readonly partial struct DocumentDataType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DocumentDataType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string PlainTextValue = "PlainText"; + + /// Unknown data type. + public static DocumentDataType Unknown { get; } = new DocumentDataType(UnknownValue); + /// Plain text data type. + public static DocumentDataType PlainText { get; } = new DocumentDataType(PlainTextValue); + /// Determines if two values are the same. + public static bool operator ==(DocumentDataType left, DocumentDataType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DocumentDataType left, DocumentDataType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DocumentDataType(string value) => new DocumentDataType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DocumentDataType other && Equals(other); + /// + public bool Equals(DocumentDataType 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/deid/Azure.HealthDataAIServices.Deid/src/Generated/File.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/File.Serialization.cs new file mode 100644 index 000000000000..0b7564ae665c --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/File.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class File : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(File)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W") + { + writer.WritePropertyName("path"u8); + writer.WriteStringValue(Path); + } + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } + if (options.Format != "W") + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(Etag); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + File IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(File)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFile(document.RootElement, options); + } + + internal static File DeserializeFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string path = default; + OperationState status = default; + ResponseError error = default; + string etag = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("path"u8)) + { + path = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new OperationState(property.Value.GetString()); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("etag"u8)) + { + etag = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new File(path, status, error, etag, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(File)} does not support '{options.Format}' format."); + } + } + + File IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(File)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static File FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFile(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/File.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/File.cs new file mode 100644 index 000000000000..03f32eec4680 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/File.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.HealthDataAIServices.Deid +{ + /// File report once job has completed. + public partial class File + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Status of the file. + internal File(OperationState status) + { + Status = status; + } + + /// Initializes a new instance of . + /// Relative path to file from location prefix. + /// Status of the file. + /// Error when file fails. + /// The entity tag for this resource. + /// Keeps track of any properties unknown to the library. + internal File(string path, OperationState status, ResponseError error, string etag, IDictionary serializedAdditionalRawData) + { + Path = path; + Status = status; + Error = error; + Etag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal File() + { + } + + /// Relative path to file from location prefix. + public string Path { get; } + /// Status of the file. + public OperationState Status { get; } + /// Error when file fails. + public ResponseError Error { get; } + /// The entity tag for this resource. + public string Etag { get; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/HealthDataAIServicesDeidClientBuilderExtensions.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/HealthDataAIServicesDeidClientBuilderExtensions.cs new file mode 100644 index 000000000000..392c2d294d07 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/HealthDataAIServicesDeidClientBuilderExtensions.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Extensions; +using Azure.HealthDataAIServices.Deid; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class HealthDataAIServicesDeidClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// Uri of your Deid Service. + public static IAzureClientBuilder AddDeidentificationClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new DeidentificationClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddDeidentificationClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/HealthDataAIServicesDeidModelFactory.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/HealthDataAIServicesDeidModelFactory.cs new file mode 100644 index 000000000000..f5b6db663752 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/HealthDataAIServicesDeidModelFactory.cs @@ -0,0 +1,123 @@ +// 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; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Model factory for models. + public static partial class HealthDataAIServicesDeidModelFactory + { + /// Initializes a new instance of . + /// Storage location to perform the operation on. + /// Target location to store output of operation. + /// Data type of the input documents. + /// Operation to perform on the input documents. + /// Format of the redacted output. Only valid when Operation is Redact. + /// Current status of a job. + /// Date and time when the job was created. + /// Error when job fails in it's entirety. + /// Date and time when the job was started. + /// + /// Date and time when the job was completed. + /// + /// If the job is canceled, this is the time when the job was canceled. + /// + /// If the job failed, this is the time when the job failed. + /// + /// Summary of a job. Exists only when the job is completed. + /// A new instance for mocking. + public static Job Job(SourceStorageLocation sourceLocation = null, TargetStorageLocation targetLocation = null, DocumentDataType dataType = default, OperationType operation = default, string redactionFormat = null, JobStatus status = default, DateTimeOffset createdAt = default, ResponseError error = null, DateTimeOffset? startedAt = null, DateTimeOffset? completedAt = null, JobSummary summary = null) + { + return new Job( + sourceLocation, + targetLocation, + dataType, + operation, + redactionFormat, + status, + createdAt, + error, + startedAt, + completedAt, + summary, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Relative path to file from location prefix. + /// Status of the file. + /// Error when file fails. + /// The entity tag for this resource. + /// A new instance for mocking. + public static File File(string path = null, OperationState status = default, ResponseError error = null, string etag = null) + { + return new File(path, status, error, etag, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Input text to deidentify. + /// Data type of the input. + /// Operation to perform on the input. + /// Requested Encoding of the tag response indices. + /// Format of the redacted output. Only valid when OperationType is Redact. + /// A new instance for mocking. + public static DeidRequest DeidRequest(string inputText = null, DocumentDataType dataType = default, OperationType operation = default, StringIndexType? stringIndexType = null, string redactionFormat = null) + { + return new DeidRequest( + inputText, + dataType, + operation, + stringIndexType, + redactionFormat, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Output text after deidentification. Not available for Tag Operation. + /// Result of the tag operation. Only available for Tag Operation. + /// A new instance for mocking. + public static DeidResponse DeidResponse(string outputText = null, PhiTaggerResult taggerResult = null) + { + return new DeidResponse(outputText, taggerResult, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// List of entities detected in the input. + /// Requested Encoding of the tag response indices. + /// Path to the file in the storage container. + /// Checksum of the file. + /// A new instance for mocking. + public static PhiTaggerResult PhiTaggerResult(IEnumerable entities = null, StringIndexType stringIndexType = default, string path = null, string checksum = null) + { + entities ??= new List(); + + return new PhiTaggerResult(entities?.ToList(), stringIndexType, path, checksum, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Phi Category of the entity. + /// Starting index of the location from within the input text. + /// Length of the input text. + /// Text of the entity. + /// Confidence score of the text/type pairing. + /// A new instance for mocking. + public static PhiEntity PhiEntity(PhiCategory category = default, int offset = default, int length = default, string text = null, double? confidenceScore = null) + { + return new PhiEntity( + category, + offset, + length, + text, + confidenceScore, + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Internal/ChangeTrackingList.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..512b918065e3 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.HealthDataAIServices.Deid +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Internal/Optional.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..112e0325caff --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Internal/Optional.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Job.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Job.Serialization.cs new file mode 100644 index 000000000000..b6f5843c9421 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Job.Serialization.cs @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class Job : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Job)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("sourceLocation"u8); + writer.WriteObjectValue(SourceLocation); + writer.WritePropertyName("targetLocation"u8); + writer.WriteObjectValue(TargetLocation); + writer.WritePropertyName("dataType"u8); + writer.WriteStringValue(DataType.ToString()); + writer.WritePropertyName("operation"u8); + writer.WriteStringValue(Operation.ToString()); + if (Optional.IsDefined(RedactionFormat)) + { + writer.WritePropertyName("redactionFormat"u8); + writer.WriteStringValue(RedactionFormat); + } + if (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (options.Format != "W") + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedAt, "O"); + } + if (options.Format != "W" && Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } + if (options.Format != "W" && Optional.IsDefined(StartedAt)) + { + writer.WritePropertyName("startedAt"u8); + writer.WriteStringValue(StartedAt.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CompletedAt)) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteStringValue(CompletedAt.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(Summary)) + { + writer.WritePropertyName("summary"u8); + writer.WriteObjectValue(Summary); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Job IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Job)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeJob(document.RootElement, options); + } + + internal static Job DeserializeJob(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SourceStorageLocation sourceLocation = default; + TargetStorageLocation targetLocation = default; + DocumentDataType dataType = default; + OperationType operation = default; + string redactionFormat = default; + JobStatus status = default; + DateTimeOffset createdAt = default; + ResponseError error = default; + DateTimeOffset? startedAt = default; + DateTimeOffset? completedAt = default; + JobSummary summary = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sourceLocation"u8)) + { + sourceLocation = SourceStorageLocation.DeserializeSourceStorageLocation(property.Value, options); + continue; + } + if (property.NameEquals("targetLocation"u8)) + { + targetLocation = TargetStorageLocation.DeserializeTargetStorageLocation(property.Value, options); + continue; + } + if (property.NameEquals("dataType"u8)) + { + dataType = new DocumentDataType(property.Value.GetString()); + continue; + } + if (property.NameEquals("operation"u8)) + { + operation = new OperationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("redactionFormat"u8)) + { + redactionFormat = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("startedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("summary"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + summary = JobSummary.DeserializeJobSummary(property.Value, options); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new Job( + sourceLocation, + targetLocation, + dataType, + operation, + redactionFormat, + status, + createdAt, + error, + startedAt, + completedAt, + summary, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Job)} does not support '{options.Format}' format."); + } + } + + Job IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeJob(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Job)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Job FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeJob(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Job.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Job.cs new file mode 100644 index 000000000000..2d8a8497c0b0 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Job.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.HealthDataAIServices.Deid +{ + /// A job containing a batch of documents to deidentify. + public partial class Job + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Storage location to perform the operation on. + /// Target location to store output of operation. + /// Data type of the input documents. + /// Operation to perform on the input documents. + /// or is null. + public Job(SourceStorageLocation sourceLocation, TargetStorageLocation targetLocation, DocumentDataType dataType, OperationType operation) + { + if (sourceLocation == null) + { + throw new ArgumentNullException(nameof(sourceLocation)); + } + if (targetLocation == null) + { + throw new ArgumentNullException(nameof(targetLocation)); + } + + SourceLocation = sourceLocation; + TargetLocation = targetLocation; + DataType = dataType; + Operation = operation; + } + + /// Initializes a new instance of . + /// Storage location to perform the operation on. + /// Target location to store output of operation. + /// Data type of the input documents. + /// Operation to perform on the input documents. + /// Format of the redacted output. Only valid when Operation is Redact. + /// Current status of a job. + /// Date and time when the job was created. + /// Error when job fails in it's entirety. + /// Date and time when the job was started. + /// + /// Date and time when the job was completed. + /// + /// If the job is canceled, this is the time when the job was canceled. + /// + /// If the job failed, this is the time when the job failed. + /// + /// Summary of a job. Exists only when the job is completed. + /// Keeps track of any properties unknown to the library. + internal Job(SourceStorageLocation sourceLocation, TargetStorageLocation targetLocation, DocumentDataType dataType, OperationType operation, string redactionFormat, JobStatus status, DateTimeOffset createdAt, ResponseError error, DateTimeOffset? startedAt, DateTimeOffset? completedAt, JobSummary summary, IDictionary serializedAdditionalRawData) + { + SourceLocation = sourceLocation; + TargetLocation = targetLocation; + DataType = dataType; + Operation = operation; + RedactionFormat = redactionFormat; + Status = status; + CreatedAt = createdAt; + Error = error; + StartedAt = startedAt; + CompletedAt = completedAt; + Summary = summary; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Job() + { + } + + /// Storage location to perform the operation on. + public SourceStorageLocation SourceLocation { get; set; } + /// Target location to store output of operation. + public TargetStorageLocation TargetLocation { get; set; } + /// Data type of the input documents. + public DocumentDataType DataType { get; set; } + /// Operation to perform on the input documents. + public OperationType Operation { get; set; } + /// Format of the redacted output. Only valid when Operation is Redact. + public string RedactionFormat { get; set; } + /// Current status of a job. + public JobStatus Status { get; } + /// Date and time when the job was created. + public DateTimeOffset CreatedAt { get; } + /// Error when job fails in it's entirety. + public ResponseError Error { get; } + /// Date and time when the job was started. + public DateTimeOffset? StartedAt { get; } + /// + /// Date and time when the job was completed. + /// + /// If the job is canceled, this is the time when the job was canceled. + /// + /// If the job failed, this is the time when the job failed. + /// + public DateTimeOffset? CompletedAt { get; } + /// Summary of a job. Exists only when the job is completed. + public JobSummary Summary { get; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobStatus.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobStatus.cs new file mode 100644 index 000000000000..48fa96827201 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobStatus.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.HealthDataAIServices.Deid +{ + /// List of statuses a job can have. + public readonly partial struct JobStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public JobStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotStartedValue = "NotStarted"; + private const string RunningValue = "Running"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string PartialFailedValue = "PartialFailed"; + + /// The operation has not started. + public static JobStatus NotStarted { get; } = new JobStatus(NotStartedValue); + /// The operation is in progress. + public static JobStatus Running { get; } = new JobStatus(RunningValue); + /// The operation has completed successfully. + public static JobStatus Succeeded { get; } = new JobStatus(SucceededValue); + /// The operation has failed. + public static JobStatus Failed { get; } = new JobStatus(FailedValue); + /// The operation has been canceled by the user. + public static JobStatus Canceled { get; } = new JobStatus(CanceledValue); + /// Job has completed with at least 1 file failing. + public static JobStatus PartialFailed { get; } = new JobStatus(PartialFailedValue); + /// Determines if two values are the same. + public static bool operator ==(JobStatus left, JobStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(JobStatus left, JobStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator JobStatus(string value) => new JobStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is JobStatus other && Equals(other); + /// + public bool Equals(JobStatus 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/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobSummary.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobSummary.Serialization.cs new file mode 100644 index 000000000000..7729a4aeb620 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobSummary.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class JobSummary : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(JobSummary)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("successful"u8); + writer.WriteNumberValue(Successful); + writer.WritePropertyName("failed"u8); + writer.WriteNumberValue(Failed); + writer.WritePropertyName("canceled"u8); + writer.WriteNumberValue(Canceled); + writer.WritePropertyName("total"u8); + writer.WriteNumberValue(Total); + writer.WritePropertyName("bytesProcessed"u8); + writer.WriteNumberValue(BytesProcessed); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + JobSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(JobSummary)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeJobSummary(document.RootElement, options); + } + + internal static JobSummary DeserializeJobSummary(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int successful = default; + int failed = default; + int canceled = default; + int total = default; + long bytesProcessed = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("successful"u8)) + { + successful = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("failed"u8)) + { + failed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("canceled"u8)) + { + canceled = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total"u8)) + { + total = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("bytesProcessed"u8)) + { + bytesProcessed = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new JobSummary( + successful, + failed, + canceled, + total, + bytesProcessed, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(JobSummary)} does not support '{options.Format}' format."); + } + } + + JobSummary IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeJobSummary(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(JobSummary)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static JobSummary FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeJobSummary(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobSummary.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobSummary.cs new file mode 100644 index 000000000000..0d632594617a --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/JobSummary.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Summary metrics the documents pertaining to a job. + public partial class JobSummary + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Number of blobs that have completed. + /// Number of blobs that have failed. + /// Number of blobs that have been canceled. + /// Number of blobs total. + /// Number of bytes processed. + public JobSummary(int successful, int failed, int canceled, int total, long bytesProcessed) + { + Successful = successful; + Failed = failed; + Canceled = canceled; + Total = total; + BytesProcessed = bytesProcessed; + } + + /// Initializes a new instance of . + /// Number of blobs that have completed. + /// Number of blobs that have failed. + /// Number of blobs that have been canceled. + /// Number of blobs total. + /// Number of bytes processed. + /// Keeps track of any properties unknown to the library. + internal JobSummary(int successful, int failed, int canceled, int total, long bytesProcessed, IDictionary serializedAdditionalRawData) + { + Successful = successful; + Failed = failed; + Canceled = canceled; + Total = total; + BytesProcessed = bytesProcessed; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal JobSummary() + { + } + + /// Number of blobs that have completed. + public int Successful { get; set; } + /// Number of blobs that have failed. + public int Failed { get; set; } + /// Number of blobs that have been canceled. + public int Canceled { get; set; } + /// Number of blobs total. + public int Total { get; set; } + /// Number of bytes processed. + public long BytesProcessed { get; set; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Jobs.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Jobs.cs new file mode 100644 index 000000000000..82210cd19f56 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Jobs.cs @@ -0,0 +1,975 @@ +// 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.HealthDataAIServices.Deid +{ + // Data plane generated sub-client. + /// The Jobs sub-client. + public partial class Jobs + { + private static readonly string[] AuthorizationScopes = new string[] { "https://deid.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 Jobs for mocking. + protected Jobs() + { + } + + /// Initializes a new instance of Jobs. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// Uri of your Deid Service. + /// The API version to use for this operation. + internal Jobs(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get a DeID Job. + /// The name of a job. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Resource read operation template. + /// + public virtual async Task> GetJobAsync(string name, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetJobAsync(name, context).ConfigureAwait(false); + return Response.FromValue(Job.FromResponse(response), response); + } + + /// Get a DeID Job. + /// The name of a job. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Resource read operation template. + /// + public virtual Response GetJob(string name, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetJob(name, context); + return Response.FromValue(Job.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get a DeID Job + /// + /// + /// + /// 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 name of a job. + /// 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 GetJobAsync(string name, RequestContext context) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.GetJob"); + scope.Start(); + try + { + using HttpMessage message = CreateGetJobRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get a DeID Job + /// + /// + /// + /// 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 name of a job. + /// 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 GetJob(string name, RequestContext context) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.GetJob"); + scope.Start(); + try + { + using HttpMessage message = CreateGetJobRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Cancel a DeID Job. + /// The name of a job. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + /// Cancels a job that is in progress. + /// + /// The job will be marked as canceled and the service will stop processing the job. The service will not delete any files that have already been processed. + /// + /// If the job is already complete, this will have no effect. + /// + /// + public virtual async Task> CancelAsync(string name, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CancelAsync(name, context).ConfigureAwait(false); + return Response.FromValue(Job.FromResponse(response), response); + } + + /// Cancel a DeID Job. + /// The name of a job. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + /// Cancels a job that is in progress. + /// + /// The job will be marked as canceled and the service will stop processing the job. The service will not delete any files that have already been processed. + /// + /// If the job is already complete, this will have no effect. + /// + /// + public virtual Response Cancel(string name, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Cancel(name, context); + return Response.FromValue(Job.FromResponse(response), response); + } + + /// + /// [Protocol Method] Cancel a DeID Job + /// + /// + /// + /// 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 name of a job. + /// 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 CancelAsync(string name, RequestContext context) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.Cancel"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Cancel a DeID Job + /// + /// + /// + /// 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 name of a job. + /// 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 Cancel(string name, RequestContext context) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.Cancel"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRequest(name, 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 a DeID Job + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of a job. + /// 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 DeleteAsync(string name, RequestContext context = null) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(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 a DeID Job + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of a job. + /// 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 Delete(string name, RequestContext context = null) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List DeID Jobs. + /// The maximum number of result items per page. + /// Token to continue a previous query. + /// The cancellation token to use. + /// Resource list operation template. + /// + public virtual AsyncPageable GetJobsAsync(int? maxpagesize = null, string continuationToken = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Job.DeserializeJob(e), ClientDiagnostics, _pipeline, "Jobs.GetJobs", "value", "nextLink", context); + } + + /// List DeID Jobs. + /// The maximum number of result items per page. + /// Token to continue a previous query. + /// The cancellation token to use. + /// Resource list operation template. + /// + public virtual Pageable GetJobs(int? maxpagesize = null, string continuationToken = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Job.DeserializeJob(e), ClientDiagnostics, _pipeline, "Jobs.GetJobs", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List DeID Jobs + /// + /// + /// + /// 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 maximum number of result items per page. + /// Token to continue a previous query. + /// 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 GetJobsAsync(int? maxpagesize, string continuationToken, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Jobs.GetJobs", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List DeID Jobs + /// + /// + /// + /// 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 maximum number of result items per page. + /// Token to continue a previous query. + /// 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 GetJobs(int? maxpagesize, string continuationToken, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Jobs.GetJobs", "value", "nextLink", context); + } + + /// List processed files within a Job. + /// The name of a job. + /// The maximum number of result items per page. + /// Token to continue a previous query. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Resource list operation template. + /// + public virtual AsyncPageable GetFilesAsync(string name, int? maxpagesize = null, string continuationToken = null, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetFilesRequest(name, maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetFilesNextPageRequest(nextLink, name, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => File.DeserializeFile(e), ClientDiagnostics, _pipeline, "Jobs.GetFiles", "value", "nextLink", context); + } + + /// List processed files within a Job. + /// The name of a job. + /// The maximum number of result items per page. + /// Token to continue a previous query. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Resource list operation template. + /// + public virtual Pageable GetFiles(string name, int? maxpagesize = null, string continuationToken = null, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetFilesRequest(name, maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetFilesNextPageRequest(nextLink, name, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => File.DeserializeFile(e), ClientDiagnostics, _pipeline, "Jobs.GetFiles", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List processed files within a Job + /// + /// + /// + /// 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 name of a job. + /// The maximum number of result items per page. + /// Token to continue a previous query. + /// 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 GetFilesAsync(string name, int? maxpagesize, string continuationToken, RequestContext context) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetFilesRequest(name, maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetFilesNextPageRequest(nextLink, name, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Jobs.GetFiles", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List processed files within a Job + /// + /// + /// + /// 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 name of a job. + /// The maximum number of result items per page. + /// Token to continue a previous query. + /// 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 GetFiles(string name, int? maxpagesize, string continuationToken, RequestContext context) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetFilesRequest(name, maxpagesize, continuationToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetFilesNextPageRequest(nextLink, name, maxpagesize, continuationToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Jobs.GetFiles", "value", "nextLink", context); + } + + /// Create a DeID Job. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of a job. + /// The resource instance. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Long-running resource create or replace operation template. + /// + public virtual async Task> CreateAsync(WaitUntil waitUntil, string name, Job resource, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + if (resource == null) + { + throw new ArgumentNullException(nameof(resource)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = resource.ToRequestContent(); + Operation response = await CreateAsync(waitUntil, name, content, context).ConfigureAwait(false); + return ProtocolOperationHelpers.Convert(response, Job.FromResponse, ClientDiagnostics, "Jobs.Create"); + } + + /// Create a DeID Job. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of a job. + /// The resource instance. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Long-running resource create or replace operation template. + /// + public virtual Operation Create(WaitUntil waitUntil, string name, Job resource, CancellationToken cancellationToken = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + if (resource == null) + { + throw new ArgumentNullException(nameof(resource)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = resource.ToRequestContent(); + Operation response = Create(waitUntil, name, content, context); + return ProtocolOperationHelpers.Convert(response, Job.FromResponse, ClientDiagnostics, "Jobs.Create"); + } + + /// + /// [Protocol Method] Create a DeID Job + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of a job. + /// 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 representing an asynchronous operation on the service. + /// + public virtual async Task> CreateAsync(WaitUntil waitUntil, string name, RequestContent content, RequestContext context = null) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(name, content, context); + return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "Jobs.Create", OperationFinalStateVia.OriginalUri, context, waitUntil).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a DeID Job + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of a job. + /// 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 representing an asynchronous operation on the service. + /// + public virtual Operation Create(WaitUntil waitUntil, string name, RequestContent content, RequestContext context = null) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (name.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", nameof(name)); + } + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + using var scope = ClientDiagnostics.CreateScope("Jobs.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(name, content, context); + return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "Jobs.Create", OperationFinalStateVia.OriginalUri, context, waitUntil); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateRequest(string name, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/jobs/", 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/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetJobRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/jobs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetJobsRequest(int? maxpagesize, string continuationToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/jobs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (continuationToken != null) + { + uri.AppendQuery("continuationToken", continuationToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetFilesRequest(string name, int? maxpagesize, string continuationToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/jobs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (continuationToken != null) + { + uri.AppendQuery("continuationToken", continuationToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCancelRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/jobs/", false); + uri.AppendPath(name, true); + uri.AppendPath(":cancel", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/jobs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetJobsNextPageRequest(string nextLink, int? maxpagesize, string continuationToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetFilesNextPageRequest(string nextLink, string name, int? maxpagesize, string continuationToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + 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 _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/OperationState.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/OperationState.cs new file mode 100644 index 000000000000..939f1c9b3b16 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/OperationState.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Enum describing allowed operation states. + public readonly partial struct OperationState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotStartedValue = "NotStarted"; + private const string RunningValue = "Running"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// The operation has not started. + public static OperationState NotStarted { get; } = new OperationState(NotStartedValue); + /// The operation is in progress. + public static OperationState Running { get; } = new OperationState(RunningValue); + /// The operation has completed successfully. + public static OperationState Succeeded { get; } = new OperationState(SucceededValue); + /// The operation has failed. + public static OperationState Failed { get; } = new OperationState(FailedValue); + /// The operation has been canceled by the user. + public static OperationState Canceled { get; } = new OperationState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(OperationState left, OperationState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationState left, OperationState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OperationState(string value) => new OperationState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationState other && Equals(other); + /// + public bool Equals(OperationState 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/deid/Azure.HealthDataAIServices.Deid/src/Generated/OperationType.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/OperationType.cs new file mode 100644 index 000000000000..3407b3c81082 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/OperationType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Enum of supported Operation Types. + public readonly partial struct OperationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RedactValue = "Redact"; + private const string SurrogateValue = "Surrogate"; + private const string TagValue = "Tag"; + + /// Redact Operation will remove all entities of PHI and replace them with a placeholder value. + public static OperationType Redact { get; } = new OperationType(RedactValue); + /// Surrogation Operation will replace all entities of PHI with a surrogate value. + public static OperationType Surrogate { get; } = new OperationType(SurrogateValue); + /// Tag Operation will detect all entities of PHI, their type, and return their locations in the document. + public static OperationType Tag { get; } = new OperationType(TagValue); + /// Determines if two values are the same. + public static bool operator ==(OperationType left, OperationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationType left, OperationType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OperationType(string value) => new OperationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationType other && Equals(other); + /// + public bool Equals(OperationType 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/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiCategory.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiCategory.cs new file mode 100644 index 000000000000..b54e10c66886 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiCategory.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.HealthDataAIServices.Deid +{ + /// List of PHI Entities. + public readonly partial struct PhiCategory : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PhiCategory(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string AccountValue = "Account"; + private const string AgeValue = "Age"; + private const string BioIDValue = "BioID"; + private const string CityValue = "City"; + private const string CountryOrRegionValue = "CountryOrRegion"; + private const string DateValue = "Date"; + private const string DeviceValue = "Device"; + private const string DoctorValue = "Doctor"; + private const string EmailValue = "Email"; + private const string FaxValue = "Fax"; + private const string HealthPlanValue = "HealthPlan"; + private const string HospitalValue = "Hospital"; + private const string IDNumValue = "IDNum"; + private const string IPAddressValue = "IPAddress"; + private const string LicenseValue = "License"; + private const string LocationOtherValue = "LocationOther"; + private const string MedicalRecordValue = "MedicalRecord"; + private const string OrganizationValue = "Organization"; + private const string PatientValue = "Patient"; + private const string PhoneValue = "Phone"; + private const string ProfessionValue = "Profession"; + private const string SocialSecurityValue = "SocialSecurity"; + private const string StateValue = "State"; + private const string StreetValue = "Street"; + private const string UrlValue = "Url"; + private const string UsernameValue = "Username"; + private const string VehicleValue = "Vehicle"; + private const string ZipValue = "Zip"; + + /// Unknown PHI Type. + public static PhiCategory Unknown { get; } = new PhiCategory(UnknownValue); + /// Account Number. + public static PhiCategory Account { get; } = new PhiCategory(AccountValue); + /// Age. + public static PhiCategory Age { get; } = new PhiCategory(AgeValue); + /// Biological Identifier, such as a fingerprint or retinal scan. + public static PhiCategory BioID { get; } = new PhiCategory(BioIDValue); + /// City. + public static PhiCategory City { get; } = new PhiCategory(CityValue); + /// Country or Region. + public static PhiCategory CountryOrRegion { get; } = new PhiCategory(CountryOrRegionValue); + /// Date. + public static PhiCategory Date { get; } = new PhiCategory(DateValue); + /// Device ID or serial numbers. + public static PhiCategory Device { get; } = new PhiCategory(DeviceValue); + /// Doctor's Name. + public static PhiCategory Doctor { get; } = new PhiCategory(DoctorValue); + /// Email Addresses. + public static PhiCategory Email { get; } = new PhiCategory(EmailValue); + /// Fax Number. + public static PhiCategory Fax { get; } = new PhiCategory(FaxValue); + /// Health Plan ID Numbers. + public static PhiCategory HealthPlan { get; } = new PhiCategory(HealthPlanValue); + /// Hospital Name. + public static PhiCategory Hospital { get; } = new PhiCategory(HospitalValue); + /// Id Numbers. Such as a passport number. + public static PhiCategory IDNum { get; } = new PhiCategory(IDNumValue); + /// IP Address. + public static PhiCategory IPAddress { get; } = new PhiCategory(IPAddressValue); + /// License. Such as a driver's license or medical license. + public static PhiCategory License { get; } = new PhiCategory(LicenseValue); + /// Location Other. Such as Golden Gate Park. + public static PhiCategory LocationOther { get; } = new PhiCategory(LocationOtherValue); + /// Medical Record Number. + public static PhiCategory MedicalRecord { get; } = new PhiCategory(MedicalRecordValue); + /// Organization. Such as a company name. + public static PhiCategory Organization { get; } = new PhiCategory(OrganizationValue); + /// Patient Name. + public static PhiCategory Patient { get; } = new PhiCategory(PatientValue); + /// Phone Number. + public static PhiCategory Phone { get; } = new PhiCategory(PhoneValue); + /// Profession. + public static PhiCategory Profession { get; } = new PhiCategory(ProfessionValue); + /// Social Security Numbers in the US. + public static PhiCategory SocialSecurity { get; } = new PhiCategory(SocialSecurityValue); + /// State. + public static PhiCategory State { get; } = new PhiCategory(StateValue); + /// Street. + public static PhiCategory Street { get; } = new PhiCategory(StreetValue); + /// Web URL. + public static PhiCategory Url { get; } = new PhiCategory(UrlValue); + /// Usernames, such as a social media handle. + public static PhiCategory Username { get; } = new PhiCategory(UsernameValue); + /// Vehicle IDs, such as license plates or VIN numbers. + public static PhiCategory Vehicle { get; } = new PhiCategory(VehicleValue); + /// Zip Code. + public static PhiCategory Zip { get; } = new PhiCategory(ZipValue); + /// Determines if two values are the same. + public static bool operator ==(PhiCategory left, PhiCategory right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PhiCategory left, PhiCategory right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PhiCategory(string value) => new PhiCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PhiCategory other && Equals(other); + /// + public bool Equals(PhiCategory 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/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiEntity.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiEntity.Serialization.cs new file mode 100644 index 000000000000..88e797e15a60 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiEntity.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class PhiEntity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PhiEntity)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("category"u8); + writer.WriteStringValue(Category.ToString()); + writer.WritePropertyName("offset"u8); + writer.WriteNumberValue(Offset); + writer.WritePropertyName("length"u8); + writer.WriteNumberValue(Length); + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsDefined(ConfidenceScore)) + { + writer.WritePropertyName("confidenceScore"u8); + writer.WriteNumberValue(ConfidenceScore.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + PhiEntity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PhiEntity)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePhiEntity(document.RootElement, options); + } + + internal static PhiEntity DeserializePhiEntity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PhiCategory category = default; + int offset = default; + int length = default; + string text = default; + double? confidenceScore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("category"u8)) + { + category = new PhiCategory(property.Value.GetString()); + continue; + } + if (property.NameEquals("offset"u8)) + { + offset = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("length"u8)) + { + length = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("confidenceScore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScore = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PhiEntity( + category, + offset, + length, + text, + confidenceScore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PhiEntity)} does not support '{options.Format}' format."); + } + } + + PhiEntity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePhiEntity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PhiEntity)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PhiEntity FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePhiEntity(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiEntity.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiEntity.cs new file mode 100644 index 000000000000..f05a41fd44ea --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiEntity.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Phi Entity tag in the input. + public partial class PhiEntity + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Phi Category of the entity. + /// Starting index of the location from within the input text. + /// Length of the input text. + internal PhiEntity(PhiCategory category, int offset, int length) + { + Category = category; + Offset = offset; + Length = length; + } + + /// Initializes a new instance of . + /// Phi Category of the entity. + /// Starting index of the location from within the input text. + /// Length of the input text. + /// Text of the entity. + /// Confidence score of the text/type pairing. + /// Keeps track of any properties unknown to the library. + internal PhiEntity(PhiCategory category, int offset, int length, string text, double? confidenceScore, IDictionary serializedAdditionalRawData) + { + Category = category; + Offset = offset; + Length = length; + Text = text; + ConfidenceScore = confidenceScore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PhiEntity() + { + } + + /// Phi Category of the entity. + public PhiCategory Category { get; } + /// Starting index of the location from within the input text. + public int Offset { get; } + /// Length of the input text. + public int Length { get; } + /// Text of the entity. + public string Text { get; } + /// Confidence score of the text/type pairing. + public double? ConfidenceScore { get; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiTaggerResult.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiTaggerResult.Serialization.cs new file mode 100644 index 000000000000..87dba43e91a3 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiTaggerResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class PhiTaggerResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PhiTaggerResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("entities"u8); + writer.WriteStartArray(); + foreach (var item in Entities) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("stringIndexType"u8); + writer.WriteStringValue(StringIndexType.ToString()); + if (Optional.IsDefined(Path)) + { + writer.WritePropertyName("path"u8); + writer.WriteStringValue(Path); + } + if (Optional.IsDefined(Checksum)) + { + writer.WritePropertyName("checksum"u8); + writer.WriteStringValue(Checksum); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + PhiTaggerResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PhiTaggerResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePhiTaggerResult(document.RootElement, options); + } + + internal static PhiTaggerResult DeserializePhiTaggerResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList entities = default; + StringIndexType stringIndexType = default; + string path = default; + string checksum = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("entities"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(PhiEntity.DeserializePhiEntity(item, options)); + } + entities = array; + continue; + } + if (property.NameEquals("stringIndexType"u8)) + { + stringIndexType = new StringIndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("path"u8)) + { + path = property.Value.GetString(); + continue; + } + if (property.NameEquals("checksum"u8)) + { + checksum = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PhiTaggerResult(entities, stringIndexType, path, checksum, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PhiTaggerResult)} does not support '{options.Format}' format."); + } + } + + PhiTaggerResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePhiTaggerResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PhiTaggerResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PhiTaggerResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePhiTaggerResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiTaggerResult.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiTaggerResult.cs new file mode 100644 index 000000000000..dc79e41e8d9f --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/PhiTaggerResult.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Result of the tag operation. + public partial class PhiTaggerResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// List of entities detected in the input. + /// Requested Encoding of the tag response indices. + /// is null. + internal PhiTaggerResult(IEnumerable entities, StringIndexType stringIndexType) + { + if (entities == null) + { + throw new ArgumentNullException(nameof(entities)); + } + + Entities = entities.ToList(); + StringIndexType = stringIndexType; + } + + /// Initializes a new instance of . + /// List of entities detected in the input. + /// Requested Encoding of the tag response indices. + /// Path to the file in the storage container. + /// Checksum of the file. + /// Keeps track of any properties unknown to the library. + internal PhiTaggerResult(IReadOnlyList entities, StringIndexType stringIndexType, string path, string checksum, IDictionary serializedAdditionalRawData) + { + Entities = entities; + StringIndexType = stringIndexType; + Path = path; + Checksum = checksum; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PhiTaggerResult() + { + } + + /// List of entities detected in the input. + public IReadOnlyList Entities { get; } + /// Requested Encoding of the tag response indices. + public StringIndexType StringIndexType { get; } + /// Path to the file in the storage container. + public string Path { get; } + /// Checksum of the file. + public string Checksum { get; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Realtime.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Realtime.cs new file mode 100644 index 000000000000..8677f7729628 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/Realtime.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.HealthDataAIServices.Deid +{ + // Data plane generated sub-client. + /// The Realtime sub-client. + public partial class Realtime + { + private static readonly string[] AuthorizationScopes = new string[] { "https://deid.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 Realtime for mocking. + protected Realtime() + { + } + + /// Initializes a new instance of Realtime. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// Uri of your Deid Service. + /// The API version to use for this operation. + internal Realtime(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Realtime Synchronous Deidentification. + /// The request body for realtime deidentification. + /// The cancellation token to use. + /// is null. + /// A remote procedure call (RPC) operation. + /// + public virtual async Task> DeidAsync(DeidRequest options, CancellationToken cancellationToken = default) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = options.ToRequestContent(); + Response response = await DeidAsync(content, context).ConfigureAwait(false); + return Response.FromValue(DeidResponse.FromResponse(response), response); + } + + /// Realtime Synchronous Deidentification. + /// The request body for realtime deidentification. + /// The cancellation token to use. + /// is null. + /// A remote procedure call (RPC) operation. + /// + public virtual Response Deid(DeidRequest options, CancellationToken cancellationToken = default) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = options.ToRequestContent(); + Response response = Deid(content, context); + return Response.FromValue(DeidResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Realtime Synchronous Deidentification. + /// + /// + /// + /// 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 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. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeidAsync(RequestContent content, RequestContext context = null) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + using var scope = ClientDiagnostics.CreateScope("Realtime.Deid"); + scope.Start(); + try + { + using HttpMessage message = CreateDeidRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Realtime Synchronous Deidentification. + /// + /// + /// + /// 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 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. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Deid(RequestContent content, RequestContext context = null) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + using var scope = ClientDiagnostics.CreateScope("Realtime.Deid"); + scope.Start(); + try + { + using HttpMessage message = CreateDeidRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateDeidRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/deid", 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; + } + + 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 }); + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/SourceStorageLocation.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/SourceStorageLocation.Serialization.cs new file mode 100644 index 000000000000..c2339cd83513 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/SourceStorageLocation.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class SourceStorageLocation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceStorageLocation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.AbsoluteUri); + writer.WritePropertyName("prefix"u8); + writer.WriteStringValue(Prefix); + if (Optional.IsCollectionDefined(Extensions)) + { + writer.WritePropertyName("extensions"u8); + writer.WriteStartArray(); + foreach (var item in Extensions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SourceStorageLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceStorageLocation)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceStorageLocation(document.RootElement, options); + } + + internal static SourceStorageLocation DeserializeSourceStorageLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri location = default; + string prefix = default; + IList extensions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + location = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("prefix"u8)) + { + prefix = property.Value.GetString(); + continue; + } + if (property.NameEquals("extensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + extensions = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SourceStorageLocation(location, prefix, extensions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SourceStorageLocation)} does not support '{options.Format}' format."); + } + } + + SourceStorageLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSourceStorageLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceStorageLocation)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SourceStorageLocation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSourceStorageLocation(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/SourceStorageLocation.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/SourceStorageLocation.cs new file mode 100644 index 000000000000..a7fff7ac81eb --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/SourceStorageLocation.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Storage location. + public partial class SourceStorageLocation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// URL to storage location. Must be a valid Azure Storage SAS URI. + /// Prefix to filter blobs by. + /// or is null. + public SourceStorageLocation(Uri location, string prefix) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (prefix == null) + { + throw new ArgumentNullException(nameof(prefix)); + } + + Location = location; + Prefix = prefix; + Extensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// URL to storage location. Must be a valid Azure Storage SAS URI. + /// Prefix to filter blobs by. + /// List of extensions to filter blobs by. + /// Keeps track of any properties unknown to the library. + internal SourceStorageLocation(Uri location, string prefix, IList extensions, IDictionary serializedAdditionalRawData) + { + Location = location; + Prefix = prefix; + Extensions = extensions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SourceStorageLocation() + { + } + + /// URL to storage location. Must be a valid Azure Storage SAS URI. + public Uri Location { get; set; } + /// Prefix to filter blobs by. + public string Prefix { get; set; } + /// List of extensions to filter blobs by. + public IList Extensions { get; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/StringIndexType.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/StringIndexType.cs new file mode 100644 index 000000000000..67e27815a58f --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/StringIndexType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.HealthDataAIServices.Deid +{ + /// List of supported index encodings. + public readonly partial struct StringIndexType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StringIndexType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextElementV8Value = "TextElement_v8"; + private const string UnicodeCodePointValue = "UnicodeCodePoint"; + private const string Utf16CodeUnitValue = "Utf16CodeUnit"; + + /// Iterates over graphemes as defined by the Unicode 8.0.0 standard. + public static StringIndexType TextElementV8 { get; } = new StringIndexType(TextElementV8Value); + /// Iterates over Unicode Code Points, the default scheme for Python 3. + public static StringIndexType UnicodeCodePoint { get; } = new StringIndexType(UnicodeCodePointValue); + /// Iterates over UTF-16 Code Units, the default scheme for JavaScript, Java, and .NET. + public static StringIndexType Utf16CodeUnit { get; } = new StringIndexType(Utf16CodeUnitValue); + /// Determines if two values are the same. + public static bool operator ==(StringIndexType left, StringIndexType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StringIndexType left, StringIndexType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator StringIndexType(string value) => new StringIndexType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StringIndexType other && Equals(other); + /// + public bool Equals(StringIndexType 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/deid/Azure.HealthDataAIServices.Deid/src/Generated/TargetStorageLocation.Serialization.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/TargetStorageLocation.Serialization.cs new file mode 100644 index 000000000000..2c1bf189a757 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/TargetStorageLocation.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.HealthDataAIServices.Deid +{ + public partial class TargetStorageLocation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetStorageLocation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.AbsoluteUri); + writer.WritePropertyName("prefix"u8); + writer.WriteStringValue(Prefix); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TargetStorageLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetStorageLocation)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetStorageLocation(document.RootElement, options); + } + + internal static TargetStorageLocation DeserializeTargetStorageLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri location = default; + string prefix = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + location = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("prefix"u8)) + { + prefix = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TargetStorageLocation(location, prefix, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetStorageLocation)} does not support '{options.Format}' format."); + } + } + + TargetStorageLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetStorageLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetStorageLocation)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TargetStorageLocation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTargetStorageLocation(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/TargetStorageLocation.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/TargetStorageLocation.cs new file mode 100644 index 000000000000..b52de73ff116 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Generated/TargetStorageLocation.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.HealthDataAIServices.Deid +{ + /// Storage location. + public partial class TargetStorageLocation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// URL to storage location. Must be a valid Azure Storage SAS URI. + /// Prefix to filter blobs by. + /// or is null. + public TargetStorageLocation(Uri location, string prefix) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (prefix == null) + { + throw new ArgumentNullException(nameof(prefix)); + } + + Location = location; + Prefix = prefix; + } + + /// Initializes a new instance of . + /// URL to storage location. Must be a valid Azure Storage SAS URI. + /// Prefix to filter blobs by. + /// Keeps track of any properties unknown to the library. + internal TargetStorageLocation(Uri location, string prefix, IDictionary serializedAdditionalRawData) + { + Location = location; + Prefix = prefix; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TargetStorageLocation() + { + } + + /// URL to storage location. Must be a valid Azure Storage SAS URI. + public Uri Location { get; set; } + /// Prefix to filter blobs by. + public string Prefix { get; set; } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/src/Properties/AssemblyInfo.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..d0c9afa8b0c1 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.HealthDataAIServices.Deid.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Azure.HealthDataAIServices.Deid.Tests.csproj b/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Azure.HealthDataAIServices.Deid.Tests.csproj new file mode 100644 index 000000000000..95500e34630a --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Azure.HealthDataAIServices.Deid.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Generated/Samples/Samples_Jobs.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Generated/Samples/Samples_Jobs.cs new file mode 100644 index 000000000000..88c251a63fd4 --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Generated/Samples/Samples_Jobs.cs @@ -0,0 +1,923 @@ +// 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.Core; +using Azure.HealthDataAIServices.Deid; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.HealthDataAIServices.Deid.Samples +{ + public partial class Samples_Jobs + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJob_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.GetJob("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJob_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.GetJobAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJob_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.GetJob(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJob_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.GetJobAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJob_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.GetJob("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJob_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.GetJobAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJob_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.GetJob(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJob_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.GetJobAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Jobs_Cancel_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.Cancel("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Jobs_Cancel_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.CancelAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Jobs_Cancel_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.Cancel(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Jobs_Cancel_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.CancelAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Jobs_Cancel_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.Cancel("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Jobs_Cancel_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.CancelAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Jobs_Cancel_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.Cancel(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Jobs_Cancel_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.CancelAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_Delete_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.Delete(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_Delete_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.DeleteAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_Delete_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = client.Delete(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_Delete_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Response response = await client.DeleteAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJobs_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (BinaryData item in client.GetJobs(null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJobs_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (BinaryData item in client.GetJobsAsync(null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJobs_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (Job item in client.GetJobs()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJobs_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (Job item in client.GetJobsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJobs_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (BinaryData item in client.GetJobs(1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJobs_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (BinaryData item in client.GetJobsAsync(1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_GetJobs_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (Job item in client.GetJobs(maxpagesize: 1234, continuationToken: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_GetJobs_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (Job item in client.GetJobsAsync(maxpagesize: 1234, continuationToken: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_File_GetFiles_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (BinaryData item in client.GetFiles("", null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_File_GetFiles_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (BinaryData item in client.GetFilesAsync("", null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_File_GetFiles_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (File item in client.GetFiles("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_File_GetFiles_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (File item in client.GetFilesAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_File_GetFiles_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (BinaryData item in client.GetFiles("", 1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_File_GetFiles_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (BinaryData item in client.GetFilesAsync("", 1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("etag").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_File_GetFiles_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + foreach (File item in client.GetFiles("", maxpagesize: 1234, continuationToken: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_File_GetFiles_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + await foreach (File item in client.GetFilesAsync("", maxpagesize: 1234, continuationToken: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_Create_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", + }); + Operation operation = client.Create(WaitUntil.Completed, "", content); + BinaryData responseData = operation.Value; + + JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_Create_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", + }); + Operation operation = await client.CreateAsync(WaitUntil.Completed, "", content); + BinaryData responseData = operation.Value; + + JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_Create_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), ""), new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact); + Operation operation = client.Create(WaitUntil.Completed, "", resource); + Job responseData = operation.Value; + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_Create_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), ""), new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact); + Operation operation = await client.CreateAsync(WaitUntil.Completed, "", resource); + Job responseData = operation.Value; + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_Create_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + extensions = new object[] + { +"" + }, + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", + redactionFormat = "", + }); + Operation operation = client.Create(WaitUntil.Completed, "", content); + BinaryData responseData = operation.Value; + + JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_Create_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + sourceLocation = new + { + location = "http://localhost:3000", + prefix = "", + extensions = new object[] + { +"" + }, + }, + targetLocation = new + { + location = "http://localhost:3000", + prefix = "", + }, + dataType = "Unknown", + operation = "Redact", + redactionFormat = "", + }); + Operation operation = await client.CreateAsync(WaitUntil.Completed, "", content); + BinaryData responseData = operation.Value; + + JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString()); + Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString()); + Console.WriteLine(result.GetProperty("dataType").ToString()); + Console.WriteLine(result.GetProperty("operation").ToString()); + Console.WriteLine(result.GetProperty("redactionFormat").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("startedAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString()); + Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Job_Create_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), "") + { + Extensions = { "" }, + }, new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact) + { + RedactionFormat = "", + }; + Operation operation = client.Create(WaitUntil.Completed, "", resource); + Job responseData = operation.Value; + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Job_Create_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Jobs client = new DeidentificationClient(endpoint, credential).GetJobsClient(apiVersion: "2024-01-31-preview"); + + Job resource = new Job(new SourceStorageLocation(new Uri("http://localhost:3000"), "") + { + Extensions = { "" }, + }, new TargetStorageLocation(new Uri("http://localhost:3000"), ""), DocumentDataType.Unknown, OperationType.Redact) + { + RedactionFormat = "", + }; + Operation operation = await client.CreateAsync(WaitUntil.Completed, "", resource); + Job responseData = operation.Value; + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Generated/Samples/Samples_Realtime.cs b/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Generated/Samples/Samples_Realtime.cs new file mode 100644 index 000000000000..9fb3f9c5229a --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/tests/Generated/Samples/Samples_Realtime.cs @@ -0,0 +1,177 @@ +// 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.Core; +using Azure.HealthDataAIServices.Deid; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.HealthDataAIServices.Deid.Samples +{ + public partial class Samples_Realtime + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RealtimeOperations_Deid_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputText = "", + dataType = "Unknown", + operation = "Redact", + }); + Response response = client.Deid(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RealtimeOperations_Deid_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputText = "", + dataType = "Unknown", + operation = "Redact", + }); + Response response = await client.DeidAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RealtimeOperations_Deid_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact); + Response response = client.Deid(options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RealtimeOperations_Deid_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact); + Response response = await client.DeidAsync(options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RealtimeOperations_Deid_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputText = "", + dataType = "Unknown", + operation = "Redact", + stringIndexType = "TextElement_v8", + redactionFormat = "", + }); + Response response = client.Deid(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("outputText").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("category").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("stringIndexType").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("checksum").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RealtimeOperations_Deid_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputText = "", + dataType = "Unknown", + operation = "Redact", + stringIndexType = "TextElement_v8", + redactionFormat = "", + }); + Response response = await client.DeidAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("outputText").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("category").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("stringIndexType").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("path").ToString()); + Console.WriteLine(result.GetProperty("taggerResult").GetProperty("checksum").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RealtimeOperations_Deid_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact) + { + StringIndexType = StringIndexType.TextElementV8, + RedactionFormat = "", + }; + Response response = client.Deid(options); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RealtimeOperations_Deid_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Realtime client = new DeidentificationClient(endpoint, credential).GetRealtimeClient(apiVersion: "2024-01-31-preview"); + + DeidRequest options = new DeidRequest("", DocumentDataType.Unknown, OperationType.Redact) + { + StringIndexType = StringIndexType.TextElementV8, + RedactionFormat = "", + }; + Response response = await client.DeidAsync(options); + } + } +} diff --git a/sdk/deid/Azure.HealthDataAIServices.Deid/tsp-location.yaml b/sdk/deid/Azure.HealthDataAIServices.Deid/tsp-location.yaml new file mode 100644 index 000000000000..cecaa3eec3bb --- /dev/null +++ b/sdk/deid/Azure.HealthDataAIServices.Deid/tsp-location.yaml @@ -0,0 +1,5 @@ +repo: Azure/azure-rest-api-specs +directory: specification/healthdataaiservices/HealthDataAIServices.Deidentification +additionalDirectories: [] +commit: a6098c3e3d2d4c2d62f988be1a645b3e305f926c + diff --git a/sdk/deid/ci.yml b/sdk/deid/ci.yml new file mode 100644 index 000000000000..e22bc5fac68c --- /dev/null +++ b/sdk/deid/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/deid + - sdk/deid/ci.yml + - sdk/deid/Azure.HealthDataAIServices.Deid + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/deid + - sdk/deid/ci.yml + - sdk/deid/Azure.HealthDataAIServices.Deid + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: deid + ArtifactName: packages + Artifacts: + - name: Azure.HealthDataAIServices.Deid + safeName: AzureHealthDataAIServicesDeid