rbtools.api.client¶
Main client used to talk to a Review Board server’s API.
Classes
|
Main client used to talk to a Review Board server's API. |
|
Options for a client's use of web-based login. |
- class rbtools.api.client.RBClient(url: str, transport_cls: type[Transport] = <class 'rbtools.api.transport.sync.SyncTransport'>, *args, web_login_options: RBClientWebLoginOptions | None = None, **kwargs)[source]¶
Bases:
objectMain client used to talk to a Review Board server’s API.
This provides methods used to authenticate with a Review Board API and perform API requests.
Clients make use of a transport class for all server communication. This handles all HTTP-related state and communication, and can be used to mock, intercept, or alter the way in which clients talk to Review Board.
Most methods wrap methods on the transport, which may change how arguments are provided and data is returned. With the default sync transport, no additional arguments are provided in any
*argsor**kwargs, and results are returned directly from the methods.- __firstlineno__ = 37¶
- __init__(url: str, transport_cls: type[Transport] = <class 'rbtools.api.transport.sync.SyncTransport'>, *args, web_login_options: RBClientWebLoginOptions | None = None, **kwargs) None[source]¶
Initialize the client.
- Parameters:
url (
str) – The URL of the Review Board server.transport_cls (
type, optional) – The type of transport to use for communicating with the server.*args (
tuple) – Positional arguments to pass to the transport.web_login_options (
rbtools.api.client.RBClientWebLoginOptions, optional) –Options for web-based login.
This will determine if and how web-based login is used to authenticate the client.
Added in version 6.0.
**kwargs (
dict) – Keyword arguments to pass to the transport.
- __static_attributes__ = ('_transport', 'domain', 'url', 'user_agent', 'web_login_options')¶
- get_path(path: str, *args, **kwargs) Resource | None[source]¶
Return the API resource at the given path.
- Parameters:
path (
str) – The path relative to the Review Board server URL.*args (
tuple) – Positional arguments to pass to the transport’sget_path().**kwargs (
dict) – Keyword arguments to pass to the transport’sget_path().
- Returns:
The resource at the given path.
- Return type:
rbtools.api.resource.Resource- Raises:
rbtools.api.errors.APIError – The API returned an error. Details are in the error object.
rbtools.api.errors.ServerInterfaceError – There was a non-API error communicating with the Review Board server. The URL may have been invalid. The reason is in the exception’s message.
- get_root(*args, **kwargs) RootResource[source]¶
Return the root resource of the API.
- Parameters:
*args (
tuple) – Positional arguments to pass to the transport’sget_root().**kwargs (
dict) – Keyword arguments to pass to the transport’sget_root().
- Returns:
The root API resource.
- Return type:
rbtools.api.resource.Resource- Raises:
rbtools.api.errors.APIError – The API returned an error. Details are in the error object.
rbtools.api.errors.ServerInterfaceError – There was a non-API error communicating with the Review Board server. The URL may have been invalid. The reason is in the exception’s message.
- get_url(url: str, *args, **kwargs) Resource | None[source]¶
Return the API resource at the given URL.
- Parameters:
- Returns:
The resource at the given path.
- Return type:
rbtools.api.resource.Resource- Raises:
rbtools.api.errors.APIError – The API returned an error. Details are in the error object.
rbtools.api.errors.ServerInterfaceError – There was a non-API error communicating with the Review Board server. The URL may have been invalid. The reason is in the exception’s message.
- 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(*args, **kwargs) None[source]¶
Log in to the Review Board server.
- Parameters:
- Raises:
rbtools.api.errors.APIError – The API returned an error. Details are in the error object.
rbtools.api.errors.ServerInterfaceError – There was a non-API error communicating with the Review Board server. The URL may have been invalid. The reason is in the exception’s message.
- logout(*args, **kwargs) None[source]¶
Log out from the Review Board server.
- Parameters:
- Returns:
The return value from
logout().- Return type:
- Raises:
rbtools.api.errors.APIError – The API returned an error. Details are in the error object.
rbtools.api.errors.ServerInterfaceError – There was a non-API error communicating with the Review Board server. The URL may have been invalid. The reason is in the exception’s message.
- web_login_options: RBClientWebLoginOptions | None¶
Options for web-based login.
This will determine if and how web-based login is used to authenticate the client.
Added in version 6.0.
- class rbtools.api.client.RBClientWebLoginOptions(allow: bool, debug: bool, open_browser: bool)[source]¶
Bases:
objectOptions for a client’s use of web-based login.
This can be set on
RBClientto dictate if and how web-based login is used to authenticate the client.Added in version 6.0.
- __dataclass_fields__ = {'allow': Field(name='allow',type='bool',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'debug': Field(name='debug',type='bool',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'open_browser': Field(name='open_browser',type='bool',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)¶
- __eq__(other)¶
Return self==value.
- __firstlineno__ = 16¶
- __hash__ = None¶
- __match_args__ = ('allow', 'debug', 'open_browser')¶
- __replace__(**changes)¶
- __repr__()¶
Return repr(self).
- __static_attributes__ = ()¶