Skip to content

Commit f01ddff

Browse files
authored
[Azure Maps] - Onboarding/Signoff for Search SDKs (Azure#24953)
* Search SDK onboarding review * Update README * Modification - Add SearchClientBase - Aligned SearchClient usage for README, samples and tests - New recordings - Code clean up * more clean up * Update async * fix minor pylint error * fix according to comment * modify test.yaml * Fix syntax errors * update * Update README * update README * update sample files * update README * Changed naming from SearchClient to MapsSearchClient * Update according to PR feedback - Update sync/async client operations - Update README - Update Samples files structures - Modify tests - Delete unused files - Create samples for Async - Create README.md for samples * Minor update typo * update overload method * polish methods doc-string * expose GeoJsonObject * update README * Update accroding to board review * Update README samples & setup.py * update according to feedback * update * Update according to feedback - Created convertor.py for converting geo_interface property type to GeoJson - Created e2e tests for all the SDKs - Update doc strings, samples, README * update * Update expected release date&removed Python2.7 packages * Modified BoundingBox type * Update * update converter.py & minor enhancement * Minor update for testing * update unittest & docstring * minor update
1 parent 02e4224 commit f01ddff

File tree

89 files changed

+23799
-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.

89 files changed

+23799
-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.0b1 (2022-09-02)
4+
5+
* Initial Release
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
recursive-include tests *.py *.yaml
2+
recursive-include samples *.py *.md
3+
include *.md
4+
include LICENSE
5+
include azure/__init__.py
6+
include azure/maps/__init__.py
7+
include azure/maps/search/py.typed

sdk/maps/azure-maps-search/README.md

Lines changed: 378 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# ------------------------------------
5+
6+
from ._version import VERSION
7+
from ._search_client import MapsSearchClient
8+
9+
__all__ = [
10+
'MapsSearchClient'
11+
]
12+
__version__ = VERSION
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# ------------------------------------
5+
6+
# pylint: disable=unused-import
7+
from typing import Union, Any
8+
from azure.core.pipeline.policies import AzureKeyCredentialPolicy
9+
from azure.core.credentials import AzureKeyCredential, TokenCredential
10+
from ._generated import SearchClient as _MapsSearchClient
11+
from ._version import VERSION
12+
13+
# To check the credential is either AzureKeyCredential or TokenCredential
14+
def _authentication_policy(credential):
15+
authentication_policy = None
16+
if credential is None:
17+
raise ValueError("Parameter 'credential' must not be None.")
18+
if isinstance(credential, AzureKeyCredential):
19+
authentication_policy = AzureKeyCredentialPolicy(
20+
name="subscription-key", credential=credential
21+
)
22+
elif credential is not None and not hasattr(credential, "get_token"):
23+
raise TypeError(
24+
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
25+
"or a token credential from azure.identity".format(type(credential))
26+
)
27+
return authentication_policy
28+
29+
class MapsSearchClientBase:
30+
def __init__(
31+
self,
32+
credential: Union[AzureKeyCredential, TokenCredential],
33+
**kwargs: Any
34+
) -> None:
35+
36+
self._maps_client = _MapsSearchClient(
37+
credential=credential, # type: ignore
38+
api_version=kwargs.pop("api_version", VERSION),
39+
base_url=kwargs.pop("base_url", None),
40+
client_id=kwargs.pop("client_id", None),
41+
authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)),
42+
**kwargs
43+
)
44+
self._search_client = self._maps_client.search
45+
46+
def __enter__(self):
47+
self._maps_client.__enter__() # pylint:disable=no-member
48+
return self
49+
50+
def __exit__(self, *args):
51+
self._maps_client.__exit__(*args) # pylint:disable=no-member

sdk/maps/azure-maps-search/azure/maps/search/_common/__init__.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from ._search_client import SearchClient
10+
from ._version import VERSION
11+
12+
__version__ = VERSION
13+
__all__ = ['SearchClient']
14+
15+
try:
16+
from ._patch import patch_sdk # type: ignore
17+
patch_sdk()
18+
except ImportError:
19+
pass
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import TYPE_CHECKING
10+
11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
# pylint: disable=unused-import,ungrouped-imports
18+
from typing import Any, Optional
19+
20+
from azure.core.credentials import TokenCredential
21+
22+
23+
class SearchClientConfiguration(Configuration):
24+
"""Configuration for SearchClient.
25+
26+
Note that all parameters used to create this instance are saved as instance
27+
attributes.
28+
29+
:param credential: Credential needed for the client to connect to Azure.
30+
:type credential: ~azure.core.credentials.TokenCredential
31+
:param client_id: Specifies which account is intended for usage in conjunction with the Azure AD security model. It represents a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane Account API. To use Azure AD security in Azure Maps see the following `articles <https://aka.ms/amauthdetails>`_ for guidance.
32+
:type client_id: str
33+
"""
34+
35+
def __init__(
36+
self,
37+
credential, # type: "TokenCredential"
38+
client_id=None, # type: Optional[str]
39+
**kwargs # type: Any
40+
):
41+
# type: (...) -> None
42+
if credential is None:
43+
raise ValueError("Parameter 'credential' must not be None.")
44+
super(SearchClientConfiguration, self).__init__(**kwargs)
45+
46+
self.credential = credential
47+
self.client_id = client_id
48+
self.api_version = "1.0"
49+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://atlas.microsoft.com/.default'])
50+
kwargs.setdefault('sdk_moniker', 'maps-search/{}'.format(VERSION))
51+
self._configure(**kwargs)
52+
53+
def _configure(
54+
self,
55+
**kwargs # type: Any
56+
):
57+
# type: (...) -> None
58+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
59+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
60+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
61+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
62+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
63+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
64+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
65+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
66+
self.authentication_policy = kwargs.get('authentication_policy')
67+
if self.credential and not self.authentication_policy:
68+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)