rbtools.api.transport.sync¶
Classes
|
A synchronous transport layer for the API client. |
- class rbtools.api.transport.sync.SyncTransport(url: str, cookie_file: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, api_token: Optional[str] = None, agent: Optional[str] = None, session: Optional[str] = None, disable_proxy: bool = False, auth_callback: Optional[Callable[[...], Tuple[str, str]]] = None, otp_token_callback: Optional[Callable[[str, str], str]] = None, verify_ssl: bool = True, allow_caching: bool = True, cache_location: Optional[str] = None, in_memory_cache: bool = False, save_cookies: bool = True, ext_auth_cookies: Optional[str] = None, ca_certs: Optional[str] = None, client_key: Optional[str] = None, client_cert: Optional[str] = None, proxy_authorization: Optional[str] = None, *args, **kwargs)[source]¶
Bases:
Transport
A synchronous transport layer for the API client.
The file provided in cookie_file is used to store and retrieve the authentication cookies for the API.
The optional agent parameter can be used to specify a custom User-Agent string for the API. If not provided, the default RBTools User-Agent will be used.
The optional session can be used to specify an ‘rbsessionid’ to use when authenticating with reviewboard.
- __init__(url: str, cookie_file: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, api_token: Optional[str] = None, agent: Optional[str] = None, session: Optional[str] = None, disable_proxy: bool = False, auth_callback: Optional[Callable[[...], Tuple[str, str]]] = None, otp_token_callback: Optional[Callable[[str, str], str]] = None, verify_ssl: bool = True, allow_caching: bool = True, cache_location: Optional[str] = None, in_memory_cache: bool = False, save_cookies: bool = True, ext_auth_cookies: Optional[str] = None, ca_certs: Optional[str] = None, client_key: Optional[str] = None, client_cert: Optional[str] = None, proxy_authorization: Optional[str] = None, *args, **kwargs) None [source]¶
Initialize the transport.
- Parameters:
url (
str
) – The URL of the Review Board server.cookie_file (
str
, optional) – The name of the file to store authentication cookies in.username (
str
, optional) – The username to use for authentication.password (
str
, optional) – The password to use for authentication.api_token (
str
, optional) – An API token to use for authentication. If present, this is preferred over the username and password.agent (
str
, optional) – A User-Agent string to use for the client. If not specified, the default RBTools User-Agent will be used.session (
str
, optional) – Anrbsessionid
string to use for authentication.disable_proxy (
bool
) – Whether to disable HTTP proxies.auth_callback (
callable
, optional) – A callback method to prompt the user for a username and password.otp_token_callback (
callable
, optional) – A callback method to prompt the user for their two-factor authentication code.verify_ssl (
bool
, optional) – Whether to verify SSL certificates.allow_caching (
bool
, optional) – Whether to cache the result of HTTP requests.cache_location (
str
, optional) – The filename to store the cache in, if using a persistent cache.in_memory_cache (
bool
, optional) – Whether to keep the cache data in memory rather than persisting to a file.save_cookies (
bool
, optional) – Whether to save authentication cookies.ext_auth_cookies (
str
, optional) – The name of a file to load additional cookies from. These will be layered on top of any cookies loaded fromcookie_file
.ca_certs (
str
, optional) – The name of a file to load certificates from.client_key (
str
, optional) – The key for a client certificate to load into the chain.client_cert (
str
, optional) – A client certificate to load into the chain.proxy_authorization (
str
, optional) – A string to use for theProxy-Authorization
header.*args (
tuple
) – Positional arguments to pass to the base class.**kwargs (
dict
) – Keyword arguments to pass to the base class.
- 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.
- 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.
Either a username and password combination or an API token must be provided.
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:
- Raises:
ValueError – No username and password or API token was provided.
- execute_request_method(method: Callable, *args, **kwargs) Any [source]¶
Execute a method and return the resulting resource.
- 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: