From 6d58360d4a4f299a91a34818290e3d8c1f5a91cd Mon Sep 17 00:00:00 2001 From: <> Date: Fri, 5 Apr 2024 09:57:13 +0000 Subject: [PATCH] Deployed 79fc6cb with MkDocs version: 1.5.3 --- .nojekyll | 0 404.html | 830 ++ api/documentation/client/index.html | 4353 +++++++++++ api/documentation/config/index.html | 1107 +++ api/documentation/env/index.html | 992 +++ api/documentation/exceptions/index.html | 1411 ++++ api/documentation/field/index.html | 1074 +++ assets/_mkdocstrings.css | 114 + assets/images/favicon.png | Bin 0 -> 1870 bytes assets/javascripts/bundle.1e8ae164.min.js | 29 + assets/javascripts/bundle.1e8ae164.min.js.map | 7 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++++++++++++++++ .../workers/search.b8dbb3d2.min.js | 42 + .../workers/search.b8dbb3d2.min.js.map | 7 + assets/stylesheets/main.bcfcd587.min.css | 1 + assets/stylesheets/main.bcfcd587.min.css.map | 1 + assets/stylesheets/palette.06af60db.min.css | 1 + .../stylesheets/palette.06af60db.min.css.map | 1 + cli/documentation/index.html | 1483 ++++ cli/getting-started/index.html | 1121 +++ fields/lookups/index.html | 1561 ++++ fields/types/index.html | 1157 +++ img/onyx.png | Bin 0 -> 1128473 bytes index.html | 1040 +++ objects.inv | Bin 0 -> 702 bytes onyx-client.pdf | Bin 0 -> 1474644 bytes search/search_index.json | 1 + sitemap.xml | 53 + sitemap.xml.gz | Bin 0 -> 295 bytes 62 files changed, 23587 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 api/documentation/client/index.html create mode 100644 api/documentation/config/index.html create mode 100644 api/documentation/env/index.html create mode 100644 api/documentation/exceptions/index.html create mode 100644 api/documentation/field/index.html create mode 100644 assets/_mkdocstrings.css create mode 100644 assets/images/favicon.png create mode 100644 assets/javascripts/bundle.1e8ae164.min.js create mode 100644 assets/javascripts/bundle.1e8ae164.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/workers/search.b8dbb3d2.min.js create mode 100644 assets/javascripts/workers/search.b8dbb3d2.min.js.map create mode 100644 assets/stylesheets/main.bcfcd587.min.css create mode 100644 assets/stylesheets/main.bcfcd587.min.css.map create mode 100644 assets/stylesheets/palette.06af60db.min.css create mode 100644 assets/stylesheets/palette.06af60db.min.css.map create mode 100644 cli/documentation/index.html create mode 100644 cli/getting-started/index.html create mode 100644 fields/lookups/index.html create mode 100644 fields/types/index.html create mode 100644 img/onyx.png create mode 100644 index.html create mode 100644 objects.inv create mode 100644 onyx-client.pdf create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..b4d86ff --- /dev/null +++ b/404.html @@ -0,0 +1,830 @@ + + + +
+ + + + + + + + + + + + + + + + +
+ Bases: OnyxClientBase
Class for querying and manipulating data within Onyx.
+ + + + +__init__(config)
+
+¶Initialise a client.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
config |
+
+
+
+ Object that stores information for connecting and authenticating with Onyx. +
+
+ TYPE:
+ |
+
Examples:
+The recommended way to initialise a client (as a context manager): +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ pass # Do something with the client here
+
Alternatively, the client can be initialised as follows: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+client = OnyxClient(config)
+# Do something with the client here
+
projects()
+
+¶View available projects.
+ + + +RETURNS | +DESCRIPTION | +
---|---|
+
+ List[Dict[str, str]]
+
+ |
+
+
+
+ List of projects. + |
+
Examples:
+ + + +fields(project)
+
+¶View fields for a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict of fields. + |
+
Examples:
+import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ fields = client.fields("project")
+
>>> fields
+{
+ "version": "0.1.0",
+ "fields": {
+ "climb_id": {
+ "description": "Unique identifier for a project record in Onyx.",
+ "type": "text",
+ "required": True,
+ "actions": [
+ "get",
+ "list",
+ "filter",
+ ],
+ "restrictions": [
+ "Max length: 12",
+ ],
+ },
+ "is_published": {
+ "description": "Indicator for whether a project record has been published.",
+ "type": "bool",
+ "required": False,
+ "actions": [
+ "get",
+ "list",
+ "filter",
+ "add",
+ "change",
+ ],
+ "default": True,
+ },
+ "published_date": {
+ "description": "The date the project record was published in Onyx.",
+ "type": "date (YYYY-MM-DD)",
+ "required": False,
+ "actions": [
+ "get",
+ "list",
+ "filter",
+ ],
+ },
+ "country": {
+ "description": "Country of origin.",
+ "type": "choice",
+ "required": False,
+ "actions": [
+ "get",
+ "list",
+ "filter",
+ "add",
+ "change",
+ ],
+ "values": [
+ "ENG",
+ "WALES",
+ "SCOT",
+ "NI",
+ ],
+ },
+ },
+}
+
choices(project, field)
+
+¶View choices for a field.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
field |
+
+
+
+ Choice field on the project. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ List[str]
+
+ |
+
+
+
+ List of choices for the field. + |
+
Examples:
+ + + +get(project, climb_id=None, fields=None, include=None, exclude=None)
+
+¶Get a record from a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
climb_id |
+
+
+
+ Unique identifier for the record in the project. +
+
+ TYPE:
+ |
+
fields |
+
+
+
+ Series of conditions on fields, used to filter the data. +
+
+ TYPE:
+ |
+
include |
+
+
+
+ Fields to include in the output. +
+
+ TYPE:
+ |
+
exclude |
+
+
+
+ Fields to exclude from the output. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict containing the record. + |
+
Examples:
+Get a record by CLIMB ID: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ record = client.get("project", "C-1234567890")
+
>>> record
+{
+ "climb_id": "C-1234567890",
+ "published_date": "2023-01-01",
+ "field1": "value1",
+ "field2": "value2",
+}
+
Get a record by fields that uniquely identify it: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ record = client.get(
+ "project",
+ fields={
+ "field1": "value1",
+ "field2": "value2",
+ },
+ )
+
>>> record
+{
+ "climb_id": "C-1234567890",
+ "published_date": "2023-01-01",
+ "field1": "value1",
+ "field2": "value2",
+}
+
The include
and exclude
arguments can be used to control the fields returned:
+
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ record_v1 = client.get(
+ "project",
+ climb_id="C-1234567890",
+ include=["climb_id", "published_date"],
+ )
+ record_v2 = client.get(
+ "project",
+ climb_id="C-1234567890",
+ exclude=["field2"],
+ )
+
>>> record_v1
+{
+ "climb_id": "C-1234567890",
+ "published_date": "2023-01-01",
+}
+>>> record_v2
+{
+ "climb_id": "C-1234567890",
+ "published_date": "2023-01-01",
+ "field1": "value1",
+}
+
filter(project, fields=None, include=None, exclude=None, summarise=None)
+
+¶Filter records from a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
fields |
+
+
+
+ Series of conditions on fields, used to filter the data. +
+
+ TYPE:
+ |
+
include |
+
+
+
+ Fields to include in the output. +
+
+ TYPE:
+ |
+
exclude |
+
+
+
+ Fields to exclude from the output. +
+
+ TYPE:
+ |
+
summarise |
+
+
+
+ For a given field (or group of fields), return the frequency of each unique value (or unique group of values). +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Generator[Dict[str, Any], Any, None]
+
+ |
+
+
+
+ Generator of records. If a summarise argument is provided, each record will be a dict containing values of the summary fields and a count for the frequency. + |
+
"published_date" : "2023-01-01"
)."published_date__year" : "2023"
)."published_date__range" : "2023-01-01, 2023-01-02"
).Examples:
+Retrieve all records that match a set of field requirements: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ records = list(
+ client.filter(
+ project="project",
+ fields={
+ "field1": "abcd",
+ "published_date__range" : "2023-01-01, 2023-01-02",
+ },
+ )
+ )
+
>>> records
+[
+ {
+ "climb_id": "C-1234567890",
+ "published_date": "2023-01-01",
+ "field1": "abcd",
+ "field2": 123,
+ },
+ {
+ "climb_id": "C-1234567891",
+ "published_date": "2023-01-02",
+ "field1": "abcd",
+ "field2": 456,
+ },
+]
+
The summarise
argument can be used to return the frequency of each unique value for a given field, or the frequency of each unique set of values for a group of fields:
+
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ records_v1 = list(
+ client.filter(
+ project="project",
+ fields={
+ "field1": "abcd",
+ "published_date__range" : "2023-01-01, 2023-01-02",
+ },
+ summarise="published_date",
+ )
+ )
+
+ records_v2 = list(
+ client.filter(
+ project="project",
+ fields={
+ "field1": "abcd",
+ "published_date__range" : "2023-01-01, 2023-01-02",
+ },
+ summarise=["published_date", "field2"],
+ )
+ )
+
>>> records_v1
+[
+ {
+ "published_date": "2023-01-01",
+ "count": 1,
+ },
+ {
+ "published_date": "2023-01-02",
+ "count": 1,
+ },
+]
+>>> records_v2
+[
+ {
+ "published_date": "2023-01-01",
+ "field2": 123,
+ "count": 1,
+ },
+ {
+ "published_date": "2023-01-02",
+ "field2": 456,
+ "count": 1,
+ },
+]
+
query(project, query=None, include=None, exclude=None, summarise=None)
+
+¶Query records from a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
query |
+
+
+
+ OnyxField object representing the query being made. +
+
+ TYPE:
+ |
+
include |
+
+
+
+ Fields to include in the output. +
+
+ TYPE:
+ |
+
exclude |
+
+
+
+ Fields to exclude from the output. +
+
+ TYPE:
+ |
+
summarise |
+
+
+
+ For a given field (or group of fields), return the frequency of each unique value (or unique group of values). +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Generator[Dict[str, Any], Any, None]
+
+ |
+
+
+
+ Generator of records. If a summarise argument is provided, each record will be a dict containing values of the summary fields and a count for the frequency. + |
+
&
(AND), |
(OR), ^
(XOR), and ~
(NOT).Examples:
+Retrieve all records that match the query provided by an OnyxField object: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient, OnyxField
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ records = list(
+ client.query(
+ project="project",
+ query=(
+ OnyxField(field1="abcd")
+ & OnyxField(published_date__range=["2023-01-01", "2023-01-02"])
+ ),
+ )
+ )
+
to_csv(csv_file, data, delimiter=None)
+
+
+ classmethod
+
+
+¶Write a set of records to a CSV file.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
csv_file |
+
+
+
+ File object for the CSV file being written to. +
+
+ TYPE:
+ |
+
data |
+
+
+
+ The data being written to the CSV file. Must be either a list / generator of dict records. +
+
+ TYPE:
+ |
+
delimiter |
+
+
+
+ CSV delimiter. If not provided, defaults to ',' for CSVs. Set this to '\t' to work with TSV files. +
+
+ TYPE:
+ |
+
Examples:
+import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ client.to_csv(
+ csv_file=csv_file,
+ data=client.filter(
+ "project",
+ fields={
+ "field1": "value1",
+ "field2": "value2",
+ },
+ )
+
identify(project, field, value, site=None)
+
+¶Get the anonymised identifier for a value on a field.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
field |
+
+
+
+ Field on the project. +
+
+ TYPE:
+ |
+
value |
+
+
+
+ Value to identify. +
+
+ TYPE:
+ |
+
site |
+
+
+
+ Site to identify the value on. If not provided, defaults to the user's site. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, str]
+
+ |
+
+
+
+ Dict containing the project, site, field, value and anonymised identifier. + |
+
Examples:
+ + + +create(project, fields, test=False)
+
+¶Create a record in a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
fields |
+
+
+
+ Object representing the record to be created. +
+
+ TYPE:
+ |
+
test |
+
+
+
+ If True, runs the command as a test. Default: False +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict containing the CLIMB ID of the created record. + |
+
Examples:
+import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ result = client.create(
+ "project",
+ fields={
+ "field1": "value1",
+ "field2": "value2",
+ },
+ )
+
update(project, climb_id, fields=None, test=False)
+
+¶Update a record in a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
climb_id |
+
+
+
+ Unique identifier for the record in the project. +
+
+ TYPE:
+ |
+
fields |
+
+
+
+ Object representing the record to be updated. +
+
+ TYPE:
+ |
+
test |
+
+
+
+ If True, runs the command as a test. Default: False +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict containing the CLIMB ID of the updated record. + |
+
Examples:
+import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ result = client.update(
+ project="project",
+ climb_id="C-1234567890",
+ fields={
+ "field1": "value1",
+ "field2": "value2",
+ },
+ )
+
delete(project, climb_id)
+
+¶Delete a record in a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
climb_id |
+
+
+
+ Unique identifier for the record in the project. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict containing the CLIMB ID of the deleted record. + |
+
Examples:
+ + + +csv_create(project, csv_file, fields=None, delimiter=None, multiline=False, test=False)
+
+¶Use a CSV file to create record(s) in a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
csv_file |
+
+
+
+ File object for the CSV file being used for record upload. +
+
+ TYPE:
+ |
+
fields |
+
+
+
+ Additional fields provided for each record being uploaded. Takes precedence over fields in the CSV. +
+
+ TYPE:
+ |
+
delimiter |
+
+
+
+ CSV delimiter. If not provided, defaults to ',' for CSVs. Set this to '\t' to work with TSV files. +
+
+ TYPE:
+ |
+
multiline |
+
+
+
+ If True, allows processing of CSV files with more than one record. Default: False +
+
+ TYPE:
+ |
+
test |
+
+
+
+ If True, runs the command as a test. Default: False +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Union[Dict[str, Any], List[Dict[str, Any]]]
+
+ |
+
+
+
+ Dict containing the CLIMB ID of the created record. If multiline = True, returns a list of dicts containing the CLIMB ID of each created record. + |
+
Examples:
+Create a single record: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ result = client.csv_create(
+ project="project",
+ csv_file=csv_file,
+ )
+
Create multiple records: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ results = client.csv_create(
+ project="project",
+ csv_file=csv_file,
+ multiline=True,
+ )
+
csv_update(project, csv_file, fields=None, delimiter=None, multiline=False, test=False)
+
+¶Use a CSV file to update record(s) in a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
csv_file |
+
+
+
+ File object for the CSV file being used for record upload. +
+
+ TYPE:
+ |
+
fields |
+
+
+
+ Additional fields provided for each record being uploaded. Takes precedence over fields in the CSV. +
+
+ TYPE:
+ |
+
delimiter |
+
+
+
+ CSV delimiter. If not provided, defaults to ',' for CSVs. Set this to '\t' to work with TSV files. +
+
+ TYPE:
+ |
+
multiline |
+
+
+
+ If True, allows processing of CSV files with more than one record. Default: False +
+
+ TYPE:
+ |
+
test |
+
+
+
+ If True, runs the command as a test. Default: False +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Union[Dict[str, Any], List[Dict[str, Any]]]
+
+ |
+
+
+
+ Dict containing the CLIMB ID of the updated record. If multiline = True, returns a list of dicts containing the CLIMB ID of each updated record. + |
+
Examples:
+Update a single record: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ result = client.csv_update(
+ project="project",
+ csv_file=csv_file,
+ )
+
Update multiple records: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ results = client.csv_update(
+ project="project",
+ csv_file=csv_file,
+ multiline=True,
+ )
+
csv_delete(project, csv_file, delimiter=None, multiline=False)
+
+¶Use a CSV file to delete record(s) in a project.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
project |
+
+
+
+ Name of the project. +
+
+ TYPE:
+ |
+
csv_file |
+
+
+
+ File object for the CSV file being used for record upload. +
+
+ TYPE:
+ |
+
delimiter |
+
+
+
+ CSV delimiter. If not provided, defaults to ',' for CSVs. Set this to '\t' to work with TSV files. +
+
+ TYPE:
+ |
+
multiline |
+
+
+
+ If True, allows processing of CSV files with more than one record. Default: False +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Union[Dict[str, Any], List[Dict[str, Any]]]
+
+ |
+
+
+
+ Dict containing the CLIMB ID of the deleted record. If multiline = True, returns a list of dicts containing the CLIMB ID of each deleted record. + |
+
Examples:
+Delete a single record: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ result = client.csv_delete(
+ project="project",
+ csv_file=csv_file,
+ )
+
Delete multiple records: +
import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client, open("/path/to/file.csv") as csv_file:
+ results = client.csv_delete(
+ project="project",
+ csv_file=csv_file,
+ multiline=True,
+ )
+
register(domain, first_name, last_name, email, site, password)
+
+
+ classmethod
+
+
+¶Create a new user.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
domain |
+
+
+
+ Name of the domain. +
+
+ TYPE:
+ |
+
first_name |
+
+
+
+ First name of the user. +
+
+ TYPE:
+ |
+
last_name |
+
+
+
+ Last name of the user. +
+
+ TYPE:
+ |
+
email |
+
+
+
+ Email address of the user. +
+
+ TYPE:
+ |
+
site |
+
+
+
+ Name of the site. +
+
+ TYPE:
+ |
+
password |
+
+
+
+ Password for the user. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict containing the user's information. + |
+
Examples:
+ + + +login()
+
+¶Log in the user.
+ + + +RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict containing the user's authentication token and it's expiry. + |
+
Examples:
+ + + +logout()
+
+¶logoutall()
+
+¶profile()
+
+¶View the user's information.
+ + + +RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, str]
+
+ |
+
+
+
+ Dict containing the user's information. + |
+
Examples:
+ + + +approve(username)
+
+¶Approve another user.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
username |
+
+
+
+ Username of the user to be approved. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ Dict[str, Any]
+
+ |
+
+
+
+ Dict confirming user approval success. + |
+
Examples:
+ + + +waiting()
+
+¶Get users waiting for approval.
+ + + +RETURNS | +DESCRIPTION | +
---|---|
+
+ List[Dict[str, Any]]
+
+ |
+
+
+
+ List of users waiting for approval. + |
+
Examples:
+ + + +site_users()
+
+¶Get users within the site of the requesting user.
+ + + +RETURNS | +DESCRIPTION | +
---|---|
+
+ List[Dict[str, Any]]
+
+ |
+
+
+
+ List of users within the site of the requesting user. + |
+
Examples:
+ + + +all_users()
+
+¶Get all users.
+ + + +RETURNS | +DESCRIPTION | +
---|---|
+
+ List[Dict[str, Any]]
+
+ |
+
+
+
+ List of all users. + |
+
Examples:
+ + + +Class for storing information required to connect/authenticate with Onyx.
+ + + + +__init__(domain, token=None, username=None, password=None)
+
+¶Initialise a config.
+This object stores information required to connect and authenticate with Onyx.
+A domain must be provided, alongside an API token and/or the username + password.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
domain |
+
+
+
+ Domain for connecting to Onyx. +
+
+ TYPE:
+ |
+
token |
+
+
+
+ Token for authenticating with Onyx. +
+
+ TYPE:
+ |
+
username |
+
+
+
+ Username for authenticating with Onyx. +
+
+ TYPE:
+ |
+
password |
+
+
+
+ Password for authenticating with Onyx. +
+
+ TYPE:
+ |
+
Examples:
+Create a config using environment variables for the domain and an API token: +
import os
+from onyx import OnyxConfig, OnyxEnv
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
Or using environment variables for the domain and login credentials: +
+ +Class containing recommended environment variable names for Onyx.
+If environment variables are created with these recommended names, then the attributes of this class can be used to access them.
+These attributes and the recommended environment variable names are: +
OnyxEnv.DOMAIN = "ONYX_DOMAIN"
+OnyxEnv.TOKEN = "ONYX_TOKEN"
+OnyxEnv.USERNAME = "ONYX_USERNAME"
+OnyxEnv.PASSWORD = "ONYX_PASSWORD"
+
Examples:
+In the shell, create the following environment variables with your credentials: +
$ export ONYX_DOMAIN="https://onyx.example.domain"
+$ export ONYX_TOKEN="example-onyx-token"
+$ export ONYX_USERNAME="example-onyx-username"
+$ export ONYX_PASSWORD="example-onyx-password"
+
Then access them in Python to create an OnyxConfig object: +
import os
+from onyx import OnyxEnv, OnyxConfig
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+ username=os.environ[OnyxEnv.USERNAME],
+ password=os.environ[OnyxEnv.PASSWORD],
+)
+
OnyxError
+
+
+¶
+ Bases: Exception
Generic class for all Onyx exceptions.
+ + +OnyxConfigError
+
+
+¶
+ Bases: OnyxError
Config validation error.
+This error occurs due to validation failures when initialising an OnyxConfig
object.
Examples:
+domain
was not provided.token
or valid login credentials (username
and password
) were provided.OnyxClientError
+
+
+¶
+ Bases: OnyxError
Client validation error.
+This error occurs due to validation failures within an OnyxClient
object, and not due to error codes returned by the Onyx API.
Examples:
+OnyxClient
methods.climb_id
, creating an invalid URL.OnyxClient.csv_create
, OnyxClient.csv_update
, or OnyxClient.csv_delete
.OnyxClient.csv_create
, OnyxClient.csv_update
, or OnyxClient.csv_delete
when multiline = False
.OnyxClient.get
request using fields
returns more than one result.OnyxRequestError
because for this particular combination of parameters, an underlying call to the OnyxClient.filter
method is made.OnyxClient.get
method expects a single record, resulting in the error being raised.OnyxFieldError
+
+
+¶
+ Bases: OnyxError
Field validation error.
+This error occurs due to validation failures within the OnyxField
class.
Examples:
+OnyxField
instance with a different type.OnyxField.query
is somehow incorrect.OnyxConnectionError
+
+
+¶
+ Bases: OnyxError
Onyx connection error.
+This error occurs due to a failure to connect to the Onyx API.
+ +requests.RequestException
(excluding requests.HTTPError
) being raised.OnyxHTTPError
+
+
+¶
+ Bases: OnyxError
Onyx HTTP error.
+This error occurs due to a request to the Onyx API either failing (code 4xx
) or causing a server error (code 5xx
).
requests.HTTPError
being raised.requests.HTTPError
class, instances of this class have a response
object containing details of the error.response
object, see: https://requests.readthedocs.io/en/latest/api/#requests.ResponseExamples:
+import os
+from onyx import OnyxConfig, OnyxEnv, OnyxClient, OnyxField
+from onyx.exceptions import OnyxHTTPError
+
+config = OnyxConfig(
+ domain=os.environ[OnyxEnv.DOMAIN],
+ token=os.environ[OnyxEnv.TOKEN],
+)
+
+with OnyxClient(config) as client:
+ try:
+ records = list(
+ client.query(
+ project="project",
+ query=(
+ OnyxField(field1="abcd")
+ & OnyxField(published_date__range=["2023-01-01", "2023-01-02"])
+ ),
+ )
+ )
+ except OnyxHTTPError as e:
+ print(e.response.json())
+
OnyxRequestError
+
+
+¶
+ Bases: OnyxHTTPError
Onyx request error.
+This error occurs due to a failed request to the Onyx API (code 4xx
).
Examples:
+400 Bad Request
).401 Unauthorized
).403 Forbidden
).404 Not Found
).405 Method Not Allowed
).OnyxServerError
+
+
+¶
+ Bases: OnyxHTTPError
Onyx server error.
+This error occurs due to a request to the Onyx API causing a server error (code 5xx
).
Server errors are unintended and should be reported to an admin if encountered.
+Class that represents a single field-value pair for use in Onyx queries.
+ + + + +__init__(**kwargs)
+
+¶Initialise a field.
+ + + +PARAMETER | +DESCRIPTION | +
---|---|
**kwargs |
+
+
+
+ Keyword arguments containing a single key-value pair. +
+
+ TYPE:
+ |
+
&
(AND), |
(OR), ^
(XOR), and ~
(NOT).Examples:
+Create OnyxField objects and combine them using Python bitwise operators: +
from onyx import OnyxField
+
+field1 = OnyxField(field1="value1")
+field2 = OnyxField(field2__contains="value2")
+
+expression = (field1 | field2) & OnyxField(
+ published_date__range=["2023-01-01", "2023-01-02"]
+)
+
>>> field1
+<onyx.field.OnyxField object at 0x1028eb850>
+>>> field2
+<onyx.field.OnyxField object at 0x1028eb850>
+>>> expression
+<onyx.field.OnyxField object at 0x103b6fc40>
+>>> field1.query
+{"field1": "value1"}
+>>> field2.query
+{"field2__contains": "value2"}
+>>> expression.query
+{
+ "&": [
+ {"|": [{"field1": "value1"}, {"field2__contains": "value2"}]},
+ {"published_date__range": "2023-01-01,2023-01-02"},
+ ]
+}
+
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var Va=/["'&<>]/;qn.exports=za;function za(e){var t=""+e,r=Va.exec(t);if(!r)return t;var o,n="",i=0,a=0;for(i=r.index;i