sdesk.api.client module

class sdesk.api.client.BaseUrlSession(base_url=None)

Bases: requests_toolbelt.sessions.BaseUrlSession

Change sessions.BaseUrlSession default behavior.

Meta private:
create_url(url)

Create the URL based off this partial path.

class sdesk.api.client.SdeskClient(sdesk_host, schema='https', verify=False, disable_warning=False)

Bases: object

__init__(sdesk_host, schema='https', verify=False, disable_warning=False)

Science Desk Client class

The client will aims to be a implement several functions to make it easier to interact with Science Desk API.

Parameters:
  • sdesk_host (str) – ScienceDesk host name (e.g sciencedesk.mydomain.com)
  • schema (str, optional) – URL Schema, defaults to “https”
  • verify (bool, optional) – Verify SSL certificate, defaults to False
  • disable_warning (bool, optional) – Disable Insegure Request Warning, defaults to False
auth_required()
authenticate(username, password)

Authenticate the client

Parameters:
  • username (str) – Username
  • password (str) – Password
create_entry(notebook_id, description, title, datetime=None, submited=True, saved=True, task_id=None, sample_id=None)

Create a new entry on a Notebook

Parameters:
  • notebook_id (int) – Notebook Id
  • description (str) – Description
  • title (str) – Title
  • datetime (datetime, optional) – Entry’s datetime, defaults to now()
  • submited (bool, optional) – defaults to True
  • saved (bool, optional) – defaults to True
  • task_id (int, optional) – defaults to None
  • sample_id (int, optional) – defaults to None
Return type:

Entry

get_file_info(file_id)

Get a File by its Id

Parameters:file_id (int) – File Id
Return type:File
get_notebook(id)

Get a Notebook by its ID

Parameters:id (int) – Notebook id
Return type:Notebook
list_entries(notebook_id, limit=9999, offset=0)

List Notebook’s Entries

Parameters:
  • notebook_id (int) – Notebook id
  • limit (int, optional) – Results Limit, defaults to 9999
  • offset (int, optional) – Results Offset, defaults to 0
Return type:

Entry list

list_entry_files(entry, limit=9999, offset=0)

List Files

Parameters:
  • entry (int) – Entry Id
  • limit (int, optional) – Results Limit, defaults to 9999
  • offset (int, optional) – Results Offset, defaults to 0
Return type:

File list

list_files(limit=9999, offset=0)

List Files

Parameters:
  • limit (int, optional) – Results Limit, defaults to 9999
  • offset (int, optional) – Results Offset, defaults to 0
Return type:

File list

list_notebooks(limit=9999, offset=0)

List SDesk Notebooks

Parameters:
  • limit (int, optional) – Results Limit, defaults to 9999
  • offset (int, optional) – Results Offset, defaults to 0
Return type:

Notebook list

upload_file(notebook_id, entry_code, file_path)

Upload a file to a Notebook’s Entry

Parameters:
  • notebook_id (int) – Notebook Id
  • entry_code (int) – Entry Code
  • file_path (str) – Path to the file to be uploaded
Return type:

File

exception sdesk.api.client.SdeskClientAutheticationError

Bases: Exception

Raised on authentication errors.