@scaleway/sdk-block 1.0.1
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.
- package/LICENSE +191 -0
- package/dist/index.gen.cjs +6 -0
- package/dist/index.gen.d.ts +6 -0
- package/dist/index.gen.js +6 -0
- package/dist/v1/api.gen.cjs +285 -0
- package/dist/v1/api.gen.d.ts +134 -0
- package/dist/v1/api.gen.js +285 -0
- package/dist/v1/content.gen.cjs +22 -0
- package/dist/v1/content.gen.d.ts +7 -0
- package/dist/v1/content.gen.js +22 -0
- package/dist/v1/index.gen.cjs +23 -0
- package/dist/v1/index.gen.d.ts +5 -0
- package/dist/v1/index.gen.js +23 -0
- package/dist/v1/marshalling.gen.cjs +198 -0
- package/dist/v1/marshalling.gen.d.ts +14 -0
- package/dist/v1/marshalling.gen.js +198 -0
- package/dist/v1/types.gen.d.ts +516 -0
- package/dist/v1/validation-rules.gen.cjs +56 -0
- package/dist/v1/validation-rules.gen.d.ts +47 -0
- package/dist/v1/validation-rules.gen.js +56 -0
- package/dist/v1alpha1/api.gen.cjs +305 -0
- package/dist/v1alpha1/api.gen.d.ts +144 -0
- package/dist/v1alpha1/api.gen.js +305 -0
- package/dist/v1alpha1/content.gen.cjs +22 -0
- package/dist/v1alpha1/content.gen.d.ts +7 -0
- package/dist/v1alpha1/content.gen.js +22 -0
- package/dist/v1alpha1/index.gen.cjs +23 -0
- package/dist/v1alpha1/index.gen.d.ts +5 -0
- package/dist/v1alpha1/index.gen.js +23 -0
- package/dist/v1alpha1/marshalling.gen.cjs +206 -0
- package/dist/v1alpha1/marshalling.gen.d.ts +14 -0
- package/dist/v1alpha1/marshalling.gen.js +206 -0
- package/dist/v1alpha1/types.gen.d.ts +546 -0
- package/dist/v1alpha1/validation-rules.gen.cjs +62 -0
- package/dist/v1alpha1/validation-rules.gen.d.ts +52 -0
- package/dist/v1alpha1/validation-rules.gen.js +62 -0
- package/package.json +51 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import randomName from "@scaleway/random-name";
|
|
2
|
+
import { resolveOneOf, isJSONObject, unmarshalDate, unmarshalArrayOfObject, unmarshalMoney } from "@scaleway/sdk-client";
|
|
3
|
+
const unmarshalReference = (data) => {
|
|
4
|
+
if (!isJSONObject(data)) {
|
|
5
|
+
throw new TypeError(
|
|
6
|
+
`Unmarshalling the type 'Reference' failed as data isn't a dictionary.`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
createdAt: unmarshalDate(data.created_at),
|
|
11
|
+
id: data.id,
|
|
12
|
+
productResourceId: data.product_resource_id,
|
|
13
|
+
productResourceType: data.product_resource_type,
|
|
14
|
+
status: data.status,
|
|
15
|
+
type: data.type
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const unmarshalSnapshotParentVolume = (data) => {
|
|
19
|
+
if (!isJSONObject(data)) {
|
|
20
|
+
throw new TypeError(
|
|
21
|
+
`Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
id: data.id,
|
|
26
|
+
name: data.name,
|
|
27
|
+
status: data.status,
|
|
28
|
+
type: data.type
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const unmarshalSnapshot = (data) => {
|
|
32
|
+
if (!isJSONObject(data)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
class: data.class,
|
|
39
|
+
createdAt: unmarshalDate(data.created_at),
|
|
40
|
+
id: data.id,
|
|
41
|
+
name: data.name,
|
|
42
|
+
parentVolume: data.parent_volume ? unmarshalSnapshotParentVolume(data.parent_volume) : void 0,
|
|
43
|
+
projectId: data.project_id,
|
|
44
|
+
references: unmarshalArrayOfObject(data.references, unmarshalReference),
|
|
45
|
+
size: data.size,
|
|
46
|
+
status: data.status,
|
|
47
|
+
tags: data.tags,
|
|
48
|
+
updatedAt: unmarshalDate(data.updated_at),
|
|
49
|
+
zone: data.zone
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const unmarshalVolumeSpecifications = (data) => {
|
|
53
|
+
if (!isJSONObject(data)) {
|
|
54
|
+
throw new TypeError(
|
|
55
|
+
`Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
class: data.class,
|
|
60
|
+
perfIops: data.perf_iops
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const unmarshalVolume = (data) => {
|
|
64
|
+
if (!isJSONObject(data)) {
|
|
65
|
+
throw new TypeError(
|
|
66
|
+
`Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
createdAt: unmarshalDate(data.created_at),
|
|
71
|
+
id: data.id,
|
|
72
|
+
lastDetachedAt: unmarshalDate(data.last_detached_at),
|
|
73
|
+
name: data.name,
|
|
74
|
+
parentSnapshotId: data.parent_snapshot_id,
|
|
75
|
+
projectId: data.project_id,
|
|
76
|
+
references: unmarshalArrayOfObject(data.references, unmarshalReference),
|
|
77
|
+
size: data.size,
|
|
78
|
+
specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : void 0,
|
|
79
|
+
status: data.status,
|
|
80
|
+
tags: data.tags,
|
|
81
|
+
type: data.type,
|
|
82
|
+
updatedAt: unmarshalDate(data.updated_at),
|
|
83
|
+
zone: data.zone
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const unmarshalListSnapshotsResponse = (data) => {
|
|
87
|
+
if (!isJSONObject(data)) {
|
|
88
|
+
throw new TypeError(
|
|
89
|
+
`Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
|
|
94
|
+
totalCount: data.total_count
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const unmarshalVolumeType = (data) => {
|
|
98
|
+
if (!isJSONObject(data)) {
|
|
99
|
+
throw new TypeError(
|
|
100
|
+
`Unmarshalling the type 'VolumeType' failed as data isn't a dictionary.`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
pricing: data.pricing ? unmarshalMoney(data.pricing) : void 0,
|
|
105
|
+
snapshotPricing: data.snapshot_pricing ? unmarshalMoney(data.snapshot_pricing) : void 0,
|
|
106
|
+
specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : void 0,
|
|
107
|
+
type: data.type
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
const unmarshalListVolumeTypesResponse = (data) => {
|
|
111
|
+
if (!isJSONObject(data)) {
|
|
112
|
+
throw new TypeError(
|
|
113
|
+
`Unmarshalling the type 'ListVolumeTypesResponse' failed as data isn't a dictionary.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
totalCount: data.total_count,
|
|
118
|
+
volumeTypes: unmarshalArrayOfObject(data.volume_types, unmarshalVolumeType)
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
const unmarshalListVolumesResponse = (data) => {
|
|
122
|
+
if (!isJSONObject(data)) {
|
|
123
|
+
throw new TypeError(
|
|
124
|
+
`Unmarshalling the type 'ListVolumesResponse' failed as data isn't a dictionary.`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
totalCount: data.total_count,
|
|
129
|
+
volumes: unmarshalArrayOfObject(data.volumes, unmarshalVolume)
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
const marshalCreateSnapshotRequest = (request, defaults) => ({
|
|
133
|
+
name: request.name || randomName("snp"),
|
|
134
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
135
|
+
tags: request.tags,
|
|
136
|
+
volume_id: request.volumeId
|
|
137
|
+
});
|
|
138
|
+
const marshalCreateVolumeRequestFromEmpty = (request, defaults) => ({
|
|
139
|
+
size: request.size
|
|
140
|
+
});
|
|
141
|
+
const marshalCreateVolumeRequestFromSnapshot = (request, defaults) => ({
|
|
142
|
+
size: request.size,
|
|
143
|
+
snapshot_id: request.snapshotId
|
|
144
|
+
});
|
|
145
|
+
const marshalCreateVolumeRequest = (request, defaults) => ({
|
|
146
|
+
name: request.name || randomName("vol"),
|
|
147
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
148
|
+
tags: request.tags,
|
|
149
|
+
...resolveOneOf([
|
|
150
|
+
{
|
|
151
|
+
param: "from_empty",
|
|
152
|
+
value: request.fromEmpty !== void 0 ? marshalCreateVolumeRequestFromEmpty(request.fromEmpty) : void 0
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
param: "from_snapshot",
|
|
156
|
+
value: request.fromSnapshot !== void 0 ? marshalCreateVolumeRequestFromSnapshot(
|
|
157
|
+
request.fromSnapshot
|
|
158
|
+
) : void 0
|
|
159
|
+
}
|
|
160
|
+
]),
|
|
161
|
+
...resolveOneOf([{ param: "perf_iops", value: request.perfIops }])
|
|
162
|
+
});
|
|
163
|
+
const marshalExportSnapshotToObjectStorageRequest = (request, defaults) => ({
|
|
164
|
+
bucket: request.bucket,
|
|
165
|
+
key: request.key
|
|
166
|
+
});
|
|
167
|
+
const marshalImportSnapshotFromObjectStorageRequest = (request, defaults) => ({
|
|
168
|
+
bucket: request.bucket,
|
|
169
|
+
key: request.key,
|
|
170
|
+
name: request.name,
|
|
171
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
172
|
+
size: request.size,
|
|
173
|
+
tags: request.tags
|
|
174
|
+
});
|
|
175
|
+
const marshalImportSnapshotFromS3Request = (request, defaults) => ({
|
|
176
|
+
bucket: request.bucket,
|
|
177
|
+
key: request.key,
|
|
178
|
+
name: request.name,
|
|
179
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
180
|
+
size: request.size,
|
|
181
|
+
tags: request.tags
|
|
182
|
+
});
|
|
183
|
+
const marshalUpdateSnapshotRequest = (request, defaults) => ({
|
|
184
|
+
name: request.name,
|
|
185
|
+
tags: request.tags
|
|
186
|
+
});
|
|
187
|
+
const marshalUpdateVolumeRequest = (request, defaults) => ({
|
|
188
|
+
name: request.name,
|
|
189
|
+
perf_iops: request.perfIops,
|
|
190
|
+
size: request.size,
|
|
191
|
+
tags: request.tags
|
|
192
|
+
});
|
|
193
|
+
export {
|
|
194
|
+
marshalCreateSnapshotRequest,
|
|
195
|
+
marshalCreateVolumeRequest,
|
|
196
|
+
marshalExportSnapshotToObjectStorageRequest,
|
|
197
|
+
marshalImportSnapshotFromObjectStorageRequest,
|
|
198
|
+
marshalImportSnapshotFromS3Request,
|
|
199
|
+
marshalUpdateSnapshotRequest,
|
|
200
|
+
marshalUpdateVolumeRequest,
|
|
201
|
+
unmarshalListSnapshotsResponse,
|
|
202
|
+
unmarshalListVolumeTypesResponse,
|
|
203
|
+
unmarshalListVolumesResponse,
|
|
204
|
+
unmarshalSnapshot,
|
|
205
|
+
unmarshalVolume
|
|
206
|
+
};
|