accsyn_api.session

class accsyn_api.session.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

JSON serialiser.

default(obj: Any) → Any[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
__init__(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (’, ‘, ‘: ‘) if indent is None and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.

If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

encode(o)[source]

Return a JSON string representation of a Python data structure.

>>> from json.encoder import JSONEncoder
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo": ["bar", "baz"]}'
item_separator = ', '
iterencode(o, _one_shot=False)[source]

Encode the given object and yield each string representation as available.

For example:

for chunk in JSONEncoder().iterencode(bigobject):
    mysocket.write(chunk)
key_separator = ': '
class accsyn_api.session.JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]

JSON deserialize.

decode(json_string: str) → Any[source]

Return the Python representation of s (a str instance containing a JSON document).

__init__(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]

object_hook, if specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given dict. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting).

object_pairs_hook, if specified will be called with the result of every JSON object decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders. If object_hook is also defined, the object_pairs_hook takes priority.

parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).

parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).

parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.

If strict is false (true is the default), then control characters will be allowed inside strings. Control characters in this context are those with character codes in the 0-31 range, including '\t' (tab), '\n', '\r' and '\0'.

raw_decode(s, idx=0)[source]

Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended.

This can be used to decode a JSON document from a string that may have extraneous data at the end.

class accsyn_api.session.Session(workspace: Optional[str, None] = None, username: Optional[str, None] = None, api_key: Optional[str, None] = None, hostname: Optional[str, None] = None, port: Optional[int, None] = None, proxy: Optional[str, None] = None, verbose: bool = False, pretty_json: bool = False, path_logfile: Optional[str, None] = None, timeout: Optional[int, None] = None, connect_timeout: Optional[int, None] = None, domain: Optional[str, None] = None, path_envfile: Optional[str, None] = None)[source]

accsyn API session object.

DEFAULT_CONNECT_TIMEOUT = 10
DEFAULT_TIMEOUT = 120
username
timeout
connect_timeout
__init__(workspace: Optional[str, None] = None, username: Optional[str, None] = None, api_key: Optional[str, None] = None, hostname: Optional[str, None] = None, port: Optional[int, None] = None, proxy: Optional[str, None] = None, verbose: bool = False, pretty_json: bool = False, path_logfile: Optional[str, None] = None, timeout: Optional[int, None] = None, connect_timeout: Optional[int, None] = None, domain: Optional[str, None] = None, path_envfile: Optional[str, None] = None) → None[source]

Initiate a new API session object. Throws exception upon authentication failure.

Parameters:
  • workspace – The accsyn workspace code (or read from ACCSYN_WORKSPACE environment variable)
  • username – The accsyn username (or read from ACCSYN_API_USER environment variable)
  • api_key – The secret API key for authentication (or read from ACCSYN_API_KEY environment variable)
  • hostname – Override the hostname/IP of the workspace to connect to.
  • port – Override default port (443/TCP)
  • proxy – The proxy settings (or read from ACCSYN_PROXY environment variable).
  • verbose – Printing verbose debugging output to stdout.
  • pretty_json – (verbose) Print pretty formatted JSON.
  • path_logfile – Output all log messages to this logfile instead of stdout.
  • timeout – Timeout in seconds for API calls - waiting for response.
  • connect_timeout – Timeout in seconds for API calls - waiting for connection.
  • domain – (Backward compatibility) The accsyn domain (or read from ACCSYN_DOMAIN environment variable)
  • path_envfile – Path to .env file to load credentials from (or read from ACCSYN_CREDENTIALS_PATH environment variable)

Deprecated since version 3.1.0: Use the :param workspace: parameter instead

static get_hostname() → str[source]
Returns:The hostname of this computer.
get_last_message() → Optional[str, None][source]

Retreive error message from last API call.

create(entitytype: str, data: Union[str, Dict[str, Any], List[Dict[str, Any]]], entityid: Optional[str, None] = None, allow_duplicates: Optional[bool, None] = None, replace_duplicates: Optional[bool, None] = None) → Union[Dict[str, Any], List[Dict[str, Any]]][source]

Create a new accsyn entity.

