swimlane.core.resources.record module

class swimlane.core.resources.record.Record(*args, **kwargs)[source]

Bases: APIResource

A single Swimlane Record instance

id

Full Record ID

Type:

str

tracking_id

Record tracking ID

Type:

str

created

Pendulum datetime for Record created date

Type:

pendulum.DateTime

modified

Pendulum datetime for Record last modified date

Type:

pendulum.DateTime

is_new

True if Record does not yet exist on server. Other values may be temporarily None if True

Type:

bool

app

App instance that Record belongs to

Type:

App

add_restriction(*usergroups)[source]

Add UserGroup(s) to list of accounts with access to record

New in version 2.16.1.

UserGroups already in the restricted list can be added multiple times and duplicates will be ignored

Notes:

Parameters:

*usergroups (UserGroup) – 1 or more Swimlane UserGroup(s) to add to restriction list

Raises:

TypeError – If 0 UserGroups provided or provided a non-UserGroup instance

property app
delete()[source]

Delete record from Swimlane server

New in version 2.16.1.

Resets to new state, but leaves field data as-is. Saving a deleted record will create a new Swimlane record

Raises

ValueError: If record.is_new

execute_task(task_name, timeout=20)[source]
for_json(*field_names)[source]

Returns json.dump()-compatible dict representation of the record

New in version 4.1.

Useful for resolving any Cursor, datetime/Pendulum, etc. field values to useful formats outside of Python

Parameters:

*field_names (str) – Optional subset of field(s) to include in returned dict. Defaults to all fields

Raises:

UnknownField – Raised if any of field_names not found in parent App

Returns:

field names -> JSON compatible field values

Return type:

dict

get_cache_index_keys()[source]

Return values available for retrieving records, but only for already existing records

get_field(field_name)[source]

Get field instance used to get, set, and serialize internal field value

Parameters:

field_name (str) – Field name or key to retrieve

Returns:

Requested field instance

Return type:

Field

Raises:

UnknownField – Raised if field_name not found in parent App

lock()[source]

Lock the record to the Current User.

Notes:

Warnings:

Args:

patch()[source]

Patch record on Swimlane server

Raises

ValueError: If record.is_new, or if comments or attachments are attempted to be patched

remove_restriction(*usergroups)[source]

Remove UserGroup(s) from list of accounts with access to record

New in version 2.16.1.

Notes:

Warning

Providing no UserGroups will clear the restriction list, opening access to ALL accounts

Parameters:

*usergroups (UserGroup) – 0 or more Swimlane UserGroup(s) to remove from restriction list

Raises:
  • TypeError – If provided a non-UserGroup instance

  • ValueError – If provided UserGroup not in current restriction list

property restrictions

Returns cached set of retrieved UserGroups in the record’s list of allowed accounts

save()[source]

Persist record changes on Swimlane server

Updates internal raw data with response content from server to guarantee calculated field values match values on server

Raises:

ValidationError – If any fields fail validation

unlock()[source]

Unlock the record.

Notes:

Warnings:

Args:

validate()[source]

Explicitly validate field data

Notes

Called automatically during save call before sending data to server

Raises:

ValidationError – If any fields fail validation

swimlane.core.resources.record.record_factory(app, fields=None)[source]

Return a temporary Record instance to be used for field validation and value parsing

Parameters:
  • app (App) – Target App to create a transient Record instance for

  • fields (dict) – Optional dict of fields and values to set on new Record instance before returning

Returns:

Unsaved Record instance to be used for validation, creation, etc.

Return type:

Record