rbtools.api.transport¶
Classes
|
Base class for API Transport layers. |
- class rbtools.api.transport.Transport(url: str, *args, **kwargs)[source]¶
Bases:
object
Base 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.
- get_root(*args, **kwargs) Optional[RootResource] [source]¶
Return the root API resource.
- Parameters:
- Returns:
The root API resource.
- Return type:
- get_path(path: str, *args, **kwargs) Optional[Resource] [source]¶
Return the API resource at the provided path.
- Parameters:
- Returns:
The resource at the given path.
- Return type:
- get_url(url: str, *args, **kwargs) Optional[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:
- login(username: Optional[str] = None, password: Optional[str] = None, api_token: Optional[str] = None, *args, **kwargs) None [source]¶
Log in to the Review Board server.
Changed in version 5.0: Added an optional
api_token
parameter and made theusername
andpassword
parameters 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).
- execute_request_method(method: Callable, *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:
- enable_cache(cache_location: Optional[str] = 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.