11from __future__ import annotations
22
3+ from collections .abc import Iterator
34from typing import Any
45
56from ..models .state_version_output import (
67 StateVersionOutput ,
7- StateVersionOutputsList ,
88 StateVersionOutputsListOptions ,
99)
1010from ..utils import valid_string_id
@@ -42,7 +42,7 @@ def read_current(
4242 self ,
4343 workspace_id : str ,
4444 options : StateVersionOutputsListOptions | None = None ,
45- ) -> StateVersionOutputsList :
45+ ) -> Iterator [ StateVersionOutput ] :
4646 """
4747 Read outputs for the workspace's current state version.
4848 Note: sensitive outputs are returned with null values by the API.
@@ -52,32 +52,13 @@ def read_current(
5252
5353 params : dict [str , Any ] = {}
5454 if options :
55- if options .page_number is not None :
56- params ["page[number]" ] = options .page_number
5755 if options .page_size is not None :
5856 params ["page[size]" ] = options .page_size
57+ path = f"/api/v2/workspaces/{ workspace_id } /current-state-version-outputs"
5958
60- r = self .t .request (
61- "GET" ,
62- f"/api/v2/workspaces/{ workspace_id } /current-state-version-outputs" ,
63- params = params ,
64- )
65- data = r .json ()
66-
67- items : list [StateVersionOutput ] = []
68- for item in data .get ("data" , []):
69- attr = item .get ("attributes" , {}) or {}
70- items .append (
71- StateVersionOutput (
72- id = _safe_str (item .get ("id" )),
73- ** {k .replace ("-" , "_" ): v for k , v in attr .items ()},
74- )
59+ for d in self ._list (path , params = params ):
60+ attr = d .get ("attributes" , {}) or {}
61+ yield StateVersionOutput (
62+ id = _safe_str (d .get ("id" )),
63+ ** {k .replace ("-" , "_" ): v for k , v in attr .items ()},
7564 )
76-
77- meta = data .get ("meta" , {}).get ("pagination" , {}) or {}
78- return StateVersionOutputsList (
79- items = items ,
80- current_page = meta .get ("current-page" ),
81- total_pages = meta .get ("total-pages" ),
82- total_count = meta .get ("total-count" ),
83- )
0 commit comments