Parameters:
  • entitytype – The type of entity to create (job, share, acl)
  • data – The entity data as a dictionary.
  • entityid – For creating sub entities (tasks), this is the parent (job) id.
  • allow_duplicates – (jobs and tasks) Allow duplicate tasks (same uri), will ignore the provided task and retry the existing task instead.
  • replace_duplicates – (jobs and tasks) Do not retry the existing task, replace duplicate tasks (same uri) with the new one instead.
Returns:

The created entity data, as dictionary.

find(query: str, entityid: Optional[str, None] = None, attributes: Optional[List[str], None] = None, finished: Optional[bool, None] = None, inactive: Optional[bool, None] = None, offline: Optional[bool, None] = None, archived: Optional[bool, None] = None, limit: Optional[int, None] = None, skip: Optional[int, None] = None, create: bool = False, update: bool = False, single_entity_query: bool = False) → Optional[List[Dict[str, Any]], None][source]

Return (GET) a list of entities/entitytypes/attributes based on query.

Parameters:
  • query – The query, a string on accsyn query format.
  • entityid – The parent entity ID, required for sub entities “task” and “file”.
  • attributes – The attributes to return, default is to return all attributes with access.
  • finished – (job) Search among finished/aborted jobs.
  • inactive – (user,share) Search among inactive entities.
  • offline – (user,share) Search among offline entities. (Deprecated)
  • archived – Search among archived (deleted/purged) entities.
  • limit – The maximum amount of entities to return.
  • skip – The amount of entities to skip.
  • create – (attributes) Return create (POST) attributes.
  • update – (attributes) Return update (PUT) attributes.
  • single_entity_query – It is a single entity query, tell backend to be more relaxed regarding status scope.
Returns:

List of dictionaries.

find_one(query: str, entityid: Optional[str, None] = None, attributes: Optional[List[str], None] = None, finished: Optional[bool, None] = None, inactive: Optional[bool, None] = None, offline: Optional[bool, None] = None, archived: Optional[bool, None] = None) → Optional[Dict[str, Any], None][source]

Return a single entity.

Parameters:
  • query – The query, a string on accsyn query format.
  • entityid – The parent entity ID, required for sub entities “task” and “file”.
  • attributes – The attributes to return, default is to return all attributes with access.
  • finished – (job) Search among finished/aborted jobs.
  • inactive – (user,share) Search among inactive entities.
  • offline – (user,share) Search among offline entities. (Deprecated)
  • archived – Search among archived (purged/deleted) entities.
Returns:

If found, a single dictionary. None otherwise.

get_entity(entitytype: str, entityid: str) → Optional[Dict[str, Any], None][source]

Return an entity by its entitytype and entityid, regardless if it is inactive or archived.

Parameters:
  • entitytype – The type of entity to return (job, share, acl, ..)
  • entityid – The id of the entity.
Returns:

If found, a single dictionary. None otherwise.

report(query: str) → str[source]

(Support) Return an internal backend report of an entity.

Parameters:query – The query, a string on accsyn query format.
Returns:A text string containing the human readable report.
metrics(query: str, attributes: Optional[List[str], None] = None, time: Optional[str, None] = None) → Dict[str, Any][source]

Return metrics for an entity (job)

New in version 2.0.

Parameters:
  • query
  • attributes
  • time
Returns:

update(entitytype: str, entityid: str, data: Dict[str, Any]) → Optional[Dict[str, Any], None][source]

Update/modify an entity.

Parameters:
  • entitytype – The type of entity to update (job, share, acl, ..)
  • entityid – The entity ID of the parent entity to update (job).
  • data – The dictionary containing attributes to update.
Returns:

The updated entity data, as dictionary.

update_one(entitytype: str, entityid: str, data: Dict[str, Any]) → Optional[Dict[str, Any], None][source]

Update/modify an entity.

Parameters:
  • entitytype – The type of entity to update (job, share, acl, ..)
  • entityid – The id of the entity.
  • data – The dictionary containing attributes to update.
Returns:

The updated entity data, as dictionary

Deprecated since version 2.0.2: Since version 2.0.2 you should use the update() function instead

update_many(entitytype: str, entityid: str, data: List[Dict[str, Any]]) → Optional[List[Dict[str, Any]], None][source]

Update/modify multiple entities - tasks beneath a job.

