2121_Client = Annotated [CloudClient | None , SkipValidation ()]
2222
2323
24+ def _resolve_org_id (org_id : str | None , client : CloudClient ) -> str :
25+ """Return *org_id* if given, otherwise pull it from client config."""
26+ if org_id :
27+ return org_id
28+ resolved = getattr (client , "config" , None )
29+ if resolved and getattr (resolved , "org_id" , "" ):
30+ return resolved .org_id
31+ raise ValueError (
32+ "org_id is required but was not provided and could not be "
33+ "resolved from the client config. Either pass org_id explicitly "
34+ "or set NDI_CLOUD_ORGANIZATION_ID in the environment."
35+ )
36+
37+
2438@_auto_client
2539@validate_call (config = VALIDATE_CONFIG )
2640def getDataset (dataset_id : CloudId , * , client : _Client = None ) -> dict [str , Any ]:
@@ -29,16 +43,22 @@ def getDataset(dataset_id: CloudId, *, client: _Client = None) -> dict[str, Any]
2943
3044
3145@_auto_client
32- @validate_call (config = VALIDATE_CONFIG )
3346def createDataset (
34- org_id : NonEmptyStr ,
35- name : NonEmptyStr ,
47+ org_id : str | None = None ,
48+ name : str = "" ,
3649 description : str = "" ,
3750 * ,
3851 client : _Client = None ,
3952 ** kwargs : Any ,
4053) -> dict [str , Any ]:
41- """POST /organizations/{organizationId}/datasets"""
54+ """POST /organizations/{organizationId}/datasets
55+
56+ If *org_id* is omitted it is resolved from the client's config
57+ (populated automatically during login), matching MATLAB behaviour.
58+ """
59+ org_id = _resolve_org_id (org_id , client )
60+ if not name :
61+ raise ValueError ("name is required" )
4262 body : dict [str , Any ] = {"name" : name }
4363 if description :
4464 body ["description" ] = description
@@ -92,15 +112,19 @@ def deleteDataset(
92112
93113
94114@_auto_client
95- @validate_call (config = VALIDATE_CONFIG )
96115def listDatasets (
97- org_id : NonEmptyStr ,
98- page : PageNumber = 1 ,
99- page_size : PageSize = 1000 ,
116+ org_id : str | None = None ,
117+ page : int = 1 ,
118+ page_size : int = 1000 ,
100119 * ,
101120 client : _Client = None ,
102121) -> dict [str , Any ]:
103- """GET /organizations/{organizationId}/datasets?page=&pageSize="""
122+ """GET /organizations/{organizationId}/datasets?page=&pageSize=
123+
124+ If *org_id* is omitted it is resolved from the client's config
125+ (populated automatically during login), matching MATLAB behaviour.
126+ """
127+ org_id = _resolve_org_id (org_id , client )
104128 return client .get (
105129 "/organizations/{organizationId}/datasets" ,
106130 params = {"page" : page , "pageSize" : page_size },
@@ -112,9 +136,13 @@ def listDatasets(
112136
113137
114138@_auto_client
115- @validate_call (config = VALIDATE_CONFIG )
116- def listAllDatasets (org_id : NonEmptyStr , * , client : _Client = None ) -> APIResponse :
117- """Auto-paginate through all datasets for an organisation."""
139+ def listAllDatasets (org_id : str | None = None , * , client : _Client = None ) -> APIResponse :
140+ """Auto-paginate through all datasets for an organisation.
141+
142+ If *org_id* is omitted it is resolved from the client's config
143+ (populated automatically during login), matching MATLAB behaviour.
144+ """
145+ org_id = _resolve_org_id (org_id , client )
118146 all_datasets : list [dict [str , Any ]] = []
119147 page = 1
120148 while page <= _MAX_PAGES :
0 commit comments