rbtools.api.transport¶
Base class for API Transport layers.
Classes
|
Base class for API Transport layers. |
- class rbtools.api.transport.Transport(url: str, *args, **kwargs)[source]¶
Bases:
objectBase class for API Transport layers.
An API Transport layer acts as an intermediary between the API user and the Resource objects. All access to a resource’s data, and all communication with the Review Board server are handled by the Transport. This allows for Transport implementations with unique interfaces which operate on the same underlying resource classes. Specifically, this allows for both a synchronous, and an asynchronous implementation of the transport.
- __annotations_cache__ = {}¶
- __firstlineno__ = 14¶
- __static_attributes__ = ('url',)¶
- enable_cache(cache_location: str | None = None, in_memory: bool = False) None[source]¶
Enable caching for all future HTTP requests.
The cache will be created at the default location if none is provided.
If the in_memory parameter is True, the cache will be created in memory instead of on disk. This overrides the cache_location parameter.
- execute_request_method(method: Callable[..., Any], *args, **kwargs) Any[source]¶
Execute a method and carry out the returned HttpRequest.
- Parameters:
- Returns:
If the method returns an HttpRequest, this will construct a resource from that. If it returns another value, that value will be returned directly.
- Return type:
rbtools.api.resource.Resourceorobject
- get_path(path: str, *args, **kwargs) Resource[source]¶
Return the API resource at the provided path.
- Parameters:
- Returns:
The resource at the given path.
- Return type:
rbtools.api.resource.Resource
- get_root(*args, **kwargs) RootResource[source]¶
Return the root API resource.
- get_url(url: str, *args, **kwargs) Resource[source]¶
Return the API resource at the provided URL.
The URL is not guaranteed to be part of the configured Review Board domain.
- Parameters:
- Returns:
The resource at the given path.
- Return type:
rbtools.api.resource.Resource
- has_session_cookie() bool[source]¶
Return whether a local session cookie exists for this server.
This does not guarantee that the session is valid server-side (the cookie may be stale), this just returns whether a local session cookie has been set for this server.
Added in version 6.0.
- Returns:
Whether a local session cookie exists for this server.
- Return type:
- login(username: str | None = None, password: str | None = None, api_token: str | None = None, *args, **kwargs) None[source]¶
Log in to the Review Board server.
Changed in version 5.0: Added an optional
api_tokenparameter and made theusernameandpasswordparameters optional to allow logging in with either a username and password or API token.- Parameters:
username (
str, optional) – The username to log in with.password (
str, optional) – The password to log in with.api_token (
str, optional) – The API token to log in with.*args (
tuple, unused) – Positional arguments (may be used by the transport implementation).**kwargs (
dict, unused) – Keyword arguments (may be used by the transport implementation).