-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add data structures for object-locking To be used in commands Co-authored-by: Rafael Oliveira <ra.ph@live.com> * feat: add object-locking commands to bucket level sets default behavior of objects in bucket Co-authored-by: Rafael Oliveira <ra.ph@live.com> * feat: add object-locking command in object level manipulate isolate objects to prevent deletion Co-authored-by: Rafael Oliveira <ra.ph@live.com> * feat: add object-locking command in object level manipulate isolate objects to prevent deletion Co-authored-by: Rafael Oliveira <ra.ph@live.com> --------- Co-authored-by: Rafael Oliveira <ra.ph@live.com>
- Loading branch information
1 parent
54ed1ab
commit 50c54d8
Showing
17 changed files
with
680 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
mgc/cli/docs/object-storage/buckets/object-lock/get/help.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Get object locking configuration for the specified bucket | ||
|
||
## Usage: | ||
```bash | ||
Usage: | ||
./mgc object-storage buckets object-lock get [dst] [flags] | ||
``` | ||
|
||
## Product catalog: | ||
- Flags: | ||
- --dst string Specifies the bucket whose ACL is being requested (required) | ||
- -h, --help help for get | ||
|
||
## Other commands: | ||
- Global Flags: | ||
- --api-key string Use your API key to authenticate with the API | ||
- --chunk-size integer Chunk size to consider when doing multipart requests. Specified in Mb (range: 8 - 5120) (default 8) | ||
- -U, --cli.retry-until string Retry the action with the same parameters until the given condition is met. The flag parameters | ||
- use the format: 'retries,interval,condition', where 'retries' is a positive integer, 'interval' is | ||
- a duration (ex: 2s) and 'condition' is a 'engine=value' pair such as "jsonpath=expression" | ||
- -t, --cli.timeout duration If > 0, it's the timeout for the action execution. It's specified as numbers and unit suffix. | ||
- Valid unit suffixes: ns, us, ms, s, m and h. Examples: 300ms, 1m30s | ||
- --debug Display detailed log information at the debug level | ||
- --no-confirm Bypasses confirmation step for commands that ask a confirmation from the user | ||
- -o, --output string Change the output format. Use '--output=help' to know more details. | ||
- -r, --raw Output raw data, without any formatting or coloring | ||
- --region enum Region to reach the service (one of "br-mgl1", "br-ne1" or "br-se1") (default "br-se1") | ||
- --server-url uri Manually specify the server to use | ||
- --workers integer Number of routines that spawn to do parallel operations within object_storage (min: 1) (default 5) | ||
|
||
## Flags: | ||
```bash | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Object locking commands | ||
|
||
## Usage: | ||
```bash | ||
Usage: | ||
./mgc object-storage buckets object-lock [flags] | ||
./mgc object-storage buckets object-lock [command] | ||
``` | ||
|
||
## Product catalog: | ||
- Commands: | ||
- get Get object locking configuration for the specified bucket | ||
- set set number of either days or years to lock new objects for | ||
|
||
## Other commands: | ||
- Flags: | ||
- -h, --help help for object-lock | ||
|
||
## Flags: | ||
```bash | ||
Global Flags: | ||
--api-key string Use your API key to authenticate with the API | ||
-U, --cli.retry-until string Retry the action with the same parameters until the given condition is met. The flag parameters | ||
use the format: 'retries,interval,condition', where 'retries' is a positive integer, 'interval' is | ||
a duration (ex: 2s) and 'condition' is a 'engine=value' pair such as "jsonpath=expression" | ||
-t, --cli.timeout duration If > 0, it's the timeout for the action execution. It's specified as numbers and unit suffix. | ||
Valid unit suffixes: ns, us, ms, s, m and h. Examples: 300ms, 1m30s | ||
--debug Display detailed log information at the debug level | ||
--no-confirm Bypasses confirmation step for commands that ask a confirmation from the user | ||
-o, --output string Change the output format. Use '--output=help' to know more details. | ||
-r, --raw Output raw data, without any formatting or coloring | ||
``` | ||
38 changes: 38 additions & 0 deletions
38
mgc/cli/docs/object-storage/buckets/object-lock/set/help.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# set number of either days or years to lock new objects for | ||
|
||
## Usage: | ||
```bash | ||
Usage: | ||
./mgc object-storage buckets object-lock set [dst] [flags] | ||
``` | ||
|
||
## Product catalog: | ||
- Examples: | ||
- ./mgc object-storage buckets object-lock set --days=30 --dst="my-bucket" --years=5 | ||
|
||
## Other commands: | ||
- Flags: | ||
- --days integer Number of days to lock new objects for. Cannot be used alongside 'years' | ||
- --dst string Name of the bucket to set object locking for its objects (required) | ||
- -h, --help help for set | ||
- --years integer Number of years to lock new objects for. Cannot be used alongside 'days' | ||
|
||
## Flags: | ||
```bash | ||
Global Flags: | ||
--api-key string Use your API key to authenticate with the API | ||
--chunk-size integer Chunk size to consider when doing multipart requests. Specified in Mb (range: 8 - 5120) (default 8) | ||
-U, --cli.retry-until string Retry the action with the same parameters until the given condition is met. The flag parameters | ||
use the format: 'retries,interval,condition', where 'retries' is a positive integer, 'interval' is | ||
a duration (ex: 2s) and 'condition' is a 'engine=value' pair such as "jsonpath=expression" | ||
-t, --cli.timeout duration If > 0, it's the timeout for the action execution. It's specified as numbers and unit suffix. | ||
Valid unit suffixes: ns, us, ms, s, m and h. Examples: 300ms, 1m30s | ||
--debug Display detailed log information at the debug level | ||
--no-confirm Bypasses confirmation step for commands that ask a confirmation from the user | ||
-o, --output string Change the output format. Use '--output=help' to know more details. | ||
-r, --raw Output raw data, without any formatting or coloring | ||
--region enum Region to reach the service (one of "br-mgl1", "br-ne1" or "br-se1") (default "br-se1") | ||
--server-url uri Manually specify the server to use | ||
--workers integer Number of routines that spawn to do parallel operations within object_storage (min: 1) (default 5) | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
mgc/cli/docs/object-storage/objects/object-lock/get/help.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Get object locking configuration for the specified object | ||
|
||
## Usage: | ||
```bash | ||
Usage: | ||
./mgc object-storage objects object-lock get [dst] [flags] | ||
``` | ||
|
||
## Product catalog: | ||
- Flags: | ||
- --dst uri Specifies the object whose lock is being requested (required) | ||
- -h, --help help for get | ||
|
||
## Other commands: | ||
- Global Flags: | ||
- --api-key string Use your API key to authenticate with the API | ||
- --chunk-size integer Chunk size to consider when doing multipart requests. Specified in Mb (range: 8 - 5120) (default 8) | ||
- -U, --cli.retry-until string Retry the action with the same parameters until the given condition is met. The flag parameters | ||
- use the format: 'retries,interval,condition', where 'retries' is a positive integer, 'interval' is | ||
- a duration (ex: 2s) and 'condition' is a 'engine=value' pair such as "jsonpath=expression" | ||
- -t, --cli.timeout duration If > 0, it's the timeout for the action execution. It's specified as numbers and unit suffix. | ||
- Valid unit suffixes: ns, us, ms, s, m and h. Examples: 300ms, 1m30s | ||
- --debug Display detailed log information at the debug level | ||
- --no-confirm Bypasses confirmation step for commands that ask a confirmation from the user | ||
- -o, --output string Change the output format. Use '--output=help' to know more details. | ||
- -r, --raw Output raw data, without any formatting or coloring | ||
- --region enum Region to reach the service (one of "br-mgl1", "br-ne1" or "br-se1") (default "br-se1") | ||
- --server-url uri Manually specify the server to use | ||
- --workers integer Number of routines that spawn to do parallel operations within object_storage (min: 1) (default 5) | ||
|
||
## Flags: | ||
```bash | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Object locking commands | ||
|
||
## Usage: | ||
```bash | ||
Usage: | ||
./mgc object-storage objects object-lock [flags] | ||
./mgc object-storage objects object-lock [command] | ||
``` | ||
|
||
## Product catalog: | ||
- Commands: | ||
- get Get object locking configuration for the specified object | ||
- set set number of either days or years to lock new objects for | ||
|
||
## Other commands: | ||
- Flags: | ||
- -h, --help help for object-lock | ||
|
||
## Flags: | ||
```bash | ||
Global Flags: | ||
--api-key string Use your API key to authenticate with the API | ||
-U, --cli.retry-until string Retry the action with the same parameters until the given condition is met. The flag parameters | ||
use the format: 'retries,interval,condition', where 'retries' is a positive integer, 'interval' is | ||
a duration (ex: 2s) and 'condition' is a 'engine=value' pair such as "jsonpath=expression" | ||
-t, --cli.timeout duration If > 0, it's the timeout for the action execution. It's specified as numbers and unit suffix. | ||
Valid unit suffixes: ns, us, ms, s, m and h. Examples: 300ms, 1m30s | ||
--debug Display detailed log information at the debug level | ||
--no-confirm Bypasses confirmation step for commands that ask a confirmation from the user | ||
-o, --output string Change the output format. Use '--output=help' to know more details. | ||
-r, --raw Output raw data, without any formatting or coloring | ||
``` | ||
37 changes: 37 additions & 0 deletions
37
mgc/cli/docs/object-storage/objects/object-lock/set/help.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# set number of either days or years to lock new objects for | ||
|
||
## Usage: | ||
```bash | ||
Usage: | ||
./mgc object-storage objects object-lock set [dst] [flags] | ||
``` | ||
|
||
## Product catalog: | ||
- Examples: | ||
- ./mgc object-storage objects object-lock set --retain-until-date="2025-10-03T00:00:00" | ||
|
||
## Other commands: | ||
- Flags: | ||
- --dst uri Specifies the object whose lock is being requested (required) | ||
- -h, --help help for set | ||
- --retain-until-date string Timestamp in ISO 8601 format (required) | ||
|
||
## Flags: | ||
```bash | ||
Global Flags: | ||
--api-key string Use your API key to authenticate with the API | ||
--chunk-size integer Chunk size to consider when doing multipart requests. Specified in Mb (range: 8 - 5120) (default 8) | ||
-U, --cli.retry-until string Retry the action with the same parameters until the given condition is met. The flag parameters | ||
use the format: 'retries,interval,condition', where 'retries' is a positive integer, 'interval' is | ||
a duration (ex: 2s) and 'condition' is a 'engine=value' pair such as "jsonpath=expression" | ||
-t, --cli.timeout duration If > 0, it's the timeout for the action execution. It's specified as numbers and unit suffix. | ||
Valid unit suffixes: ns, us, ms, s, m and h. Examples: 300ms, 1m30s | ||
--debug Display detailed log information at the debug level | ||
--no-confirm Bypasses confirmation step for commands that ask a confirmation from the user | ||
-o, --output string Change the output format. Use '--output=help' to know more details. | ||
-r, --raw Output raw data, without any formatting or coloring | ||
--region enum Region to reach the service (one of "br-mgl1", "br-ne1" or "br-se1") (default "br-se1") | ||
--server-url uri Manually specify the server to use | ||
--workers integer Number of routines that spawn to do parallel operations within object_storage (min: 1) (default 5) | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package object_lock | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"magalu.cloud/core" | ||
"magalu.cloud/core/utils" | ||
"magalu.cloud/sdk/static/object_storage/common" | ||
) | ||
|
||
type GetBucketObjectLockParams struct { | ||
Bucket common.BucketName `json:"dst" jsonschema:"description=Specifies the bucket whose ACL is being requested" mgc:"positional"` | ||
} | ||
|
||
type objectLockingResponse struct { | ||
ObjectLockEnabled string | ||
Rule common.ObjectLockRule | ||
} | ||
|
||
var getGet = utils.NewLazyLoader[core.Executor](func() core.Executor { | ||
var exec core.Executor = core.NewStaticExecute( | ||
core.DescriptorSpec{ | ||
Name: "get", | ||
Description: "Get object locking configuration for the specified bucket", | ||
}, | ||
getObjectLocking, | ||
) | ||
exec = core.NewExecuteResultOutputOptions(exec, func(exec core.Executor, result core.Result) string { | ||
return "json" | ||
}) | ||
return exec | ||
}) | ||
|
||
func getObjectLocking(ctx context.Context, params GetBucketObjectLockParams, cfg common.Config) (result objectLockingResponse, err error) { | ||
req, err := newGetObjectLockingRequest(ctx, cfg, params.Bucket) | ||
if err != nil { | ||
return | ||
} | ||
|
||
res, err := common.SendRequest(ctx, req) | ||
if err != nil { | ||
return | ||
} | ||
|
||
result, err = common.UnwrapResponse[objectLockingResponse](res, req) | ||
return | ||
} | ||
|
||
func newGetObjectLockingRequest(ctx context.Context, cfg common.Config, bucketName common.BucketName) (*http.Request, error) { | ||
url, err := common.BuildBucketHostURL(cfg, bucketName) | ||
if err != nil { | ||
return nil, core.UsageError{Err: err} | ||
} | ||
|
||
query := url.Query() | ||
query.Add("object-lock", "") | ||
url.RawQuery = query.Encode() | ||
|
||
return http.NewRequestWithContext(ctx, http.MethodGet, url.String(), nil) | ||
} |
21 changes: 21 additions & 0 deletions
21
mgc/sdk/static/object_storage/buckets/object-lock/group.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package object_lock | ||
|
||
import ( | ||
"magalu.cloud/core" | ||
"magalu.cloud/core/utils" | ||
) | ||
|
||
var GetGroup = utils.NewLazyLoader(func() core.Grouper { | ||
return core.NewStaticGroup( | ||
core.DescriptorSpec{ | ||
Name: "object-lock", | ||
Description: "Object locking commands", | ||
}, | ||
func() []core.Descriptor { | ||
return []core.Descriptor{ | ||
getGet(), // object-storage buckets object-lock get | ||
getSet(), // object-storage buckets object-lock set | ||
} | ||
}, | ||
) | ||
}) |
Oops, something went wrong.