This message was deleted.
# general
s
This message was deleted.
l
What's not working? Are you looking for the versioning property? And it'd better to use the NEARLINE constant rather than the string, since then you get the hover docs.
Once you enable versioning, you can set up the noncurrent and max number properties via the lifecycleRules property.
n
Alright, how do i get the
NEARLINE
as constant?
l
It should come in the import gcp statement... let me look up the specific file...
๐Ÿ‘ 1
Wow, it hasn't been turned into a constant. The string value is used everywhere. It is "NEARLINE", all caps.
n
Okay ๐Ÿ˜„ So Iโ€™ve modified my
lifecycleRules
to this, would this behave like the
Expire noncurrent versions after
, so that all objects within this bucket is deleted after 30 days?
Copy code
const bucket = new gcp.storage.Bucket("name", {
  location: "US",
  name: "name",
  storageClass: "NEAERLINE",
  uniformBucketLevelAccess: true,
  versioning: {
    enabled: true,
  },
  lifecycleRules: [
    {
      action: {
        type: "Delete",
      },
      condition: {
        age: 30,
      },
    },
  ],
});
l
That'll include current versions, do you want that? Or only non-current versions?
n
only non-current-versions ๐Ÿ™‚
l
Then remove
age
, and put in
daysSinceNoncurrentTime
. And probably
numNewerVersions
too.
n
alright got it:
Copy code
lifecycleRules: [
    {
      action: {
        type: "Delete",
      },
      condition: {
        daysSinceNoncurrentTime: 30,
        numNewerVersions: 2,
      },
    },
  ],
And thatโ€™ll include
Max. Number of versions per object
as well, right?
l
You'd have to split it into two separate rules for that, I think.
Rules are _or_ed, conditions are _and_ed.
n
okay, interesting
Copy code
lifecycleRules: [
    {
      action: {
        type: "Delete",
      },
      condition: {
        daysSinceNoncurrentTime: 30,
      },
    },
    {
      action: {
        type: "Delete",
      },
      condition: {
        numNewerVersions: 2,
      },
    },
  ],
l
Your 1st example means "delete objects that have at least 2 newer versions and haven't been current in at least 30 days".
The second one is "delete objects that haven't been current in 30 days, and delete objects that have at least 2 newer versions (any age)".
Which I think is what your screenshot says, too.
n
yeah exactly
Thanks for the clarification :)
And obv thanks for helping ๐Ÿ™‚
๐Ÿ‘ 1