REST client API¶
API reference¶
- class atlassian.rest_client.AtlassianRestAPI(url: str, username: str | None = None, password: str | None = None, timeout: int = 75, api_root: str = 'rest/api', api_version: str | int = 'latest', verify_ssl: bool = True, session: Session | None = None, oauth: dict | None = None, oauth2: dict | None = None, cookies: CookieJar | None = None, advanced_mode: bool | None = None, kerberos: object = None, cloud: bool = False, proxies: MutableMapping[str, str] | None = None, token: str | None = None, cert: str | Tuple[str, str] | None = None, backoff_and_retry: bool = False, retry_status_codes: List[int] = [413, 429, 503], max_backoff_seconds: int = 1800, max_backoff_retries: int = 1000, backoff_factor=1.0, backoff_jitter=1.0, retry_with_header=True, header=None)¶
Bases:
object- close() None¶
Close the underlying HTTP session and release its connections.
- default_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}¶
- delete(path: str, data: dict | str | None = None, headers: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, *, advanced_mode: Literal[False]) dict | None¶
- delete(path: str, data: dict | str | None = None, headers: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: Literal[False] = False) dict | None
- delete(path: str, data: dict | str | None = None, headers: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, *, advanced_mode: Literal[True]) Response
- delete(path: str, data: dict | str | None = None, headers: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: bool = False) Response | dict | None
Deletes resources at given paths. :param path: :param data: :param headers: :param params: :param trailing: :param absolute: :param advanced_mode: bool, OPTIONAL: Return the raw response :rtype: dict :return: Empty dictionary to have consistent interface. Some of Atlassian REST resources don’t return any content. If advanced_mode is set - returns raw response.
- experimental_headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'X-ExperimentalApi': 'opt-in'}¶
- experimental_headers_general = {'X-Atlassian-Token': 'no-check', 'X-ExperimentalApi': 'opt-in'}¶
- form_token_headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Atlassian-Token': 'no-check'}¶
- get(path: str, data: dict | str | None = None, flags: list | None = None, params: dict | None = None, headers: dict | None = None, *, not_json_response: Literal[True], trailing: bool | None = None, absolute: bool = False, advanced_mode: Literal[True]) bytes¶
- get(path: str, data: dict | str | None = None, flags: list | None = None, params: dict | None = None, headers: dict | None = None, *, not_json_response: Literal[True], trailing: bool | None = None, absolute: bool = False, advanced_mode: bool = False) bytes
- get(path: str, data: dict | str | None = None, flags: list | None = None, params: dict | None = None, headers: dict | None = None, not_json_response: Literal[False] | None = None, trailing: bool | None = None, absolute: bool = False, *, advanced_mode: Literal[True]) Response
- get(path: str, data: dict | str | None = None, flags: list | None = None, params: dict | None = None, headers: dict | None = None, not_json_response: Literal[False] | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: Literal[False] = False) dict | None
- get(path: str, data: dict | str | None = None, flags: list | None = None, params: dict | None = None, headers: dict | None = None, not_json_response: bool | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: bool = False) Response | dict | None | str | bytes
Get request based on the python-requests module. You can override headers, and also, get not json response :param path: :param data: :param flags: :param params: :param headers: :param not_json_response: OPTIONAL: For get content from raw request’s packet :param trailing: OPTIONAL: for wrap slash symbol in the end of string :param absolute: bool, OPTIONAL: Do not prefix url, url is absolute :param advanced_mode: bool, OPTIONAL: Return the raw response :return:
- log_curl_debug(method: str, url: str, data: dict | str | bool | None = None, headers: dict | None = None, level: int = 10) None¶
- Parameters:
method
url
data
headers
level
- Returns:
- no_check_headers = {'X-Atlassian-Token': 'no-check'}¶
- patch(path: str, data: dict | str | None = None, headers: dict | None = None, files: dict | None = None, trailing: bool | None = None, params: dict | None = None, absolute: bool = False, advanced_mode: bool = False) Response | dict | None¶
- Parameters:
path – Path of request
data
headers – adjusted headers, usually it’s default
files
trailing
params
absolute
advanced_mode – bool, OPTIONAL: Return the raw response
- Returns:
if advanced_mode is not set - returns dictionary. If it is set - returns raw response.
- post(path: str, data: dict | str, *, json: dict | str | None = None, headers: dict | None = None, files: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: Literal[False] = False) dict | None¶
- post(path: str, data: dict | str | None = None, json: dict | str | None = None, headers: dict | None = None, files: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, *, advanced_mode: Literal[False] = False) dict | None
- post(path: str, data: dict | str | None = None, json: dict | str | None = None, headers: dict | None = None, files: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: Literal[False] = False) dict | None
- post(path: str, data: dict | str | None = None, json: dict | str | None = None, headers: dict | None = None, files: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, *, advanced_mode: Literal[True]) Response
- post(path: str, data: dict | str | None = None, json: dict | str | None = None, headers: dict | None = None, files: dict | None = None, params: dict | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: bool = False) Response | dict | None
- Parameters:
path
data
json
headers
files
params
trailing
absolute
advanced_mode – bool, OPTIONAL: Return the raw response
- Returns:
if advanced_mode is not set - returns dictionary. If it is set - returns raw response.
- put(path: str, data: dict | str | bool | None = None, headers: dict | None = None, files: dict | None = None, trailing: bool | None = None, params: dict | None = None, absolute: bool = False, *, advanced_mode: Literal[False]) dict | None¶
- put(path: str, data: dict | str | bool | None = None, headers: dict | None = None, files: dict | None = None, trailing: bool | None = None, params: dict | None = None, absolute: bool = False, advanced_mode: Literal[False] = False) dict | None
- put(path: str, data: dict | str | bool | None = None, headers: dict | None = None, files: dict | None = None, trailing: bool | None = None, params: dict | None = None, absolute: bool = False, *, advanced_mode: Literal[True]) Response
- put(path: str, data: dict | str | bool | None = None, headers: dict | None = None, files: dict | None = None, trailing: bool | None = None, params: dict | None = None, absolute: bool = False, advanced_mode: bool = False) Response | dict | None
- Parameters:
path – Path of request
data
headers – adjusted headers, usually it’s default
files
trailing
params
absolute
advanced_mode – bool, OPTIONAL: Return the raw response
- Returns:
if advanced_mode is not set - returns dictionary. If it is set - returns raw response.
- raise_for_status(response: Response) None¶
Checks the response for errors and throws an exception if return code >= 400 Since different tools (Atlassian, Jira, …) have different formats of returned json, this method is intended to be overwritten by a tool specific implementation. :param response: :return:
- request(method: str = 'GET', path: str = '/', data: dict | str | bool | None = None, json: dict | str | None = None, flags: list | None = None, params: dict | None = None, headers: dict | None = None, files: dict | None = None, trailing: bool | None = None, absolute: bool = False, advanced_mode: bool = False, allow_redirects: bool = True) Response¶
- Parameters:
method
path
data
json
flags
params
headers
files
trailing – bool - OPTIONAL: Add trailing slash to url
absolute – bool, OPTIONAL: Do not prefix url, url is absolute
advanced_mode – bool, OPTIONAL: Return the raw response
- Returns:
- resource_url(resource: str, api_root: str | None = None, api_version: str | int | None = None) str¶
Build a relative REST resource URL from the configured API settings.
- Args:
resource: Endpoint path below the API root and version. api_root: Optional API root overriding the client default. api_version: Optional API version overriding the client default.
- Returns:
Normalized relative REST resource URL.
- response = None¶
- safe_mode_headers = {'Content-Type': 'application/vnd.atl.plugins.safe.mode.flag+json', 'X-Atlassian-Token': 'no-check'}¶
- property session: Session¶
Providing access to the restricted field
- static url_joiner(url: str | None, path: str, trailing: bool | None = None) str¶
Join URL components without duplicate slashes.
- Args:
url: Base URL or relative path. path: Path to append. trailing: Whether to add a trailing slash.
- Returns:
Normalized joined URL.