Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filemanager): add FileStateChange event schema #607

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/stacks/schema/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export const getEventSchemaStackProps = (): SchemaStackProps => {
docBase + '/metadatamanager/MetadataStateChange.schema.json'
),
},
{
...defaultProps,
schemaName: 'orcabus.filemanager@FileStateChange',
schemaDescription: 'Change of state for an object in the file manager',
schemaLocation: path.join(__dirname, docBase + '/filemanager/FileStateChange.schema.json'),
},
],
};
};
179 changes: 179 additions & 0 deletions docs/schemas/events/filemanager/FileStateChange.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "FileStateChange",
"description": "A filemanager object state change event.",
"type": "object",
"required": [
"detail",
"detail-type",
"source"
],
"properties": {
"account": {
"description": "The account ID of the event.",
"type": [
"string",
"null"
]
},
"detail": {
"description": "The detail of the event.",
"allOf": [
{
"$ref": "#/definitions/Detail"
}
]
},
"detail-type": {
"description": "The type of the event.",
"allOf": [
{
"$ref": "#/definitions/FileStateChange"
}
]
},
"id": {
"description": "The ID of the event.",
"type": [
"string",
"null"
],
"format": "uuid"
},
"region": {
"description": "The region the event was generated in.",
"type": [
"string",
"null"
]
},
"resources": {
"description": "The resources of the event.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"source": {
"description": "The source of the event.",
"type": "string"
},
"time": {
"description": "The time the event was generated.",
"type": [
"string",
"null"
],
"format": "date-time"
},
"version": {
"description": "The version of the event.",
"type": [
"string",
"null"
]
}
},
"definitions": {
"Detail": {
"description": "The detail of an S3 object state change event.",
"type": "object",
"properties": {
"expiration": {
"description": "The number of days to wait before expiring the object. Performs no expiry by default.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"keep-on-move": {
"description": "Whether to keep the expiry rule when the object is moved. By default, the rule is removed when an object is moved.",
"type": "boolean"
},
"object-size-greater-than": {
"description": "Apply the transition to objects that are greater than the specified size. Applies to objects of any size by default.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"object-size-less-than": {
"description": "Apply the transition to objects that are less than the specified size. Applies to objects of any size by default.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 1.0
},
"prefix": {
"description": "The key name prefix to apply this transition to. Applies to all objects by default.",
"type": [
"string",
"null"
]
},
"transitions": {
"description": "A set of transitions to apply. Performs no transition by default.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Transition"
}
}
}
},
"FileStateChange": {
"description": "The type of S3 object state change event.",
"type": "string",
"enum": [
"FileStateChange"
]
},
"StorageClass": {
"description": "AWS storage types.",
"type": "string",
"enum": [
"STANDARD_IA",
"INTELLIGENT_TIERING",
"ONEZONE_IA",
"GLACIER",
"GLACIER_IR",
"DEEP_ARCHIVE"
]
},
"Transition": {
"description": "An S3 storage class transition.",
"type": "object",
"required": [
"days",
"storage-class"
],
"properties": {
"days": {
"description": "The number of days to wait before transitioning the object.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"storage-class": {
"description": "The storage class to transition to.",
"allOf": [
{
"$ref": "#/definitions/StorageClass"
}
]
}
}
}
}
}
3 changes: 3 additions & 0 deletions docs/schemas/events/filemanager/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
@check-jsonschema --schemafile FileStateChange.schema.json example/FSC__example1.json
@check-jsonschema --schemafile FileStateChange.schema.json example/FSC__example2.json
15 changes: 15 additions & 0 deletions docs/schemas/events/filemanager/example/FSC__example1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"detail-type": "FileStateChange",
"source": "orcabus.filemanager",
"version": "0",
"id": "01929850-275f-7511-9fe2-3825cd786a76",
"account": "123456789012",
"time": "2024-10-17T02:30:42.783745070Z",
"region": "ap-southeast-2",
"resources": [],
"detail": {
"expiration": 30,
"object-size-greater-than": 1024,
"keep-on-move": true
}
}
25 changes: 25 additions & 0 deletions docs/schemas/events/filemanager/example/FSC__example2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"detail-type": "FileStateChange",
"source": "orcabus.filemanager",
"version": "0",
"id": "01929850-275f-7511-9fe2-383de94eca70",
"account": "123456789012",
"time": "2024-10-17T02:30:42.783850460Z",
"region": "ap-southeast-2",
"resources": [],
"detail": {
"prefix": "key_prefix/",
"transitions": [
{
"storage-class": "STANDARD_IA",
"days": 30
},
{
"storage-class": "GLACIER",
"days": 90
}
],
"expiration": 365,
"object-size-less-than": 1024
}
}
Loading