Parameters:
  • entitytype – The type of parent entity to update (job)
  • entityid – The id of the parent entity job to update
  • data – The list dictionaries containing sub entity (task) id and attributes to update.
Returns:

The updated sub entities (tasks), as dictionaries.

Changed in version 3.2.0: The entityid and data parameters have switched places.

assign(entitytype_parent: str, entitytype: str, data: Dict[str, Any]) → bool[source]

Assign one entity to another.

New in version 2.0.

Parameters:
  • entitytype_parent – The parent entity type to assign entity to.
  • entitytype_other – The entity type to assign to parent entity.
  • data – Assignment data, should contain parent entity id and entity ids.
Returns:

True if assignment was a success, exception otherwise.

assignments(entitytype: str, entityid: str) → List[Dict[str, Any]][source]

Return list of assigned entities.

This can be used to list servers assigned to a volume.

New in version 2.0.

Parameters:query
Returns:List of dictionaries.
deassign(entitytype_parent: str, entitytype: str, data: Dict[str, Any]) → bool[source]

De-assign one entity from another.

New in version 2.0.

Parameters:
  • entitytype_parent – The parent entity type to deassign entity from
  • entitytype – The entity type to deassign from parent entity
  • data – De-assignment data, should contain parent entity id and entity ids + additional information as required
Returns:

True if deassignment was a success, exception otherwise.

grant(entitytype: str, entityid: str, targettype: str, targetid: str, data: Dict[str, Any] = None) → bool[source]

Grant access to an entity.

New in version 3.2.

Parameters:
  • entitytype – The entity type that should be granted access.
  • entityid – The id of the entity that should be granted access.
  • targettype – The entity type to grant access to.
  • targetid – The id of the entity to grant access to.
  • data – ACL data, should permissions and other data.
Returns:

True if assignment was a success, exception otherwise.

access(targettype: str, targetid: str, recursive: bool = False) → List[Dict[str, Any]][source]

Return list of ACLs for an entity.

This can be used to list user with access to a delivery or a share (volume, folder, home, collection).

New in version 3.2.

Parameters:
  • targettype – The entity type to list access for (delivery, volume, folder, home, collection).
  • targetid – The id of the entity to list access for.
  • recursive – If True, list ACLs for all shares beneath the target volume, folder or home.
Returns:

List of dictionaries.

revoke(entitytype: str, entityid: str, targettype: str, targetid: str) → bool[source]

Revoke access to an entity.

New in version 3.2.

Parameters:
  • entity – The entity type to revoke access for.
  • entityid – The id of the entity to revoke access for.
  • target – The entity type to revoke access from.
  • targetid – The id of the entity to revoke access from.
  • data – ACL data, should contain parent entity id and entity ids.
Returns:

True if revocation was a success, exception otherwise.

offline_one(entitytype: str, entityid: str) → Any[source]

Deactivate an entity - remove from accsyn but keep in database for audit/later restoration.

Deprecated since version 3.2.0: Use the deactivate_one() function instead

deactivate_one(entitytype: str, entityid: str) → Any[source]

Deactivate an entity - remove from accsyn but keep in database for audit/later restoration.

New in version 3.2.

Parameters:
  • entitytype – The type of entity to delete (job, share, acl, ..)
  • entityid – The id of the entity.
Returns:

True if offline, an exception is thrown otherwise.

delete_one(entitytype: str, entityid: str, data: Dict[str, Any] = None) → Any[source]

Delete(archive) an entity.

Parameters:
  • entitytype – The type of entity to delete (job, share, acl, ..)
  • entityid – The id of the entity.
  • data – (Optional) The dictionary containing additional delete options, such as force=True to delete even if there are active related entities.
Returns:

True if deleted, an exception is thrown otherwise.

delete_many(entitytype: str, entityid: str, data: Dict[str, Any]) → Any[source]

Delete multiple sub entities (files) beneath a parent entity.

Parameters:
  • entitytype – The type of parent entity to delete (job)
  • entityid – The id of the parent entity job to delete
  • data – The dictionary containing attributes to delete.
Returns:

True if deleted, an exception is thrown otherwise.

activate_one(entitytype: str, entityident: str) → Any[source]

Activate an entity - bring back from deactivated(offline) state.

