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

[Cogs Face] Update Face SDK with latest auto-rest Swagger and update unit tests #3977

Merged
merged 1 commit into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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,28 @@
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using System.Net.Http;
using Vision = Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;

namespace ComputerVisionSDK.Tests
{
public abstract class BaseTests
{
public static bool IsTestTenant = false;
private static readonly string ComputerVisionSubscriptionKey;

static BaseTests()
{
// Retrieve the configuration information.
ComputerVisionSubscriptionKey = "";
}

protected IComputerVisionAPI GetComputerVisionClient(DelegatingHandler handler)
{
IComputerVisionAPI client = new ComputerVisionAPI(new ApiKeyServiceClientCredentials(ComputerVisionSubscriptionKey), handlers: handler)
{
AzureRegion = Vision.AzureRegions.Westus
};

return client;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<Description>Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Tests Class Library</Description>
<AssemblyName>Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Tests</AssemblyName>
<VersionPrefix>1.0.2-preview</VersionPrefix>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" />
<ProjectReference Include="..\ComputerVision\Microsoft.Azure.CognitiveServices.Vision.ComputerVision.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="SessionRecords\**\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestImages\*.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestImages\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
""
],
"User-Agent": [
"FxVersion/4.6.25815.04",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/1.0.0.0"
"FxVersion/4.6.25211.01",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/1.0.2.0"
]
},
"ResponseBody": "{\r\n \"categories\": [\r\n {\r\n \"name\": \"building_\",\r\n \"score\": 0.640625\r\n },\r\n {\r\n \"name\": \"outdoor_house\",\r\n \"score\": 0.31640625\r\n }\r\n ],\r\n \"adult\": {\r\n \"isAdultContent\": false,\r\n \"isRacyContent\": false,\r\n \"adultScore\": 0.010395138524472713,\r\n \"racyScore\": 0.014745410531759262\r\n },\r\n \"tags\": [\r\n {\r\n \"name\": \"grass\",\r\n \"confidence\": 0.9999992847442627\r\n },\r\n {\r\n \"name\": \"outdoor\",\r\n \"confidence\": 0.99983179569244385\r\n },\r\n {\r\n \"name\": \"sky\",\r\n \"confidence\": 0.994972825050354\r\n },\r\n {\r\n \"name\": \"house\",\r\n \"confidence\": 0.98920279741287231\r\n },\r\n {\r\n \"name\": \"building\",\r\n \"confidence\": 0.96683281660079956\r\n },\r\n {\r\n \"name\": \"green\",\r\n \"confidence\": 0.84886491298675537\r\n },\r\n {\r\n \"name\": \"lawn\",\r\n \"confidence\": 0.8137822151184082\r\n },\r\n {\r\n \"name\": \"residential\",\r\n \"confidence\": 0.41664695739746094\r\n },\r\n {\r\n \"name\": \"grassy\",\r\n \"confidence\": 0.40174955129623413\r\n }\r\n ],\r\n \"requestId\": \"bbfc7b5a-354f-4e17-9a25-f6026cbaa5a6\",\r\n \"metadata\": {\r\n \"width\": 600,\r\n \"height\": 462,\r\n \"format\": \"Jpeg\"\r\n },\r\n \"faces\": [],\r\n \"color\": {\r\n \"dominantColorForeground\": \"Green\",\r\n \"dominantColorBackground\": \"Green\",\r\n \"dominantColors\": [\r\n \"Green\",\r\n \"White\"\r\n ],\r\n \"accentColor\": \"448318\",\r\n \"isBWImg\": false\r\n },\r\n \"imageType\": {\r\n \"clipArtType\": 0,\r\n \"lineDrawingType\": 0\r\n }\r\n}",
"ResponseBody": "{\r\n \"categories\": [\r\n {\r\n \"name\": \"building_\",\r\n \"score\": 0.640625\r\n },\r\n {\r\n \"name\": \"outdoor_house\",\r\n \"score\": 0.31640625\r\n }\r\n ],\r\n \"adult\": {\r\n \"isAdultContent\": false,\r\n \"isRacyContent\": false,\r\n \"adultScore\": 0.010395138524472713,\r\n \"racyScore\": 0.014745410531759262\r\n },\r\n \"tags\": [\r\n {\r\n \"name\": \"grass\",\r\n \"confidence\": 0.9999992847442627\r\n },\r\n {\r\n \"name\": \"outdoor\",\r\n \"confidence\": 0.99983179569244385\r\n },\r\n {\r\n \"name\": \"sky\",\r\n \"confidence\": 0.994972825050354\r\n },\r\n {\r\n \"name\": \"house\",\r\n \"confidence\": 0.98920279741287231\r\n },\r\n {\r\n \"name\": \"building\",\r\n \"confidence\": 0.96683281660079956\r\n },\r\n {\r\n \"name\": \"green\",\r\n \"confidence\": 0.84886491298675537\r\n },\r\n {\r\n \"name\": \"lawn\",\r\n \"confidence\": 0.8137822151184082\r\n },\r\n {\r\n \"name\": \"residential\",\r\n \"confidence\": 0.41664695739746094\r\n },\r\n {\r\n \"name\": \"grassy\",\r\n \"confidence\": 0.40174955129623413\r\n }\r\n ],\r\n \"requestId\": \"5210e9cd-df01-4898-aef6-9e562a03102d\",\r\n \"metadata\": {\r\n \"width\": 600,\r\n \"height\": 462,\r\n \"format\": \"Jpeg\"\r\n },\r\n \"faces\": [],\r\n \"color\": {\r\n \"dominantColorForeground\": \"Green\",\r\n \"dominantColorBackground\": \"Green\",\r\n \"dominantColors\": [\r\n \"Green\",\r\n \"White\"\r\n ],\r\n \"accentColor\": \"448318\",\r\n \"isBWImg\": false\r\n },\r\n \"imageType\": {\r\n \"clipArtType\": 0,\r\n \"lineDrawingType\": 0\r\n }\r\n}",
"ResponseHeaders": {
"Content-Length": [
"1002"
Expand All @@ -35,7 +35,7 @@
"no-cache"
],
"Date": [
"Wed, 29 Nov 2017 17:04:51 GMT"
"Thu, 21 Dec 2017 13:25:19 GMT"
],
"Pragma": [
"no-cache"
Expand All @@ -47,7 +47,7 @@
"ASP.NET"
],
"apim-request-id": [
"bbfc7b5a-354f-4e17-9a25-f6026cbaa5a6"
"5210e9cd-df01-4898-aef6-9e562a03102d"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using FaceSDK.Tests;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Xunit;

namespace VisionSDK.Tests
namespace ComputerVisionSDK.Tests
{
public class VisionAnalyzeTests : BaseTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.CognitiveServices.Vision.ComputerVision", "ComputerVision\Microsoft.Azure.CognitiveServices.Vision.ComputerVision.csproj", "{6807B854-8528-4FEE-A25D-C43C3AA2D601}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Tests", "ComputerVision.Tests\Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Tests.csproj", "{5987D97A-E532-450C-BF22-A1F595C927F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6807B854-8528-4FEE-A25D-C43C3AA2D601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6807B854-8528-4FEE-A25D-C43C3AA2D601}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6807B854-8528-4FEE-A25D-C43C3AA2D601}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6807B854-8528-4FEE-A25D-C43C3AA2D601}.Release|Any CPU.Build.0 = Release|Any CPU
{5987D97A-E532-450C-BF22-A1F595C927F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5987D97A-E532-450C-BF22-A1F595C927F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5987D97A-E532-450C-BF22-A1F595C927F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5987D97A-E532-450C-BF22-A1F595C927F1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Microsoft.Azure.CognitiveServices.Vision.ComputerVision
{
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Rest;

/// <summary>
/// Allows authentication to the API using a basic apiKey mechanism
/// </summary>
public class ApiKeyServiceClientCredentials : ServiceClientCredentials
{
private readonly string subscriptionKey;

/// <summary>
/// Creates a new instance of the ApiKeyServiceClientCredentails class
/// </summary>
/// <param name="subscriptionKey">The subscription key to authenticate and authorize as</param>
public ApiKeyServiceClientCredentials(string subscriptionKey)
{
this.subscriptionKey = subscriptionKey;
}

/// <summary>
/// Add the Basic Authentication Header to each outgoing request
/// </summary>
/// <param name="request">The outgoing request</param>
/// <param name="cancellationToken">A token to cancel the operation</param>
public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request == null)
throw new ArgumentNullException("request");

request.Headers.Add("Ocp-Apim-Subscription-Key", this.subscriptionKey);

return Task.FromResult<object>(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1849,8 +1849,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down Expand Up @@ -2053,8 +2053,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down Expand Up @@ -2224,8 +2224,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down Expand Up @@ -2402,8 +2402,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down Expand Up @@ -2566,8 +2566,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down Expand Up @@ -2739,8 +2739,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down Expand Up @@ -2911,8 +2911,8 @@ private void Initialize()
}
if (image != null && image != Stream.Null)
{
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
_httpRequest.Content = new StreamContent(image);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
}
// Set Credentials
if (Credentials != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

using System;
using System.Collections.Generic;
using System.Linq;

internal static partial class SdkInfo
{
public static IEnumerable<Tuple<string, string, string>> ApiInfo_ComputerVisionAPI
{
get
{
return new Tuple<string, string, string>[]
{
new Tuple<string, string, string>("ComputerVisionAPI", "AnalyzeImage", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "AnalyzeImageByDomain", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "AnalyzeImageByDomainInStream", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "AnalyzeImageInStream", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "DescribeImage", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "DescribeImageInStream", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "GenerateThumbnail", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "GenerateThumbnailInStream", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "GetTextOperationResult", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "ListModels", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "RecognizePrintedText", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "RecognizePrintedTextInStream", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "RecognizeText", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "RecognizeTextInStream", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "TagImage", "1.0"),
new Tuple<string, string, string>("ComputerVisionAPI", "TagImageInStream", "1.0"),
}.AsEnumerable();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Please do not move/edit code below this line -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.reference.props'))" />
<!-- Please do not move/edit code above this line -->

<PropertyGroup>
<PackageId>Microsoft.Azure.CognitiveServices.Vision.ComputerVision</PackageId>
<Description>This client library provides access to the Microsoft Cognitive Services ComputerVision APIs.</Description>
<VersionPrefix>1.0.2-preview</VersionPrefix>
<AssemblyName>Microsoft.Azure.CognitiveServices.Vision.ComputerVision</AssemblyName>
<PackageTags>Microsoft Cognitive Services;Cognitive Services;Cognitive Services SDK;REST HTTP client;Computer Vision;Computer Vision API;Computer Vision SDK;Vision;netcore451511</PackageTags>
<PackageReleaseNotes>This is a preview release of the Cognitive Services Computer Vision SDK.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net452;netstandard1.4</TargetFrameworks>
</PropertyGroup>

<!-- Please do not move/edit code below this line -->
<Import Condition=" Exists('$([MSBuild]::GetPathOfFileAbove(AzSdk.RP.props))') " Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.RP.props'))" />
<!-- Please do not move/edit code above this line -->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
::
:: Microsoft Azure SDK for Net - Generate library code
:: Copyright (C) Microsoft Corporation. All Rights Reserved.
::

@echo off
call %~dp0..\..\..\..\..\..\..\tools\generate.cmd cognitiveservices/data-plane/ComputerVision %*
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.Azure.CognitiveServices.Vision.Face;
using System.Net.Http;
using Face = Microsoft.Azure.CognitiveServices.Vision.Face.Models;

namespace FaceSDK.Tests
{
public abstract class BaseTests
{
public static bool IsTestTenant = false;
private static readonly string FaceSubscriptionKey;

static BaseTests()
{
// Retrieve the configuration information.
FaceSubscriptionKey = "";
}

protected IFaceAPI GetFaceClient(DelegatingHandler handler)
{
IFaceAPI client = new FaceAPI(new ApiKeyServiceClientCredentials(FaceSubscriptionKey), handlers: handler)
{
AzureRegion = Face.AzureRegions.Westus
};

return client;
}
}
}
Loading