Skip to content

Commit 12a7807

Browse files
khmic5ambientlightTaras Vozniukdubiety
authored
Azure Maps Search (Azure#29350)
* untouched codegen with --public-clients generated portion moved out from Generated/ * remove ResponseFormat / JsonFormat parameters for all apis * LatLong and BoundingBox in conveniece layer * SearchClient: add shared key auth constructor * use dedicated LatLong type for various lat,lng invariants (IEnumerable<double>, sep params) * parameter restructed into dedicated option types modeled to be consisted to those in ts * coordinate -> coordinates, SearchPointOfInterestCategoryOptions * add countryFilter overload for all search apis that need reference coords * seachAlongRoute -> searchPointOfInterestAlongRoute * geojson update codegen * follow other clients approach for coord/countryFilter overload * LatLong -> LatLon * geojson type revamps * expose/fix/add-missing public desirialization * FromJsonElement for PolygonFeature and CircleFeature * SearchAddressResult / ReverseSearchAddressResult flattening * flatten result types, query scaffolds for batch requests * src according to base project template, dotnet build /t:GenerateCode -> json updates * base empty tests/samples template * export public api * mv SearchClientOptions alongside SearchClient * add clientId pipeline for polling operations to work, fix LatLon toString(), fix _clientDiagnostic scopes * search address tests * fuzzy, reverse, cross-street search tests * add geojson tests * fix diagnostic scope in searchAlongRoute * address review comments from https://apiview.dev/Assemblies/Review/07d5b915b41147beb1c6c3268f8ae349 1. Polygon::ProviderID -> Polygon::ProviderId, 2. SearchAddressResultItem::Info -> SearchAddressResultItem::DataSourceInfo 3. Classification -> PointOfInterestClassification 4. OperatingHoursTimeRange StartTime/EndTime as DateTimeOffset 5. JsonFormat as internal type 6. OperatingHoursTIme as internal type * fix trailing whitespace failing style check * search sdk changes * search summary bug * ready for pr * add tests * updated search client * ci yml file update * Update GetSearchAddressBatchOperation method signature * fix rebase errors * rebase main * add readme * modify readme * modify readme links * fix broken link * fix link format * add code snippet * fix pipeline playback test errors * correct spellcheck error * fix pipeline playback errors * fix spellcheck errors * modify spellcheck error * apiview changes * apiview updates * fix bounding box * additional apiview changes * apiview changes * name changes * apiview changes * search index change * fixed polygon and internal geojson classes * internal geojson classes * update polygons test * fixed all polygon tests * add common * fixed localizedmapview * fix test resources file * fix snippets * change autorest * update common readme * update changelog to fix pipeline error * update readme * update test snippets * update * update maps search * final changes * pr review changes * pr updates * update tagging * finish pr updates * update changelog release date Co-authored-by: ambientlight <primary.taras.vozniuk@gmail.com> Co-authored-by: Taras Vozniuk <tarasvozniuk@microsoft.com> Co-authored-by: Charlie Chen <yuchungchen@microsoft.com>
1 parent 18ff322 commit 12a7807

File tree

326 files changed

+62173
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+62173
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0-beta.1 (Unreleased)
4+
5+
- Started changelog to capture release notes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Azure Maps Common client library for .NET
2+
3+
Azure Maps is a Microsoft-managed service providing maps service that is...
4+
5+
The Azure.Maps.Common library provides infrastructure shared across other Azure Maps client libraries.
6+
7+
[Source code](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/maps/Azure.Maps.Common/src) | [API reference documentation][https://docs.microsoft.com/rest/api/maps/] | [Product documentation][https://docs.microsoft.com/azure/azure-maps]
8+
9+
## Getting started
10+
11+
### Install the package
12+
13+
Install the Azure Maps client library for .NET you'd like to use with [NuGet](https://www.nuget.org/) and the `Azure.Maps.Common` client library will be included:
14+
15+
```dotnetcli
16+
dotnet add package Azure.Maps.Search --prerelease
17+
dotnet add package Azure.Maps.Render --prerelease
18+
```
19+
20+
### Prerequisites
21+
22+
> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Azure Maps account](https://docs.microsoft.com/azure/azure-maps/quick-demo-map-app#create-an-azure-maps-account).
23+
24+
To create a new Azure Maps account, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:
25+
26+
```powershell
27+
az maps account create --kind "Gen2" --disable-local-auth true --account-name "myMapAccountName" --resource-group "<resource group>" --sku "G2" --accept-tos
28+
```
29+
30+
### Authenticate the client
31+
32+
There are 2 ways to authenticate the client: Shared key authentication and Azure AD. Please refer to other Azure Maps packages for detailed description.
33+
34+
## Key concepts
35+
36+
The Azure Maps Common client library contains shared infrastructure like
37+
[LocalizedMapView](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/maps/Azure.Maps.Common/src/LocalizedMapView.cs) and [RequestFailedException](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/src/RequestFailedException.cs).
38+
39+
### Thread safety
40+
41+
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.
42+
43+
### Additional concepts
44+
<!-- CLIENT COMMON BAR -->
45+
[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) |
46+
[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) |
47+
[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) |
48+
[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) |
49+
[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) |
50+
[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) |
51+
[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/)
52+
<!-- CLIENT COMMON BAR -->
53+
54+
## Examples
55+
56+
Please see the examples for [Search](https://github.com/khmic5/azure-sdk-for-net/tree/khmic/search/sdk/maps/Azure.Maps.Search).
57+
58+
## Troubleshooting
59+
60+
If a `null` `LocalizedMapView` is instantiated, the program will throw a `ArgumentNullException` error.
61+
## Next steps
62+
63+
Get started with our [Common samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/maps/Azure.Maps.Common/samples) and then continue on with our [Search](https://github.com/khmic5/azure-sdk-for-net/blob/khmic/search/sdk/maps/Azure.Maps.Search/tests/Samples/SearchClientSamples.HelloWorld.cs) samples.
64+
65+
## Contributing
66+
67+
See the [CONTRIBUTING.md](https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md) for details on building, testing, and contributing to this library.
68+
69+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit <cla.microsoft.com>.
70+
71+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
72+
73+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact <opencode@microsoft.com> with any additional questions or comments.
74+
75+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/maps/Azure.Maps.Common/README.png)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace Azure.Maps
2+
{
3+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
4+
public readonly partial struct LocalizedMapView : System.IEquatable<Azure.Maps.LocalizedMapView>
5+
{
6+
private readonly object _dummy;
7+
private readonly int _dummyPrimitive;
8+
public LocalizedMapView(string value) { throw null; }
9+
public static Azure.Maps.LocalizedMapView AE { get { throw null; } }
10+
public static Azure.Maps.LocalizedMapView AR { get { throw null; } }
11+
public static Azure.Maps.LocalizedMapView Auto { get { throw null; } }
12+
public static Azure.Maps.LocalizedMapView BH { get { throw null; } }
13+
public static Azure.Maps.LocalizedMapView IN { get { throw null; } }
14+
public static Azure.Maps.LocalizedMapView IQ { get { throw null; } }
15+
public static Azure.Maps.LocalizedMapView JO { get { throw null; } }
16+
public static Azure.Maps.LocalizedMapView KW { get { throw null; } }
17+
public static Azure.Maps.LocalizedMapView LB { get { throw null; } }
18+
public static Azure.Maps.LocalizedMapView MA { get { throw null; } }
19+
public static Azure.Maps.LocalizedMapView OM { get { throw null; } }
20+
public static Azure.Maps.LocalizedMapView PK { get { throw null; } }
21+
public static Azure.Maps.LocalizedMapView PS { get { throw null; } }
22+
public static Azure.Maps.LocalizedMapView QA { get { throw null; } }
23+
public static Azure.Maps.LocalizedMapView SA { get { throw null; } }
24+
public static Azure.Maps.LocalizedMapView SY { get { throw null; } }
25+
public static Azure.Maps.LocalizedMapView Unified { get { throw null; } }
26+
public static Azure.Maps.LocalizedMapView YE { get { throw null; } }
27+
public bool Equals(Azure.Maps.LocalizedMapView other) { throw null; }
28+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
29+
public override bool Equals(object obj) { throw null; }
30+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
31+
public override int GetHashCode() { throw null; }
32+
public static bool operator ==(Azure.Maps.LocalizedMapView left, Azure.Maps.LocalizedMapView right) { throw null; }
33+
public static implicit operator Azure.Maps.LocalizedMapView (string value) { throw null; }
34+
public static bool operator !=(Azure.Maps.LocalizedMapView left, Azure.Maps.LocalizedMapView right) { throw null; }
35+
public override string ToString() { throw null; }
36+
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# LocalizedMapView
2+
3+
`LocalizedMapView` is a enum-like struct user can assign localized map view for geo-political concern. The possible example looks like:
4+
5+
```C# Snippet:LocalizedMapViewUsage
6+
var view = new LocalizedMapView("Unified");
7+
var autoView = new LocalizedMapView("auto");
8+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
eng\scripts\CodeChecks.ps1 -ServiceDirectory maps---
2+
page_type: sample
3+
languages:
4+
- csharp
5+
products:
6+
- azure
7+
name: Azure.Maps.Common samples for .NET
8+
description: Samples for the Azure.Maps.Common client library.
9+
---
10+
11+
# Azure.Maps Samples
12+
13+
## Import the namespaces
14+
15+
To use common module, import `Azure.Maps` namespace:
16+
17+
```C# Snippet:ImportCommonNamespace
18+
using Azure.Maps;
19+
```
20+
21+
## Features
22+
23+
Below are the features of the Azure.Maps.Common module:
24+
25+
[LocalizedMapView](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/maps/Azure.Maps.Common/samples/LocalizedMapView.md)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
4+
</PropertyGroup>
5+
<PropertyGroup>
6+
<AssemblyTitle>Microsoft Azure.Maps.Common client library</AssemblyTitle>
7+
<Version>1.0.0-beta.1</Version>
8+
<DefineConstants>CommonSDK;$(DefineConstants)</DefineConstants>
9+
<NoWarn>$(NoWarn);AZC0001;AZC0012</NoWarn>
10+
<PackageTags>Microsoft Azure Maps Common, Microsoft, Azure, Maps, azureofficial</PackageTags>
11+
<Description>
12+
This client library enables working with the Microsoft Azure Maps services which provides developers from all industries with powerful geospatial capabilities.
13+
For this release see notes - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/maps/Azure.Maps.Common/README.md and https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/maps/Azure.Maps.Common/CHANGELOG.md
14+
Microsoft Azure Maps quickstarts and tutorials - https://docs.microsoft.com/azure/azure-maps/
15+
Microsoft Azure Maps REST API Reference - https://docs.microsoft.com/rest/api/maps/
16+
</Description>
17+
<RootNamespace>Azure.Maps</RootNamespace>
18+
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Azure.Core" />
23+
<PackageReference Include="System.Text.Json" />
24+
</ItemGroup>
25+
</Project>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#nullable disable
5+
6+
using System;
7+
using System.ComponentModel;
8+
9+
namespace Azure.Maps
10+
{
11+
/// <summary> The LocalizedMapView. </summary>
12+
public readonly struct LocalizedMapView : IEquatable<LocalizedMapView>
13+
{
14+
private readonly string _value;
15+
16+
/// <summary> Initializes a new instance of <see cref="LocalizedMapView"/>. </summary>
17+
/// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
18+
public LocalizedMapView(string value)
19+
{
20+
_value = value ?? throw new ArgumentNullException(nameof(value));
21+
}
22+
23+
private const string AEValue = "AE";
24+
private const string ARValue = "AR";
25+
private const string BHValue = "BH";
26+
private const string INValue = "IN";
27+
private const string IQValue = "IQ";
28+
private const string JOValue = "JO";
29+
private const string KWValue = "KW";
30+
private const string LBValue = "LB";
31+
private const string MAValue = "MA";
32+
private const string OMValue = "OM";
33+
private const string PKValue = "PK";
34+
private const string PSValue = "PS";
35+
private const string QAValue = "QA";
36+
private const string SAValue = "SA";
37+
private const string SYValue = "SY";
38+
private const string YEValue = "YE";
39+
private const string AutoValue = "Auto";
40+
private const string UnifiedValue = "Unified";
41+
42+
/// <summary> United Arab Emirates (Arabic View). </summary>
43+
public static LocalizedMapView AE { get; } = new LocalizedMapView(AEValue);
44+
/// <summary> Argentina (Argentinian View). </summary>
45+
public static LocalizedMapView AR { get; } = new LocalizedMapView(ARValue);
46+
/// <summary> Bahrain (Arabic View). </summary>
47+
public static LocalizedMapView BH { get; } = new LocalizedMapView(BHValue);
48+
/// <summary> India (Indian View). </summary>
49+
public static LocalizedMapView IN { get; } = new LocalizedMapView(INValue);
50+
/// <summary> Iraq (Arabic View). </summary>
51+
public static LocalizedMapView IQ { get; } = new LocalizedMapView(IQValue);
52+
/// <summary> Jordan (Arabic View). </summary>
53+
public static LocalizedMapView JO { get; } = new LocalizedMapView(JOValue);
54+
/// <summary> Kuwait (Arabic View). </summary>
55+
public static LocalizedMapView KW { get; } = new LocalizedMapView(KWValue);
56+
/// <summary> Lebanon (Arabic View). </summary>
57+
public static LocalizedMapView LB { get; } = new LocalizedMapView(LBValue);
58+
/// <summary> Morocco (Moroccan View). </summary>
59+
public static LocalizedMapView MA { get; } = new LocalizedMapView(MAValue);
60+
/// <summary> Oman (Arabic View). </summary>
61+
public static LocalizedMapView OM { get; } = new LocalizedMapView(OMValue);
62+
/// <summary> Pakistan (Pakistani View). </summary>
63+
public static LocalizedMapView PK { get; } = new LocalizedMapView(PKValue);
64+
/// <summary> Palestinian Authority (Arabic View). </summary>
65+
public static LocalizedMapView PS { get; } = new LocalizedMapView(PSValue);
66+
/// <summary> Qatar (Arabic View). </summary>
67+
public static LocalizedMapView QA { get; } = new LocalizedMapView(QAValue);
68+
/// <summary> Saudi Arabia (Arabic View). </summary>
69+
public static LocalizedMapView SA { get; } = new LocalizedMapView(SAValue);
70+
/// <summary> Syria (Arabic View). </summary>
71+
public static LocalizedMapView SY { get; } = new LocalizedMapView(SYValue);
72+
/// <summary> Yemen (Arabic View). </summary>
73+
public static LocalizedMapView YE { get; } = new LocalizedMapView(YEValue);
74+
/// <summary> Return the map data based on the IP address of the request. </summary>
75+
public static LocalizedMapView Auto { get; } = new LocalizedMapView(AutoValue);
76+
/// <summary> Unified View (Others). </summary>
77+
public static LocalizedMapView Unified { get; } = new LocalizedMapView(UnifiedValue);
78+
/// <summary> Determines if two <see cref="LocalizedMapView"/> values are the same. </summary>
79+
public static bool operator ==(LocalizedMapView left, LocalizedMapView right) => left.Equals(right);
80+
/// <summary> Determines if two <see cref="LocalizedMapView"/> values are not the same. </summary>
81+
public static bool operator !=(LocalizedMapView left, LocalizedMapView right) => !left.Equals(right);
82+
/// <summary> Converts a string to a <see cref="LocalizedMapView"/>. </summary>
83+
public static implicit operator LocalizedMapView(string value) => new LocalizedMapView(value);
84+
85+
/// <inheritdoc />
86+
[EditorBrowsable(EditorBrowsableState.Never)]
87+
public override bool Equals(object obj) => obj is LocalizedMapView other && Equals(other);
88+
/// <inheritdoc />
89+
public bool Equals(LocalizedMapView other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
90+
91+
/// <inheritdoc />
92+
[EditorBrowsable(EditorBrowsableState.Never)]
93+
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
94+
/// <inheritdoc />
95+
public override string ToString() => _value;
96+
}
97+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
4+
5+
<!-- We don't care about XML doc comments on test types and members -->
6+
<NoWarn>$(NoWarn);CS1591</NoWarn>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="$(AzureCoreTestFramework)" />
11+
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\src\Azure.Maps.Common.csproj" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="NUnit" />
16+
<PackageReference Include="NUnit3TestAdapter" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
18+
<PackageReference Include="Moq" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Folder Include="SessionRecords\" />
23+
</ItemGroup>
24+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
#region Snippet:ImportCommonNamespace
6+
using Azure.Maps;
7+
#endregion
8+
using Azure.Core.TestFramework;
9+
using NUnit.Framework;
10+
11+
namespace Azure.Maps.Tests
12+
{
13+
public class LocalizedMapViewTests
14+
{
15+
[Test]
16+
public void LocalizedMapViewTest()
17+
{
18+
// Exception case
19+
Assert.Throws<ArgumentNullException>(() => new LocalizedMapView(null));
20+
21+
// Normal case
22+
#region Snippet:LocalizedMapViewUsage
23+
var view = new LocalizedMapView("Unified");
24+
var autoView = new LocalizedMapView("auto");
25+
#endregion
26+
Assert.AreEqual(LocalizedMapView.Unified, view);
27+
Assert.AreEqual(LocalizedMapView.Auto, autoView);
28+
}
29+
}
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Release History
2+
3+
## 1.0.0-beta.1 (2022-09-06)
4+
- Initial release.

0 commit comments

Comments
 (0)