Locations Class

Locations interface

Direct access to the locations endpoint.

The user is not expected to use this class directly. It is an attribute of the Archivist class.

For example instantiate an Archivist instance and execute the methods of the class:

with open(".auth_token", mode="r", encoding="utf-8") as tokenfile:
    authtoken = tokenfile.read().strip()

# Initialize connection to Archivist
arch = Archivist(
    "https://app.datatrails.ai",
    authtoken,
)
location = arch.locations.create(...)
class archivist.locations.Location[source]

Location object has dictionary attributes.

property name: str | None

name of the location

Type:

str

class archivist.locations._LocationsClient(archivist_instance: Archivist)[source]

LocationsClient

Access to locations entities using CRUD interface. This class is usually accessed as an attribute of the Archivist class.

Parameters:

archivist (Archivist) -- Archivist instance

count(*, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None) int[source]

Count locations.

Counts number of locations that match criteria.

Parameters:
  • props (dict) -- e.g. {"display_name": "Macclesfield" }

  • attrs (dict) -- e.g. {"director": "john smith" }

Returns:

integer count of locations.

create(props: dict[str, Any], *, attrs: dict[str, Any] | None = None) Location[source]

Create location

Creates location with defined properties and attributes.

Parameters:
  • props (dict) -- properties for this location.

  • attrs (dict) -- attributes of created location.

Returns:

Location instance

create_from_data(data: dict[str, Any]) Location[source]

Create location

Creates location with request body from data stream. Suitable for reading data from a file using json.load or yaml.load

Parameters:

data (dict) -- request body of location.

Returns:

Location instance

create_if_not_exists(data: dict[str, Any]) tuple[Location, bool][source]

Create a location if not already exists

Parameters:

data (dict) -- request body of location.

A YAML representation of the data argument would be:

selector:
  - display_name
  - attributes:
    - wavestone_ext
display_name: Apartements du Gare du Nord
description: Residential apartment building in new complex above GdN station
latitude: 48.8809
longitude: 2.3553
attributes:
  address: 18 Rue de Dunkerque, 75010 Paris, France
  wavestone_ext: managed

The 'selector' setting is required.

Returns:

tuple of Location instance, Boolean True if already exists

list(*, page_size: int | None = None, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None)[source]

List locations.

Lists locations that match criteria.

Parameters:
  • props (dict) -- optional e.g. {"display_name": "Macclesfield" }

  • attrs (dict) -- optional e.g. {"director": "john smith" }

  • page_size (int) -- optional page size. (Rarely used)

Returns:

iterable that returns Location instances

read(identity: str) Location[source]

Read location

Reads location.

Parameters:

identity (str) -- location identity e.g. locations/xxxxxxxxxxxxxxxxxxxxxxx

Returns:

Location instance

read_by_signature(*, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None) Location[source]

Read location by signature.

Reads location that meets criteria. Only one location is expected.

Parameters:
  • props (dict) -- e.g. {"display_name": "Macclesfield" }

  • attrs (dict) -- e.g. {"director": "john smith" }

Returns:

Location instance