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[Resource] [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: str, password: str, *args, **kwargs) None [source]¶
Log in to the Review Board server.
- 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.