dataspace-sdk 0.4.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dataspace_sdk/__init__.py +18 -0
- dataspace_sdk/__version__.py +3 -0
- dataspace_sdk/auth.py +470 -0
- dataspace_sdk/base.py +160 -0
- dataspace_sdk/client.py +206 -0
- dataspace_sdk/exceptions.py +36 -0
- dataspace_sdk/resources/__init__.py +8 -0
- dataspace_sdk/resources/aimodels.py +989 -0
- dataspace_sdk/resources/datasets.py +233 -0
- dataspace_sdk/resources/sectors.py +128 -0
- dataspace_sdk/resources/usecases.py +248 -0
- dataspace_sdk-0.4.2.dist-info/METADATA +551 -0
- dataspace_sdk-0.4.2.dist-info/RECORD +15 -0
- dataspace_sdk-0.4.2.dist-info/WHEEL +5 -0
- dataspace_sdk-0.4.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"""Dataset resource client for DataSpace SDK."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from dataspace_sdk.base import BaseAPIClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DatasetClient(BaseAPIClient):
|
|
9
|
+
"""Client for interacting with Dataset resources."""
|
|
10
|
+
|
|
11
|
+
def search(
|
|
12
|
+
self,
|
|
13
|
+
query: Optional[str] = None,
|
|
14
|
+
tags: Optional[List[str]] = None,
|
|
15
|
+
sectors: Optional[List[str]] = None,
|
|
16
|
+
geographies: Optional[List[str]] = None,
|
|
17
|
+
status: Optional[str] = None,
|
|
18
|
+
access_type: Optional[str] = None,
|
|
19
|
+
sort: Optional[str] = None,
|
|
20
|
+
page: int = 1,
|
|
21
|
+
page_size: int = 10,
|
|
22
|
+
) -> Dict[str, Any]:
|
|
23
|
+
"""
|
|
24
|
+
Search for datasets using Elasticsearch.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
query: Search query string
|
|
28
|
+
tags: Filter by tags
|
|
29
|
+
sectors: Filter by sectors
|
|
30
|
+
geographies: Filter by geographies
|
|
31
|
+
status: Filter by status (DRAFT, PUBLISHED, etc.)
|
|
32
|
+
access_type: Filter by access type (OPEN, RESTRICTED, etc.)
|
|
33
|
+
sort: Sort order (recent, alphabetical)
|
|
34
|
+
page: Page number (1-indexed)
|
|
35
|
+
page_size: Number of results per page
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Dictionary containing search results and metadata
|
|
39
|
+
"""
|
|
40
|
+
params: Dict[str, Any] = {
|
|
41
|
+
"page": page,
|
|
42
|
+
"page_size": page_size,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if query:
|
|
46
|
+
params["q"] = query
|
|
47
|
+
if tags:
|
|
48
|
+
params["tags"] = ",".join(tags)
|
|
49
|
+
if sectors:
|
|
50
|
+
params["sectors"] = ",".join(sectors)
|
|
51
|
+
if geographies:
|
|
52
|
+
params["geographies"] = ",".join(geographies)
|
|
53
|
+
if status:
|
|
54
|
+
params["status"] = status
|
|
55
|
+
if access_type:
|
|
56
|
+
params["access_type"] = access_type
|
|
57
|
+
if sort:
|
|
58
|
+
params["sort"] = sort
|
|
59
|
+
|
|
60
|
+
return super().get("/api/search/dataset/", params=params)
|
|
61
|
+
|
|
62
|
+
def get_by_id(self, dataset_id: str) -> Dict[str, Any]:
|
|
63
|
+
"""
|
|
64
|
+
Get a dataset by ID using GraphQL.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
dataset_id: UUID of the dataset
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Dictionary containing dataset information
|
|
71
|
+
"""
|
|
72
|
+
query = """
|
|
73
|
+
query GetDataset($id: UUID!) {
|
|
74
|
+
dataset(id: $id) {
|
|
75
|
+
id
|
|
76
|
+
title
|
|
77
|
+
description
|
|
78
|
+
status
|
|
79
|
+
accessType
|
|
80
|
+
license
|
|
81
|
+
createdAt
|
|
82
|
+
updatedAt
|
|
83
|
+
organization {
|
|
84
|
+
id
|
|
85
|
+
name
|
|
86
|
+
description
|
|
87
|
+
}
|
|
88
|
+
tags {
|
|
89
|
+
id
|
|
90
|
+
value
|
|
91
|
+
}
|
|
92
|
+
sectors {
|
|
93
|
+
id
|
|
94
|
+
name
|
|
95
|
+
}
|
|
96
|
+
geographies {
|
|
97
|
+
id
|
|
98
|
+
name
|
|
99
|
+
}
|
|
100
|
+
resources {
|
|
101
|
+
id
|
|
102
|
+
title
|
|
103
|
+
description
|
|
104
|
+
fileDetails
|
|
105
|
+
schema
|
|
106
|
+
createdAt
|
|
107
|
+
updatedAt
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
response = self.post(
|
|
114
|
+
"/api/graphql",
|
|
115
|
+
json_data={
|
|
116
|
+
"query": query,
|
|
117
|
+
"variables": {"id": dataset_id},
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if "errors" in response:
|
|
122
|
+
from dataspace_sdk.exceptions import DataSpaceAPIError
|
|
123
|
+
|
|
124
|
+
raise DataSpaceAPIError(f"GraphQL error: {response['errors']}")
|
|
125
|
+
|
|
126
|
+
result: Dict[str, Any] = response.get("data", {}).get("dataset", {})
|
|
127
|
+
return result
|
|
128
|
+
|
|
129
|
+
def list_all(
|
|
130
|
+
self,
|
|
131
|
+
status: Optional[str] = None,
|
|
132
|
+
organization_id: Optional[str] = None,
|
|
133
|
+
limit: int = 10,
|
|
134
|
+
offset: int = 0,
|
|
135
|
+
) -> Any:
|
|
136
|
+
"""
|
|
137
|
+
List all datasets with pagination using GraphQL.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
status: Filter by status
|
|
141
|
+
organization_id: Filter by organization
|
|
142
|
+
limit: Number of results to return
|
|
143
|
+
offset: Number of results to skip
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
Dictionary containing list of datasets
|
|
147
|
+
"""
|
|
148
|
+
query = """
|
|
149
|
+
query ListDatasets($filters: DatasetFilter, $pagination: OffsetPaginationInput) {
|
|
150
|
+
datasets(filters: $filters, pagination: $pagination) {
|
|
151
|
+
id
|
|
152
|
+
title
|
|
153
|
+
description
|
|
154
|
+
status
|
|
155
|
+
accessType
|
|
156
|
+
license
|
|
157
|
+
createdAt
|
|
158
|
+
updatedAt
|
|
159
|
+
organization {
|
|
160
|
+
id
|
|
161
|
+
name
|
|
162
|
+
}
|
|
163
|
+
tags {
|
|
164
|
+
id
|
|
165
|
+
value
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
filters: Dict[str, Any] = {}
|
|
172
|
+
if status:
|
|
173
|
+
filters["status"] = status
|
|
174
|
+
if organization_id:
|
|
175
|
+
filters["organization"] = {"id": {"exact": organization_id}}
|
|
176
|
+
|
|
177
|
+
variables: Dict[str, Any] = {
|
|
178
|
+
"pagination": {"limit": limit, "offset": offset},
|
|
179
|
+
}
|
|
180
|
+
if filters:
|
|
181
|
+
variables["filters"] = filters
|
|
182
|
+
|
|
183
|
+
response = self.post(
|
|
184
|
+
"/api/graphql",
|
|
185
|
+
json_data={
|
|
186
|
+
"query": query,
|
|
187
|
+
"variables": variables,
|
|
188
|
+
},
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
if "errors" in response:
|
|
192
|
+
from dataspace_sdk.exceptions import DataSpaceAPIError
|
|
193
|
+
|
|
194
|
+
raise DataSpaceAPIError(f"GraphQL error: {response['errors']}")
|
|
195
|
+
|
|
196
|
+
data = response.get("data", {})
|
|
197
|
+
datasets_result: Any = data.get("datasets", []) if isinstance(data, dict) else []
|
|
198
|
+
return datasets_result
|
|
199
|
+
|
|
200
|
+
def get_trending(self, limit: int = 10) -> Dict[str, Any]:
|
|
201
|
+
"""
|
|
202
|
+
Get trending datasets.
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
limit: Number of results to return
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
Dictionary containing trending datasets
|
|
209
|
+
"""
|
|
210
|
+
return self.get("/api/trending/datasets/", params={"limit": limit})
|
|
211
|
+
|
|
212
|
+
def get_organization_datasets(
|
|
213
|
+
self,
|
|
214
|
+
organization_id: str,
|
|
215
|
+
limit: int = 10,
|
|
216
|
+
offset: int = 0,
|
|
217
|
+
) -> Any:
|
|
218
|
+
"""
|
|
219
|
+
Get datasets for a specific organization.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
organization_id: UUID of the organization
|
|
223
|
+
limit: Number of results to return
|
|
224
|
+
offset: Number of results to skip
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
Dictionary containing organization's datasets
|
|
228
|
+
"""
|
|
229
|
+
return self.list_all(
|
|
230
|
+
organization_id=organization_id,
|
|
231
|
+
limit=limit,
|
|
232
|
+
offset=offset,
|
|
233
|
+
)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Sector resource client for DataSpace SDK."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from dataspace_sdk.base import BaseAPIClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SectorClient(BaseAPIClient):
|
|
9
|
+
"""Client for interacting with Sector resources."""
|
|
10
|
+
|
|
11
|
+
def list_all(
|
|
12
|
+
self,
|
|
13
|
+
search: Optional[str] = None,
|
|
14
|
+
min_dataset_count: Optional[int] = None,
|
|
15
|
+
min_aimodel_count: Optional[int] = None,
|
|
16
|
+
limit: int = 100,
|
|
17
|
+
offset: int = 0,
|
|
18
|
+
) -> List[Dict[str, Any]]:
|
|
19
|
+
"""
|
|
20
|
+
List all sectors with optional filters using GraphQL.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
search: Search query for name/description
|
|
24
|
+
min_dataset_count: Filter sectors with at least this many published datasets
|
|
25
|
+
min_aimodel_count: Filter sectors with at least this many active AI models
|
|
26
|
+
limit: Number of results to return
|
|
27
|
+
offset: Number of results to skip
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
List of sector dictionaries
|
|
31
|
+
"""
|
|
32
|
+
query = """
|
|
33
|
+
query ListSectors($filters: SectorFilter, $pagination: OffsetPaginationInput) {
|
|
34
|
+
sectors(filters: $filters, pagination: $pagination) {
|
|
35
|
+
id
|
|
36
|
+
name
|
|
37
|
+
slug
|
|
38
|
+
description
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
filters: Dict[str, Any] = {}
|
|
44
|
+
if search:
|
|
45
|
+
filters["search"] = search
|
|
46
|
+
if min_dataset_count is not None:
|
|
47
|
+
filters["min_dataset_count"] = min_dataset_count
|
|
48
|
+
if min_aimodel_count is not None:
|
|
49
|
+
filters["min_aimodel_count"] = min_aimodel_count
|
|
50
|
+
|
|
51
|
+
variables: Dict[str, Any] = {
|
|
52
|
+
"pagination": {"limit": limit, "offset": offset},
|
|
53
|
+
}
|
|
54
|
+
if filters:
|
|
55
|
+
variables["filters"] = filters
|
|
56
|
+
|
|
57
|
+
response = self.post(
|
|
58
|
+
"/api/graphql",
|
|
59
|
+
json_data={
|
|
60
|
+
"query": query,
|
|
61
|
+
"variables": variables,
|
|
62
|
+
},
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if "errors" in response:
|
|
66
|
+
from dataspace_sdk.exceptions import DataSpaceAPIError
|
|
67
|
+
|
|
68
|
+
raise DataSpaceAPIError(f"GraphQL error: {response['errors']}")
|
|
69
|
+
|
|
70
|
+
data = response.get("data", {})
|
|
71
|
+
sectors_result: List[Dict[str, Any]] = (
|
|
72
|
+
data.get("sectors", []) if isinstance(data, dict) else []
|
|
73
|
+
)
|
|
74
|
+
return sectors_result
|
|
75
|
+
|
|
76
|
+
def get_by_id(self, sector_id: str) -> Dict[str, Any]:
|
|
77
|
+
"""
|
|
78
|
+
Get a sector by ID using GraphQL.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
sector_id: UUID of the sector
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Dictionary containing sector information
|
|
85
|
+
"""
|
|
86
|
+
query = """
|
|
87
|
+
query GetSector($id: UUID!) {
|
|
88
|
+
sector(id: $id) {
|
|
89
|
+
id
|
|
90
|
+
name
|
|
91
|
+
slug
|
|
92
|
+
description
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
response = self.post(
|
|
98
|
+
"/api/graphql",
|
|
99
|
+
json_data={
|
|
100
|
+
"query": query,
|
|
101
|
+
"variables": {"id": sector_id},
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if "errors" in response:
|
|
106
|
+
from dataspace_sdk.exceptions import DataSpaceAPIError
|
|
107
|
+
|
|
108
|
+
raise DataSpaceAPIError(f"GraphQL error: {response['errors']}")
|
|
109
|
+
|
|
110
|
+
result: Dict[str, Any] = response.get("data", {}).get("sector", {})
|
|
111
|
+
return result
|
|
112
|
+
|
|
113
|
+
def get_sectors_with_aimodels(
|
|
114
|
+
self,
|
|
115
|
+
limit: int = 100,
|
|
116
|
+
offset: int = 0,
|
|
117
|
+
) -> List[Dict[str, Any]]:
|
|
118
|
+
"""
|
|
119
|
+
Get sectors that have at least one active AI model.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
limit: Number of results to return
|
|
123
|
+
offset: Number of results to skip
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
List of sector dictionaries with AI models
|
|
127
|
+
"""
|
|
128
|
+
return self.list_all(min_aimodel_count=1, limit=limit, offset=offset)
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""UseCase resource client for DataSpace SDK."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from dataspace_sdk.base import BaseAPIClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UseCaseClient(BaseAPIClient):
|
|
9
|
+
"""Client for interacting with UseCase resources."""
|
|
10
|
+
|
|
11
|
+
def search(
|
|
12
|
+
self,
|
|
13
|
+
query: Optional[str] = None,
|
|
14
|
+
tags: Optional[List[str]] = None,
|
|
15
|
+
sectors: Optional[List[str]] = None,
|
|
16
|
+
geographies: Optional[List[str]] = None,
|
|
17
|
+
status: Optional[str] = None,
|
|
18
|
+
running_status: Optional[str] = None,
|
|
19
|
+
sort: Optional[str] = None,
|
|
20
|
+
page: int = 1,
|
|
21
|
+
page_size: int = 10,
|
|
22
|
+
) -> Dict[str, Any]:
|
|
23
|
+
"""
|
|
24
|
+
Search for use cases using Elasticsearch.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
query: Search query string
|
|
28
|
+
tags: Filter by tags
|
|
29
|
+
sectors: Filter by sectors
|
|
30
|
+
geographies: Filter by geographies
|
|
31
|
+
status: Filter by status (DRAFT, PUBLISHED, etc.)
|
|
32
|
+
running_status: Filter by running status (INITIATED, ONGOING, COMPLETED)
|
|
33
|
+
sort: Sort order (recent, alphabetical, started_on, completed_on)
|
|
34
|
+
page: Page number (1-indexed)
|
|
35
|
+
page_size: Number of results per page
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Dictionary containing search results and metadata
|
|
39
|
+
"""
|
|
40
|
+
params: Dict[str, Any] = {
|
|
41
|
+
"page": page,
|
|
42
|
+
"page_size": page_size,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if query:
|
|
46
|
+
params["q"] = query
|
|
47
|
+
if tags:
|
|
48
|
+
params["tags"] = ",".join(tags)
|
|
49
|
+
if sectors:
|
|
50
|
+
params["sectors"] = ",".join(sectors)
|
|
51
|
+
if geographies:
|
|
52
|
+
params["geographies"] = ",".join(geographies)
|
|
53
|
+
if status:
|
|
54
|
+
params["status"] = status
|
|
55
|
+
if running_status:
|
|
56
|
+
params["running_status"] = running_status
|
|
57
|
+
if sort:
|
|
58
|
+
params["sort"] = sort
|
|
59
|
+
|
|
60
|
+
return super().get("/api/search/usecase/", params=params)
|
|
61
|
+
|
|
62
|
+
def get_by_id(self, usecase_id: int) -> Dict[str, Any]:
|
|
63
|
+
"""
|
|
64
|
+
Get a use case by ID using GraphQL.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
usecase_id: ID of the use case
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Dictionary containing use case information
|
|
71
|
+
"""
|
|
72
|
+
query = """
|
|
73
|
+
query GetUseCase($id: ID!) {
|
|
74
|
+
useCase(id: $id) {
|
|
75
|
+
id
|
|
76
|
+
title
|
|
77
|
+
summary
|
|
78
|
+
status
|
|
79
|
+
runningStatus
|
|
80
|
+
platformUrl
|
|
81
|
+
logo
|
|
82
|
+
startedOn
|
|
83
|
+
completedOn
|
|
84
|
+
createdAt
|
|
85
|
+
updatedAt
|
|
86
|
+
tags {
|
|
87
|
+
id
|
|
88
|
+
value
|
|
89
|
+
}
|
|
90
|
+
sectors {
|
|
91
|
+
id
|
|
92
|
+
name
|
|
93
|
+
}
|
|
94
|
+
geographies {
|
|
95
|
+
id
|
|
96
|
+
name
|
|
97
|
+
}
|
|
98
|
+
sdgs {
|
|
99
|
+
id
|
|
100
|
+
name
|
|
101
|
+
description
|
|
102
|
+
}
|
|
103
|
+
datasets {
|
|
104
|
+
id
|
|
105
|
+
title
|
|
106
|
+
description
|
|
107
|
+
}
|
|
108
|
+
organizations {
|
|
109
|
+
id
|
|
110
|
+
organization {
|
|
111
|
+
id
|
|
112
|
+
name
|
|
113
|
+
}
|
|
114
|
+
relationshipType
|
|
115
|
+
}
|
|
116
|
+
contributors {
|
|
117
|
+
id
|
|
118
|
+
username
|
|
119
|
+
firstName
|
|
120
|
+
lastName
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
response = self.post(
|
|
127
|
+
"/api/graphql",
|
|
128
|
+
json_data={
|
|
129
|
+
"query": query,
|
|
130
|
+
"variables": {"id": str(usecase_id)},
|
|
131
|
+
},
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if "errors" in response:
|
|
135
|
+
from dataspace_sdk.exceptions import DataSpaceAPIError
|
|
136
|
+
|
|
137
|
+
raise DataSpaceAPIError(f"GraphQL error: {response['errors']}")
|
|
138
|
+
|
|
139
|
+
result: Dict[str, Any] = response.get("data", {}).get("useCase", {})
|
|
140
|
+
return result
|
|
141
|
+
|
|
142
|
+
def list_all(
|
|
143
|
+
self,
|
|
144
|
+
status: Optional[str] = None,
|
|
145
|
+
running_status: Optional[str] = None,
|
|
146
|
+
organization_id: Optional[str] = None,
|
|
147
|
+
limit: int = 10,
|
|
148
|
+
offset: int = 0,
|
|
149
|
+
) -> Any:
|
|
150
|
+
"""
|
|
151
|
+
List all use cases with pagination using GraphQL.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
status: Filter by status
|
|
155
|
+
running_status: Filter by running status
|
|
156
|
+
organization_id: Filter by organization
|
|
157
|
+
limit: Number of results to return
|
|
158
|
+
offset: Number of results to skip
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
Dictionary containing list of use cases
|
|
162
|
+
"""
|
|
163
|
+
query = """
|
|
164
|
+
query ListUseCases($filters: UseCaseFilter, $pagination: OffsetPaginationInput) {
|
|
165
|
+
useCases(filters: $filters, pagination: $pagination) {
|
|
166
|
+
id
|
|
167
|
+
title
|
|
168
|
+
summary
|
|
169
|
+
status
|
|
170
|
+
runningStatus
|
|
171
|
+
platformUrl
|
|
172
|
+
startedOn
|
|
173
|
+
completedOn
|
|
174
|
+
createdAt
|
|
175
|
+
updatedAt
|
|
176
|
+
tags {
|
|
177
|
+
id
|
|
178
|
+
value
|
|
179
|
+
}
|
|
180
|
+
sectors {
|
|
181
|
+
id
|
|
182
|
+
name
|
|
183
|
+
}
|
|
184
|
+
organizations {
|
|
185
|
+
id
|
|
186
|
+
organization {
|
|
187
|
+
id
|
|
188
|
+
name
|
|
189
|
+
}
|
|
190
|
+
relationshipType
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
filters: Dict[str, Any] = {}
|
|
197
|
+
if status:
|
|
198
|
+
filters["status"] = status
|
|
199
|
+
if running_status:
|
|
200
|
+
filters["runningStatus"] = running_status
|
|
201
|
+
if organization_id:
|
|
202
|
+
filters["organizations"] = {"organization": {"id": {"exact": organization_id}}}
|
|
203
|
+
|
|
204
|
+
variables: Dict[str, Any] = {
|
|
205
|
+
"pagination": {"limit": limit, "offset": offset},
|
|
206
|
+
}
|
|
207
|
+
if filters:
|
|
208
|
+
variables["filters"] = filters
|
|
209
|
+
|
|
210
|
+
response = self.post(
|
|
211
|
+
"/api/graphql",
|
|
212
|
+
json_data={
|
|
213
|
+
"query": query,
|
|
214
|
+
"variables": variables,
|
|
215
|
+
},
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
if "errors" in response:
|
|
219
|
+
from dataspace_sdk.exceptions import DataSpaceAPIError
|
|
220
|
+
|
|
221
|
+
raise DataSpaceAPIError(f"GraphQL error: {response['errors']}")
|
|
222
|
+
|
|
223
|
+
data = response.get("data", {})
|
|
224
|
+
usecases_result: Any = data.get("useCases", []) if isinstance(data, dict) else []
|
|
225
|
+
return usecases_result
|
|
226
|
+
|
|
227
|
+
def get_organization_usecases(
|
|
228
|
+
self,
|
|
229
|
+
organization_id: str,
|
|
230
|
+
limit: int = 10,
|
|
231
|
+
offset: int = 0,
|
|
232
|
+
) -> Any:
|
|
233
|
+
"""
|
|
234
|
+
Get use cases for a specific organization.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
organization_id: UUID of the organization
|
|
238
|
+
limit: Number of results to return
|
|
239
|
+
offset: Number of results to skip
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
Dictionary containing organization's use cases
|
|
243
|
+
"""
|
|
244
|
+
return self.list_all(
|
|
245
|
+
organization_id=organization_id,
|
|
246
|
+
limit=limit,
|
|
247
|
+
offset=offset,
|
|
248
|
+
)
|