Client
pokelance.http.HttpClient(*, cache_size, client, session=None)
⚓︎
The HTTP client for PokeLance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'PokeLance'
|
The client that this HTTP client is for. |
required |
cache_size
|
int
|
The size of the cache. |
required |
session
|
Optional[ClientSession]
|
The session to use for the HTTP client. If not provided, one is created internally on the first request and owned by this client. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
session |
ClientSession
|
The session to use for the HTTP client. |
_is_ready |
bool
|
Whether the HTTP client is ready. |
_cache |
Cache
|
The cache to use for the HTTP client. |
_client |
PokeLance
|
The client that this HTTP client is for. |
_tasks_queue |
List[Task]
|
The queue for the tasks. |
_session_owner |
bool
|
Whether the session was created internally (True) or passed in by the
caller (False). Only owned sessions are closed by |
Initializes the HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_size
|
int
|
The size of the cache. |
required |
client
|
'PokeLance'
|
The client that this HTTP client is for. |
required |
session
|
Optional[ClientSession]
|
The session to use for the HTTP client. |
None
|
Source code in pokelance/http/__init__.py
logger
property
⚓︎
close()
async
⚓︎
Closes the HTTP client.
Only closes the underlying session if it was created internally. A session passed in by the caller is left open, since the caller owns its lifecycle and may still be using it elsewhere.
Source code in pokelance/http/__init__.py
connect()
async
⚓︎
Connects the HTTP client.
Source code in pokelance/http/__init__.py
| Python | |
|---|---|
load_audio(url)
async
⚓︎
Loads an audio from the url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to load the audio from. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The audio. |
Raises:
| Type | Description |
|---|---|
AudioNotFound
|
The audio was not found. |
Source code in pokelance/http/__init__.py
load_image(url)
async
⚓︎
Loads an image from the url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to load the image from. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The image. |
Raises:
| Type | Description |
|---|---|
ImageNotFound
|
The image was not found. |
Source code in pokelance/http/__init__.py
ping()
async
⚓︎
Pings the PokeAPI and returns the latency.
Returns:
| Type | Description |
|---|---|
float
|
The latency of the PokeAPI. |
Source code in pokelance/http/__init__.py
request(route)
async
⚓︎
Makes a request to the PokeAPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route
|
Route
|
The route to use for the request. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The response from the PokeAPI. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
An error occurred while making the request. |