Skip to content

Commit 8d20078

Browse files
authored
[Azure Maps] Update client prefix on Geolocation SDK Python (Azure#26675)
1 parent 7339b70 commit 8d20078

18 files changed

+92
-126
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Install the Azure Maps Service Geolocation SDK.
3131
pip install azure-maps-geolocation
3232
```
3333

34-
### Create and Authenticate the GeolocationClient
34+
### Create and Authenticate the MapsGeolocationClient
3535

3636
To create a client object to access the Azure Maps Geolocation API, you will need a **credential** object. Azure Maps Geolocation client also support two ways to authenticate.
3737

@@ -43,11 +43,11 @@ Then pass an `AZURE_SUBSCRIPTION_KEY` as the `credential` parameter into an inst
4343

4444
```python
4545
from azure.core.credentials import AzureKeyCredential
46-
from azure.maps.geolocation import GeolocationClient
46+
from azure.maps.geolocation import MapsGeolocationClient
4747

4848
credential = AzureKeyCredential(os.environ.get("AZURE_SUBSCRIPTION_KEY"))
4949

50-
geolocation_client = GeolocationClient(
50+
geolocation_client = MapsGeolocationClient(
5151
credential=credential,
5252
)
5353
```
@@ -71,11 +71,11 @@ Next, set the values of the client ID, tenant ID, and client secret of the AAD a
7171
You will also need to specify the Azure Maps resource you intend to use by specifying the `clientId` in the client options. The Azure Maps resource client id can be found in the Authentication sections in the Azure Maps resource. Please refer to the [documentation][how_to_manage_authentication] on how to find it.
7272

7373
```python
74-
from azure.maps.geolocation import GeolocationClient
74+
from azure.maps.geolocation import MapsGeolocationClient
7575
from azure.identity import DefaultAzureCredential
7676

7777
credential = DefaultAzureCredential()
78-
geolocation_client = GeolocationClient(
78+
geolocation_client = MapsGeolocationClient(
7979
client_id="<Azure Maps Client ID>",
8080
credential=credential
8181
)
@@ -87,8 +87,8 @@ The Azure Maps Geolocation client library for Python allows you to interact with
8787

8888
### Sync Clients
8989

90-
`GeolocationClient` is the primary client for developers using the Azure Maps Geolocation client library for Python.
91-
Once you initialized a `GeolocationClient` class, you can explore the methods on this client object to understand the different features of the Azure Maps Geolocation service that you can access.
90+
`MapsGeolocationClient` is the primary client for developers using the Azure Maps Geolocation client library for Python.
91+
Once you initialized a `MapsGeolocationClient` class, you can explore the methods on this client object to understand the different features of the Azure Maps Geolocation service that you can access.
9292

9393
### Async Clients
9494

@@ -109,11 +109,11 @@ The following sections provide several code snippets covering some of the most c
109109
This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
110110

111111
```python
112-
from azure.maps.geolocation import GeolocationClient
112+
from azure.maps.geolocation import MapsGeolocationClient
113113

114114
BLOCK_COUNTRY_LIST = ['US', 'TW', 'AF', 'AX', 'DL']
115115
INCOME_IP_ADDRESS = "2001:4898:80e8:b::189"
116-
geolocation_result = client.get_geolocation(ip_address=INCOME_IP_ADDRESS)
116+
geolocation_result = client.get_country_code(ip_address=INCOME_IP_ADDRESS)
117117

118118
result_country_code = geolocation_result.iso_code
119119

@@ -139,7 +139,7 @@ Detailed DEBUG level logging, including request/response bodies and unredacted h
139139
```python
140140
import sys
141141
import logging
142-
from azure.maps.geolocation import GeolocationClient
142+
from azure.maps.geolocation import MapsGeolocationClient
143143

144144
# Create a logger for the 'azure.maps.geolocation' SDK
145145
logger = logging.getLogger('azure.maps.geolocation')
@@ -169,7 +169,7 @@ set AZURE_SUBSCRIPTION_KEY="<RealSubscriptionKey>"
169169
pip install azure-maps-geolocation --pre
170170

171171
python samples/sample_authentication.py
172-
python sample/sample_get_geolocation.py
172+
python sample/sample_get_country_code.py
173173
```
174174

175175
> Notes: `--pre` flag can be optionally added, it is to include pre-release and development versions for `pip install`. By default, `pip` only finds stable versions.

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# ------------------------------------
55

66
from ._version import VERSION
7-
from ._geolocation_client import GeolocationClient
7+
from ._geolocation_client import MapsGeolocationClient
88

99
__all__ = [
10-
'GeolocationClient'
10+
'MapsGeolocationClient'
1111
]
1212
__version__ = VERSION

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/_base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _authentication_policy(credential):
2525
)
2626
return authentication_policy
2727

28-
class GeolocationClientBase:
28+
class MapsGeolocationClientBase:
2929
def __init__(
3030
self,
3131
credential: Union[AzureKeyCredential, TokenCredential],

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/_geolocation_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
from azure.core.tracing.decorator import distributed_trace
99
from azure.core.credentials import AzureKeyCredential, TokenCredential
1010

11-
from ._base_client import GeolocationClientBase
11+
from ._base_client import MapsGeolocationClientBase
1212
from .models import (
13-
Geolocation
13+
CountryRegionResult
1414
)
1515

1616

1717
# By default, use the latest supported API version
18-
class GeolocationClient(GeolocationClientBase):
18+
class MapsGeolocationClient(MapsGeolocationClientBase):
1919
"""Azure Maps Geolocation REST APIs.
2020
2121
:param credential:
@@ -37,13 +37,13 @@ class GeolocationClient(GeolocationClientBase):
3737
:end-before: [END create_maps_geolocation_service_client_with_key]
3838
:language: python
3939
:dedent: 4
40-
:caption: Creating the GeolocationClient with an subscription key.
40+
:caption: Creating the MapsGeolocationClient with an subscription key.
4141
.. literalinclude:: ../samples/sample_authentication.py
4242
:start-after: [START create_maps_geolocation_service_client_with_aad]
4343
:end-before: [END create_maps_geolocation_service_client_with_aad]
4444
:language: python
4545
:dedent: 4
46-
:caption: Creating the GeolocationClient with a token credential.
46+
:caption: Creating the MapsGeolocationClient with a token credential.
4747
"""
4848

4949
def __init__(
@@ -57,11 +57,11 @@ def __init__(
5757
)
5858

5959
@distributed_trace
60-
def get_geolocation(
60+
def get_country_code(
6161
self,
6262
ip_address: str,
6363
**kwargs: Any
64-
) -> Geolocation:
64+
) -> CountryRegionResult:
6565
"""
6666
This service will return the ISO country code for the provided IP address. Developers can use
6767
this information to block or alter certain content based on geographical locations where the
@@ -72,16 +72,16 @@ def get_geolocation(
7272
:type ip_address:
7373
str
7474
:return:
75-
Geolocation
75+
CountryRegionResult
7676
:rtype:
77-
~azure.maps.geolocation.models.Geolocation
77+
~azure.maps.geolocation.models.CountryRegionResult
7878
:raises ~azure.core.exceptions.HttpResponseError:
7979
8080
.. admonition:: Example:
8181
82-
.. literalinclude:: ../samples/sample_get_geolocation.py
83-
:start-after: [START get_geolocation]
84-
:end-before: [END get_geolocation]
82+
.. literalinclude:: ../samples/sample_get_country_code.py
83+
:start-after: [START get_country_code]
84+
:end-before: [END get_country_code]
8585
:language: python
8686
:dedent: 4
8787
:caption: Return the ISO country code for the provided IP address.
@@ -93,7 +93,7 @@ def get_geolocation(
9393
**kwargs
9494
)
9595

96-
return Geolocation(
96+
return CountryRegionResult(
9797
ip_address=geolocation_result.ip_address,
9898
iso_code=geolocation_result.country_region.iso_code
9999
)

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/aio/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._geolocation_client_async import GeolocationClient
10-
__all__ = ['GeolocationClient']
9+
from ._geolocation_client_async import MapsGeolocationClient
10+
__all__ = ['MapsGeolocationClient']

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/aio/_base_client_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from azure.core.pipeline.policies import AzureKeyCredentialPolicy
88
from azure.core.credentials import AzureKeyCredential
99
from azure.core.credentials_async import AsyncTokenCredential
10-
from .._generated.aio import GeolocationClient as _GeolocationClient
10+
from .._generated.aio import GeolocationClient as _MapsGeolocationClient
1111
from .._version import VERSION
1212

1313
def _authentication_policy(credential):
@@ -25,14 +25,14 @@ def _authentication_policy(credential):
2525
)
2626
return authentication_policy
2727

28-
class AsyncGeolocationClientBase:
28+
class AsyncMapsGeolocationClientBase:
2929
def __init__(
3030
self,
3131
credential: Union[AzureKeyCredential, AsyncTokenCredential],
3232
**kwargs: Any
3333
) -> None:
3434

35-
self._maps_client = _GeolocationClient(
35+
self._maps_client = _MapsGeolocationClient(
3636
credential=credential, # type: ignore
3737
api_version=kwargs.pop("api_version", VERSION),
3838
authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)),

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/aio/_geolocation_client_async.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
from azure.core.credentials import AzureKeyCredential
1111
from azure.core.credentials_async import AsyncTokenCredential
1212

13-
from ._base_client_async import AsyncGeolocationClientBase
13+
from ._base_client_async import AsyncMapsGeolocationClientBase
1414
from ..models import (
15-
Geolocation
15+
CountryRegionResult
1616
)
1717

1818
# By default, use the latest supported API version
19-
class GeolocationClient(AsyncGeolocationClientBase):
19+
class MapsGeolocationClient(AsyncMapsGeolocationClientBase):
2020
"""Azure Maps Geolocation REST APIs.
2121
2222
:param credential: Credential needed for the client to connect to Azure.
@@ -36,13 +36,13 @@ class GeolocationClient(AsyncGeolocationClientBase):
3636
:end-before: [END create_maps_geolocation_service_client_with_key_async]
3737
:language: python
3838
:dedent: 4
39-
:caption: Creating the GeolocationClient with an subscription key.
39+
:caption: Creating the MapsGeolocationClient with an subscription key.
4040
.. literalinclude:: ../samples/async_samples/sample_authentication_async.py
4141
:start-after: [START create_maps_geolocation_service_client_with_aad_async]
4242
:end-before: [END create_maps_geolocation_service_client_with_aad_async]
4343
:language: python
4444
:dedent: 4
45-
:caption: Creating the GeolocationClient with a token credential.
45+
:caption: Creating the MapsGeolocationClient with a token credential.
4646
"""
4747
def __init__(
4848
self,
@@ -55,11 +55,11 @@ def __init__(
5555

5656

5757
@distributed_trace_async
58-
async def get_geolocation(
58+
async def get_country_code(
5959
self,
6060
ip_address: str,
6161
**kwargs: Any
62-
) -> Geolocation:
62+
) -> CountryRegionResult:
6363
"""
6464
This service will return the ISO country code for the provided IP address. Developers can use
6565
this information to block or alter certain content based on geographical locations where the
@@ -69,16 +69,16 @@ async def get_geolocation(
6969
The IP address. Both IPv4 and IPv6 are allowed. Required.
7070
:type ip_address: str
7171
:return:
72-
Geolocation
72+
CountryRegionResult
7373
:rtype:
74-
~azure.maps.geolocation.models.Geolocation
74+
~azure.maps.geolocation.models.CountryRegionResult
7575
:raises ~azure.core.exceptions.HttpResponseError:
7676
7777
.. admonition:: Example:
7878
79-
.. literalinclude:: ../samples/async_samples/sample_get_geolocation_async.py
80-
:start-after: [START get_geolocation_async]
81-
:end-before: [END get_geolocation_async]
79+
.. literalinclude:: ../samples/async_samples/sample_get_country_code_async.py
80+
:start-after: [START get_country_code_async]
81+
:end-before: [END get_country_code_async]
8282
:language: python
8383
:dedent: 4
8484
:caption: Return the ISO country code for the provided IP address.
@@ -90,7 +90,7 @@ async def get_geolocation(
9090
**kwargs
9191
)
9292

93-
return Geolocation(
93+
return CountryRegionResult(
9494
ip_address=geolocation_result.ip_address,
9595
iso_code=geolocation_result.country_region.iso_code
9696
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
from ._models import (
3-
Geolocation
3+
CountryRegionResult
44
)
55

66

77
__all__ = [
8-
'Geolocation'
8+
'CountryRegionResult'
99
]

sdk/maps/azure-maps-geolocation/azure/maps/geolocation/models/_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License.
44
# ------------------------------------
55

6-
class Geolocation(object):
6+
class CountryRegionResult(object):
77
"""Represents coordinate latitude and longitude
88
99
:keyword ip_address:

sdk/maps/azure-maps-geolocation/samples/async_samples/sample_authentication_async.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
async def authentication_maps_service_client_with_subscription_key_credential_async():
3030
# [START create_maps_geolocation_service_client_with_key_async]
3131
from azure.core.credentials import AzureKeyCredential
32-
from azure.maps.geolocation.aio import GeolocationClient
32+
from azure.maps.geolocation.aio import MapsGeolocationClient
3333

3434
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY")
3535

36-
maps_geolocation_client = GeolocationClient(credential=AzureKeyCredential(subscription_key))
36+
maps_geolocation_client = MapsGeolocationClient(credential=AzureKeyCredential(subscription_key))
3737
# [END create_maps_geolocation_service_client_with_key_async]
3838

3939
async with maps_geolocation_client:
40-
result = await maps_geolocation_client.get_geolocation(ip_address="2001:4898:80e8:b::189")
40+
result = await maps_geolocation_client.get_country_code(ip_address="2001:4898:80e8:b::189")
4141

4242
print(result)
4343

@@ -47,16 +47,16 @@ async def authentication_maps_service_client_with_aad_credential_async():
4747
"""
4848
# [START create_maps_geolocation_service_client_with_aad_async]
4949
from azure.identity.aio import DefaultAzureCredential
50-
from azure.maps.geolocation.aio import GeolocationClient
50+
from azure.maps.geolocation.aio import MapsGeolocationClient
5151

5252
credential = DefaultAzureCredential()
5353
maps_client_id = os.getenv("AZURE_MAPS_CLIENT_ID")
5454

55-
maps_geolocation_client = GeolocationClient(client_id=maps_client_id, credential=credential)
55+
maps_geolocation_client = MapsGeolocationClient(client_id=maps_client_id, credential=credential)
5656
# [END create_maps_geolocation_service_client_with_aad_async]
5757

5858
async with maps_geolocation_client:
59-
result = await maps_geolocation_client.get_geolocation(ip_address="2001:4898:80e8:b::189")
59+
result = await maps_geolocation_client.get_country_code(ip_address="2001:4898:80e8:b::189")
6060

6161
print(result)
6262

0 commit comments

Comments
 (0)