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

Split Cognitive Services Search into standalone SDKs #3869

Merged
merged 3 commits into from
Nov 21, 2017
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
Expand Up @@ -7,16 +7,18 @@

namespace SearchSDK.Tests
{
public class EntitySearchTests : BaseTests
public class EntitySearchTests
{
private static string SubscriptionKey = "fake";

[Fact]
public void EntitySearch()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
HttpMockServer.Initialize(this.GetType().FullName, "EntitySearch");

IEntitySearchAPI client = GetClient(HttpMockServer.CreateInstance(), SearchTypes.EntitySearch);
IEntitySearchAPI client = new EntitySearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());

var resp = client.Entities.Search(query: "tom cruise");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<Description>Microsoft.Azure.CognitiveServices.Search.EntitySearch.Tests Class Library</Description>
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.EntitySearch.Tests</AssemblyName>
<VersionPrefix>1.1.0-preview</VersionPrefix>
</PropertyGroup>

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

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

<ItemGroup>
<None Update="SessionRecords\**\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

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

</Project>
28 changes: 28 additions & 0 deletions src/SDKs/CognitiveServices/dataPlane/Search/BingEntitySearch.sln
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.Search.EntitySearch", "BingEntitySearch\Microsoft.Azure.CognitiveServices.Search.EntitySearch.csproj", "{6807B854-8528-4FEE-A25D-C43C3AA2D601}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.CognitiveServices.Search.EntitySearch.Tests", "BingEntitySearch.Tests\Microsoft.Azure.CognitiveServices.Search.EntitySearch.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,43 @@
namespace Microsoft.Azure.CognitiveServices.Search.EntitySearch
{
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)
{
if (string.IsNullOrWhiteSpace(subscriptionKey))
throw new ArgumentNullException("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
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.reference.props'))" />
<PropertyGroup>
<PackageId>Microsoft.Azure.CognitiveServices.Search.EntitySearch</PackageId>
<Description>This client library provides access to the Microsoft Cognitive Services Entity Search API.</Description>
<VersionPrefix>1.1.0-preview</VersionPrefix>
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.EntitySearch</AssemblyName>
<PackageTags>Microsoft Cognitive Services;Cognitive Services;Cognitive Services SDK;EntitySearch API;BingEntitySearch API;REST HTTPclient;EntitySearchSDK;BingEntitySearchSDK;netcore451511</PackageTags>
<PackageReleaseNotes>This is a preview release of the Cognitive Services Entity Search SDK. Included with this release is support for Entity Search API.</PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net452;netstandard1.4</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Reflection;
using System.Resources;

[assembly: AssemblyTitle("Microsoft Azure Cognitive Services Entity Search Client Library")]
[assembly: AssemblyDescription("Provides API functions for consuming the Microsoft Azure Cognitive Services Entity Search API.")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Microsoft Azure .NET SDK")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
::

@echo off
<<<<<<< HEAD:src/SDKs/CognitiveServices/dataPlane/Search/EntitySearch/generate.cmd
call %~dp0..\..\..\..\..\..\tools\generate.cmd cognitiveservices/data-plane/EntitySearch %*
=======
call %~dp0..\..\..\..\..\..\tools\generate.cmd cognitiveservices/data-plane/EntitySearch %*
call %~dp0..\..\..\..\..\..\tools\generate.cmd cognitiveservices/data-plane/VideoSearch %*
call %~dp0..\..\..\..\..\..\tools\generate.cmd cognitiveservices/data-plane/WebSearch %*
call %~dp0..\..\..\..\..\..\tools\generate.cmd cognitiveservices/data-plane/WebSearch %*
>>>>>>> upstream/psSdkJson6:src/SDKs/CognitiveServices/dataPlane/Search/Search/generate.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<Description>Microsoft.Azure.CognitiveServices.Search.VideoSearch.Tests Class Library</Description>
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.VideoSearch.Tests</AssemblyName>
<VersionPrefix>1.1.0-preview</VersionPrefix>
</PropertyGroup>

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

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

<ItemGroup>
<None Update="SessionRecords\**\*.json">
<CopyToOutputDirectory>PreserveNewest</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 @@ -5,10 +5,11 @@

namespace SearchSDK.Tests
{
public class VideoSearchTests : BaseTests
public class VideoSearchTests
{
private const string Query = "cars";
private const string VideoResultId = "A9A6BF1A1882870A2BF1A9A6BF1A1882870A2BF1";
private static string SubscriptionKey = "fake";

[Fact]
public void VideoSearch()
Expand All @@ -17,7 +18,7 @@ public void VideoSearch()
{
HttpMockServer.Initialize(this.GetType().FullName, "VideoSearch");

IVideoSearchAPI client = GetClient(HttpMockServer.CreateInstance(), SearchTypes.VideoSearch);
IVideoSearchAPI client = new VideoSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());

var resp = client.Videos.SearchAsync(query: Query).Result;

Expand All @@ -39,7 +40,7 @@ public void VideoDetail()
{
HttpMockServer.Initialize(this.GetType().FullName, "VideoDetail");

IVideoSearchAPI client = GetClient(HttpMockServer.CreateInstance(), SearchTypes.VideoSearch);
IVideoSearchAPI client = new VideoSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());

var resp = client.Videos.DetailsAsync(query: Query, id: VideoResultId).Result;

Expand Down Expand Up @@ -67,7 +68,7 @@ public void VideoTrending()
{
HttpMockServer.Initialize(this.GetType().FullName, "VideoTrending");

IVideoSearchAPI client = GetClient(HttpMockServer.CreateInstance(), SearchTypes.VideoSearch);
IVideoSearchAPI client = new VideoSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());

var resp = client.Videos.TrendingAsync().Result;

Expand Down
28 changes: 28 additions & 0 deletions src/SDKs/CognitiveServices/dataPlane/Search/BingVideoSearch.sln
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.Search.VideoSearch", "BingVideoSearch\Microsoft.Azure.CognitiveServices.Search.VideoSearch.csproj", "{6807B854-8528-4FEE-A25D-C43C3AA2D601}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.CognitiveServices.Search.VideoSearch.Tests", "BingVideoSearch.Tests\Microsoft.Azure.CognitiveServices.Search.VideoSearch.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,43 @@
namespace Microsoft.Azure.CognitiveServices.Search.VideoSearch
{
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)
{
if (string.IsNullOrWhiteSpace(subscriptionKey))
throw new ArgumentNullException("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
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.reference.props'))" />
<PropertyGroup>
<PackageId>Microsoft.Azure.CognitiveServices.Search.VideoSearch</PackageId>
<Description>This client library provides access to the Microsoft Cognitive Services Video Search API.</Description>
<VersionPrefix>1.1.0-preview</VersionPrefix>
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.VideoSearch</AssemblyName>
<PackageTags>Microsoft Cognitive Services;Cognitive Services;Cognitive Services SDK;VideoSearch API;BingVideoSearch API;REST HTTPclient;VideoSearchSDK;BingVideoSearchSDK;netcore451511</PackageTags>
<PackageReleaseNotes>This is a preview release of the Cognitive Services Search SDK. Included with this release is support for Video Search API.</PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net452;netstandard1.4</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Reflection;
using System.Resources;

[assembly: AssemblyTitle("Microsoft Azure Cognitive Services Web Search Client Library")]
[assembly: AssemblyDescription("Provides API functions for consuming the Microsoft Azure Cognitive Services Video Search API.")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Microsoft Azure .NET SDK")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
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/VideoSearch %*
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<Description>Microsoft.Azure.CognitiveServices.Search.Tests Class Library</Description>
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.Tests</AssemblyName>
<Description>Microsoft.Azure.CognitiveServices.Search.WebSearch.Tests Class Library</Description>
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.WebSearch.Tests</AssemblyName>
<VersionPrefix>1.1.0-preview</VersionPrefix>
</PropertyGroup>

Expand All @@ -12,7 +12,7 @@

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Entries": [
{
"RequestUri": "/bing/v7.0/search?q=tom%20cruise",
"RequestUri": "/bing/v7.0/search?mkt=en-us&q=tom%20cruise",
"RequestMethod": "GET",
"RequestHeaders": {
"User-Agent": [
Expand Down
Loading