ENLYZE Client

class enlyze.client.EnlyzeClient(token, *, _base_url=None)[source]

Main entrypoint for interacting with the ENLYZE platform.

You should instantiate it only once and use it for all requests to make the best use of connection pooling. This client is thread-safe.

Parameters:

token (str) – API token for the ENLYZE platform

get_sites()[source]

Retrieve all sites of your organization.

Returns:

Sites of your organization

Return type:

list[Site]

Raises:

InvalidTokenError on authentication failure

Raises:

EnlyzeError on general failure

get_machines(site=None)[source]

Retrieve all machines, optionally filtered by site.

Parameters:

site (Site | None) – Only get machines of this site. Gets all machines of the organization if None.

Returns:

Machines

Return type:

list[Machine]

Raises:

InvalidTokenError on authentication failure

Raises:

EnlyzeError on general failure

get_variables(machine)[source]

Retrieve all variables of a machine.

Parameters:

machine (Machine) – The machine for which to get all variables.

Returns:

Variables of machine

Raises:

InvalidTokenError on authentication failure

Raises:

EnlyzeError on general failure

Return type:

Sequence[Variable]

get_products()[source]

Retrieve all products.

Returns:

All products

Raises:

InvalidTokenError on authentication failure

Raises:

EnlyzeError on general failure

Return type:

Sequence[Product]

get_timeseries(start, end, variables)[source]

Get timeseries data of variables for a given time frame.

Timeseries data for multiple variables can be requested at once. However, all variables must belong to the same machine.

You should always pass timezone-aware datetime objects to this method! If you don’t, naive datetime objects will be assumed to be expressed in the local timezone of the system where the code is run.

Parameters:
  • start (datetime) – Start of the time frame for which to fetch timeseries data. Must not be before end.

  • end (datetime) – End of the time frame for which to fetch timeseries data.

  • variables (Sequence[Variable]) – The variables for which to fetch timeseries data.

Returns:

Timeseries data or None if the API returned no data for the request

Raises:

InvalidTokenError on authentication failure

Raises:

EnlyzeError on general failure

Return type:

TimeseriesData | None

get_timeseries_with_resampling(start, end, variables, resampling_interval)[source]

Get resampled timeseries data of variables for a given time frame.

Timeseries data for multiple variables can be requested at once. However, all variables must belong to the same machine.

You should always pass timezone-aware datetime objects to this method! If you don’t, naive datetime objects will be assumed to be expressed in the local timezone of the system where the code is run.

Parameters:
  • start (datetime) – Start of the time frame for which to fetch timeseries data. Must not be before end.

  • end (datetime) – End of the time frame for which to fetch timeseries data.

  • variables (Mapping[Variable, ResamplingMethod]) – The variables for which to fetch timeseries data along with a ResamplingMethod for each variable. Resampling isn’t supported for variables whose VariableDataType is one of the ARRAY data types.

  • resampling_interval (int) – The interval in seconds to resample timeseries data with. Must be greater than or equal MINIMUM_RESAMPLING_INTERVAL.

Returns:

Timeseries data or None if the API returned no data for the request

Raises:

InvalidTokenError on authentication failure

Raises:

ResamplingValidationError on resampling validation error

Raises:

EnlyzeError on general failure

Return type:

TimeseriesData | None

get_production_runs(*, production_order=None, product=None, machine=None, start=None, end=None)[source]

Retrieve optionally filtered list of production runs.

Parameters:
  • machine (Machine | None) – The machine for which to get all production runs.

  • product (Product | str | None) – Filter production runs by product.

  • production_order (str | None) – Filter production runs by production order.

Returns:

Production runs

Return type:

ProductionRuns

Raises:

InvalidTokenError on authentication failure

Raises:

EnlyzeError on general failure