swimlane.core.adapters.record module

class swimlane.core.adapters.record.RecordAdapter(app)[source]

Bases: swimlane.core.resolver.AppResolver

Handles retrieval and creation of Swimlane Record resources

bulk_create(*args, **kwargs)[source]

Create and validate multiple records in associated app

Parameters:*records (dict) – One or more dicts of new record field names and values

Notes

Requires Swimlane 2.15+

Validates like create(), but only sends a single request to create all provided fields, and does not return the newly created records

Any validation failures on any of the records will abort the batch creation, not creating any new records

Does not return the newly created records

Examples

Create 3 new records with single request

app.records.bulk_create(
    {'Field 1': 'value 1', ...},
    {'Field 1': 'value 2', ...},
    {'Field 1': 'value 3', ...}
)
Raises:
bulk_delete(*args, **kwargs)[source]

Shortcut to bulk delete records

New in version 2.17.0.

Parameters:*filters_or_records (tuple) or (Record) – Either a list of Records, or a list of filters.

Notes

Requires Swimlane 2.17+

Examples

# Bulk delete records by filter
app.records.bulk_delete(
    ('Field_1', 'equals', value1),
    ('Field_2', 'equals', value2)
)

# Bulk delete by record instances
record1 = app.records.get(tracking_id='APP-1')
record2 = app.records.get(tracking_id='APP-2')
record3 = app.records.get(tracking_id='APP-3')
app.records.bulk_delete(record1, record2, record3)
Returns:Bulk Modify Job ID
Return type:string
bulk_modify(*args, **kwargs)[source]

Shortcut to bulk modify records

New in version 2.17.0.

Parameters:*filters_or_records (tuple) or (Record) – Either a list of Records, or a list of filters.
Keyword Arguments:
 values (dict) – Dictionary of one or more ‘field_name’: ‘new_value’ pairs to update

Notes

Requires Swimlane 2.17+

Examples

# Bulk update records by filter

app.records.bulk_modify(
    # Query filters
    ('Field_1', 'equals', value1),
    ('Field_2', 'equals', value2),
    ...
    # New values for records
    values={
        "Field_3": value3,
        "Field_4": value4,
        ...
    }
)

# Bulk update records

record1 = app.records.get(tracking_id='APP-1')
record2 = app.records.get(tracking_id='APP-2')
record3 = app.records.get(tracking_id='APP-3')

app.records.bulk_modify(record1, record2, record3, values={"Field_Name": 'new value'})
Returns:Bulk Modify Job ID
Return type:string
create(**fields)[source]

Create and return a new record in associated app and return the newly created Record instance

Parameters:**fields – Field names and values to be validated and sent to server with create request

Notes

Keyword arguments should be field names with their respective python values

Field values are validated before sending create request to server

Examples

Create a new record on an app with simple field names

record = app.records.create(
    field_a='Some Value',
    someOtherField=100,
    ...
)

Create a new record on an app with complex field names

record = app.records.create(**{
    'Field 1': 'Field 1 Value',
    'Field 2': 100,
    ...
})
Returns:

Newly created Record instance with data as returned from API response

Return type:

Record

Raises:
create_batch(*args, **kwargs)[source]

Old method name before bulk_create, bulk_modify, and bulk_delete were added

Calls bulk_create() with whatever arguments have been passed and emits a DeprecationWarning

Deprecated since version 2.17.0: Use bulk_create() instead

get(*args, **kwargs)[source]

Get a single record by id

Supports resource cache

Changed in version 2.17.0: Added option to retrieve record by tracking_id

Keyword Arguments:
 
  • id (str) – Full record ID
  • tracking_id (str) – Record Tracking ID
Returns:

Matching Record instance returned from API

Return type:

Record

Raises:

TypeError – No id argument provided

search(*filters, **kwargs)[source]

Shortcut to generate a new temporary search report using provided filters and return the resulting records

Parameters:

*filters (tuple) – Zero or more filter tuples of (field_name, operator, field_value)

Keyword Arguments:
 
  • keywords (list(str)) – List of strings of keywords to use in report search
  • limit (int) – Set maximum number of returned Records, defaults to Report.default_limit. Set to 0 to return all records

Notes

Uses a temporary Report instance with a random name to facilitate search. Records are normally paginated, but are returned as a single list here, potentially causing performance issues with large searches.

All provided filters are AND’ed together

Filter operators are available as constants in swimlane.core.search

Examples

# Return records matching all filters with default limit

from swimlane.core import search

records = app.records.search(
    ('field_name', 'equals', 'field_value'),
    ('other_field', search.NOT_EQ, 'value')
)
# Run keyword search with multiple keywords
records = app.records.search(keywords=['example', 'test'])
# Return all records from app
records = app.records.search(limit=0)
Returns:
List of Record instances returned from the
search results
Return type:list of Record
swimlane.core.adapters.record.validate_filters_or_records(filters_or_records)[source]

Validation for filters_or_records variable from bulk_modify and bulk_delete