-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add C# client SDK for Bing Local Search API. * added generate.cmd * update ErrorResponse.cs limited to "Errors" field only. * update BingLocalSearch.Tests project to build a class library rather than a console app. * regenerated from the checked-in Swagger spec. Disabled tests. Added generate.ps1 * deleted <ItemGroup> lines 25-28, added release notes.
- Loading branch information
1 parent
7d1c598
commit a50c4ab
Showing
42 changed files
with
3,967 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/SDKs/CognitiveServices/dataPlane/Search/BingLocalSearch/AzSdk.RP.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file--> | ||
<PropertyGroup> | ||
<AzureApiTag /> | ||
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags> | ||
</PropertyGroup> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
...vices/dataPlane/Search/BingLocalSearch/BingLocalSearch.Tests/BingLocalSearch.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" /> | ||
<PropertyGroup> | ||
<PackageId>BingLocalSearch.Tests</PackageId> | ||
<VersionPrefix>1.0.0-preview</VersionPrefix> | ||
<AssemblyName>BingLocalSearch.Tests</AssemblyName> | ||
<Description>BingLocalSearch.Tests Class Library</Description> | ||
<FileUpgradeFlags> | ||
</FileUpgradeFlags> | ||
<UpgradeBackupLocation> | ||
</UpgradeBackupLocation> | ||
<OldToolsVersion>2.0</OldToolsVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\BingLocalSearch\BingLocalSearch.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="SessionRecords\**\*.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<!--Do not remove until VS Test Tools fixes #472--> | ||
<ItemGroup> | ||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> | ||
</ItemGroup> | ||
</Project> |
33 changes: 33 additions & 0 deletions
33
...nitiveServices/dataPlane/Search/BingLocalSearch/BingLocalSearch.Tests/LocalSearchTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.Azure.Test.HttpRecorder; | ||
using Microsoft.Azure.CognitiveServices.Search.LocalSearch; | ||
using Microsoft.Azure.CognitiveServices.Search.LocalSearch.Models; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SearchSDK.Tests | ||
{ | ||
public class LocalSearchTests | ||
{ | ||
private static string SubscriptionKey = "fake"; | ||
|
||
// [Fact] | ||
public void LocalSearch() | ||
{ | ||
using (MockContext context = MockContext.Start(this.GetType().FullName)) | ||
{ | ||
HttpMockServer.Initialize(this.GetType().FullName, "LocalSearch"); | ||
|
||
ILocalSearchClient client = new LocalSearchClient(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance()); | ||
|
||
var resp = client.Local.Search(query: "restaurants"); | ||
|
||
Assert.NotNull(resp); | ||
Assert.NotNull(resp.QueryContext); | ||
Assert.NotNull(resp.Places); | ||
Assert.NotNull(resp.Places.Value); | ||
} | ||
} | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
src/SDKs/CognitiveServices/dataPlane/Search/BingLocalSearch/BingLocalSearch.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28010.2019 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BingLocalSearch", "BingLocalSearch\BingLocalSearch.csproj", "{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {8D427FAB-986B-4B80-8831-4C6B4FCD87F0} | ||
EndGlobalSection | ||
EndGlobal |
33 changes: 33 additions & 0 deletions
33
...CognitiveServices/dataPlane/Search/BingLocalSearch/BingLocalSearch/BingLocalSearch.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<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 below this line --> | ||
|
||
<PropertyGroup> | ||
<PackageId>Microsoft.Azure.CognitiveServices.Search.LocalSearch</PackageId> | ||
<Description>Provides ability to search for businesses</Description> | ||
<Version>0.9.0-preview</Version> | ||
<AssemblyName>Microsoft.Azure.CognitiveServices.BingLocalSearch</AssemblyName> | ||
<PackageTags>CognitiveServices;Bing;BingLocalSearch;LocalSearch;Local Search</PackageTags> | ||
<PackageReleaseNotes> | ||
<![CDATA[ | ||
This version is based on the v1.0 Bing Local Search API specification. | ||
Features: | ||
1. Search for businesses by name ("mcdonald's") or by category ("restaurants") | ||
2. Search for businesses near named geographic places ("restaurants in seattle") | ||
3. Search near specific geographic coordinates using the localCircularView and/or localMapView parameters | ||
4. Search by category id using the localCategories parameter. | ||
]]> | ||
</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> |
43 changes: 43 additions & 0 deletions
43
...e/Search/BingLocalSearch/BingLocalSearch/Customizations/ApiKeyServiceClientCredentials.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Microsoft.Azure.CognitiveServices.Search.LocalSearch | ||
{ | ||
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.