ctfy.sdk.admin_resources.nodes
client.admin.nodes — worker-node fleet management + bootstrap invites.
The non-admin /nodes registration routes are operator-only in practice
(no player registers a worker node), so register / remove live here
alongside the rest of the fleet tooling. The public node list is on
ctfy.sdk.resources.nodes.NodesResource.list().
1"""``client.admin.nodes`` — worker-node fleet management + bootstrap invites. 2 3The non-admin ``/nodes`` registration routes are operator-only in practice 4(no player registers a worker node), so ``register`` / ``remove`` live here 5alongside the rest of the fleet tooling. The public node *list* is on 6:meth:`ctfy.sdk.resources.nodes.NodesResource.list`. 7""" 8 9from __future__ import annotations 10 11from typing import Any 12 13from ctfy.core.node_join import NodeProfile 14from ctfy.core.state.models import NodeHealthSample 15from ctfy.sdk._helpers import PagedList, _extract_items, _raise_for_status 16from ctfy.sdk.base import BaseHttpClient 17from ctfy.server.models import ( 18 Activity, 19 CreateInviteResponse, 20 CreateJoinCommandResponse, 21 FleetReachAck, 22 FleetReachAckCleared, 23 FleetReachAckResult, 24 FleetReachManifest, 25 FleetReachToken, 26 NodeAddress, 27 NodeFeatures, 28 NodeInfo, 29 NodeInviteInfo, 30) 31 32 33class AdminNodesResource: 34 """Register / remove / patch worker nodes, read health + events, and 35 mint the one-time bootstrap invites a fresh node redeems.""" 36 37 def __init__(self, http: BaseHttpClient) -> None: 38 self._http = http 39 40 def register( 41 self, url: str, capacity: int = 10, labels: dict[str, str] | None = None 42 ) -> NodeInfo: 43 resp = self._http.request( 44 "POST", 45 "/nodes/register", 46 json={ 47 "url": url, 48 "capacity": capacity, 49 "labels": labels or {}, 50 }, 51 ) 52 _raise_for_status(resp) 53 return NodeInfo.model_validate(resp.json()) 54 55 def remove(self, node_id: str) -> None: 56 resp = self._http.request("DELETE", f"/nodes/{node_id}") 57 _raise_for_status(resp) 58 59 def get(self, node_id: str) -> NodeInfo: 60 """Admin-only single-node lookup (full health + capacity).""" 61 resp = self._http.request("GET", f"/admin/nodes/{node_id}") 62 _raise_for_status(resp) 63 return NodeInfo.model_validate(resp.json()) 64 65 def patch(self, node_id: str, **fields: Any) -> NodeInfo: 66 """Admin-only: update editable node metadata. Pass any subset of 67 ``display_name`` / ``labels`` / ``cordoned`` (drain the node, #1900). Omit a 68 field to leave unchanged. Wraps 69 ``PATCH /admin/nodes/{id}``. 70 71 ``labels`` goes with ``expected_labels``, the labels you read (#3738): 72 the platform answers ``409 node_labels_moved`` and writes nothing when 73 they have changed since, so re-read and apply the edit again.""" 74 resp = self._http.request("PATCH", f"/admin/nodes/{node_id}", json=fields) 75 _raise_for_status(resp) 76 return NodeInfo.model_validate(resp.json()) 77 78 def approve( 79 self, 80 node_id: str, 81 profile: NodeProfile = NodeProfile.NORMAL, 82 *, 83 competition_id: str = "", 84 disabled_features: list[str] | None = None, 85 url: str = "", 86 reach_address: str = "", 87 ) -> NodeInfo: 88 """Admin-only: approve a pending node into *profile*'s pool (#3037), 89 with *disabled_features* switched off, and its address corrected to 90 *url* when given (held from then on). Wraps 91 ``POST /admin/nodes/{id}/approve``.""" 92 resp = self._http.request( 93 "POST", 94 f"/admin/nodes/{node_id}/approve", 95 json={ 96 "profile": str(profile), 97 "competition_id": competition_id, 98 "disabled_features": disabled_features or [], 99 "url": url, 100 "reach_address": reach_address, 101 }, 102 ) 103 _raise_for_status(resp) 104 return NodeInfo.model_validate(resp.json()) 105 106 def pin_reach_address(self, node_id: str, address: str) -> NodeAddress: 107 """Admin-only: pin the address the cb VMs' fleet reach accept for this 108 node targets (#3640) — one public IPv4 address no other node holds, 109 verified out of band; never defaulted from the observed address. 110 Wraps ``POST /admin/nodes/{id}/reach-address``.""" 111 resp = self._http.request( 112 "POST", f"/admin/nodes/{node_id}/reach-address", json={"address": address} 113 ) 114 _raise_for_status(resp) 115 return NodeAddress.model_validate(resp.json()) 116 117 def features(self, node_id: str) -> NodeFeatures: 118 """Admin-only: per feature, what the node supports and whether the admin 119 enabled it (#3037). Wraps ``GET /admin/nodes/{id}/features``; switch one 120 with ``patch(node_id, disabled_features=[...])``.""" 121 resp = self._http.request("GET", f"/admin/nodes/{node_id}/features") 122 _raise_for_status(resp) 123 return NodeFeatures.model_validate(resp.json()) 124 125 def fleet_reach(self) -> FleetReachManifest: 126 """Admin-only: what an agent on one node must reach on every other, 127 derived from the node rows (#3428). Wraps ``GET /admin/fleet-reach``; 128 the cb host renders its VM firewall accepts from the same body.""" 129 resp = self._http.request("GET", "/admin/fleet-reach") 130 _raise_for_status(resp) 131 return FleetReachManifest.model_validate(resp.json()) 132 133 def ack_fleet_reach(self, ack: FleetReachAck) -> FleetReachAckResult: 134 """Record that a renderer applied *ack*'s manifest for its agent pools, 135 which placement then derives reach from (#3428). The cb timer calls 136 this after a converged apply. Wraps ``POST /admin/fleet-reach/ack``.""" 137 resp = self._http.request( 138 "POST", "/admin/fleet-reach/ack", json=ack.model_dump(mode="json") 139 ) 140 _raise_for_status(resp) 141 return FleetReachAckResult.model_validate(resp.json()) 142 143 def clear_fleet_reach_ack(self, pool: str = "") -> FleetReachAckCleared: 144 """Forget the stored ack of *pool*, or of every pool when ``""`` 145 (#3428 rollback): placement then reads it as unproven (fails open) 146 until the renderer acks again. Admin only. Wraps 147 ``DELETE /admin/fleet-reach/ack``.""" 148 params = {"pool": pool} if pool else None 149 resp = self._http.request("DELETE", "/admin/fleet-reach/ack", params=params) 150 _raise_for_status(resp) 151 return FleetReachAckCleared.model_validate(resp.json()) 152 153 def mint_fleet_reach_token(self) -> FleetReachToken: 154 """Mint the cb renderer's bearer, scoped to the fleet reach routes 155 (#3428). Shown once; replaces (voids) any previous one. Wraps 156 ``POST /admin/fleet-reach/token``.""" 157 resp = self._http.request("POST", "/admin/fleet-reach/token") 158 _raise_for_status(resp) 159 return FleetReachToken.model_validate(resp.json()) 160 161 def revoke_fleet_reach_token(self) -> None: 162 """Void the cb renderer's bearer. Idempotent. Wraps 163 ``DELETE /admin/fleet-reach/token``.""" 164 resp = self._http.request("DELETE", "/admin/fleet-reach/token") 165 _raise_for_status(resp) 166 167 def address(self, node_id: str, *, check: bool = False) -> NodeAddress: 168 """Admin-only: the node's claimed address, the source address the 169 platform saw and its UDP readings (#3037). *check* probes the UDP 170 surfaces first. Wraps ``GET /admin/nodes/{id}/address`` and 171 ``POST /admin/nodes/{id}/address/check``.""" 172 if check: 173 resp = self._http.request("POST", f"/admin/nodes/{node_id}/address/check") 174 else: 175 resp = self._http.request("GET", f"/admin/nodes/{node_id}/address") 176 _raise_for_status(resp) 177 return NodeAddress.model_validate(resp.json()) 178 179 def reject(self, node_id: str) -> None: 180 """Admin-only: reject a pending node — its row and token are removed 181 (#3037). Wraps ``POST /admin/nodes/{id}/reject``.""" 182 resp = self._http.request("POST", f"/admin/nodes/{node_id}/reject") 183 _raise_for_status(resp) 184 185 def health_history( 186 self, node_id: str, offset: int = 0, limit: int = 50 187 ) -> list[NodeHealthSample]: 188 """Recent heartbeat samples for one node — for the node detail page.""" 189 resp = self._http.request( 190 "GET", 191 f"/admin/nodes/{node_id}/health-history", 192 params={"offset": offset, "limit": limit}, 193 ) 194 _raise_for_status(resp) 195 return [NodeHealthSample.model_validate(s) for s in resp.json()["items"]] 196 197 def events(self, node_id: str, *, offset: int = 0, limit: int = 50) -> PagedList[Activity]: 198 """Activity rows where ``actor`` or subject is this node.""" 199 resp = self._http.request( 200 "GET", 201 f"/admin/nodes/{node_id}/events", 202 params={"offset": offset, "limit": limit}, 203 ) 204 _raise_for_status(resp) 205 return _extract_items(resp.json(), Activity) 206 207 def list_invites(self, offset: int = 0, limit: int = 50) -> PagedList[NodeInviteInfo]: 208 """Outstanding one-time worker-node bootstrap invites.""" 209 resp = self._http.request( 210 "GET", "/nodes/invites", params={"offset": offset, "limit": limit} 211 ) 212 _raise_for_status(resp) 213 return _extract_items(resp.json(), NodeInviteInfo) 214 215 def mint_invite(self, ttl_seconds: int = 24 * 3600) -> CreateInviteResponse: 216 """Mint a one-time node bootstrap token. A node redeems it once 217 to obtain its long-lived per-node bearer.""" 218 resp = self._http.request("POST", "/nodes/invites", json={"ttl_seconds": ttl_seconds}) 219 _raise_for_status(resp) 220 return CreateInviteResponse.model_validate(resp.json()) 221 222 def mint_join_command( 223 self, 224 profile: NodeProfile = NodeProfile.NORMAL, 225 *, 226 competition_id: str = "", 227 display_name: str = "", 228 capacity: int = 0, 229 ttl_seconds: int = 3600, 230 no_corpus: bool = False, 231 ) -> CreateJoinCommandResponse: 232 """Mint a one-time invite wrapped as the single command a bare machine 233 runs (#2115). The plaintext rides the returned ``command`` / ``join_code`` 234 once and is never listed again. Wraps ``POST /nodes/join-commands``.""" 235 resp = self._http.request( 236 "POST", 237 "/nodes/join-commands", 238 json={ 239 "profile": str(profile), 240 "competition_id": competition_id, 241 "display_name": display_name, 242 "capacity": capacity, 243 "ttl_seconds": ttl_seconds, 244 "no_corpus": no_corpus, 245 }, 246 ) 247 _raise_for_status(resp) 248 return CreateJoinCommandResponse.model_validate(resp.json()) 249 250 def revoke_invite(self, invite_id: str) -> None: 251 """Revoke an unredeemed node invite. Idempotent.""" 252 resp = self._http.request("DELETE", f"/nodes/invites/{invite_id}") 253 _raise_for_status(resp)
34class AdminNodesResource: 35 """Register / remove / patch worker nodes, read health + events, and 36 mint the one-time bootstrap invites a fresh node redeems.""" 37 38 def __init__(self, http: BaseHttpClient) -> None: 39 self._http = http 40 41 def register( 42 self, url: str, capacity: int = 10, labels: dict[str, str] | None = None 43 ) -> NodeInfo: 44 resp = self._http.request( 45 "POST", 46 "/nodes/register", 47 json={ 48 "url": url, 49 "capacity": capacity, 50 "labels": labels or {}, 51 }, 52 ) 53 _raise_for_status(resp) 54 return NodeInfo.model_validate(resp.json()) 55 56 def remove(self, node_id: str) -> None: 57 resp = self._http.request("DELETE", f"/nodes/{node_id}") 58 _raise_for_status(resp) 59 60 def get(self, node_id: str) -> NodeInfo: 61 """Admin-only single-node lookup (full health + capacity).""" 62 resp = self._http.request("GET", f"/admin/nodes/{node_id}") 63 _raise_for_status(resp) 64 return NodeInfo.model_validate(resp.json()) 65 66 def patch(self, node_id: str, **fields: Any) -> NodeInfo: 67 """Admin-only: update editable node metadata. Pass any subset of 68 ``display_name`` / ``labels`` / ``cordoned`` (drain the node, #1900). Omit a 69 field to leave unchanged. Wraps 70 ``PATCH /admin/nodes/{id}``. 71 72 ``labels`` goes with ``expected_labels``, the labels you read (#3738): 73 the platform answers ``409 node_labels_moved`` and writes nothing when 74 they have changed since, so re-read and apply the edit again.""" 75 resp = self._http.request("PATCH", f"/admin/nodes/{node_id}", json=fields) 76 _raise_for_status(resp) 77 return NodeInfo.model_validate(resp.json()) 78 79 def approve( 80 self, 81 node_id: str, 82 profile: NodeProfile = NodeProfile.NORMAL, 83 *, 84 competition_id: str = "", 85 disabled_features: list[str] | None = None, 86 url: str = "", 87 reach_address: str = "", 88 ) -> NodeInfo: 89 """Admin-only: approve a pending node into *profile*'s pool (#3037), 90 with *disabled_features* switched off, and its address corrected to 91 *url* when given (held from then on). Wraps 92 ``POST /admin/nodes/{id}/approve``.""" 93 resp = self._http.request( 94 "POST", 95 f"/admin/nodes/{node_id}/approve", 96 json={ 97 "profile": str(profile), 98 "competition_id": competition_id, 99 "disabled_features": disabled_features or [], 100 "url": url, 101 "reach_address": reach_address, 102 }, 103 ) 104 _raise_for_status(resp) 105 return NodeInfo.model_validate(resp.json()) 106 107 def pin_reach_address(self, node_id: str, address: str) -> NodeAddress: 108 """Admin-only: pin the address the cb VMs' fleet reach accept for this 109 node targets (#3640) — one public IPv4 address no other node holds, 110 verified out of band; never defaulted from the observed address. 111 Wraps ``POST /admin/nodes/{id}/reach-address``.""" 112 resp = self._http.request( 113 "POST", f"/admin/nodes/{node_id}/reach-address", json={"address": address} 114 ) 115 _raise_for_status(resp) 116 return NodeAddress.model_validate(resp.json()) 117 118 def features(self, node_id: str) -> NodeFeatures: 119 """Admin-only: per feature, what the node supports and whether the admin 120 enabled it (#3037). Wraps ``GET /admin/nodes/{id}/features``; switch one 121 with ``patch(node_id, disabled_features=[...])``.""" 122 resp = self._http.request("GET", f"/admin/nodes/{node_id}/features") 123 _raise_for_status(resp) 124 return NodeFeatures.model_validate(resp.json()) 125 126 def fleet_reach(self) -> FleetReachManifest: 127 """Admin-only: what an agent on one node must reach on every other, 128 derived from the node rows (#3428). Wraps ``GET /admin/fleet-reach``; 129 the cb host renders its VM firewall accepts from the same body.""" 130 resp = self._http.request("GET", "/admin/fleet-reach") 131 _raise_for_status(resp) 132 return FleetReachManifest.model_validate(resp.json()) 133 134 def ack_fleet_reach(self, ack: FleetReachAck) -> FleetReachAckResult: 135 """Record that a renderer applied *ack*'s manifest for its agent pools, 136 which placement then derives reach from (#3428). The cb timer calls 137 this after a converged apply. Wraps ``POST /admin/fleet-reach/ack``.""" 138 resp = self._http.request( 139 "POST", "/admin/fleet-reach/ack", json=ack.model_dump(mode="json") 140 ) 141 _raise_for_status(resp) 142 return FleetReachAckResult.model_validate(resp.json()) 143 144 def clear_fleet_reach_ack(self, pool: str = "") -> FleetReachAckCleared: 145 """Forget the stored ack of *pool*, or of every pool when ``""`` 146 (#3428 rollback): placement then reads it as unproven (fails open) 147 until the renderer acks again. Admin only. Wraps 148 ``DELETE /admin/fleet-reach/ack``.""" 149 params = {"pool": pool} if pool else None 150 resp = self._http.request("DELETE", "/admin/fleet-reach/ack", params=params) 151 _raise_for_status(resp) 152 return FleetReachAckCleared.model_validate(resp.json()) 153 154 def mint_fleet_reach_token(self) -> FleetReachToken: 155 """Mint the cb renderer's bearer, scoped to the fleet reach routes 156 (#3428). Shown once; replaces (voids) any previous one. Wraps 157 ``POST /admin/fleet-reach/token``.""" 158 resp = self._http.request("POST", "/admin/fleet-reach/token") 159 _raise_for_status(resp) 160 return FleetReachToken.model_validate(resp.json()) 161 162 def revoke_fleet_reach_token(self) -> None: 163 """Void the cb renderer's bearer. Idempotent. Wraps 164 ``DELETE /admin/fleet-reach/token``.""" 165 resp = self._http.request("DELETE", "/admin/fleet-reach/token") 166 _raise_for_status(resp) 167 168 def address(self, node_id: str, *, check: bool = False) -> NodeAddress: 169 """Admin-only: the node's claimed address, the source address the 170 platform saw and its UDP readings (#3037). *check* probes the UDP 171 surfaces first. Wraps ``GET /admin/nodes/{id}/address`` and 172 ``POST /admin/nodes/{id}/address/check``.""" 173 if check: 174 resp = self._http.request("POST", f"/admin/nodes/{node_id}/address/check") 175 else: 176 resp = self._http.request("GET", f"/admin/nodes/{node_id}/address") 177 _raise_for_status(resp) 178 return NodeAddress.model_validate(resp.json()) 179 180 def reject(self, node_id: str) -> None: 181 """Admin-only: reject a pending node — its row and token are removed 182 (#3037). Wraps ``POST /admin/nodes/{id}/reject``.""" 183 resp = self._http.request("POST", f"/admin/nodes/{node_id}/reject") 184 _raise_for_status(resp) 185 186 def health_history( 187 self, node_id: str, offset: int = 0, limit: int = 50 188 ) -> list[NodeHealthSample]: 189 """Recent heartbeat samples for one node — for the node detail page.""" 190 resp = self._http.request( 191 "GET", 192 f"/admin/nodes/{node_id}/health-history", 193 params={"offset": offset, "limit": limit}, 194 ) 195 _raise_for_status(resp) 196 return [NodeHealthSample.model_validate(s) for s in resp.json()["items"]] 197 198 def events(self, node_id: str, *, offset: int = 0, limit: int = 50) -> PagedList[Activity]: 199 """Activity rows where ``actor`` or subject is this node.""" 200 resp = self._http.request( 201 "GET", 202 f"/admin/nodes/{node_id}/events", 203 params={"offset": offset, "limit": limit}, 204 ) 205 _raise_for_status(resp) 206 return _extract_items(resp.json(), Activity) 207 208 def list_invites(self, offset: int = 0, limit: int = 50) -> PagedList[NodeInviteInfo]: 209 """Outstanding one-time worker-node bootstrap invites.""" 210 resp = self._http.request( 211 "GET", "/nodes/invites", params={"offset": offset, "limit": limit} 212 ) 213 _raise_for_status(resp) 214 return _extract_items(resp.json(), NodeInviteInfo) 215 216 def mint_invite(self, ttl_seconds: int = 24 * 3600) -> CreateInviteResponse: 217 """Mint a one-time node bootstrap token. A node redeems it once 218 to obtain its long-lived per-node bearer.""" 219 resp = self._http.request("POST", "/nodes/invites", json={"ttl_seconds": ttl_seconds}) 220 _raise_for_status(resp) 221 return CreateInviteResponse.model_validate(resp.json()) 222 223 def mint_join_command( 224 self, 225 profile: NodeProfile = NodeProfile.NORMAL, 226 *, 227 competition_id: str = "", 228 display_name: str = "", 229 capacity: int = 0, 230 ttl_seconds: int = 3600, 231 no_corpus: bool = False, 232 ) -> CreateJoinCommandResponse: 233 """Mint a one-time invite wrapped as the single command a bare machine 234 runs (#2115). The plaintext rides the returned ``command`` / ``join_code`` 235 once and is never listed again. Wraps ``POST /nodes/join-commands``.""" 236 resp = self._http.request( 237 "POST", 238 "/nodes/join-commands", 239 json={ 240 "profile": str(profile), 241 "competition_id": competition_id, 242 "display_name": display_name, 243 "capacity": capacity, 244 "ttl_seconds": ttl_seconds, 245 "no_corpus": no_corpus, 246 }, 247 ) 248 _raise_for_status(resp) 249 return CreateJoinCommandResponse.model_validate(resp.json()) 250 251 def revoke_invite(self, invite_id: str) -> None: 252 """Revoke an unredeemed node invite. Idempotent.""" 253 resp = self._http.request("DELETE", f"/nodes/invites/{invite_id}") 254 _raise_for_status(resp)
Register / remove / patch worker nodes, read health + events, and mint the one-time bootstrap invites a fresh node redeems.
41 def register( 42 self, url: str, capacity: int = 10, labels: dict[str, str] | None = None 43 ) -> NodeInfo: 44 resp = self._http.request( 45 "POST", 46 "/nodes/register", 47 json={ 48 "url": url, 49 "capacity": capacity, 50 "labels": labels or {}, 51 }, 52 ) 53 _raise_for_status(resp) 54 return NodeInfo.model_validate(resp.json())
60 def get(self, node_id: str) -> NodeInfo: 61 """Admin-only single-node lookup (full health + capacity).""" 62 resp = self._http.request("GET", f"/admin/nodes/{node_id}") 63 _raise_for_status(resp) 64 return NodeInfo.model_validate(resp.json())
Admin-only single-node lookup (full health + capacity).
66 def patch(self, node_id: str, **fields: Any) -> NodeInfo: 67 """Admin-only: update editable node metadata. Pass any subset of 68 ``display_name`` / ``labels`` / ``cordoned`` (drain the node, #1900). Omit a 69 field to leave unchanged. Wraps 70 ``PATCH /admin/nodes/{id}``. 71 72 ``labels`` goes with ``expected_labels``, the labels you read (#3738): 73 the platform answers ``409 node_labels_moved`` and writes nothing when 74 they have changed since, so re-read and apply the edit again.""" 75 resp = self._http.request("PATCH", f"/admin/nodes/{node_id}", json=fields) 76 _raise_for_status(resp) 77 return NodeInfo.model_validate(resp.json())
Admin-only: update editable node metadata. Pass any subset of
display_name / labels / cordoned (drain the node, #1900). Omit a
field to leave unchanged. Wraps
PATCH /admin/nodes/{id}.
labels goes with expected_labels, the labels you read (#3738):
the platform answers 409 node_labels_moved and writes nothing when
they have changed since, so re-read and apply the edit again.
79 def approve( 80 self, 81 node_id: str, 82 profile: NodeProfile = NodeProfile.NORMAL, 83 *, 84 competition_id: str = "", 85 disabled_features: list[str] | None = None, 86 url: str = "", 87 reach_address: str = "", 88 ) -> NodeInfo: 89 """Admin-only: approve a pending node into *profile*'s pool (#3037), 90 with *disabled_features* switched off, and its address corrected to 91 *url* when given (held from then on). Wraps 92 ``POST /admin/nodes/{id}/approve``.""" 93 resp = self._http.request( 94 "POST", 95 f"/admin/nodes/{node_id}/approve", 96 json={ 97 "profile": str(profile), 98 "competition_id": competition_id, 99 "disabled_features": disabled_features or [], 100 "url": url, 101 "reach_address": reach_address, 102 }, 103 ) 104 _raise_for_status(resp) 105 return NodeInfo.model_validate(resp.json())
Admin-only: approve a pending node into profile's pool (#3037),
with disabled_features switched off, and its address corrected to
url when given (held from then on). Wraps
POST /admin/nodes/{id}/approve.
107 def pin_reach_address(self, node_id: str, address: str) -> NodeAddress: 108 """Admin-only: pin the address the cb VMs' fleet reach accept for this 109 node targets (#3640) — one public IPv4 address no other node holds, 110 verified out of band; never defaulted from the observed address. 111 Wraps ``POST /admin/nodes/{id}/reach-address``.""" 112 resp = self._http.request( 113 "POST", f"/admin/nodes/{node_id}/reach-address", json={"address": address} 114 ) 115 _raise_for_status(resp) 116 return NodeAddress.model_validate(resp.json())
Admin-only: pin the address the cb VMs' fleet reach accept for this
node targets (#3640) — one public IPv4 address no other node holds,
verified out of band; never defaulted from the observed address.
Wraps POST /admin/nodes/{id}/reach-address.
118 def features(self, node_id: str) -> NodeFeatures: 119 """Admin-only: per feature, what the node supports and whether the admin 120 enabled it (#3037). Wraps ``GET /admin/nodes/{id}/features``; switch one 121 with ``patch(node_id, disabled_features=[...])``.""" 122 resp = self._http.request("GET", f"/admin/nodes/{node_id}/features") 123 _raise_for_status(resp) 124 return NodeFeatures.model_validate(resp.json())
Admin-only: per feature, what the node supports and whether the admin
enabled it (#3037). Wraps GET /admin/nodes/{id}/features; switch one
with patch(node_id, disabled_features=[...]).
126 def fleet_reach(self) -> FleetReachManifest: 127 """Admin-only: what an agent on one node must reach on every other, 128 derived from the node rows (#3428). Wraps ``GET /admin/fleet-reach``; 129 the cb host renders its VM firewall accepts from the same body.""" 130 resp = self._http.request("GET", "/admin/fleet-reach") 131 _raise_for_status(resp) 132 return FleetReachManifest.model_validate(resp.json())
Admin-only: what an agent on one node must reach on every other,
derived from the node rows (#3428). Wraps GET /admin/fleet-reach;
the cb host renders its VM firewall accepts from the same body.
134 def ack_fleet_reach(self, ack: FleetReachAck) -> FleetReachAckResult: 135 """Record that a renderer applied *ack*'s manifest for its agent pools, 136 which placement then derives reach from (#3428). The cb timer calls 137 this after a converged apply. Wraps ``POST /admin/fleet-reach/ack``.""" 138 resp = self._http.request( 139 "POST", "/admin/fleet-reach/ack", json=ack.model_dump(mode="json") 140 ) 141 _raise_for_status(resp) 142 return FleetReachAckResult.model_validate(resp.json())
Record that a renderer applied ack's manifest for its agent pools,
which placement then derives reach from (#3428). The cb timer calls
this after a converged apply. Wraps POST /admin/fleet-reach/ack.
144 def clear_fleet_reach_ack(self, pool: str = "") -> FleetReachAckCleared: 145 """Forget the stored ack of *pool*, or of every pool when ``""`` 146 (#3428 rollback): placement then reads it as unproven (fails open) 147 until the renderer acks again. Admin only. Wraps 148 ``DELETE /admin/fleet-reach/ack``.""" 149 params = {"pool": pool} if pool else None 150 resp = self._http.request("DELETE", "/admin/fleet-reach/ack", params=params) 151 _raise_for_status(resp) 152 return FleetReachAckCleared.model_validate(resp.json())
Forget the stored ack of pool, or of every pool when ""
(#3428 rollback): placement then reads it as unproven (fails open)
until the renderer acks again. Admin only. Wraps
DELETE /admin/fleet-reach/ack.
154 def mint_fleet_reach_token(self) -> FleetReachToken: 155 """Mint the cb renderer's bearer, scoped to the fleet reach routes 156 (#3428). Shown once; replaces (voids) any previous one. Wraps 157 ``POST /admin/fleet-reach/token``.""" 158 resp = self._http.request("POST", "/admin/fleet-reach/token") 159 _raise_for_status(resp) 160 return FleetReachToken.model_validate(resp.json())
Mint the cb renderer's bearer, scoped to the fleet reach routes
(#3428). Shown once; replaces (voids) any previous one. Wraps
POST /admin/fleet-reach/token.
162 def revoke_fleet_reach_token(self) -> None: 163 """Void the cb renderer's bearer. Idempotent. Wraps 164 ``DELETE /admin/fleet-reach/token``.""" 165 resp = self._http.request("DELETE", "/admin/fleet-reach/token") 166 _raise_for_status(resp)
Void the cb renderer's bearer. Idempotent. Wraps
DELETE /admin/fleet-reach/token.
168 def address(self, node_id: str, *, check: bool = False) -> NodeAddress: 169 """Admin-only: the node's claimed address, the source address the 170 platform saw and its UDP readings (#3037). *check* probes the UDP 171 surfaces first. Wraps ``GET /admin/nodes/{id}/address`` and 172 ``POST /admin/nodes/{id}/address/check``.""" 173 if check: 174 resp = self._http.request("POST", f"/admin/nodes/{node_id}/address/check") 175 else: 176 resp = self._http.request("GET", f"/admin/nodes/{node_id}/address") 177 _raise_for_status(resp) 178 return NodeAddress.model_validate(resp.json())
Admin-only: the node's claimed address, the source address the
platform saw and its UDP readings (#3037). check probes the UDP
surfaces first. Wraps GET /admin/nodes/{id}/address and
POST /admin/nodes/{id}/address/check.
180 def reject(self, node_id: str) -> None: 181 """Admin-only: reject a pending node — its row and token are removed 182 (#3037). Wraps ``POST /admin/nodes/{id}/reject``.""" 183 resp = self._http.request("POST", f"/admin/nodes/{node_id}/reject") 184 _raise_for_status(resp)
Admin-only: reject a pending node — its row and token are removed
(#3037). Wraps POST /admin/nodes/{id}/reject.
186 def health_history( 187 self, node_id: str, offset: int = 0, limit: int = 50 188 ) -> list[NodeHealthSample]: 189 """Recent heartbeat samples for one node — for the node detail page.""" 190 resp = self._http.request( 191 "GET", 192 f"/admin/nodes/{node_id}/health-history", 193 params={"offset": offset, "limit": limit}, 194 ) 195 _raise_for_status(resp) 196 return [NodeHealthSample.model_validate(s) for s in resp.json()["items"]]
Recent heartbeat samples for one node — for the node detail page.
198 def events(self, node_id: str, *, offset: int = 0, limit: int = 50) -> PagedList[Activity]: 199 """Activity rows where ``actor`` or subject is this node.""" 200 resp = self._http.request( 201 "GET", 202 f"/admin/nodes/{node_id}/events", 203 params={"offset": offset, "limit": limit}, 204 ) 205 _raise_for_status(resp) 206 return _extract_items(resp.json(), Activity)
Activity rows where actor or subject is this node.
208 def list_invites(self, offset: int = 0, limit: int = 50) -> PagedList[NodeInviteInfo]: 209 """Outstanding one-time worker-node bootstrap invites.""" 210 resp = self._http.request( 211 "GET", "/nodes/invites", params={"offset": offset, "limit": limit} 212 ) 213 _raise_for_status(resp) 214 return _extract_items(resp.json(), NodeInviteInfo)
Outstanding one-time worker-node bootstrap invites.
216 def mint_invite(self, ttl_seconds: int = 24 * 3600) -> CreateInviteResponse: 217 """Mint a one-time node bootstrap token. A node redeems it once 218 to obtain its long-lived per-node bearer.""" 219 resp = self._http.request("POST", "/nodes/invites", json={"ttl_seconds": ttl_seconds}) 220 _raise_for_status(resp) 221 return CreateInviteResponse.model_validate(resp.json())
Mint a one-time node bootstrap token. A node redeems it once to obtain its long-lived per-node bearer.
223 def mint_join_command( 224 self, 225 profile: NodeProfile = NodeProfile.NORMAL, 226 *, 227 competition_id: str = "", 228 display_name: str = "", 229 capacity: int = 0, 230 ttl_seconds: int = 3600, 231 no_corpus: bool = False, 232 ) -> CreateJoinCommandResponse: 233 """Mint a one-time invite wrapped as the single command a bare machine 234 runs (#2115). The plaintext rides the returned ``command`` / ``join_code`` 235 once and is never listed again. Wraps ``POST /nodes/join-commands``.""" 236 resp = self._http.request( 237 "POST", 238 "/nodes/join-commands", 239 json={ 240 "profile": str(profile), 241 "competition_id": competition_id, 242 "display_name": display_name, 243 "capacity": capacity, 244 "ttl_seconds": ttl_seconds, 245 "no_corpus": no_corpus, 246 }, 247 ) 248 _raise_for_status(resp) 249 return CreateJoinCommandResponse.model_validate(resp.json())
Mint a one-time invite wrapped as the single command a bare machine
runs (#2115). The plaintext rides the returned command / join_code
once and is never listed again. Wraps POST /nodes/join-commands.
251 def revoke_invite(self, invite_id: str) -> None: 252 """Revoke an unredeemed node invite. Idempotent.""" 253 resp = self._http.request("DELETE", f"/nodes/invites/{invite_id}") 254 _raise_for_status(resp)
Revoke an unredeemed node invite. Idempotent.