slims.slims module¶
-
class
slims.slims.
Slims
(name: str, url: str, username: str = None, password: str = None, oauth: bool = False, client_id: str = None, client_secret: str = None, repo_location: str = None, local_host: str = 'localhost', local_port: int = 5000, **request_params)¶ Bases:
object
Creates a new slims instance to work with
Parameters: - name (str) – The name of this slims instance
- url (str) – The url of the REST API of this slims instance
- username (str, optional) – The username to login with (needed for standard operations)
- password (str, optional) – The password to login with (needed for standard operations)
- oauth (bool, optional) – Whether Oauth authentication is used
- client_id (str, optional) – The client ID used to authenticate when OAuth is true
- client_secret (str, optional) – The client secret used to authenticate when OAuth is true
- repo_location (str, optional) – The location of the file repository (this can be used to access attachments without needing to download them)
- local_host (str, optional) – The IP on which this python script is running Needed for SLimsGate flows. SLims will contact the python script on this url. Defaults to “localhost”
- local_port (int, optional) – The port on which this python script is running Needed for ports. SLims will contact the python script on this ports. Defaults to “5000”
- request_params – Parameters to pass verbatim to requests when calling the REST API, e.g. verify=’path/to/cert’
-
add
(table: str, values: dict) → slims.internal.Record¶ Add a new record in slims
Parameters: - table (string) – Table where the element need to be added.
- values (dict) – The values of the new record
Returns: The added record
Examples
>>> slims.add("Content", { "cntn_id", "ID", "cntn_status", Status.PENDING.value, "cntn_fk_contentType", 1 })
Adds a content record with id “ID” in status pending with the content type with primary key 1
-
add_flow
(flow_id: str, name: str, usage: str, steps: list, testing: bool = False, last_flow: bool = True) → None¶ Add a new SLimsGate flow to the slims interface
Note
Adding a slimsgate flow means your python script will continue executing until you shut it down.
Parameters: - flow_id (string) – Technical identificator of the flow
- name (string) – Displayed name of the the flow
- usage (string) – Usage of the slimsgate flow
- steps (list step) – The steps of the slimsgate flow
- testing (bool) – Dry run=======
- last_flow (boolean) – Defines if this is the last flow you will add (Default True)
Examples
>>> def hello_world(flow_run): print("Hello world") >>> slims.add_flow( flow_id="helloWorld", name="Make python say hello", usage="CONTENT_MANAGEMENT", steps=[ Step( name="The step", action=hello_world )])
-
fetch
(table: str, criteria: slims.criteria.Criterion, sort: list = None, start: int = None, end: int = None) → List[slims.internal.Record]¶ Fetch data by criteria
The optional start and end parameters can be used to page the returned results.
Parameters: - table (str) – The table to fetch from
- criteria (criteria) – The criteria to match
- sort (list, optional) – The fields to sort on
- start (int, optional) – The first row to return
- end (int, optional) – The last row to return
Returns: The list of matched records
Examples
>>> slims.fetch("Content", start_with("cntn_id", "DNA"), sort = ["cntn_barCode"], start = 10, end = 20)
Fetches content records that have an id that starts with DNA. The returned list is sorted by cntn_barCode (ascending). The first returned results is the has the 10th barcode and the last one is the 20th
>>> slims.fetch("Content", start_with("cntn_id", "DNA"), sort = ["-cntn_barCode"])
Fetches content records that have an id that starts with DNA. The returned list is sorted by cntn_barCode (descending).
-
fetch_by_pk
(table: str, pk: int) → Optional[slims.internal.Record]¶ Fetch a record by primary key
Parameters: - table (string) – The table of the record
- pk (int) – The primary key of the record
Returns: A single record (or None)
Examples
>>> slims.fetch_by_pk("Content", 1)
-
token_updater
(token: dict) → None¶