Skip to main content
Version: 1.18.1

Agents

Get Agents

Query agents allows to get a list of agents.

agents(filter: JSON = null
ids: [ID] = null
limit: Int = null
offset: Int = null
order: [String] = null
withArchived: WithArchived = null): AgentsCollection!

Input parameters:

filter: JSON: You can filter a list of agents by specifying one or several parameters:

  • cameras: ID assigned to a camera stored in the database
  • creation_date: Exact agent creation date in ISO 8601 format
  • id: ID assigned to an agent stored in the database.
  • info__title: Agent name.
  • is_active: Agent activity attribute.
  • last_modified: Exact date of the last agent modification in ISO 8601 format

ids: [ID]: To get a list of certain agents, specify their IDs in the list.

limit: Int: The parameter allows to get the first n agents from the list.

offset: Int: The parameter allows to remove the first n agents from the list.

order: [String]: You can sort the list by specifying one of the values for the following parameters: activations, cameras, creation_date, id, info, is_active, last_modified, workspace, workspace_id.

withArchived: WithArchived: To get all agents, including the archived ones, specify all. To get only archived agents, specify archived.

Output parameters:

AgentsCollection!: The query result is a list of agents that contains the following parameters:

  • totalCount: Int: Number of returned agents
  • collectionItems: [AgentsCollection!]!:
    • id: ID!: Agent ID
    • creationDate: DateTime!: Agent creation date in ISO 8601 format.
    • lastModified: DateTime!: Last agent modification date in ISO 8601 format.
    • token: String!: Agent's token
    • camerasIds: [ID!]: List of IDs assigned to cameras connected to an agent.
    • title: String: Agent name
    • agentStatus: String!: Agent status
    • agentLastActiveTime: String: Last activity date recorded by agent's camera.
    • archived: Boolean!: Agent archivation attribute.

Example Request:

{
agents {
totalCount
collectionItems {
token
title
lastModified
id
creationDate
camerasIds
archived
agentStatus
agentLastActiveTime
}
}
}

Example Response:

API returns the following result:
{
"data": {
"agents": {
"totalCount": 1,
"collectionItems": [
{
"token": "19df2b38-7d23-44a5-85e7-c5a29b304581",
"title": "My Agent",
"lastModified": "2022-07-12T08:50:45.296225+00:00",
"id": "19df2b38-7d23-44a5-85e7-c5a29b304581",
"creationDate": "2022-07-07T07:23:08.965949+00:00",
"camerasIds": [
"3c818dc4-352c-47a7-b32b-465fbd4a9665"
],
"archived": false,
"agentStatus": "active",
"agentLastActiveTime": "2022-07-12T08:50:45.296115"
}
]
}
}
}

Create an Agent

Mutation createAgent allows to create a new agent.

createAgent(agentData: AgentInput!): AgentCreateOutput!

Input parameters:

agentData: AgentInput!: Information required for creating an agent:

  • title: String: Agent name.
  • extra: JSON: Additional information about agent.

Output parameters:

AgentCreateOutput: The mutation result is JSON that contains the following parameters:

  • ok: Boolean!: Attribute that mutation is successfully completed.
  • agent: AgentOutput!: New agent object.
  • channelCost: String: Monthly service charge.
  • writeoffDate: String: Date of the next service in ISO 8601 format.

Incorrect input errors:

  • Error when creating a new agent because the limit has been exceeded:
    {
    "message": "Agent limit exceeded",
    "code": "0x6245cd00"
    }
  • Incorrect extra transmitted:
    {
    "message": "'int' object has no attribute 'get'"
    }

Example Request:

mutation{
createAgent(agentData: {title: "My new agent"}) {
ok
agent {
id
}
}
}

Example Response:

API returns the following result:
{
"data": {
"createAgent": {
"ok": true,
"agent": {
"id": "2b769e5a-a49a-46ac-ac38-ec924bd4ec83"
}
}
}
}

Update an Agent

