@scaleway/sdk 2.0.0-alpha.13 → 2.0.0-alpha.15

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.
Files changed (215) hide show
  1. package/dist/api/account/index.js +4 -0
  2. package/dist/api/account/v2/api.gen.js +147 -0
  3. package/dist/api/account/v2/index.gen.js +4 -0
  4. package/dist/api/account/v2/marshalling.gen.js +39 -0
  5. package/dist/api/account/v3/api.gen.js +129 -0
  6. package/dist/api/account/v3/index.gen.js +6 -0
  7. package/dist/api/account/v3/marshalling.gen.js +39 -0
  8. package/dist/api/account/v3/validation-rules.gen.js +39 -0
  9. package/dist/api/applesilicon/index.js +2 -0
  10. package/dist/api/applesilicon/v1alpha1/api.gen.js +220 -0
  11. package/dist/api/applesilicon/v1alpha1/content.gen.js +7 -0
  12. package/dist/api/applesilicon/v1alpha1/index.gen.js +5 -0
  13. package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +113 -0
  14. package/dist/api/baremetal/index.js +2 -0
  15. package/dist/api/baremetal/v1/api.gen.js +523 -0
  16. package/dist/api/baremetal/v1/api.utils.js +27 -0
  17. package/dist/api/baremetal/v1/content.gen.js +13 -0
  18. package/dist/api/baremetal/v1/index.js +5 -0
  19. package/dist/api/baremetal/v1/marshalling.gen.js +406 -0
  20. package/dist/api/baremetal/v1/validation-rules.gen.js +109 -0
  21. package/dist/api/billing/index.js +2 -0
  22. package/dist/api/billing/v2alpha1/api.gen.js +80 -0
  23. package/dist/api/billing/v2alpha1/index.gen.js +4 -0
  24. package/dist/api/billing/v2alpha1/marshalling.gen.js +53 -0
  25. package/dist/api/block/index.js +2 -0
  26. package/dist/api/block/v1alpha1/api.gen.js +249 -0
  27. package/dist/api/block/v1alpha1/content.gen.js +13 -0
  28. package/dist/api/block/v1alpha1/index.gen.js +7 -0
  29. package/dist/api/block/v1alpha1/marshalling.gen.js +182 -0
  30. package/dist/api/block/v1alpha1/validation-rules.gen.js +52 -0
  31. package/dist/api/cockpit/index.js +2 -0
  32. package/dist/api/cockpit/v1beta1/api.gen.js +543 -0
  33. package/dist/api/cockpit/v1beta1/content.gen.js +7 -0
  34. package/dist/api/cockpit/v1beta1/index.gen.js +5 -0
  35. package/dist/api/cockpit/v1beta1/marshalling.gen.js +271 -0
  36. package/dist/api/container/index.js +2 -0
  37. package/dist/api/container/v1beta1/api.gen.js +549 -0
  38. package/dist/api/container/v1beta1/content.gen.js +22 -0
  39. package/dist/api/container/v1beta1/index.gen.js +7 -0
  40. package/dist/api/container/v1beta1/marshalling.gen.js +358 -0
  41. package/dist/api/container/v1beta1/validation-rules.gen.js +44 -0
  42. package/dist/api/document_db/index.js +2 -0
  43. package/dist/api/document_db/v1beta1/api.gen.js +830 -0
  44. package/dist/api/document_db/v1beta1/content.gen.js +19 -0
  45. package/dist/api/document_db/v1beta1/index.gen.js +7 -0
  46. package/dist/api/document_db/v1beta1/marshalling.gen.js +636 -0
  47. package/dist/api/document_db/v1beta1/validation-rules.gen.js +10 -0
  48. package/dist/api/domain/index.js +2 -0
  49. package/dist/api/domain/v2beta1/api.gen.js +867 -0
  50. package/dist/api/domain/v2beta1/content.gen.js +28 -0
  51. package/dist/api/domain/v2beta1/index.gen.js +5 -0
  52. package/dist/api/domain/v2beta1/marshalling.gen.js +1172 -0
  53. package/dist/api/flexibleip/index.js +2 -0
  54. package/dist/api/flexibleip/v1alpha1/api.gen.js +195 -0
  55. package/dist/api/flexibleip/v1alpha1/content.gen.js +10 -0
  56. package/dist/api/flexibleip/v1alpha1/index.gen.js +7 -0
  57. package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +97 -0
  58. package/dist/api/flexibleip/v1alpha1/validation-rules.gen.js +14 -0
  59. package/dist/api/function/index.js +2 -0
  60. package/dist/api/function/v1beta1/api.gen.js +560 -0
  61. package/dist/api/function/v1beta1/content.gen.js +22 -0
  62. package/dist/api/function/v1beta1/index.gen.js +7 -0
  63. package/dist/api/function/v1beta1/marshalling.gen.js +396 -0
  64. package/dist/api/function/v1beta1/validation-rules.gen.js +44 -0
  65. package/dist/api/iam/index.js +2 -0
  66. package/dist/api/iam/v1alpha1/api.gen.js +783 -0
  67. package/dist/api/iam/v1alpha1/index.gen.js +6 -0
  68. package/dist/api/iam/v1alpha1/marshalling.gen.js +384 -0
  69. package/dist/api/iam/v1alpha1/validation-rules.gen.js +207 -0
  70. package/dist/api/instance/index.js +2 -0
  71. package/dist/api/instance/v1/api.gen.js +1003 -0
  72. package/dist/api/instance/v1/api.utils.js +369 -0
  73. package/dist/api/instance/v1/content.gen.js +31 -0
  74. package/dist/api/instance/v1/index.js +2 -0
  75. package/dist/api/instance/v1/marshalling.gen.js +1415 -0
  76. package/dist/api/instance/v1/marshalling.utils.js +63 -0
  77. package/dist/api/iot/index.js +2 -0
  78. package/dist/api/iot/v1/api.gen.js +573 -0
  79. package/dist/api/iot/v1/content.gen.js +7 -0
  80. package/dist/api/iot/v1/index.gen.js +5 -0
  81. package/dist/api/iot/v1/marshalling.gen.js +439 -0
  82. package/dist/api/ipam/index.js +2 -0
  83. package/dist/api/ipam/v1/api.gen.js +113 -0
  84. package/dist/api/ipam/v1/index.gen.js +6 -0
  85. package/dist/api/ipam/v1/marshalling.gen.js +77 -0
  86. package/dist/api/ipam/v1/validation-rules.gen.js +11 -0
  87. package/dist/api/ipfs/index.js +2 -0
  88. package/dist/api/ipfs/v1alpha1/api.gen.js +314 -0
  89. package/dist/api/ipfs/v1alpha1/content.gen.js +10 -0
  90. package/dist/api/ipfs/v1alpha1/index.gen.js +5 -0
  91. package/dist/api/ipfs/v1alpha1/marshalling.gen.js +180 -0
  92. package/dist/api/k8s/index.js +2 -0
  93. package/dist/api/k8s/v1/api.gen.js +454 -0
  94. package/dist/api/k8s/v1/api.utils.js +13 -0
  95. package/dist/api/k8s/v1/content.gen.js +13 -0
  96. package/dist/api/k8s/v1/index.js +4 -0
  97. package/dist/api/k8s/v1/marshalling.gen.js +421 -0
  98. package/dist/api/k8s/v1/validation-rules.gen.js +101 -0
  99. package/dist/api/lb/index.js +2 -0
  100. package/dist/api/lb/v1/api.gen.js +1669 -0
  101. package/dist/api/lb/v1/api.utils.js +81 -0
  102. package/dist/api/lb/v1/content.gen.js +16 -0
  103. package/dist/api/lb/v1/index.js +2 -0
  104. package/dist/api/lb/v1/marshalling.gen.js +1039 -0
  105. package/dist/api/marketplace/index.js +4 -0
  106. package/dist/api/marketplace/v1/api.gen.js +60 -0
  107. package/dist/api/marketplace/v1/index.gen.js +4 -0
  108. package/dist/api/marketplace/v1/marshalling.gen.js +92 -0
  109. package/dist/api/marketplace/v2/api.gen.js +162 -0
  110. package/dist/api/marketplace/v2/index.gen.js +4 -0
  111. package/dist/api/marketplace/v2/marshalling.gen.js +94 -0
  112. package/dist/api/mnq/index.js +4 -0
  113. package/dist/api/mnq/v1alpha1/api.gen.js +197 -0
  114. package/dist/api/mnq/v1alpha1/index.gen.js +4 -0
  115. package/dist/api/mnq/v1alpha1/marshalling.gen.js +126 -0
  116. package/dist/api/mnq/v1beta1/api.gen.js +529 -0
  117. package/dist/api/mnq/v1beta1/index.gen.js +6 -0
  118. package/dist/api/mnq/v1beta1/marshalling.gen.js +212 -0
  119. package/dist/api/mnq/v1beta1/validation-rules.gen.js +77 -0
  120. package/dist/api/rdb/index.js +2 -0
  121. package/dist/api/rdb/v1/api.gen.js +972 -0
  122. package/dist/api/rdb/v1/content.gen.js +22 -0
  123. package/dist/api/rdb/v1/index.gen.js +7 -0
  124. package/dist/api/rdb/v1/marshalling.gen.js +694 -0
  125. package/dist/api/rdb/v1/validation-rules.gen.js +10 -0
  126. package/dist/api/redis/index.js +2 -0
  127. package/dist/api/redis/v1/api.gen.js +389 -0
  128. package/dist/api/redis/v1/content.gen.js +7 -0
  129. package/dist/api/redis/v1/index.gen.js +5 -0
  130. package/dist/api/redis/v1/marshalling.gen.js +283 -0
  131. package/dist/api/registry/index.js +2 -0
  132. package/dist/api/registry/v1/api.gen.js +252 -0
  133. package/dist/api/registry/v1/content.gen.js +13 -0
  134. package/dist/api/registry/v1/index.gen.js +5 -0
  135. package/dist/api/registry/v1/marshalling.gen.js +108 -0
  136. package/dist/api/secret/index.js +2 -0
  137. package/dist/api/secret/v1alpha1/api.gen.js +415 -0
  138. package/dist/api/secret/v1alpha1/index.gen.js +4 -0
  139. package/dist/api/secret/v1alpha1/marshalling.gen.js +150 -0
  140. package/dist/api/tem/index.js +2 -0
  141. package/dist/api/tem/v1alpha1/api.gen.js +229 -0
  142. package/dist/api/tem/v1alpha1/content.gen.js +10 -0
  143. package/dist/api/tem/v1alpha1/index.gen.js +5 -0
  144. package/dist/api/tem/v1alpha1/marshalling.gen.js +168 -0
  145. package/dist/api/test/index.js +2 -0
  146. package/dist/api/test/v1/api.gen.js +152 -0
  147. package/dist/api/test/v1/content.gen.js +7 -0
  148. package/dist/api/test/v1/index.gen.js +5 -0
  149. package/dist/api/test/v1/marshalling.gen.js +81 -0
  150. package/dist/api/vpc/index.js +4 -0
  151. package/dist/api/vpc/v1/api.gen.js +110 -0
  152. package/dist/api/vpc/v1/index.gen.js +4 -0
  153. package/dist/api/vpc/v1/marshalling.gen.js +44 -0
  154. package/dist/api/vpc/v2/api.gen.js +276 -0
  155. package/dist/api/vpc/v2/index.gen.js +4 -0
  156. package/dist/api/vpc/v2/marshalling.gen.js +137 -0
  157. package/dist/api/vpcgw/index.js +2 -0
  158. package/dist/api/vpcgw/v1/api.gen.js +669 -0
  159. package/dist/api/vpcgw/v1/content.gen.js +10 -0
  160. package/dist/api/vpcgw/v1/index.gen.js +5 -0
  161. package/dist/api/vpcgw/v1/marshalling.gen.js +359 -0
  162. package/dist/api/webhosting/index.js +2 -0
  163. package/dist/api/webhosting/v1alpha1/api.gen.js +158 -0
  164. package/dist/api/webhosting/v1alpha1/content.gen.js +7 -0
  165. package/dist/api/webhosting/v1alpha1/index.gen.js +7 -0
  166. package/dist/api/webhosting/v1alpha1/marshalling.gen.js +146 -0
  167. package/dist/api/webhosting/v1alpha1/validation-rules.gen.js +14 -0
  168. package/dist/helpers/is-browser.js +5 -0
  169. package/dist/helpers/is-response.js +10 -0
  170. package/dist/helpers/json.js +11 -0
  171. package/dist/helpers/marshalling.js +130 -0
  172. package/dist/index.cjs +26484 -0
  173. package/dist/index.d.ts +31184 -0
  174. package/dist/index.js +71 -0
  175. package/dist/internal/async/interval-retrier.js +105 -0
  176. package/dist/internal/async/sleep.js +13 -0
  177. package/dist/internal/interceptors/composer.js +46 -0
  178. package/dist/internal/interceptors/helpers.js +32 -0
  179. package/dist/internal/logger/console-logger.js +38 -0
  180. package/dist/internal/logger/index.js +41 -0
  181. package/dist/internal/logger/level-resolver.js +13 -0
  182. package/dist/internal/validations/string-validation.js +38 -0
  183. package/dist/node_modules/.pnpm/@scaleway_random-name@4.0.2/node_modules/@scaleway/random-name/dist/index.js +13 -0
  184. package/dist/scw/api.js +12 -0
  185. package/dist/scw/auth.js +68 -0
  186. package/dist/scw/client-ini-factory.js +174 -0
  187. package/dist/scw/client-ini-profile.js +54 -0
  188. package/dist/scw/client-settings.js +78 -0
  189. package/dist/scw/client.js +98 -0
  190. package/dist/scw/constants.js +4 -0
  191. package/dist/scw/custom-marshalling.js +131 -0
  192. package/dist/scw/errors/error-parser.js +107 -0
  193. package/dist/scw/errors/non-standard/invalid-request-mapper.js +36 -0
  194. package/dist/scw/errors/non-standard/unknown-resource-mapper.js +27 -0
  195. package/dist/scw/errors/scw-error.js +66 -0
  196. package/dist/scw/errors/standard/already-exists-error.js +26 -0
  197. package/dist/scw/errors/standard/denied-authentication-error.js +52 -0
  198. package/dist/scw/errors/standard/index.js +13 -0
  199. package/dist/scw/errors/standard/invalid-arguments-error.js +67 -0
  200. package/dist/scw/errors/standard/out-of-stock-error.js +22 -0
  201. package/dist/scw/errors/standard/permissions-denied-error.js +48 -0
  202. package/dist/scw/errors/standard/precondition-failed-error.js +42 -0
  203. package/dist/scw/errors/standard/quotas-exceeded-error.js +68 -0
  204. package/dist/scw/errors/standard/resource-expired-error.js +26 -0
  205. package/dist/scw/errors/standard/resource-locked-error.js +25 -0
  206. package/dist/scw/errors/standard/resource-not-found-error.js +25 -0
  207. package/dist/scw/errors/standard/too-many-requests-error.js +70 -0
  208. package/dist/scw/errors/standard/transient-state-error.js +26 -0
  209. package/dist/scw/errors/types.js +23 -0
  210. package/dist/scw/fetch/build-fetcher.js +72 -0
  211. package/dist/scw/fetch/http-dumper.js +54 -0
  212. package/dist/scw/fetch/http-interceptors.js +99 -0
  213. package/dist/scw/fetch/resource-paginator.js +84 -0
  214. package/dist/scw/fetch/response-parser.js +72 -0
  215. package/package.json +2 -2