ls(path: Union[str, Dict[str, Any], List[str]], recursive: bool = False, maxdepth: Optional[int, None] = None, getsize: bool = False, files_only: bool = False, directories_only: bool = False, include: Union[str, List[str], None] = None, exclude: Union[str, List[str], None] = None) → Optional[Dict[str, Any], None][source]

List files on a share.

Parameters:
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’
  • recursive – If True - a recursive listing will be performed.
  • maxdepth – (Recursive) The maximum depth to descend.
  • getsize – If True - file sizes will be returned.
  • files_only – If True - only return files, no directories.
  • directories_only – If True - only return directories, no files.
  • include – Filter expression (string or list) dictating what to include in result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(’…’)” - regular expression. Has precedence over exclude.
  • exclude – Filter expression (string or list) dictating what to exclude from result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(’…’)” - regular expression.
Returns:

A dictionary containing result of file listing.

Include and exclude filters are case-insensitive, to make regular expression case-sensitive, use the following syntax: “re(’…’, ‘I’)”.

New in version 2.2.0: (app/daemon: 2.6-20)

getsize(path: Union[str, Dict[str, Any], List[str]], include: Union[str, List[str], None] = None, exclude: Union[str, List[str], None] = None) → Optional[Dict[str, Any], None][source]

Get size of a file or directory.

Parameters:
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.
  • include – Filter expression (string or list) dictating what to include in result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(’…’)” - regular expression. Has precedence over exclude.
  • exclude – Filter expression (string or list) dictating what to exclude from result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(’…’)” - regular expression.
Returns:

A dictionary containing result of file listing.

Include and exclude filters are case-insensitive, to make regular expression case-sensitive, use the following syntax: “re(’…’, ‘I’)”.

New in version 2.2.0: (app/daemon: 2.6-20)

exists(path: Union[str, Dict[str, Any], List[str]]) → Optional[bool, None][source]

Check if a file or directory exists.

Parameters:path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.
Returns:True if file exists, False otherwise.
mkdir(path: Union[str, Dict[str, Any], List[str]]) → Optional[Any, None][source]

Create a directory on a share.

New in version 2.0.

Parameters:path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.
Returns:True if file exists, False otherwise.
rename(path: Union[str, Dict[str, Any], List[str]], path_to: Union[str, Dict[str, Any], List[str]]) → Optional[Any, None][source]

Rename a file/directory on a share.

New in version 2.0.

Parameters:
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.
  • path_to – The new accsyn path, has to be within the same directory as source path, on the form ‘share=<the share>/<path>/<somewhere>’.
Returns:

True if file exists, False otherwise.

mv(path_src: Union[str, Dict[str, Any], List[str]], path_dst: Union[str, Dict[str, Any], List[str]]) → Optional[Any, None][source]

Move a file/directory on a share.

New in version 2.0.

Parameters:
  • path_src – The accsyn source path, on the form ‘share=<the share>/<path>/<somewhere>’.
  • path_dst – The accsyn destination path, on the form ‘share=<the share>/<path>/<somewhere>’.
Returns:

True if file exists, False otherwise.

delete(path: Union[str, Dict[str, Any], List[str]], force: bool = False) → Optional[Any, None][source]

Delete a file/directory on a share.

New in version 2.0.

Parameters:
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.
  • force – Force removal of non-empty directory.
Returns:

True if file exists, False otherwise.

prepublish(data: List[Dict[str, Any]]) → Dict[str, Any][source]

Pre-process a publish.

Parameters:data – The pre publish data, see documentation.
Returns:Processed publish data, see documentation.
get_setting(name: Optional[str, None] = None, entitytype: str = 'workspace', entityid: Optional[str, None] = None, integration: Optional[str, None] = None, data: Optional[Dict[str, Any], None] = None) → Optional[Any, None][source]

Retrive name setting value for the given entitytype (workspace, job, volume, user, queue, …) and entityid or integration (ftrack,..).

Parameters:
  • name – Setting name.
  • entitytype – Entity type (workspace, job, volume, user, queue, …).
  • entityid – Entity ID (None for workspace entity type).
  • integration – Integration name (ftrack, ..).
  • data – Additional data to include in the request.
Returns:

