Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sdk for Content Safety #34933

Merged
merged 29 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6e42bed
Change namespace for project carnegie
mengaims Mar 15, 2023
165af9f
rename from ProjectCarnegie to ContentSafety
mengaims Mar 17, 2023
055e4af
Fix build errors
mengaims Mar 17, 2023
134bfa3
Update tests and samples for ContentSafety
mengaims Apr 26, 2023
ec58729
Merge branch 'Azure:main' into carnegie
mengaims Apr 26, 2023
8ef8873
Merge branch 'Azure:main' into carnegie
mengaims Apr 27, 2023
2490c31
update generated code
mengaims Apr 27, 2023
a10f3f6
Rename Azure.AI.netstandard2.0.cs
mengaims Apr 27, 2023
629d87c
Update sample2
mengaims Apr 27, 2023
8388951
Fix image sample
mengaims May 3, 2023
638c72d
Add blocklist management sample
mengaims May 3, 2023
e9d0ce4
Merge branch 'Azure:main' into carnegie
mengaims May 3, 2023
eda5ebc
Suppress AZC0002
mengaims May 3, 2023
84919ed
Fix GetTextBlocklistItems return type
mengaims May 3, 2023
9825c37
Fix CreateOrUpdateTextBlocklist manually
mengaims May 4, 2023
7395dbe
Remove useless samples
mengaims May 4, 2023
ba5a610
Resolve comments
mengaims May 4, 2023
dc2cd40
Update sample and test recordings
mengaims May 4, 2023
5de3987
Update CI and Changelog
mengaims May 4, 2023
bb9ee64
run export api
m-nash May 11, 2023
29e7d8a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
m-nash May 11, 2023
37c8c97
regen with latest client
m-nash May 11, 2023
9941cb3
fix broken links
m-nash May 11, 2023
de2e5cd
update nuget since the package hasn't shipped yet
m-nash May 11, 2023
85b54ec
fix link in samples readme
m-nash May 11, 2023
df0984c
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
m-nash May 12, 2023
e95b8f7
regen with latest generator
m-nash May 12, 2023
422aaa4
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
m-nash May 15, 2023
7b4e275
regen with latest and update test to use the image.jpg bytes vs hard …
m-nash May 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33502.453
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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.AI.ContentSafety.Perf", "perf\Azure.AI.ContentSafety.Perf.csproj", "{30C5FF85-655A-49FC-A324-16438130FF3F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.AI.ContentSafety.Tests", "tests\Azure.AI.ContentSafety.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.AI.ContentSafety", "src\Azure.AI.ContentSafety.csproj", "{D57E62A5-01D2-4D1E-8E10-2A66345F38CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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
{30C5FF85-655A-49FC-A324-16438130FF3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30C5FF85-655A-49FC-A324-16438130FF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30C5FF85-655A-49FC-A324-16438130FF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30C5FF85-655A-49FC-A324-16438130FF3F}.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
{D57E62A5-01D2-4D1E-8E10-2A66345F38CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D57E62A5-01D2-4D1E-8E10-2A66345F38CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D57E62A5-01D2-4D1E-8E10-2A66345F38CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D57E62A5-01D2-4D1E-8E10-2A66345F38CD}.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
11 changes: 11 additions & 0 deletions sdk/contentsafety/Azure.AI.ContentSafety/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
-->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
</Project>
91 changes: 91 additions & 0 deletions sdk/contentsafety/Azure.AI.ContentSafety/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Azure ContentSafety client library for .NET

This section should give out brief introduction of the client library.
mengaims marked this conversation as resolved.
Show resolved Hide resolved

* First sentence: **Describe the service** briefly. You can usually use the first line of the service's docs landing page for this (Example: [Cosmos DB docs landing page](https://docs.microsoft.com/azure/cosmos-db/)).
* Next, add a **bulleted list** of the **most common tasks** supported by the package or library, prefaced with "Use the client library for [Product Name] to:". Then, provide code snippets for these tasks in the [Examples](#examples) section later in the document. Keep the task list short but include those tasks most developers need to perform with your package.

[Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk//Azure.AI/src) | [Package (NuGet)](https://www.nuget.org/packages/Azure.AI) | [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.AI --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 COMMON BAR -->
[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/)
<!-- CLIENT COMMON BAR -->

## Examples

You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk//Azure.AI/samples).

### <scenario>

You can create a client and call the client's `<operation>` method.

<!--```C# Snippet:Azure___Scenario
Console.WriteLine("Hello, world!");
```-->

## 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.

<!-- LINKS -->
[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//Azure.AI/README.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Azure.AI.ContentSafety
{
public partial class ContentSafetyClient
{
protected ContentSafetyClient() { }
public ContentSafetyClient(string endpoint, Azure.Core.TokenCredential credential, Azure.AI.ClientOptions options = null) { }
public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } }
}
m-nash marked this conversation as resolved.
Show resolved Hide resolved
public partial class ContentSafetyClientOptions : Azure.Core.ClientOptions
{
public ContentSafetyClientOptions(Azure.AI.Generated.ClientOptions.ServiceVersion version = Azure.AI.Generated.ClientOptions.ServiceVersion.V1_0_0) { }
public enum ServiceVersion
{
V1_0_0 = 1,
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\src\Azure.AI.ContentSafety.csproj" />
<ProjectReference Include="..\..\..\..\common\Perf\Azure.Test.Perf\Azure.Test.Perf.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions sdk/contentsafety/Azure.AI.ContentSafety/perf/ClientTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading;
using System.Threading.Tasks;
using Azure.Identity;
using Azure.Test.Perf;
using CommandLine;

namespace Azure.AI.ContentSafety.Perf
{
public class ClientTest : PerfTest<ClientTest.ClientPerfOptions>
{
/* please refer to https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/perf/TemplateClientTest.cs to write perf test. */

public ClientTest(ClientPerfOptions options) : base(options)
{
}
public class ClientPerfOptions : PerfOptions
{
}

public override void Run(CancellationToken cancellationToken)
{
}

public override async Task RunAsync(CancellationToken cancellationToken)
{
await Task.Run(() =>
{
Console.WriteLine("exec some async operation");
});
}
}
}
7 changes: 7 additions & 0 deletions sdk/contentsafety/Azure.AI.ContentSafety/perf/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Reflection;
using Azure.Test.Perf;

await PerfProgram.Main(Assembly.GetEntryAssembly(), args);
14 changes: 14 additions & 0 deletions sdk/contentsafety/Azure.AI.ContentSafety/samples/README.md
mengaims marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
page_type: sample
languages:
- csharp
products:
# Including relevant stubs from https://review.docs.microsoft.com/help/contribute/metadata-taxonomies#product
- azure
name: Azure.AI samples for .NET
description: Samples for the Azure.AI client library.
---

# Azure.AI Samples

<!-- please refer to <https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/samples/README.md> to write sample readme. -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# <scenario_list>

To use these samples, you'll first need to set up resources. See [getting started](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk//Azure.AI/README.md#getting-started) for details.

## <scenario>

You can create a client and call the client's `<operation>` method

<!-- please refer to <https://github.com/Azure/azure-sdk-for-net/main/sdk/template/Azure.Template/samples/Sample1_HelloWorld.md> to write sample readme file. -->
```C# Snippet:Azure___Scenario
Console.WriteLine("Hello, world!");
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# <scenario_list>

To use these samples, you'll first need to set up resources. See [getting started](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk//Azure.AI/README.md#getting-started) for details.

## <scenario> asynchronously

You can create a client and call the client's `<operation>` method

<!-- please refer to <https://github.com/Azure/azure-sdk-for-net/main/sdk/template/Azure.Template/samples/Sample1_HelloWorldAsync.md> to write sample readme file. -->
```C# Snippet:Azure___ScenarioAsync
Console.WriteLine("Hello, world!");
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>This is the ContentSafety client library for developing .NET applications with rich experience.</Description>
<AssemblyTitle>Azure SDK Code Generation ContentSafety for Azure Data Plane</AssemblyTitle>
<Version>1.0.0-beta.1</Version>
<PackageTags>Azure ContentSafety</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>
</PropertyGroup>

<!-- Shared source from Azure.Core -->
<ItemGroup>
<Compile Include="$(AzureCoreSharedSources)ArrayBufferWriter.cs" LinkBase="Shared" />
<Compile Include="$(AzureCoreSharedSources)AzureResourceProviderNamespaceAttribute.cs" LinkBase="Shared" />
<Compile Include="$(AzureCoreSharedSources)AzureKeyCredentialPolicy.cs" LinkBase="Shared" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading