@@ -409,7 +409,7 @@ def delete(self, agent_pool_id: str) -> None:
409409
410410 def assign_to_workspaces (
411411 self , agent_pool_id : str , options : AgentPoolAssignToWorkspacesOptions
412- ) -> None :
412+ ) -> AgentPool :
413413 """Assign an agent pool to workspaces by updating the allowed-workspaces
414414 relationship via PATCH /agent-pools/:id.
415415
@@ -420,6 +420,9 @@ def assign_to_workspaces(
420420 agent_pool_id: Agent pool ID
421421 options: Assignment options containing workspace IDs
422422
423+ Returns:
424+ Updated AgentPool object
425+
423426 Raises:
424427 ValueError: If parameters are invalid
425428 TFEError: If API request fails
@@ -450,11 +453,34 @@ def assign_to_workspaces(
450453 },
451454 }
452455 }
453- self .t .request ("PATCH" , path , json_body = payload )
456+ response = self .t .request ("PATCH" , path , json_body = payload )
457+ data = response .json ()["data" ]
458+
459+ # Extract agent pool data from response
460+ attr = data .get ("attributes" , {}) or {}
461+ agent_pool_data = {
462+ "id" : _safe_str (data .get ("id" )),
463+ "name" : _safe_str (attr .get ("name" )),
464+ "created_at" : attr .get ("created-at" ),
465+ "organization_scoped" : attr .get ("organization-scoped" ),
466+ "allowed_workspace_policy" : attr .get ("allowed-workspace-policy" ),
467+ "agent_count" : attr .get ("agent-count" , 0 ),
468+ }
469+
470+ return AgentPool (
471+ id = _safe_str (agent_pool_data ["id" ]) or "" ,
472+ name = _safe_str (agent_pool_data ["name" ]),
473+ created_at = cast (Any , agent_pool_data ["created_at" ]),
474+ organization_scoped = _safe_bool (agent_pool_data ["organization_scoped" ]),
475+ allowed_workspace_policy = _safe_workspace_policy (
476+ agent_pool_data ["allowed_workspace_policy" ]
477+ ),
478+ agent_count = _safe_int (agent_pool_data ["agent_count" ]),
479+ )
454480
455481 def remove_from_workspaces (
456482 self , agent_pool_id : str , options : AgentPoolRemoveFromWorkspacesOptions
457- ) -> None :
483+ ) -> AgentPool :
458484 """Exclude workspaces from an agent pool by updating the excluded-workspaces
459485 relationship via PATCH /agent-pools/:id.
460486
@@ -466,6 +492,9 @@ def remove_from_workspaces(
466492 agent_pool_id: Agent pool ID
467493 options: Removal options containing workspace IDs to exclude
468494
495+ Returns:
496+ Updated AgentPool object
497+
469498 Raises:
470499 ValueError: If parameters are invalid
471500 TFEError: If API request fails
@@ -496,4 +525,27 @@ def remove_from_workspaces(
496525 },
497526 }
498527 }
499- self .t .request ("PATCH" , path , json_body = payload )
528+ response = self .t .request ("PATCH" , path , json_body = payload )
529+ data = response .json ()["data" ]
530+
531+ # Extract agent pool data from response
532+ attr = data .get ("attributes" , {}) or {}
533+ agent_pool_data = {
534+ "id" : _safe_str (data .get ("id" )),
535+ "name" : _safe_str (attr .get ("name" )),
536+ "created_at" : attr .get ("created-at" ),
537+ "organization_scoped" : attr .get ("organization-scoped" ),
538+ "allowed_workspace_policy" : attr .get ("allowed-workspace-policy" ),
539+ "agent_count" : attr .get ("agent-count" , 0 ),
540+ }
541+
542+ return AgentPool (
543+ id = _safe_str (agent_pool_data ["id" ]) or "" ,
544+ name = _safe_str (agent_pool_data ["name" ]),
545+ created_at = cast (Any , agent_pool_data ["created_at" ]),
546+ organization_scoped = _safe_bool (agent_pool_data ["organization_scoped" ]),
547+ allowed_workspace_policy = _safe_workspace_policy (
548+ agent_pool_data ["allowed_workspace_policy" ]
549+ ),
550+ agent_count = _safe_int (agent_pool_data ["agent_count" ]),
551+ )
0 commit comments