Location
location
¶
Location
¶
Bases: SyncBaseExtension[Location]
Extension for location related endpoints.
Source code in pokelance/ext/_base.py
get_location
¶
Gets a location from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Location | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/location.py
def get_location(self, name: str | int) -> models.Location | None:
"""Gets a location from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Location | None
The cached model or None.
Examples
--------
```python
location = client.location.get_location("canalave-city")
if location:
print(location)
```"""
route = Endpoint.get_location(name)
self._validate_resource(self._cache_group.location, name, route)
return self._cache_group.location.get(route, None)
fetch_location
¶
Fetches a location from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Location
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/location.py
def fetch_location(self, name: str | int) -> models.Location:
"""Fetches a location from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Location
The fetched model.
Examples
--------
```python
location = client.location.fetch_location("canalave-city")
print(location)
```"""
route = Endpoint.get_location(name)
self._validate_resource(self._cache_group.location, name, route)
data = self._client.request(route)
return self._cache_group.location.setdefault(route, self._cache_group.location.from_payload(data))
get_location_area
¶
get_location_area(name: str | int) -> LocationArea | None
Gets a location area from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
LocationArea | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/location.py
def get_location_area(self, name: str | int) -> models.LocationArea | None:
"""Gets a location area from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.LocationArea | None
The cached model or None.
Examples
--------
```python
area = client.location.get_location_area("canalave-city-area")
if area:
print(area)
```"""
route = Endpoint.get_location_area(name)
self._validate_resource(self._cache_group.location_area, name, route)
return self._cache_group.location_area.get(route, None)
fetch_location_area
¶
fetch_location_area(name: str | int) -> LocationArea
Fetches a location area from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
LocationArea
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/location.py
def fetch_location_area(self, name: str | int) -> models.LocationArea:
"""Fetches a location area from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.LocationArea
The fetched model.
Examples
--------
```python
area = client.location.fetch_location_area("canalave-city-area")
print(area)
```"""
route = Endpoint.get_location_area(name)
self._validate_resource(self._cache_group.location_area, name, route)
data = self._client.request(route)
return self._cache_group.location_area.setdefault(route, self._cache_group.location_area.from_payload(data))
get_pal_park_area
¶
get_pal_park_area(name: str | int) -> PalParkArea | None
Gets a pal park area from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PalParkArea | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/location.py
def get_pal_park_area(self, name: str | int) -> models.PalParkArea | None:
"""Gets a pal park area from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PalParkArea | None
The cached model or None.
Examples
--------
```python
area = client.location.get_pal_park_area("forest")
if area:
print(area)
```"""
route = Endpoint.get_pal_park_area(name)
self._validate_resource(self._cache_group.pal_park_area, name, route)
return self._cache_group.pal_park_area.get(route, None)
fetch_pal_park_area
¶
fetch_pal_park_area(name: str | int) -> PalParkArea
Fetches a pal park area from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PalParkArea
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/location.py
def fetch_pal_park_area(self, name: str | int) -> models.PalParkArea:
"""Fetches a pal park area from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PalParkArea
The fetched model.
Examples
--------
```python
area = client.location.fetch_pal_park_area("forest")
print(area)
```"""
route = Endpoint.get_pal_park_area(name)
self._validate_resource(self._cache_group.pal_park_area, name, route)
data = self._client.request(route)
return self._cache_group.pal_park_area.setdefault(route, self._cache_group.pal_park_area.from_payload(data))
get_region
¶
Gets a region from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Region | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/location.py
def get_region(self, name: str | int) -> models.Region | None:
"""Gets a region from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Region | None
The cached model or None.
Examples
--------
```python
region = client.location.get_region("kanto")
if region:
print(region)
```"""
route = Endpoint.get_region(name)
self._validate_resource(self._cache_group.region, name, route)
return self._cache_group.region.get(route, None)
fetch_region
¶
Fetches a region from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Region
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/location.py
def fetch_region(self, name: str | int) -> models.Region:
"""Fetches a region from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Region
The fetched model.
Examples
--------
```python
region = client.location.fetch_region("kanto")
print(region)
```"""
route = Endpoint.get_region(name)
self._validate_resource(self._cache_group.region, name, route)
data = self._client.request(route)
return self._cache_group.region.setdefault(route, self._cache_group.region.from_payload(data))
setup
¶
setup(lance: PokeLanceSyncClient) -> None