Setting value.

get_settings(entitytype: Optional[str, None] = None, entityid: Optional[str, None] = None, recursive: bool = False, upstream: bool = False, omit_defaults: bool = True, share: Optional[str, None] = None) → Dict[str, Any][source]

Return settings JSON for an entity.

Parameters:
  • entitytype – Optional entity type (workspace, job, volume, user, queue, …), defaults to ‘workspace’.
  • entityid – Optional entity ID, defaults to None.
  • recursive – Include recursive settings lookup (for share trees, etc).
  • upstream – Include inherited/upstream/default settings.
  • omit_defaults – Omit unchanged defaults from response.
  • share – Optional share ID/code used by some settings lookups.
Returns:

Settings as a JSON-compatible dictionary.

set_setting(entitytype: str, name: str, value: any, entityid: Optional[str, None] = None) → bool[source]

Set a setting for an entity.

Changed in version 3.2: Simplified to a single signature: set_setting(entitytype, entityid, name, value). Legacy compatibility argument patterns were removed.

Parameters:
  • entitytype – Entity type (workspace, job, volume, user, queue, …)
  • name – Setting name.
  • value – Setting value, must be of string type. Dictionaries are supported, but must be converted to JSON string first. Serialise dates to ISO 8601 strings.
  • entityid – Optional entity ID (None for workspace entity type, otherwise required).
Returns:

True if setting was updated.

delete_setting(entitytype: str, name: str, entityid: Optional[str, None] = None) → bool[source]

Delete a setting for an entity.

Parameters:
  • entitytype – Entity type (workspace, job, volume, user, queue, …)
  • name – Setting name.
  • entityid – Optional entity ID (None for workspace entity type, otherwise required).
Returns:

True if setting was deleted.

logs(entitytype: Optional[str, None] = None, entityid: Optional[str, None] = None, search: Optional[str, None] = None, sort: str = 'date', sort_reverse: bool = False, pagination_page: Optional[int, None] = None, pagination_limit: Optional[int, None] = None, pagination_skip: Optional[int, None] = None) → Dict[str, Any][source]

Return backend disk logs for an entity scope.

Parameters:
  • entitytype – Optional entity type/scope (workspace, job, user, …), defaults to ‘workspace’.
  • entityid – Optional entity ID reference used for entity-specific logs.
  • search – Optional free text search string to filter log rows.
  • sort – Optional sort key, defaults to ‘date’.
  • sort_reverse – Reverse sort order when True.
  • pagination_page – Optional pagination page number.
  • pagination_limit – Optional pagination page size.
  • pagination_skip – Optional pagination skip/offset.
Returns:

Raw backend response dictionary, always containing result and optionally additional metadata.

get_api_key() → str[source]

Fetch API key, by default disabled in backend.

gui_is_running() → Optional[bool, None][source]

Backward compability

app_is_running() → Optional[bool, None][source]

Check if the accsyn desktop app is running on the same machine (code/hostname match) and with same user ID.

Equivalent to do client query with user, code and type.

Returns:True if found, False otherwise.
server_is_running() → Optional[bool, None][source]

Backward compatibility

daemon_is_running() → Optional[bool, None][source]

Check if a daemon is running on the same machine (code/hostname match) with same user ID.

Equivalent to do client query with user, code and type.

Returns:True if found, False otherwise.
integration(name: str, operation: str, data: Dict[str, Any]) → Any[source]

Make an integration utility call for integration pointed out by name and providing the operation as string and data as a dictionary

help() → None[source]
static str(d: Optional[Dict[str, Any], None], indent: int = 4) → str[source]

Return a string representation of an dictionary.

Deprecated since version 3.2.0: Use the dump() function instead

static dump(d: Optional[Dict[accsyn_api.session.Session.str, Any], None], indent: int = 4) → accsyn_api.session.Session.str[source]

Return a string representation of an dictionary.

Changed in version 3.2.0: Was ‘str’ function.

Parameters:
  • d – The dictionary to dump.
  • indent – The number of spaces to indent the output.
Returns:

A string representation of the dictionary.

exception accsyn_api.session.AccsynException(message: str)[source]
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__init__(message: str) → None[source]

Initialize self. See help(type(self)) for accurate signature.