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

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]

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.create_batch(
    {'Field 1': 'value 1', ...},
    {'Field 1': 'value 2', ...},
    {'Field 1': 'value 3', ...}
)
Raises:
get(*args, **kwargs)[source]

Get a single record by id

Keyword Arguments:
 id (str) – Full record ID
Returns:Matching Record instance returned from API
Return type:Record
Raises:TypeError – No id argument provided
search(*filter_tuples, **kwargs)[source]

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

Parameters:

*filter_tuples (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