@@ -12,6 +12,8 @@ import type {
1212 CreateFolderRequest ,
1313 CreateSecretRequest ,
1414 CreateSecretVersionRequest ,
15+ EphemeralPolicy ,
16+ EphemeralProperties ,
1517 Folder ,
1618 GeneratePasswordRequest ,
1719 ListFoldersResponse ,
@@ -42,6 +44,20 @@ export const unmarshalFolder = (data: unknown): Folder => {
4244 } as Folder
4345}
4446
47+ const unmarshalEphemeralProperties = ( data : unknown ) : EphemeralProperties => {
48+ if ( ! isJSONObject ( data ) ) {
49+ throw new TypeError (
50+ `Unmarshalling the type 'EphemeralProperties' failed as data isn't a dictionary.` ,
51+ )
52+ }
53+
54+ return {
55+ action : data . action ,
56+ expiresAt : unmarshalDate ( data . expires_at ) ,
57+ expiresOnceAccessed : data . expires_once_accessed ,
58+ } as EphemeralProperties
59+ }
60+
4561export const unmarshalSecretVersion = ( data : unknown ) : SecretVersion => {
4662 if ( ! isJSONObject ( data ) ) {
4763 throw new TypeError (
@@ -52,6 +68,9 @@ export const unmarshalSecretVersion = (data: unknown): SecretVersion => {
5268 return {
5369 createdAt : unmarshalDate ( data . created_at ) ,
5470 description : data . description ,
71+ ephemeralProperties : data . ephemeral_properties
72+ ? unmarshalEphemeralProperties ( data . ephemeral_properties )
73+ : undefined ,
5574 isLatest : data . is_latest ,
5675 revision : data . revision ,
5776 secretId : data . secret_id ,
@@ -60,6 +79,20 @@ export const unmarshalSecretVersion = (data: unknown): SecretVersion => {
6079 } as SecretVersion
6180}
6281
82+ export const unmarshalEphemeralPolicy = ( data : unknown ) : EphemeralPolicy => {
83+ if ( ! isJSONObject ( data ) ) {
84+ throw new TypeError (
85+ `Unmarshalling the type 'EphemeralPolicy' failed as data isn't a dictionary.` ,
86+ )
87+ }
88+
89+ return {
90+ action : data . action ,
91+ expiresOnceAccessed : data . expires_once_accessed ,
92+ timeToLive : data . time_to_live ,
93+ } as EphemeralPolicy
94+ }
95+
6396export const unmarshalSecret = ( data : unknown ) : Secret => {
6497 if ( ! isJSONObject ( data ) ) {
6598 throw new TypeError (
@@ -70,8 +103,9 @@ export const unmarshalSecret = (data: unknown): Secret => {
70103 return {
71104 createdAt : unmarshalDate ( data . created_at ) ,
72105 description : data . description ,
73- ephemeralAction : data . ephemeral_action ,
74- expiresAt : unmarshalDate ( data . expires_at ) ,
106+ ephemeralPolicy : data . ephemeral_policy
107+ ? unmarshalEphemeralPolicy ( data . ephemeral_policy )
108+ : undefined ,
75109 id : data . id ,
76110 isManaged : data . is_managed ,
77111 isProtected : data . is_protected ,
@@ -179,13 +213,24 @@ export const marshalCreateFolderRequest = (
179213 project_id : request . projectId ?? defaults . defaultProjectId ,
180214} )
181215
216+ export const marshalEphemeralPolicy = (
217+ request : EphemeralPolicy ,
218+ defaults : DefaultValues ,
219+ ) : Record < string , unknown > => ( {
220+ action : request . action ,
221+ expires_once_accessed : request . expiresOnceAccessed ,
222+ time_to_live : request . timeToLive ,
223+ } )
224+
182225export const marshalCreateSecretRequest = (
183226 request : CreateSecretRequest ,
184227 defaults : DefaultValues ,
185228) : Record < string , unknown > => ( {
186229 description : request . description ,
187- ephemeral_action : request . ephemeralAction ,
188- expires_at : request . expiresAt ,
230+ ephemeral_policy :
231+ request . ephemeralPolicy !== undefined
232+ ? marshalEphemeralPolicy ( request . ephemeralPolicy , defaults )
233+ : undefined ,
189234 name : request . name ,
190235 path : request . path ,
191236 project_id : request . projectId ?? defaults . defaultProjectId ,
@@ -236,14 +281,31 @@ export const marshalUpdateSecretRequest = (
236281 defaults : DefaultValues ,
237282) : Record < string , unknown > => ( {
238283 description : request . description ,
284+ ephemeral_policy :
285+ request . ephemeralPolicy !== undefined
286+ ? marshalEphemeralPolicy ( request . ephemeralPolicy , defaults )
287+ : undefined ,
239288 name : request . name ,
240289 path : request . path ,
241290 tags : request . tags ,
242291} )
243292
293+ const marshalEphemeralProperties = (
294+ request : EphemeralProperties ,
295+ defaults : DefaultValues ,
296+ ) : Record < string , unknown > => ( {
297+ action : request . action ,
298+ expires_at : request . expiresAt ,
299+ expires_once_accessed : request . expiresOnceAccessed ,
300+ } )
301+
244302export const marshalUpdateSecretVersionRequest = (
245303 request : UpdateSecretVersionRequest ,
246304 defaults : DefaultValues ,
247305) : Record < string , unknown > => ( {
248306 description : request . description ,
307+ ephemeral_properties :
308+ request . ephemeralProperties !== undefined
309+ ? marshalEphemeralProperties ( request . ephemeralProperties , defaults )
310+ : undefined ,
249311} )
0 commit comments