Select Items

pyclarify.client.Client.select_items(filter: Optional[pyclarify.query.filter.Filter] = None, include: Optional[List] = [], skip: int = 0, limit: Optional[int] = 10, sort: List[str] = [], total: Optional[bool] = False) pyclarify.views.generics.Response

Return item metadata from selected items. For more information click here .

Parameters
  • filter (Filter, optional) – A Filter Model that describes a mongodb filter to be applied.

  • include (List of strings, optional) – A list of strings specifying which relationships to be included in the response.

  • skip (int, default 0) – Integer describing how many of the first N items to exclude from response.

  • limit (int, default 10) – Number of items to include in the match.

  • sort (list of strings) – List of strings describing the order in which to sort the items in the response.

  • total (bool, default False) – When true, force the inclusion of a total count in the response. A total count is the total number of resources that matches filter.

Returns

Response.result.data is an array of ItemSelectView

Return type

Response

Examples

>>> client = Client("./clarify-credentials.json")

Querying items based on a filter.

>>> client.select_items(
...     filter = Filter(fields={"name": filter.NotEqual(value="Air Temperature")}),
... )

Getting 1000 items.

>>> client.select_items(
...     limit = 1000,
... )

Getting 100 items and sorting by name.

>>> client.select_signals(
...     limit = 100,
...     sort = ["name"],
... )

Getting total number of signals (as meta data).

>>> client.select_signals(
...     total= True,
... )

Using multiple query parameters.

>>> client.select_items(
...     filter = query.Filter(fields={"name": query.NotEqual(value="Air Temperature")}),
...     skip = 3,
...     limit = 10,
...     sort = ["-id", "name"],
...     total=True,
... )
Response

In case of a valid return value, returns a pydantic model with the following format:

>>> jsonrpc = '2.0'
... id = '1'
... result = Selection(
...     meta={
...         'total': -1,
...         'groupIncludedByType': True
...     },
...     data=[
...         ItemSelectView(
...             id='c5i41fjsbu8cohpkcpvg',
...             type='items',
...             meta=ResourceMetadata(
...                 annotations={
...                     "docs-clarify-io/example/environment": "office"
...                  },
...                 attributesHash='7602afa2fe611e0c8eff17f7936e108ee29e6817',
...                 relationshipsHash='5f36b2220a14b54ee5ea290645ee34d943ea5be5',
...                 updatedAt=datetime.datetime(2022, 3, 25, 9, 58, 20, 264000, tzinfo=datetime.timezone.utc),
...                 createdAt=datetime.datetime(2021, 10, 11, 13, 48, 46, 958000, tzinfo=datetime.timezone.utc)
...             ),
...             attributes=Item(
...                 name='Dunder ReBond Inventory Level',
...                 valueType=<TypeSignal.numeric: 'numeric'>,
...                 description='How many reams of the Dunder ReBond we have in the warehouse.',
...                 labels={
...                     'type': ['Recycled', 'Bond'],
...                     'location': ['Scranton'],
...                     'threat-level': ['Midnight']
...                 },
...                 engUnit='',
...                 enumValues={},
...                 sourceType=<SourceTypeSignal.measurement: 'measurement'>,
...                 sampleInterval=None,
...                 gapDetection=datetime.timedelta(seconds=7200),
...                 visible=True
...             ),
...             relationships={}
...         ),
...         ItemSelectView(...),
...         ...
...     ]
... ),
... error=None

In case of the error the method return a pydantic model with the following format:

>>> jsonrpc = '2.0'
... id = '1'
... result = None
... error = Error(
...         code = '-32602',
...         message = 'Invalid params',
...         data = ErrorData(trace = <trace_id>, params = {})
... )