@scaleway/sdk-secret 1.1.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.
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkClient = require("@scaleway/sdk-client");
4
+ const unmarshalEphemeralProperties = (data) => {
5
+ if (!sdkClient.isJSONObject(data)) {
6
+ throw new TypeError(
7
+ `Unmarshalling the type 'EphemeralProperties' failed as data isn't a dictionary.`
8
+ );
9
+ }
10
+ return {
11
+ action: data.action,
12
+ expiresAt: sdkClient.unmarshalDate(data.expires_at),
13
+ expiresOnceAccessed: data.expires_once_accessed
14
+ };
15
+ };
16
+ const unmarshalSecretVersion = (data) => {
17
+ if (!sdkClient.isJSONObject(data)) {
18
+ throw new TypeError(
19
+ `Unmarshalling the type 'SecretVersion' failed as data isn't a dictionary.`
20
+ );
21
+ }
22
+ return {
23
+ createdAt: sdkClient.unmarshalDate(data.created_at),
24
+ deletedAt: sdkClient.unmarshalDate(data.deleted_at),
25
+ deletionRequestedAt: sdkClient.unmarshalDate(data.deletion_requested_at),
26
+ description: data.description,
27
+ ephemeralProperties: data.ephemeral_properties ? unmarshalEphemeralProperties(data.ephemeral_properties) : void 0,
28
+ latest: data.latest,
29
+ revision: data.revision,
30
+ secretId: data.secret_id,
31
+ status: data.status,
32
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
33
+ };
34
+ };
35
+ const unmarshalEphemeralPolicy = (data) => {
36
+ if (!sdkClient.isJSONObject(data)) {
37
+ throw new TypeError(
38
+ `Unmarshalling the type 'EphemeralPolicy' failed as data isn't a dictionary.`
39
+ );
40
+ }
41
+ return {
42
+ action: data.action,
43
+ expiresOnceAccessed: data.expires_once_accessed,
44
+ timeToLive: data.time_to_live
45
+ };
46
+ };
47
+ const unmarshalSecret = (data) => {
48
+ if (!sdkClient.isJSONObject(data)) {
49
+ throw new TypeError(
50
+ `Unmarshalling the type 'Secret' failed as data isn't a dictionary.`
51
+ );
52
+ }
53
+ return {
54
+ createdAt: sdkClient.unmarshalDate(data.created_at),
55
+ deletionRequestedAt: sdkClient.unmarshalDate(data.deletion_requested_at),
56
+ description: data.description,
57
+ ephemeralPolicy: data.ephemeral_policy ? unmarshalEphemeralPolicy(data.ephemeral_policy) : void 0,
58
+ id: data.id,
59
+ keyId: data.key_id,
60
+ managed: data.managed,
61
+ name: data.name,
62
+ path: data.path,
63
+ projectId: data.project_id,
64
+ protected: data.protected,
65
+ region: data.region,
66
+ status: data.status,
67
+ tags: data.tags,
68
+ type: data.type,
69
+ updatedAt: sdkClient.unmarshalDate(data.updated_at),
70
+ usedBy: data.used_by,
71
+ versionCount: data.version_count
72
+ };
73
+ };
74
+ const unmarshalAccessSecretVersionResponse = (data) => {
75
+ if (!sdkClient.isJSONObject(data)) {
76
+ throw new TypeError(
77
+ `Unmarshalling the type 'AccessSecretVersionResponse' failed as data isn't a dictionary.`
78
+ );
79
+ }
80
+ return {
81
+ data: data.data,
82
+ dataCrc32: data.data_crc32,
83
+ revision: data.revision,
84
+ secretId: data.secret_id,
85
+ type: data.type
86
+ };
87
+ };
88
+ const unmarshalBrowseSecretsResponseItemFolderDetails = (data) => {
89
+ if (!sdkClient.isJSONObject(data)) {
90
+ throw new TypeError(
91
+ `Unmarshalling the type 'BrowseSecretsResponseItemFolderDetails' failed as data isn't a dictionary.`
92
+ );
93
+ }
94
+ return {};
95
+ };
96
+ const unmarshalBrowseSecretsResponseItemSecretDetails = (data) => {
97
+ if (!sdkClient.isJSONObject(data)) {
98
+ throw new TypeError(
99
+ `Unmarshalling the type 'BrowseSecretsResponseItemSecretDetails' failed as data isn't a dictionary.`
100
+ );
101
+ }
102
+ return {
103
+ ephemeralPolicy: data.ephemeral_policy ? unmarshalEphemeralPolicy(data.ephemeral_policy) : void 0,
104
+ id: data.id,
105
+ protected: data.protected,
106
+ tags: data.tags,
107
+ type: data.type,
108
+ versionCount: data.version_count
109
+ };
110
+ };
111
+ const unmarshalBrowseSecretsResponseItem = (data) => {
112
+ if (!sdkClient.isJSONObject(data)) {
113
+ throw new TypeError(
114
+ `Unmarshalling the type 'BrowseSecretsResponseItem' failed as data isn't a dictionary.`
115
+ );
116
+ }
117
+ return {
118
+ createdAt: sdkClient.unmarshalDate(data.created_at),
119
+ folder: data.folder ? unmarshalBrowseSecretsResponseItemFolderDetails(data.folder) : void 0,
120
+ name: data.name,
121
+ secret: data.secret ? unmarshalBrowseSecretsResponseItemSecretDetails(data.secret) : void 0,
122
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
123
+ };
124
+ };
125
+ const unmarshalBrowseSecretsResponse = (data) => {
126
+ if (!sdkClient.isJSONObject(data)) {
127
+ throw new TypeError(
128
+ `Unmarshalling the type 'BrowseSecretsResponse' failed as data isn't a dictionary.`
129
+ );
130
+ }
131
+ return {
132
+ currentPath: data.current_path,
133
+ items: sdkClient.unmarshalArrayOfObject(
134
+ data.items,
135
+ unmarshalBrowseSecretsResponseItem
136
+ ),
137
+ totalCount: data.total_count
138
+ };
139
+ };
140
+ const unmarshalListSecretTypesResponse = (data) => {
141
+ if (!sdkClient.isJSONObject(data)) {
142
+ throw new TypeError(
143
+ `Unmarshalling the type 'ListSecretTypesResponse' failed as data isn't a dictionary.`
144
+ );
145
+ }
146
+ return {
147
+ totalCount: data.total_count,
148
+ types: data.types
149
+ };
150
+ };
151
+ const unmarshalListSecretVersionsResponse = (data) => {
152
+ if (!sdkClient.isJSONObject(data)) {
153
+ throw new TypeError(
154
+ `Unmarshalling the type 'ListSecretVersionsResponse' failed as data isn't a dictionary.`
155
+ );
156
+ }
157
+ return {
158
+ totalCount: data.total_count,
159
+ versions: sdkClient.unmarshalArrayOfObject(data.versions, unmarshalSecretVersion)
160
+ };
161
+ };
162
+ const unmarshalListSecretsResponse = (data) => {
163
+ if (!sdkClient.isJSONObject(data)) {
164
+ throw new TypeError(
165
+ `Unmarshalling the type 'ListSecretsResponse' failed as data isn't a dictionary.`
166
+ );
167
+ }
168
+ return {
169
+ secrets: sdkClient.unmarshalArrayOfObject(data.secrets, unmarshalSecret),
170
+ totalCount: data.total_count
171
+ };
172
+ };
173
+ const unmarshalListTagsResponse = (data) => {
174
+ if (!sdkClient.isJSONObject(data)) {
175
+ throw new TypeError(
176
+ `Unmarshalling the type 'ListTagsResponse' failed as data isn't a dictionary.`
177
+ );
178
+ }
179
+ return {
180
+ tags: data.tags,
181
+ totalCount: data.total_count
182
+ };
183
+ };
184
+ const marshalAddSecretOwnerRequest = (request, defaults) => ({
185
+ product: request.product
186
+ });
187
+ const marshalEphemeralPolicy = (request, defaults) => ({
188
+ action: request.action,
189
+ expires_once_accessed: request.expiresOnceAccessed,
190
+ time_to_live: request.timeToLive
191
+ });
192
+ const marshalCreateSecretRequest = (request, defaults) => ({
193
+ description: request.description,
194
+ ephemeral_policy: request.ephemeralPolicy !== void 0 ? marshalEphemeralPolicy(request.ephemeralPolicy) : void 0,
195
+ key_id: request.keyId,
196
+ name: request.name,
197
+ path: request.path,
198
+ project_id: request.projectId ?? defaults.defaultProjectId,
199
+ protected: request.protected,
200
+ tags: request.tags,
201
+ type: request.type
202
+ });
203
+ const marshalCreateSecretVersionRequest = (request, defaults) => ({
204
+ data: request.data,
205
+ data_crc32: request.dataCrc32,
206
+ description: request.description,
207
+ disable_previous: request.disablePrevious
208
+ });
209
+ const marshalUpdateSecretRequest = (request, defaults) => ({
210
+ description: request.description,
211
+ ephemeral_policy: request.ephemeralPolicy !== void 0 ? marshalEphemeralPolicy(request.ephemeralPolicy) : void 0,
212
+ name: request.name,
213
+ path: request.path,
214
+ tags: request.tags
215
+ });
216
+ const marshalEphemeralProperties = (request, defaults) => ({
217
+ action: request.action,
218
+ expires_at: request.expiresAt,
219
+ expires_once_accessed: request.expiresOnceAccessed
220
+ });
221
+ const marshalUpdateSecretVersionRequest = (request, defaults) => ({
222
+ description: request.description,
223
+ ephemeral_properties: request.ephemeralProperties !== void 0 ? marshalEphemeralProperties(request.ephemeralProperties) : void 0
224
+ });
225
+ exports.marshalAddSecretOwnerRequest = marshalAddSecretOwnerRequest;
226
+ exports.marshalCreateSecretRequest = marshalCreateSecretRequest;
227
+ exports.marshalCreateSecretVersionRequest = marshalCreateSecretVersionRequest;
228
+ exports.marshalUpdateSecretRequest = marshalUpdateSecretRequest;
229
+ exports.marshalUpdateSecretVersionRequest = marshalUpdateSecretVersionRequest;
230
+ exports.unmarshalAccessSecretVersionResponse = unmarshalAccessSecretVersionResponse;
231
+ exports.unmarshalBrowseSecretsResponse = unmarshalBrowseSecretsResponse;
232
+ exports.unmarshalListSecretTypesResponse = unmarshalListSecretTypesResponse;
233
+ exports.unmarshalListSecretVersionsResponse = unmarshalListSecretVersionsResponse;
234
+ exports.unmarshalListSecretsResponse = unmarshalListSecretsResponse;
235
+ exports.unmarshalListTagsResponse = unmarshalListTagsResponse;
236
+ exports.unmarshalSecret = unmarshalSecret;
237
+ exports.unmarshalSecretVersion = unmarshalSecretVersion;
@@ -0,0 +1,15 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { AccessSecretVersionResponse, AddSecretOwnerRequest, BrowseSecretsResponse, CreateSecretRequest, CreateSecretVersionRequest, ListSecretTypesResponse, ListSecretVersionsResponse, ListSecretsResponse, ListTagsResponse, Secret, SecretVersion, UpdateSecretRequest, UpdateSecretVersionRequest } from './types.gen';
3
+ export declare const unmarshalSecretVersion: (data: unknown) => SecretVersion;
4
+ export declare const unmarshalSecret: (data: unknown) => Secret;
5
+ export declare const unmarshalAccessSecretVersionResponse: (data: unknown) => AccessSecretVersionResponse;
6
+ export declare const unmarshalBrowseSecretsResponse: (data: unknown) => BrowseSecretsResponse;
7
+ export declare const unmarshalListSecretTypesResponse: (data: unknown) => ListSecretTypesResponse;
8
+ export declare const unmarshalListSecretVersionsResponse: (data: unknown) => ListSecretVersionsResponse;
9
+ export declare const unmarshalListSecretsResponse: (data: unknown) => ListSecretsResponse;
10
+ export declare const unmarshalListTagsResponse: (data: unknown) => ListTagsResponse;
11
+ export declare const marshalAddSecretOwnerRequest: (request: AddSecretOwnerRequest, defaults: DefaultValues) => Record<string, unknown>;
12
+ export declare const marshalCreateSecretRequest: (request: CreateSecretRequest, defaults: DefaultValues) => Record<string, unknown>;
13
+ export declare const marshalCreateSecretVersionRequest: (request: CreateSecretVersionRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalUpdateSecretRequest: (request: UpdateSecretRequest, defaults: DefaultValues) => Record<string, unknown>;
15
+ export declare const marshalUpdateSecretVersionRequest: (request: UpdateSecretVersionRequest, defaults: DefaultValues) => Record<string, unknown>;
@@ -0,0 +1,237 @@
1
+ import { isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ const unmarshalEphemeralProperties = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'EphemeralProperties' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ action: data.action,
10
+ expiresAt: unmarshalDate(data.expires_at),
11
+ expiresOnceAccessed: data.expires_once_accessed
12
+ };
13
+ };
14
+ const unmarshalSecretVersion = (data) => {
15
+ if (!isJSONObject(data)) {
16
+ throw new TypeError(
17
+ `Unmarshalling the type 'SecretVersion' failed as data isn't a dictionary.`
18
+ );
19
+ }
20
+ return {
21
+ createdAt: unmarshalDate(data.created_at),
22
+ deletedAt: unmarshalDate(data.deleted_at),
23
+ deletionRequestedAt: unmarshalDate(data.deletion_requested_at),
24
+ description: data.description,
25
+ ephemeralProperties: data.ephemeral_properties ? unmarshalEphemeralProperties(data.ephemeral_properties) : void 0,
26
+ latest: data.latest,
27
+ revision: data.revision,
28
+ secretId: data.secret_id,
29
+ status: data.status,
30
+ updatedAt: unmarshalDate(data.updated_at)
31
+ };
32
+ };
33
+ const unmarshalEphemeralPolicy = (data) => {
34
+ if (!isJSONObject(data)) {
35
+ throw new TypeError(
36
+ `Unmarshalling the type 'EphemeralPolicy' failed as data isn't a dictionary.`
37
+ );
38
+ }
39
+ return {
40
+ action: data.action,
41
+ expiresOnceAccessed: data.expires_once_accessed,
42
+ timeToLive: data.time_to_live
43
+ };
44
+ };
45
+ const unmarshalSecret = (data) => {
46
+ if (!isJSONObject(data)) {
47
+ throw new TypeError(
48
+ `Unmarshalling the type 'Secret' failed as data isn't a dictionary.`
49
+ );
50
+ }
51
+ return {
52
+ createdAt: unmarshalDate(data.created_at),
53
+ deletionRequestedAt: unmarshalDate(data.deletion_requested_at),
54
+ description: data.description,
55
+ ephemeralPolicy: data.ephemeral_policy ? unmarshalEphemeralPolicy(data.ephemeral_policy) : void 0,
56
+ id: data.id,
57
+ keyId: data.key_id,
58
+ managed: data.managed,
59
+ name: data.name,
60
+ path: data.path,
61
+ projectId: data.project_id,
62
+ protected: data.protected,
63
+ region: data.region,
64
+ status: data.status,
65
+ tags: data.tags,
66
+ type: data.type,
67
+ updatedAt: unmarshalDate(data.updated_at),
68
+ usedBy: data.used_by,
69
+ versionCount: data.version_count
70
+ };
71
+ };
72
+ const unmarshalAccessSecretVersionResponse = (data) => {
73
+ if (!isJSONObject(data)) {
74
+ throw new TypeError(
75
+ `Unmarshalling the type 'AccessSecretVersionResponse' failed as data isn't a dictionary.`
76
+ );
77
+ }
78
+ return {
79
+ data: data.data,
80
+ dataCrc32: data.data_crc32,
81
+ revision: data.revision,
82
+ secretId: data.secret_id,
83
+ type: data.type
84
+ };
85
+ };
86
+ const unmarshalBrowseSecretsResponseItemFolderDetails = (data) => {
87
+ if (!isJSONObject(data)) {
88
+ throw new TypeError(
89
+ `Unmarshalling the type 'BrowseSecretsResponseItemFolderDetails' failed as data isn't a dictionary.`
90
+ );
91
+ }
92
+ return {};
93
+ };
94
+ const unmarshalBrowseSecretsResponseItemSecretDetails = (data) => {
95
+ if (!isJSONObject(data)) {
96
+ throw new TypeError(
97
+ `Unmarshalling the type 'BrowseSecretsResponseItemSecretDetails' failed as data isn't a dictionary.`
98
+ );
99
+ }
100
+ return {
101
+ ephemeralPolicy: data.ephemeral_policy ? unmarshalEphemeralPolicy(data.ephemeral_policy) : void 0,
102
+ id: data.id,
103
+ protected: data.protected,
104
+ tags: data.tags,
105
+ type: data.type,
106
+ versionCount: data.version_count
107
+ };
108
+ };
109
+ const unmarshalBrowseSecretsResponseItem = (data) => {
110
+ if (!isJSONObject(data)) {
111
+ throw new TypeError(
112
+ `Unmarshalling the type 'BrowseSecretsResponseItem' failed as data isn't a dictionary.`
113
+ );
114
+ }
115
+ return {
116
+ createdAt: unmarshalDate(data.created_at),
117
+ folder: data.folder ? unmarshalBrowseSecretsResponseItemFolderDetails(data.folder) : void 0,
118
+ name: data.name,
119
+ secret: data.secret ? unmarshalBrowseSecretsResponseItemSecretDetails(data.secret) : void 0,
120
+ updatedAt: unmarshalDate(data.updated_at)
121
+ };
122
+ };
123
+ const unmarshalBrowseSecretsResponse = (data) => {
124
+ if (!isJSONObject(data)) {
125
+ throw new TypeError(
126
+ `Unmarshalling the type 'BrowseSecretsResponse' failed as data isn't a dictionary.`
127
+ );
128
+ }
129
+ return {
130
+ currentPath: data.current_path,
131
+ items: unmarshalArrayOfObject(
132
+ data.items,
133
+ unmarshalBrowseSecretsResponseItem
134
+ ),
135
+ totalCount: data.total_count
136
+ };
137
+ };
138
+ const unmarshalListSecretTypesResponse = (data) => {
139
+ if (!isJSONObject(data)) {
140
+ throw new TypeError(
141
+ `Unmarshalling the type 'ListSecretTypesResponse' failed as data isn't a dictionary.`
142
+ );
143
+ }
144
+ return {
145
+ totalCount: data.total_count,
146
+ types: data.types
147
+ };
148
+ };
149
+ const unmarshalListSecretVersionsResponse = (data) => {
150
+ if (!isJSONObject(data)) {
151
+ throw new TypeError(
152
+ `Unmarshalling the type 'ListSecretVersionsResponse' failed as data isn't a dictionary.`
153
+ );
154
+ }
155
+ return {
156
+ totalCount: data.total_count,
157
+ versions: unmarshalArrayOfObject(data.versions, unmarshalSecretVersion)
158
+ };
159
+ };
160
+ const unmarshalListSecretsResponse = (data) => {
161
+ if (!isJSONObject(data)) {
162
+ throw new TypeError(
163
+ `Unmarshalling the type 'ListSecretsResponse' failed as data isn't a dictionary.`
164
+ );
165
+ }
166
+ return {
167
+ secrets: unmarshalArrayOfObject(data.secrets, unmarshalSecret),
168
+ totalCount: data.total_count
169
+ };
170
+ };
171
+ const unmarshalListTagsResponse = (data) => {
172
+ if (!isJSONObject(data)) {
173
+ throw new TypeError(
174
+ `Unmarshalling the type 'ListTagsResponse' failed as data isn't a dictionary.`
175
+ );
176
+ }
177
+ return {
178
+ tags: data.tags,
179
+ totalCount: data.total_count
180
+ };
181
+ };
182
+ const marshalAddSecretOwnerRequest = (request, defaults) => ({
183
+ product: request.product
184
+ });
185
+ const marshalEphemeralPolicy = (request, defaults) => ({
186
+ action: request.action,
187
+ expires_once_accessed: request.expiresOnceAccessed,
188
+ time_to_live: request.timeToLive
189
+ });
190
+ const marshalCreateSecretRequest = (request, defaults) => ({
191
+ description: request.description,
192
+ ephemeral_policy: request.ephemeralPolicy !== void 0 ? marshalEphemeralPolicy(request.ephemeralPolicy) : void 0,
193
+ key_id: request.keyId,
194
+ name: request.name,
195
+ path: request.path,
196
+ project_id: request.projectId ?? defaults.defaultProjectId,
197
+ protected: request.protected,
198
+ tags: request.tags,
199
+ type: request.type
200
+ });
201
+ const marshalCreateSecretVersionRequest = (request, defaults) => ({
202
+ data: request.data,
203
+ data_crc32: request.dataCrc32,
204
+ description: request.description,
205
+ disable_previous: request.disablePrevious
206
+ });
207
+ const marshalUpdateSecretRequest = (request, defaults) => ({
208
+ description: request.description,
209
+ ephemeral_policy: request.ephemeralPolicy !== void 0 ? marshalEphemeralPolicy(request.ephemeralPolicy) : void 0,
210
+ name: request.name,
211
+ path: request.path,
212
+ tags: request.tags
213
+ });
214
+ const marshalEphemeralProperties = (request, defaults) => ({
215
+ action: request.action,
216
+ expires_at: request.expiresAt,
217
+ expires_once_accessed: request.expiresOnceAccessed
218
+ });
219
+ const marshalUpdateSecretVersionRequest = (request, defaults) => ({
220
+ description: request.description,
221
+ ephemeral_properties: request.ephemeralProperties !== void 0 ? marshalEphemeralProperties(request.ephemeralProperties) : void 0
222
+ });
223
+ export {
224
+ marshalAddSecretOwnerRequest,
225
+ marshalCreateSecretRequest,
226
+ marshalCreateSecretVersionRequest,
227
+ marshalUpdateSecretRequest,
228
+ marshalUpdateSecretVersionRequest,
229
+ unmarshalAccessSecretVersionResponse,
230
+ unmarshalBrowseSecretsResponse,
231
+ unmarshalListSecretTypesResponse,
232
+ unmarshalListSecretVersionsResponse,
233
+ unmarshalListSecretsResponse,
234
+ unmarshalListTagsResponse,
235
+ unmarshalSecret,
236
+ unmarshalSecretVersion
237
+ };