pydent.models.data_associations.DataAssociatorMixin

class pydent.models.data_associations.DataAssociatorMixin[source]

Bases: object

Mixin for handling data associations.

__init__()

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

Methods

__init__

Initialize self.

associate(key, value[, upload, create_new, save])

Adds a data association with the key and value to this object.

associate_file(key, value, file[, job_id])

Associate a file.

associate_file_from_path(key, value, filepath)

Associate a file from a filepath.

get(key)

get_data_associations(key)

associate(key, value, upload=None, create_new=False, save=None)[source]

Adds a data association with the key and value to this object.

Parameters
  • key (str) – Key of the association

  • value (dict | str | int | float) – a json serializable object

  • upload (File) – optional file to upload

  • create_new – if True (default) will create a new association instead of updating the existing association.

Tuype create_new

bool

Returns

newly created or updated data association

Return type

DataAssociation

associate_file(key, value, file, job_id=None)[source]

Associate a file.

Parameters
  • key (str or json) – association key

  • value (str or json) – association value

  • file (file object) – file to create Upload

  • job_id (int) – optional job_id to associate the Upload

Returns

new data association

Return type

DataAssociation

associate_file_from_path(key, value, filepath, job_id=None)[source]

Associate a file from a filepath.

Parameters
  • key (str or json) – association key

  • value (str or json) – association value

  • filepath (str) – path to file to create Upload

  • job_id (int) – optional job_id to associate the Upload

Returns

new data association

Return type

DataAssociation