ordflow.api.API

class ordflow.api.API(api_key, server_url=None)[source]

Bases: object

Creates an instance of the API class to communicate with DataFlow

Parameters
  • api_key (str) – API key for accessing DataFlow Please omit the “Bearer ” prefix before the API key

  • server_url (str, Optional) – URL for DataFlow server. Default: staging server

Methods

dataset_create

Create a new dataset

dataset_info

Show information about a dataset

dataset_search

Search for a dataset in DataFlow

file_upload

Upload the provided file to the specified Dataset.

files_search

Search for individual files in datasets

globus_endpoints_activate

Activates Globus endpoints necessary to transfer data.

globus_endpoints_active

Checks whether both source and destination Globus endpoints are active

instrument_info

Show information about an Instrument

instrument_list

List all instruments connected to this DataFlow server

settings_get

Gets current default user settings

settings_set

Set or update default user settings

dataset_create(title, instrument_id=0, metadata=None)[source]

Create a new dataset

Parameters
  • title (str) – Title for dataset

  • instrument_id (int, optional) – Instrument ID. Default = 0 - UnknownInstrument

  • metadata (dict, optional) – Scientific metadata associated with this dataset. Metadata specified as {“param 1”: value_1, “param 2”: value_2} Nested dictionaries will be flattened with keys joined with a “-” separator

Returns

Response from POST request

Return type

dict

dataset_info(dset_id)[source]

Show information about a dataset

Parameters

dset_id (int) – ID for dataset

Returns

Response from GET request

Return type

dict

Search for a dataset in DataFlow

Parameters

query (str) – Text or date to search on

Returns

Response from GET request

Return type

dict

file_upload(file_path, dataset_id, relative_path=None, transport=None)[source]

Upload the provided file to the specified Dataset.

Parameters
  • file_path (str) – Local path to file that needs to be uploaded

  • dataset_id (int) – Dataset ID to upload this file to

  • relative_path (str, optional) – Relative path in destination to place this file. Default - the file will be uploaded to the root directory of the dataset

  • transport (ordflow.Transport, optional) – Transport protocol to use to transfer this specific file

Returns

Response from POST request

Return type

dict

Search for individual files in datasets

Parameters
  • query (str) – Search query

  • dataset_id (int, optional) – Filter results to the specified Dataset. Default - no filtering

Returns

Response from GET request

Return type

dict

globus_endpoints_activate(username, password, encrypted=True, endpoint='destination')[source]

Activates Globus endpoints necessary to transfer data.

Notes

It is entirely possible that the source and destination endpoints are in different security enclaves in the same organization or even in different organizations. For now, the “source” endpoint typically uses ORNL XCAMS credentials (your three-character ID and password). By default, the “destination” endpoint points to ORNL’s CADES Open-Research Network File System, which also uses ORNL XCAMS credentials.

Parameters
  • username (str) – user name associated with the specified endpoint

  • password (str) – password associated with specified endpoint

  • encrypted (bool, Optional) – Whether or not the password is encrypted (using the DataFlow web server’s encryption). Default = encrypted password

  • endpoint (str, Optional) – Endpoint to activate. The 3 valid options are: 1. “source” - DataFlow server’s endpoint, 2. “destination” - Where data will be sent to, and 3. the UUID of some other endpoint

Returns

Response from GET request

Return type

dict

globus_endpoints_active(endpoint=None)[source]

Checks whether both source and destination Globus endpoints are active

Parameters

endpoint (str, Optional.) – UUID of endpoint whose status needs to be checked. Default = None - checks the default destination Globus endpoint along with the DataFlow server’s endpoint

Returns

Response from GET request

Return type

dict

instrument_info(instr_id)[source]

Show information about an Instrument

Parameters

instr_id (int) – ID for Insrtument

Returns

Response from GET request

Return type

dict

instrument_list()[source]

List all instruments connected to this DataFlow server

Returns

Response from GET request

Return type

dict

settings_get()[source]

Gets current default user settings

Returns

Response from GET request

Return type

dict

settings_set(setting, value)[source]

Set or update default user settings

Parameters
  • setting (str) – Name of parameter Currently, only “globus.destination_endpoint” and “transport.protocol” are supported

  • value (obj) – New value for chosen parameter

Returns

Response from POST request

Return type

dict