@scaleway/sdk-datalab 1.1.0

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.
@@ -0,0 +1,220 @@
1
+ import { isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ const unmarshalVolume = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ size: data.size,
10
+ type: data.type
11
+ };
12
+ };
13
+ const unmarshalDatalabSparkMain = (data) => {
14
+ if (!isJSONObject(data)) {
15
+ throw new TypeError(
16
+ `Unmarshalling the type 'DatalabSparkMain' failed as data isn't a dictionary.`
17
+ );
18
+ }
19
+ return {
20
+ nodeType: data.node_type,
21
+ rootVolume: data.root_volume ? unmarshalVolume(data.root_volume) : void 0,
22
+ sparkMasterUrl: data.spark_master_url,
23
+ sparkUiUrl: data.spark_ui_url
24
+ };
25
+ };
26
+ const unmarshalDatalabSparkWorker = (data) => {
27
+ if (!isJSONObject(data)) {
28
+ throw new TypeError(
29
+ `Unmarshalling the type 'DatalabSparkWorker' failed as data isn't a dictionary.`
30
+ );
31
+ }
32
+ return {
33
+ nodeCount: data.node_count,
34
+ nodeType: data.node_type,
35
+ rootVolume: data.root_volume ? unmarshalVolume(data.root_volume) : void 0
36
+ };
37
+ };
38
+ const unmarshalDatalab = (data) => {
39
+ if (!isJSONObject(data)) {
40
+ throw new TypeError(
41
+ `Unmarshalling the type 'Datalab' failed as data isn't a dictionary.`
42
+ );
43
+ }
44
+ return {
45
+ createdAt: unmarshalDate(data.created_at),
46
+ description: data.description,
47
+ hasNotebook: data.has_notebook,
48
+ id: data.id,
49
+ main: data.main ? unmarshalDatalabSparkMain(data.main) : void 0,
50
+ name: data.name,
51
+ notebookMasterUrl: data.notebook_master_url,
52
+ notebookUrl: data.notebook_url,
53
+ privateNetworkId: data.private_network_id,
54
+ projectId: data.project_id,
55
+ region: data.region,
56
+ sparkVersion: data.spark_version,
57
+ status: data.status,
58
+ tags: data.tags,
59
+ totalStorage: data.total_storage ? unmarshalVolume(data.total_storage) : void 0,
60
+ updatedAt: unmarshalDate(data.updated_at),
61
+ worker: data.worker ? unmarshalDatalabSparkWorker(data.worker) : void 0
62
+ };
63
+ };
64
+ const unmarshalClusterVersion = (data) => {
65
+ if (!isJSONObject(data)) {
66
+ throw new TypeError(
67
+ `Unmarshalling the type 'ClusterVersion' failed as data isn't a dictionary.`
68
+ );
69
+ }
70
+ return {
71
+ beta: data.beta,
72
+ createdAt: unmarshalDate(data.created_at),
73
+ disabled: data.disabled,
74
+ endOfLife: unmarshalDate(data.end_of_life),
75
+ updatedAt: unmarshalDate(data.updated_at),
76
+ version: data.version
77
+ };
78
+ };
79
+ const unmarshalCluster = (data) => {
80
+ if (!isJSONObject(data)) {
81
+ throw new TypeError(
82
+ `Unmarshalling the type 'Cluster' failed as data isn't a dictionary.`
83
+ );
84
+ }
85
+ return {
86
+ description: data.description,
87
+ name: data.name,
88
+ versions: unmarshalArrayOfObject(data.versions, unmarshalClusterVersion)
89
+ };
90
+ };
91
+ const unmarshalListClusterVersionsResponse = (data) => {
92
+ if (!isJSONObject(data)) {
93
+ throw new TypeError(
94
+ `Unmarshalling the type 'ListClusterVersionsResponse' failed as data isn't a dictionary.`
95
+ );
96
+ }
97
+ return {
98
+ clusters: unmarshalArrayOfObject(data.clusters, unmarshalCluster),
99
+ totalCount: data.total_count
100
+ };
101
+ };
102
+ const unmarshalListDatalabsResponse = (data) => {
103
+ if (!isJSONObject(data)) {
104
+ throw new TypeError(
105
+ `Unmarshalling the type 'ListDatalabsResponse' failed as data isn't a dictionary.`
106
+ );
107
+ }
108
+ return {
109
+ datalabs: unmarshalArrayOfObject(data.datalabs, unmarshalDatalab),
110
+ totalCount: data.total_count
111
+ };
112
+ };
113
+ const unmarshalNodeType = (data) => {
114
+ if (!isJSONObject(data)) {
115
+ throw new TypeError(
116
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
117
+ );
118
+ }
119
+ return {
120
+ beta: data.beta,
121
+ createdAt: unmarshalDate(data.created_at),
122
+ description: data.description,
123
+ disabled: data.disabled,
124
+ gpus: data.gpus,
125
+ memoryGigabytes: data.memory_gigabytes,
126
+ name: data.name,
127
+ stockStatus: data.stock_status,
128
+ targets: data.targets,
129
+ updatedAt: unmarshalDate(data.updated_at),
130
+ vcpus: data.vcpus,
131
+ vramGigabytes: data.vram_gigabytes
132
+ };
133
+ };
134
+ const unmarshalListNodeTypesResponse = (data) => {
135
+ if (!isJSONObject(data)) {
136
+ throw new TypeError(
137
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
138
+ );
139
+ }
140
+ return {
141
+ nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
142
+ totalCount: data.total_count
143
+ };
144
+ };
145
+ const unmarshalNotebookVersion = (data) => {
146
+ if (!isJSONObject(data)) {
147
+ throw new TypeError(
148
+ `Unmarshalling the type 'NotebookVersion' failed as data isn't a dictionary.`
149
+ );
150
+ }
151
+ return {
152
+ beta: data.beta,
153
+ createdAt: unmarshalDate(data.created_at),
154
+ disabled: data.disabled,
155
+ endOfLife: unmarshalDate(data.end_of_life),
156
+ updatedAt: unmarshalDate(data.updated_at),
157
+ version: data.version
158
+ };
159
+ };
160
+ const unmarshalNotebook = (data) => {
161
+ if (!isJSONObject(data)) {
162
+ throw new TypeError(
163
+ `Unmarshalling the type 'Notebook' failed as data isn't a dictionary.`
164
+ );
165
+ }
166
+ return {
167
+ description: data.description,
168
+ name: data.name,
169
+ versions: unmarshalArrayOfObject(data.versions, unmarshalNotebookVersion)
170
+ };
171
+ };
172
+ const unmarshalListNotebookVersionsResponse = (data) => {
173
+ if (!isJSONObject(data)) {
174
+ throw new TypeError(
175
+ `Unmarshalling the type 'ListNotebookVersionsResponse' failed as data isn't a dictionary.`
176
+ );
177
+ }
178
+ return {
179
+ notebooks: unmarshalArrayOfObject(data.notebooks, unmarshalNotebook),
180
+ totalCount: data.total_count
181
+ };
182
+ };
183
+ const marshalCreateDatalabRequestSparkMain = (request, defaults) => ({
184
+ node_type: request.nodeType
185
+ });
186
+ const marshalCreateDatalabRequestSparkWorker = (request, defaults) => ({
187
+ node_count: request.nodeCount,
188
+ node_type: request.nodeType
189
+ });
190
+ const marshalVolume = (request, defaults) => ({
191
+ size: request.size,
192
+ type: request.type
193
+ });
194
+ const marshalCreateDatalabRequest = (request, defaults) => ({
195
+ description: request.description,
196
+ has_notebook: request.hasNotebook,
197
+ main: request.main !== void 0 ? marshalCreateDatalabRequestSparkMain(request.main) : void 0,
198
+ name: request.name,
199
+ private_network_id: request.privateNetworkId,
200
+ project_id: request.projectId ?? defaults.defaultProjectId,
201
+ spark_version: request.sparkVersion,
202
+ tags: request.tags,
203
+ total_storage: request.totalStorage !== void 0 ? marshalVolume(request.totalStorage) : void 0,
204
+ worker: request.worker !== void 0 ? marshalCreateDatalabRequestSparkWorker(request.worker) : void 0
205
+ });
206
+ const marshalUpdateDatalabRequest = (request, defaults) => ({
207
+ description: request.description,
208
+ name: request.name,
209
+ node_count: request.nodeCount,
210
+ tags: request.tags
211
+ });
212
+ export {
213
+ marshalCreateDatalabRequest,
214
+ marshalUpdateDatalabRequest,
215
+ unmarshalDatalab,
216
+ unmarshalListClusterVersionsResponse,
217
+ unmarshalListDatalabsResponse,
218
+ unmarshalListNodeTypesResponse,
219
+ unmarshalListNotebookVersionsResponse
220
+ };