prefect.server.models.agents
Functions for interacting with agent ORM objects. Intended for internal use by the Prefect REST API.
create_agent(session, agent)
async
Inserts a Agent.
If a Agent with the same name exists, an error will be thrown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
a database session |
required |
agent
|
Agent
|
a Agent model |
required |
Returns:
Type | Description |
---|---|
Agent
|
orm_models.Agent: the newly-created or updated Agent |
Source code in src/prefect/server/models/agents.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
delete_agent(session, agent_id)
async
Delete a Agent by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
agent_id
|
str
|
a Agent id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the Agent was deleted |
Source code in src/prefect/server/models/agents.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
read_agent(session, agent_id)
async
Reads a Agent by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
agent_id
|
str
|
a Agent id |
required |
Returns:
Type | Description |
---|---|
Union[Agent, None]
|
orm_models.Agent: the Agent |
Source code in src/prefect/server/models/agents.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
read_agents(session, offset=None, limit=None)
async
Read Agents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
offset
|
int
|
Query offset |
None
|
limit(int)
|
Query limit |
required |
Returns:
Type | Description |
---|---|
Sequence[Agent]
|
List[orm_models.Agent]: Agents |
Source code in src/prefect/server/models/agents.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
record_agent_poll(db, session, agent_id, work_queue_id)
async
Record that an agent has polled a work queue.
If the agent_id already exists, work_queue and last_activity_time will be updated.
This is a convenience method for designed for speed when agents
are polling work queues. For other operations, the
create_agent
and update_agent
methods should be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
agent_id
|
UUID
|
An agent id |
required |
work_queue_id
|
UUID
|
A work queue id |
required |
Source code in src/prefect/server/models/agents.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
update_agent(session, agent_id, agent)
async
Update a Agent by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
agent
|
Agent
|
the work queue data |
required |
agent_id
|
str
|
a Agent id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the Agent was deleted |
Source code in src/prefect/server/models/agents.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|