@@ -0,0 +1,249 @@
1
+ import { waitForResource } from '../../../internal/async/interval-retrier.js';
2
+ import { API as API$1 } from '../../../scw/api.js';
3
+ import { validatePathParam, urlParams } from '../../../helpers/marshalling.js';
4
+ import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
5
+ import { VOLUME_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES } from './content.gen.js';
6
+ import { unmarshalListVolumeTypesResponse, unmarshalListVolumesResponse, marshalCreateVolumeRequest, unmarshalVolume, marshalUpdateVolumeRequest, unmarshalListSnapshotsResponse, unmarshalSnapshot, marshalCreateSnapshotRequest, marshalImportSnapshotFromS3Request, marshalUpdateSnapshotRequest } from './marshalling.gen.js';
7
+
8
+ // This file was automatically generated. DO NOT EDIT.
9
+ // If you have any remark or suggestion do not hesitate to open an issue.
10
+ const jsonContentHeaders = {
11
+ 'Content-Type': 'application/json; charset=utf-8'
12
+ };
13
+
14
+ /**
15
+ * Scaleway Block Storage API.
16
+ *
17
+ * This API allows you to use and manage your Block Storage volumes.
18
+ */
19
+ class API extends API$1 {
20
+ /** Lists the available zones of the API. */
21
+ static LOCALITIES = ['fr-par-1', 'pl-waw-3'];
22
+ pageOfListVolumeTypes = (() => {
23
+ var _this = this;
24
+ return function (request) {
25
+ if (request === void 0) {
26
+ request = {};
27
+ }
28
+ return _this.client.fetch({
29
+ method: 'GET',
30
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? _this.client.settings.defaultZone)}/volume-types`,
31
+ urlParams: urlParams(['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize])
32
+ }, unmarshalListVolumeTypesResponse);
33
+ };
34
+ })();
35
+
36
+ /**
37
+ * List volume types. List all available volume types in a specified zone. The
38
+ * volume types listed are ordered by name in ascending order.
39
+ *
40
+ * @param request - The request {@link ListVolumeTypesRequest}
41
+ * @returns A Promise of ListVolumeTypesResponse
42
+ */
43
+ listVolumeTypes = (() => {
44
+ var _this2 = this;
45
+ return function (request) {
46
+ if (request === void 0) {
47
+ request = {};
48
+ }
49
+ return enrichForPagination('volumeTypes', _this2.pageOfListVolumeTypes, request);
50
+ };
51
+ })();
52
+ pageOfListVolumes = (() => {
53
+ var _this3 = this;
54
+ return function (request) {
55
+ if (request === void 0) {
56
+ request = {};
57
+ }
58
+ return _this3.client.fetch({
59
+ method: 'GET',
60
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? _this3.client.settings.defaultZone)}/volumes`,
61
+ urlParams: urlParams(['name', request.name], ['order_by', request.orderBy], ['page', request.page], ['page_size', request.pageSize ?? _this3.client.settings.defaultPageSize], ['product_resource_id', request.productResourceId], ['project_id', request.projectId])
62
+ }, unmarshalListVolumesResponse);
63
+ };
64
+ })();
65
+
66
+ /**
67
+ * List volumes. List all existing volumes in a specified zone. By default,
68
+ * the volumes listed are ordered by creation date in ascending order. This
69
+ * can be modified via the `order_by` field.
70
+ *
71
+ * @param request - The request {@link ListVolumesRequest}
72
+ * @returns A Promise of ListVolumesResponse
73
+ */
74
+ listVolumes = (() => {
75
+ var _this4 = this;
76
+ return function (request) {
77
+ if (request === void 0) {
78
+ request = {};
79
+ }
80
+ return enrichForPagination('volumes', _this4.pageOfListVolumes, request);
81
+ };
82
+ })();
83
+
84
+ /**
85
+ * Create a volume. To create a new volume from scratch, you must specify
86
+ * `from_empty` and the `size`. To create a volume from an existing snapshot,
87
+ * specify `from_snapshot` and the `snapshot_id` in the request payload
88
+ * instead, size is optional and can be specified if you need to extend the
89
+ * original size. The volume will take on the same volume class and underlying
90
+ * IOPS limitations as the original snapshot.
91
+ *
92
+ * @param request - The request {@link CreateVolumeRequest}
93
+ * @returns A Promise of Volume
94
+ */
95
+ createVolume = request => this.client.fetch({
96
+ body: JSON.stringify(marshalCreateVolumeRequest(request, this.client.settings)),
97
+ headers: jsonContentHeaders,
98
+ method: 'POST',
99
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/volumes`
100
+ }, unmarshalVolume);
101
+
102
+ /**
103
+ * Get a volume. Retrieve technical information about a specific volume.
104
+ * Details such as size, type, and status are returned in the response.
105
+ *
106
+ * @param request - The request {@link GetVolumeRequest}
107
+ * @returns A Promise of Volume
108
+ */
109
+ getVolume = request => this.client.fetch({
110
+ method: 'GET',
111
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/volumes/${validatePathParam('volumeId', request.volumeId)}`
112
+ }, unmarshalVolume);
113
+
114
+ /**
115
+ * Waits for {@link Volume} to be in a final state.
116
+ *
117
+ * @param request - The request {@link GetVolumeRequest}
118
+ * @param options - The waiting options
119
+ * @returns A Promise of Volume
120
+ */
121
+ waitForVolume = (request, options) => waitForResource(options?.stop ?? (res => Promise.resolve(!VOLUME_TRANSIENT_STATUSES.includes(res.status))), this.getVolume, request, options);
122
+
123
+ /**
124
+ * Delete a detached volume. You must specify the `volume_id` of the volume
125
+ * you want to delete. The volume must not be in the `in_use` status.
126
+ *
127
+ * @param request - The request {@link DeleteVolumeRequest}
128
+ */
129
+ deleteVolume = request => this.client.fetch({
130
+ method: 'DELETE',
131
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/volumes/${validatePathParam('volumeId', request.volumeId)}`
132
+ });
133
+
134
+ /**
135
+ * Update a volume. Update the technical details of a volume, such as its
136
+ * name, tags, or its new size and `volume_type` (within the same Block
137
+ * Storage class). You can only resize a volume to a larger size. It is
138
+ * currently not possible to change your Block Storage Class.
139
+ *
140
+ * @param request - The request {@link UpdateVolumeRequest}
141
+ * @returns A Promise of Volume
142
+ */
143
+ updateVolume = request => this.client.fetch({
144
+ body: JSON.stringify(marshalUpdateVolumeRequest(request, this.client.settings)),
145
+ headers: jsonContentHeaders,
146
+ method: 'PATCH',
147
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/volumes/${validatePathParam('volumeId', request.volumeId)}`
148
+ }, unmarshalVolume);
149
+ pageOfListSnapshots = (() => {
150
+ var _this5 = this;
151
+ return function (request) {
152
+ if (request === void 0) {
153
+ request = {};
154
+ }
155
+ return _this5.client.fetch({
156
+ method: 'GET',
157
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? _this5.client.settings.defaultZone)}/snapshots`,
158
+ urlParams: urlParams(['name', request.name], ['order_by', request.orderBy], ['page', request.page], ['page_size', request.pageSize ?? _this5.client.settings.defaultPageSize], ['project_id', request.projectId], ['volume_id', request.volumeId])
159
+ }, unmarshalListSnapshotsResponse);
160
+ };
161
+ })();
162
+
163
+ /**
164
+ * List all snapshots. List all available snapshots in a specified zone. By
165
+ * default, the snapshots listed are ordered by creation date in ascending
166
+ * order. This can be modified via the `order_by` field.
167
+ *
168
+ * @param request - The request {@link ListSnapshotsRequest}
169
+ * @returns A Promise of ListSnapshotsResponse
170
+ */
171
+ listSnapshots = (() => {
172
+ var _this6 = this;
173
+ return function (request) {
174
+ if (request === void 0) {
175
+ request = {};
176
+ }
177
+ return enrichForPagination('snapshots', _this6.pageOfListSnapshots, request);
178
+ };
179
+ })();
180
+
181
+ /**
182
+ * Get a snapshot. Retrieve technical information about a specific snapshot.
183
+ * Details such as size, volume type, and status are returned in the
184
+ * response.
185
+ *
186
+ * @param request - The request {@link GetSnapshotRequest}
187
+ * @returns A Promise of Snapshot
188
+ */
189
+ getSnapshot = request => this.client.fetch({
190
+ method: 'GET',
191
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`
192
+ }, unmarshalSnapshot);
193
+
194
+ /**
195
+ * Waits for {@link Snapshot} to be in a final state.
196
+ *
197
+ * @param request - The request {@link GetSnapshotRequest}
198
+ * @param options - The waiting options
199
+ * @returns A Promise of Snapshot
200
+ */
201
+ waitForSnapshot = (request, options) => waitForResource(options?.stop ?? (res => Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))), this.getSnapshot, request, options);
202
+
203
+ /**
204
+ * Create a snapshot of a volume. To create a snapshot, the volume must be in
205
+ * the `in_use` or the `available` status. If your volume is in a transient
206
+ * state, you need to wait until the end of the current operation.
207
+ *
208
+ * @param request - The request {@link CreateSnapshotRequest}
209
+ * @returns A Promise of Snapshot
210
+ */
211
+ createSnapshot = request => this.client.fetch({
212
+ body: JSON.stringify(marshalCreateSnapshotRequest(request, this.client.settings)),
213
+ headers: jsonContentHeaders,
214
+ method: 'POST',
215
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots`
216
+ }, unmarshalSnapshot);
217
+ importSnapshotFromS3 = request => this.client.fetch({
218
+ body: JSON.stringify(marshalImportSnapshotFromS3Request(request, this.client.settings)),
219
+ headers: jsonContentHeaders,
220
+ method: 'POST',
221
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/import-from-s3`
222
+ }, unmarshalSnapshot);
223
+
224
+ /**
225
+ * Delete a snapshot. You must specify the `snapshot_id` of the snapshot you
226
+ * want to delete. The snapshot must not be in use.
227
+ *
228
+ * @param request - The request {@link DeleteSnapshotRequest}
229
+ */
230
+ deleteSnapshot = request => this.client.fetch({
231
+ method: 'DELETE',
232
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`
233
+ });
234
+
235
+ /**
236
+ * Update a snapshot. Update the name or tags of the snapshot.
237
+ *
238
+ * @param request - The request {@link UpdateSnapshotRequest}
239
+ * @returns A Promise of Snapshot
240
+ */
241
+ updateSnapshot = request => this.client.fetch({
242
+ body: JSON.stringify(marshalUpdateSnapshotRequest(request, this.client.settings)),
243
+ headers: jsonContentHeaders,
244
+ method: 'PATCH',
245
+ path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`
246
+ }, unmarshalSnapshot);
247
+ }
248
+
249
+ export { API };
@@ -0,0 +1,13 @@
1
+ // This file was automatically generated. DO NOT EDIT.
2
+ // If you have any remark or suggestion do not hesitate to open an issue.
3
+
4
+ /** Lists transient statutes of the enum {@link ReferenceStatus}. */
5
+ const REFERENCE_TRANSIENT_STATUSES = ['attaching', 'detaching', 'snapshotting'];
6
+
7
+ /** Lists transient statutes of the enum {@link SnapshotStatus}. */
8
+ const SNAPSHOT_TRANSIENT_STATUSES = ['creating', 'deleting'];
9
+
10
+ /** Lists transient statutes of the enum {@link VolumeStatus}. */
11
+ const VOLUME_TRANSIENT_STATUSES = ['creating', 'deleting', 'resizing', 'snapshotting'];
12
+
13
+ export { REFERENCE_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES, VOLUME_TRANSIENT_STATUSES };
@@ -0,0 +1,7 @@
1
+ export { API } from './api.gen.js';
2
+ export { REFERENCE_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES, VOLUME_TRANSIENT_STATUSES } from './content.gen.js';
3
+ import * as validationRules_gen from './validation-rules.gen.js';
4
+ export { validationRules_gen as ValidationRules };
5
+
6
+ // This file was automatically generated. DO NOT EDIT.
7
+ // If you have any remark or suggestion do not hesitate to open an issue.
@@ -0,0 +1,182 @@
1
+ import { isJSONObject } from '../../../helpers/json.js';
2
+ import { unmarshalMoney } from '../../../scw/custom-marshalling.js';
3
+ import { unmarshalDate, unmarshalArrayOfObject, resolveOneOf } from '../../../helpers/marshalling.js';
4
+
5
+ // This file was automatically generated. DO NOT EDIT.
6
+ // If you have any remark or suggestion do not hesitate to open an issue.
7
+ const unmarshalReference = data => {
8
+ if (!isJSONObject(data)) {
9
+ throw new TypeError(`Unmarshalling the type 'Reference' failed as data isn't a dictionary.`);
10
+ }
11
+ return {
12
+ createdAt: unmarshalDate(data.created_at),
13
+ id: data.id,
14
+ productResourceId: data.product_resource_id,
15
+ productResourceType: data.product_resource_type,
16
+ status: data.status,
17
+ type: data.type
18
+ };
19
+ };
20
+ const unmarshalVolumeSpecifications = data => {
21
+ if (!isJSONObject(data)) {
22
+ throw new TypeError(`Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary.`);
23
+ }
24
+ return {
25
+ class: data.class,
26
+ perfIops: data.perf_iops
27
+ };
28
+ };
29
+ const unmarshalVolume = data => {
30
+ if (!isJSONObject(data)) {
31
+ throw new TypeError(`Unmarshalling the type 'Volume' failed as data isn't a dictionary.`);
32
+ }
33
+ return {
34
+ createdAt: unmarshalDate(data.created_at),
35
+ id: data.id,
36
+ name: data.name,
37
+ parentSnapshotId: data.parent_snapshot_id,
38
+ projectId: data.project_id,
39
+ references: unmarshalArrayOfObject(data.references, unmarshalReference),
40
+ size: data.size,
41
+ specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : undefined,
42
+ status: data.status,
43
+ tags: data.tags,
44
+ type: data.type,
45
+ updatedAt: unmarshalDate(data.updated_at),
46
+ zone: data.zone
47
+ };
48
+ };
49
+ const unmarshalSnapshotParentVolume = data => {
50
+ if (!isJSONObject(data)) {
51
+ throw new TypeError(`Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary.`);
52
+ }
53
+ return {
54
+ id: data.id,
55
+ name: data.name,
56
+ status: data.status,
57
+ type: data.type
58
+ };
59
+ };
60
+ const unmarshalSnapshotSummary = data => {
61
+ if (!isJSONObject(data)) {
62
+ throw new TypeError(`Unmarshalling the type 'SnapshotSummary' failed as data isn't a dictionary.`);
63
+ }
64
+ return {
65
+ class: data.class,
66
+ createdAt: unmarshalDate(data.created_at),
67
+ id: data.id,
68
+ name: data.name,
69
+ parentVolume: data.parent_volume ? unmarshalSnapshotParentVolume(data.parent_volume) : undefined,
70
+ projectId: data.project_id,
71
+ size: data.size,
72
+ status: data.status,
73
+ tags: data.tags,
74
+ updatedAt: unmarshalDate(data.updated_at),
75
+ zone: data.zone
76
+ };
77
+ };
78
+ const unmarshalListSnapshotsResponse = data => {
79
+ if (!isJSONObject(data)) {
80
+ throw new TypeError(`Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`);
81
+ }
82
+ return {
83
+ snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshotSummary),
84
+ totalCount: data.total_count
85
+ };
86
+ };
87
+ const unmarshalVolumeType = data => {
88
+ if (!isJSONObject(data)) {
89
+ throw new TypeError(`Unmarshalling the type 'VolumeType' failed as data isn't a dictionary.`);
90
+ }
91
+ return {
92
+ pricing: data.pricing ? unmarshalMoney(data.pricing) : undefined,
93
+ snapshotPricing: data.snapshot_pricing ? unmarshalMoney(data.snapshot_pricing) : undefined,
94
+ specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : undefined,
95
+ type: data.type
96
+ };
97
+ };
98
+ const unmarshalListVolumeTypesResponse = data => {
99
+ if (!isJSONObject(data)) {
100
+ throw new TypeError(`Unmarshalling the type 'ListVolumeTypesResponse' failed as data isn't a dictionary.`);
101
+ }
102
+ return {
103
+ totalCount: data.total_count,
104
+ volumeTypes: unmarshalArrayOfObject(data.volume_types, unmarshalVolumeType)
105
+ };
106
+ };
107
+ const unmarshalListVolumesResponse = data => {
108
+ if (!isJSONObject(data)) {
109
+ throw new TypeError(`Unmarshalling the type 'ListVolumesResponse' failed as data isn't a dictionary.`);
110
+ }
111
+ return {
112
+ totalCount: data.total_count,
113
+ volumes: unmarshalArrayOfObject(data.volumes, unmarshalVolume)
114
+ };
115
+ };
116
+ const unmarshalSnapshot = data => {
117
+ if (!isJSONObject(data)) {
118
+ throw new TypeError(`Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`);
119
+ }
120
+ return {
121
+ class: data.class,
122
+ createdAt: unmarshalDate(data.created_at),
123
+ id: data.id,
124
+ name: data.name,
125
+ parentVolume: data.parent_volume ? unmarshalSnapshotParentVolume(data.parent_volume) : undefined,
126
+ projectId: data.project_id,
127
+ references: unmarshalArrayOfObject(data.references, unmarshalReference),
128
+ size: data.size,
129
+ status: data.status,
130
+ tags: data.tags,
131
+ updatedAt: unmarshalDate(data.updated_at),
132
+ zone: data.zone
133
+ };
134
+ };
135
+ const marshalCreateSnapshotRequest = (request, defaults) => ({
136
+ name: request.name,
137
+ project_id: request.projectId ?? defaults.defaultProjectId,
138
+ tags: request.tags,
139
+ volume_id: request.volumeId
140
+ });
141
+ const marshalCreateVolumeRequestFromEmpty = (request, defaults) => ({
142
+ size: request.size
143
+ });
144
+ const marshalCreateVolumeRequestFromSnapshot = (request, defaults) => ({
145
+ size: request.size,
146
+ snapshot_id: request.snapshotId
147
+ });
148
+ const marshalCreateVolumeRequest = (request, defaults) => ({
149
+ name: request.name,
150
+ project_id: request.projectId ?? defaults.defaultProjectId,
151
+ tags: request.tags,
152
+ ...resolveOneOf([{
153
+ param: 'from_empty',
154
+ value: request.fromEmpty !== undefined ? marshalCreateVolumeRequestFromEmpty(request.fromEmpty) : undefined
155
+ }, {
156
+ param: 'from_snapshot',
157
+ value: request.fromSnapshot !== undefined ? marshalCreateVolumeRequestFromSnapshot(request.fromSnapshot) : undefined
158
+ }]),
159
+ ...resolveOneOf([{
160
+ param: 'perf_iops',
161
+ value: request.perfIops
162
+ }])
163
+ });
164
+ const marshalImportSnapshotFromS3Request = (request, defaults) => ({
165
+ bucket: request.bucket,
166
+ key: request.key,
167
+ name: request.name,
168
+ project_id: request.projectId ?? defaults.defaultProjectId,
169
+ tags: request.tags
170
+ });
171
+ const marshalUpdateSnapshotRequest = (request, defaults) => ({
172
+ name: request.name,
173
+ tags: request.tags
174
+ });
175
+ const marshalUpdateVolumeRequest = (request, defaults) => ({
176
+ name: request.name,
177
+ perf_iops: request.perfIops,
178
+ size: request.size,
179
+ tags: request.tags
180
+ });
181
+
182
+ export { marshalCreateSnapshotRequest, marshalCreateVolumeRequest, marshalImportSnapshotFromS3Request, marshalUpdateSnapshotRequest, marshalUpdateVolumeRequest, unmarshalListSnapshotsResponse, unmarshalListVolumeTypesResponse, unmarshalListVolumesResponse, unmarshalReference, unmarshalSnapshot, unmarshalVolume };
@@ -0,0 +1,52 @@
1
+ // This file was automatically generated. DO NOT EDIT.
2
+ // If you have any remark or suggestion do not hesitate to open an issue.
3
+
4
+ const CreateSnapshotRequest = {
5
+ name: {
6
+ minLength: 1
7
+ }
8
+ };
9
+ const CreateVolumeRequest = {
10
+ name: {
11
+ minLength: 1
12
+ }
13
+ };
14
+ const ImportSnapshotFromS3Request = {
15
+ name: {
16
+ minLength: 1
17
+ }
18
+ };
19
+ const ListSnapshotsRequest = {
20
+ page: {
21
+ greaterThan: 0
22
+ },
23
+ pageSize: {
24
+ greaterThan: 0,
25
+ lessThanOrEqual: 100
26
+ }
27
+ };
28
+ const ListVolumeTypesRequest = {
29
+ page: {
30
+ greaterThan: 0
31
+ },
32
+ pageSize: {
33
+ greaterThan: 0,
34
+ lessThanOrEqual: 100
35
+ }
36
+ };
37
+ const ListVolumesRequest = {
38
+ page: {
39
+ greaterThan: 0
40
+ },
41
+ pageSize: {
42
+ greaterThan: 0,
43
+ lessThanOrEqual: 100
44
+ }
45
+ };
46
+ const Reference = {
47
+ productResourceType: {
48
+ minLength: 1
49
+ }
50
+ };
51
+
52
+ export { CreateSnapshotRequest, CreateVolumeRequest, ImportSnapshotFromS3Request, ListSnapshotsRequest, ListVolumeTypesRequest, ListVolumesRequest, Reference };
@@ -0,0 +1,2 @@
1
+ import * as index_gen from './v1beta1/index.gen.js';
2
+ export { index_gen as v1beta1 };