Mutation updateAgent is used to update information about agent.

updateAgent(agentData: AgentUpdateInput!
agentId: ID!): AgentManageOutput!

Input parameters:

agentData: AgentUpdateInput!: Information necessary for updating an agent:

  • title: String: Agent name.

agentId: ID!: ID assigned to the agent to be updated.

Output parameters:

AgentManageOutput: The mutation result is JSON that contains the following parameters:

  • ok: Boolean!: Attribute that mutation is successfully completed.
  • agent: AgentOutput!: Updated agent object.

Incorrect input errors:

  • Agent not found by the transmitted id:
    {
    "message": "Camera matching query does not exist."
    }

Example Request:

mutation{
updateAgent(
agentId: "19df2b38-7d23-44a5-85e7-c5a29b304581",
agentData: {
title: "My old agent"
}) {
ok
agent {
id
title
}
}
}

Example Response:

API returns the following result:
{
"data": {
"updateAgent": {
"ok": true,
"agent": {
"id": "19df2b38-7d23-44a5-85e7-c5a29b304581",
"title": "My old agent"
}
}
}
}

Delete an Agent

Mutation deleteAgent allows to delete one or several agents.

deleteAgent(agentId: ID = "" agentIds: [ID!] = null): MutationResult!

Input parameters:

agentId: ID: ID assigned to an agent to be deleted.

agentIds: [ID!]: List of IDs assigned to agents to be deleted.

Output parameters:

MutationResult!: The mutation result is JSON that contains the following parameters:

  • ok: Boolean!: Attribute that mutation is successfully completed.

Incorrect input errors:

  • No id has been passed for agent deletion:
    {
    "message": "One of the parameters agentId or agentIds is required",
    "code": "0xe509f74d"
    }

Example Request:

mutation{
deleteAgent(agentId: "19df2b38-7d23-44a5-85e7-c5a29b304581") {
ok
}
}

Example Response:

API returns the following result:
{
"data": {
"deleteAgent": {
"ok": true
}
}
}

Get information about an Agent

Query agentInfo is used to get information about an agent.

query {
agentInfo { }}

Output parameters:

  • id

    • Agent identifier
    • Data type: ID.
  • creationDate

    • Agent creation date
    • Data format: ISO 8601.
  • lastModified

    • Last modification date
    • Data format: ISO 8601.
  • token

    • Agent token
    • Data type: ID.
  • camerasIds

    • Identifiers of cameras assigned to an agent
    • Data type: ID.
  • cameras:

    • id
      • Camera identifier
      • Data type: ID
    • creationDate
      • Camera creation date
      • Data format: ISO 8601.
    • lastModified
      • Last modification date
      • Data format: ISO 8601.
    • info
      • Camera data, e.g., camera custom fields
      • Data format: JSON.
  • title

    • Agent name
    • Data type: String.
  • agentStatus

    • Agent status
    • Data type: String.
  • agentLastActiveTime

    • Last activity date recorded by agent's camera.
    • Data format: ISO 8601.
  • archived

    • Agent archivation attribute.
    • Data type: Boolean.
  • workspaceId

    • Workspace identifier
    • Data type: ID.

Example Request:

query{
agentInfo {
agentLastActiveTime
agentStatus
archived
camerasIds
creationDate
id
lastModified
title
token
workspaceId
}
}

Example Response:

API returns the following result:
{
"data": {
"agentInfo": {
"agentLastActiveTime": null,
"agentStatus": "inactive",
"archived": false,
"camerasIds": [],
"creationDate": "2023-06-02T06:33:56.386734+00:00",
"id": "1609037c-d353-4933-a75d-ddb2a6081fca",
"lastModified": "2023-06-02T06:47:15.931345+00:00",
"title": "Agent2",
"token": "1609037c-d353-4933-a75d-ddb2a6081fca",
"workspaceId": "3f04af73-7f13-49e3-88e2-50c865c97ddf"
}
}
}