hikari.internal.routes#
Provides the valid routes that can be used on the API and the CDN.
Module Contents#
- class hikari.internal.routes.CompiledRoute[source]#
A compiled representation of a route to a specific resource.
This is a similar representation to what
Route
provides, exceptRoute
is treated as a template, this is treated as an instance.
- class hikari.internal.routes.Route(method, path_template)[source]#
A template used to create compiled routes for specific parameters.
These compiled routes are used to identify rate limit buckets. Compiled routes may have a single major parameter.
- major_params: Optional[FrozenSet[str]][source]#
The optional major parameter name combination for this endpoint.
- compile(**kwargs)[source]#
Generate a formatted
CompiledRoute
for this route.This takes into account any URL parameters that have been passed.
- Parameters
- **kwargs
typing.Any
Any parameters to interpolate into the route path.
- **kwargs
- Returns
CompiledRoute
The compiled route.
- class hikari.internal.routes.CDNRoute[source]#
Route implementation for a CDN resource.
- compile(base_url, *, file_format, size=None, **kwargs)[source]#
Generate a full CDN url from this endpoint.
- Parameters
- base_url
str
The base URL for the CDN. The generated route is concatenated onto this.
- file_format
str
The file format to use for the asset.
- size
typing.Optional
[int
] The custom size query parameter to set. If
None
, it is not passed.- **kwargs
typing.Any
Parameters to interpolate into the path template.
- base_url
- Returns
str
The full asset URL.
- Raises
TypeError
If a GIF is requested, but the asset is not animated; if an invalid file format for the endpoint is passed; or if a
size
is passed but the route is not sizable.ValueError
If
size
is specified, but is not an integer power of2
between16
and4096
inclusive or is negative.