Client
pingthings.admin.client
¶
| CLASS | DESCRIPTION |
|---|---|
AdminClient |
|
AsyncAdminClient |
|
| FUNCTION | DESCRIPTION |
|---|---|
connect |
Connect to the admin platform. |
Classes¶
AdminClient
¶
AdminClient(
pyo3_client,
loop: ClientEventLoop,
creds: dict[str, str],
)
Bases: object
| METHOD | DESCRIPTION |
|---|---|
add_streams_to_my_collection |
Adds streams to a My Collection. If any of the provided streams are already in the |
connect |
Establish a connection to the admin API. |
create_event |
Creates an event. |
create_my_collection |
Creates a new My Collection for the currently authenticated user. |
create_permalink |
Generate a permanent link that can be used for visualization in MR plotter. |
delete_event |
Deletes an event by its ID. |
delete_my_collection |
Deletes a My Collection and all of its child collections. Streams that are |
delete_permalink |
Permanently remove the permalink entry. |
get_event |
Retrieves an event by its ID. |
get_permalink |
Retrieve the data stored by the permalink. |
list_events |
Return all events that match the given criteria paginated by |
list_my_collections |
Return all custom collections you have created. |
remove_streams_from_my_collection |
Removes streams from a My Collection. If any of the provided streams are not in the |
run_coroutine_to_completion |
Ensure that a coroutine is completely ran. |
update_my_collection |
Updates a My Collection with the provided patch. |
update_permalink |
Modify the data in a permalink. |
Functions¶
add_streams_to_my_collection
¶
Adds streams to a My Collection. If any of the provided streams are already in the collection, they will be ignored.
connect
staticmethod
¶
Establish a connection to the admin API.
The adminapi is a set of capabilities that are not directly involved with timeseries manipulation like the
pingthings.timeseries.Client.
This can include features that are admin-level user specific as well as other functionality like
custom collection creation and management among others.
| PARAMETER | DESCRIPTION |
|---|---|
profile
¶ |
The name of a profile containing the required connection information as found in the user's predictive grid credentials file |
endpoint
¶ |
The address and port of the admin endpoint to connect to, e.g. |
api_key
¶ |
The API key used to authenticate requests, if not set, the key is found in the environment variable |
create_event
¶
create_event(
start_time: datetime | int,
end_time: Optional[datetime | int] = None,
stream_uuids: Optional[
list[str] | list[UUID] | list[str | UUID]
] = None,
group_names: Optional[list[str]] = None,
source: str | None = None,
type: str | None = None,
message: str | None = None,
title: str | None = None,
) -> dict
Creates an event.
| PARAMETER | DESCRIPTION |
|---|---|
start_time
¶ |
The start time of the event (datetime.datetime or int representing nanoseconds since epoch) |
end_time
¶ |
The end time of the event (optional, datetime.datetime or int representing nanoseconds since epoch). |
stream_uuids
¶ |
List of stream UUIDs (optional)
TYPE:
|
group_names
¶ |
List of group names (optional). If not provided, the event will be visible to all groups that the user creating the event is a member of. |
source
¶ |
What created/identified the event? (optional)
TYPE:
|
type
¶ |
What kind of event? (optional)
TYPE:
|
message
¶ |
Longer form description of the event (optional)
TYPE:
|
title
¶ |
A short title for the event (optional)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
A dictionary representing the created event. |
create_my_collection
¶
create_my_collection(
name: str,
description: Optional[str] = None,
parent_my_collection_uuid: Optional[str | UUID] = None,
) -> dict
Creates a new My Collection for the currently authenticated user.
| PARAMETER | DESCRIPTION |
|---|---|
name
¶ |
The name of the collection
TYPE:
|
description
¶ |
An optional description of the collection |
parent_my_collection_uuid
¶ |
An optional UUID of a different my collection to use as the parent of the new collection |
| RETURNS | DESCRIPTION |
|---|---|
dict
|
A dictionary representing the newly created My Collection. It will contain |
dict
|
the following keys:
- |
create_permalink
¶
Generate a permanent link that can be used for visualization in MR plotter.
| PARAMETER | DESCRIPTION |
|---|---|
data
¶ |
A json string representing the serialized form for MR plotter to render.
TYPE:
|
bookmark
¶ |
Should this permalink be a user-only bookmark?
TYPE:
|
public
¶ |
Can all users access this permalink if provided to them (note, this will not give them access to Streams they do not have access to)?
TYPE:
|
Returns Core data that represents the permalink for MR plotter to render.
delete_event
¶
delete_my_collection
¶
Deletes a My Collection and all of its child collections. Streams that are contained in the collection or any of its children will NOT be deleted.
delete_permalink
¶
delete_permalink(permalink_uuid: str | UUID) -> None
get_event
¶
get_permalink
¶
get_permalink(permalink_uuid: str | UUID) -> Permalink
list_events
¶
list_events(
start_time: Optional[datetime | int] = None,
end_time: Optional[datetime | int] = None,
source_contains: Optional[str] = None,
type_contains: Optional[str] = None,
message_contains: Optional[str] = None,
limit: int = 100,
offset: int = 0,
sort_by: str = "start_time",
sort_desc: bool = False,
title_contains: Optional[str] = None,
created_by_contains: Optional[str] = None,
full_text_search: Optional[str] = None,
) -> tuple[list[dict[str, Any]], int]
Return all events that match the given criteria paginated by offset and limit.
| PARAMETER | DESCRIPTION |
|---|---|
start_time
¶ |
Events must start at this time or greater than this time. |
end_time
¶ |
Events must end at this time or before this time. |
source_contains
¶ |
Substring case-insensitive filter for the event source. |
type_contains
¶ |
Substring case-insensitive filter for the event type. |
message_contains
¶ |
The event must contain this string subset, this uses a case-insensitive substring search. |
limit
¶ |
How many events to return at once
TYPE:
|
offset
¶ |
Pagination offset
TYPE:
|
sort_by
¶ |
What event parameter to sort by?
TYPE:
|
sort_desc
¶ |
Should the results be returned descending order by the
TYPE:
|
title_contains
¶ |
Substring case-insensitive filter for the event title. |
created_by_contains
¶ |
Substring case-insensitive filter for the user that created the event. |
full_text_search
¶ |
Substring case-insensitive filter across all text fields (title, message, source, type, created_by). |
| RETURNS | DESCRIPTION |
|---|---|
tuple[list[dict[str, Any]], int]
|
A tuple containing the list of events matching the given criteria and the total count of matching events. |
Examples:
Find all events that contain the word 'voltage' (case insensitive):
>>> AdminClient.list_events(message_contains="voltage")
list_my_collections
¶
remove_streams_from_my_collection
¶
remove_streams_from_my_collection(
my_collection_uuid: str | UUID,
stream_uuids: list[str | UUID],
)
Removes streams from a My Collection. If any of the provided streams are not in the collection, they will be ignored.
run_coroutine_to_completion
¶
Ensure that a coroutine is completely ran.
update_my_collection
¶
Updates a My Collection with the provided patch.
| PARAMETER | DESCRIPTION |
|---|---|
my_collection_uuid
¶ |
The UUID of the collection to update |
patch
¶ |
A dictionary of fields to update. Only fields contained in the dictionary will be updated; all other fields will remain unchanged. The list of fields that can be updated are:
- |
| RETURNS | DESCRIPTION |
|---|---|
dict
|
A dictionary representing the updated My Collection. It will contain |
dict
|
the same keys as the |
update_permalink
¶
update_permalink(
permalink_uuid: str,
data: str,
bookmark: bool = False,
public: bool = True,
collection_id: str | None = None,
) -> Permalink
Modify the data in a permalink.
| PARAMETER | DESCRIPTION |
|---|---|
permalink_uuid
¶ |
The identifier of the permalink to modify
TYPE:
|
data
¶ |
Core information that represents the MR plotter view of the data
TYPE:
|
bookmark
¶ |
Should this permalink be a user-only bookmark?
TYPE:
|
public
¶ |
Can all users access this permalink if provided to them (note, this will not give them access to Streams they do not have access to)?
TYPE:
|
collection_id
¶ |
Nested folder structure like MyCollections.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Permalink
|
The updated permalink |
AsyncAdminClient
¶
Bases: object
| METHOD | DESCRIPTION |
|---|---|
list_events |
Return all events that match the given criteria paginated by |
Functions¶
list_events
async
¶
list_events(
start_time: Optional[datetime | int] = None,
end_time: Optional[datetime | int] = None,
source_contains: Optional[str] = None,
type_contains: Optional[str] = None,
message_contains: Optional[str] = None,
limit: int = 100,
offset: int = 0,
sort_by: str = "start_time",
sort_desc: bool = False,
title_contains: Optional[str] = None,
created_by_contains: Optional[str] = None,
full_text_search: Optional[str] = None,
) -> tuple[list[dict[str, Any]], int]
Return all events that match the given criteria paginated by offset and limit.
| PARAMETER | DESCRIPTION |
|---|---|
start_time
¶ |
Events must start at this time or greater than this time. |
end_time
¶ |
Events must end at this time or before this time. |
source_contains
¶ |
Substring case-insensitive filter for the event source. |
type_contains
¶ |
Substring case-insensitive filter for the event type. |
message_contains
¶ |
The event must contain this string subset, this uses a case-insensitive substring search. |
limit
¶ |
How many events to return at once
TYPE:
|
offset
¶ |
Pagination offset
TYPE:
|
sort_by
¶ |
What event parameter to sort by?
TYPE:
|
sort_desc
¶ |
Should the results be returned descending order by the
TYPE:
|
title_contains
¶ |
Substring case-insensitive filter for the event title. |
created_by_contains
¶ |
Substring case-insensitive filter for the user that created the event. |
full_text_search
¶ |
Substring case-insensitive filter across all text fields (id, title, message, source, type, created_by). |
| RETURNS | DESCRIPTION |
|---|---|
tuple[list[dict[str, Any]], int]
|
A tuple of (list of events matching the given criteria, total count of matching events). |
Examples:
Find all events that contain the word 'voltage' (case insensitive):
>>> await AsyncAdminClient.list_events(message_contains="voltage")
Functions¶
connect
¶
connect(
profile: Optional[str] = None,
endpoint: Optional[str] = None,
api_key: Optional[str] = None,
)
Connect to the admin platform.
Different Endpoint to the Timeseries Client
The endpoint used for the admin client may be different from the timeseries client.
| PARAMETER | DESCRIPTION |
|---|---|
|
The btrdb profile to use when connecting |
|
The address and port of the admin system to connect to, e.g. |
|
The API key to use for authentication. If not set, the key is looked up from the environment variable |
| RETURNS | DESCRIPTION |
|---|---|
|
An instance of the Client class. |
Example
import pingthings
admin = pingthings.admin.connect('your_profile', 'localhost:2224', 'your-api-key')
my_collections = admin.list_my_collections()