Skip to content

Commit

Permalink
trash-bin cli has been exteneded by the list and restore commands (#7917
Browse files Browse the repository at this point in the history
)

* trash-bin cli has been exteneded by the list and restore commands

* v4 to v5 changes

---------

Co-authored-by: Roman Perekhod <[email protected]>
  • Loading branch information
2403905 and 2403905 authored Dec 19, 2023
1 parent c3422e6 commit 367f1ff
Show file tree
Hide file tree
Showing 7 changed files with 579 additions and 6 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/add-trach-bin-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Add cli commands for trash-bin

We added the `list` and `restore` commands to the trash-bin items to the CLI

https://github.com/owncloud/ocis/pull/7917
https://github.com/cs3org/reva/pull/4392
https://github.com/owncloud/ocis/issues/7845
2 changes: 1 addition & 1 deletion services/gateway/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type Debug struct {
}

type GRPCConfig struct {
Addr string `yaml:"addr" env:"GATEWAY_GRPC_ADDR" desc:"The bind address of the GRPC service."`
Addr string `yaml:"addr" env:"OCIS_GATEWAY_GRPC_ADDR;GATEWAY_GRPC_ADDR" desc:"The bind address of the GRPC service."`
TLS *shared.GRPCServiceTLS `yaml:"tls"`
Namespace string `yaml:"-"`
Protocol string `yaml:"protocol" env:"GATEWAY_GRPC_PROTOCOL" desc:"The transport protocol of the GRPC service."`
Expand Down
63 changes: 62 additions & 1 deletion services/storage-users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ Cleaned uploads:

<!-- referencing: https://github.com/owncloud/ocis/pull/5500 -->

This command is about purging old trash-bin items of `project` spaces (spaces that have been created manually) and `personal` spaces.
This command is about the trash-bin to get an overview of items, restore items and purging old items of `project` spaces (spaces that have been created manually) and `personal` spaces.

```bash
ocis storage-users trash-bin <command>
```

#### Purge-expired
```plaintext
COMMANDS:
purge-expired Purge all expired items from the trashbin
Expand All @@ -97,6 +98,66 @@ The configuration for the `purge-expired` command is done by using the following

* `STORAGE_USERS_PURGE_TRASH_BIN_PROJECT_DELETE_BEFORE` has a default value of `30 days`, which means the command will delete all files older than `30 days`. The value is human-readable, valid values are `24h`, `60m`, `60s` etc. `0` is equivalent to disable and prevents the deletion of `project space` trash-bin files.

#### List and Restore Trash-Bins Items

To authenticate the cli command use `OCIS_SERVICE_ACCOUNT_SECRET=<acc-secret>` and `OCIS_SERVICE_ACCOUNT_ID=<acc-id>`. The `storage-users` cli tool uses the default address to establish the connection to the `gateway` service. If the connection is failed check your custom `gateway`
service `GATEWAY_GRPC_ADDR` configuration and set the same address to `storage-users` variable `OCIS_GATEWAY_GRPC_ADDR` or `STORAGE_USERS_GATEWAY_GRPC_ADDR`. The variable `STORAGE_USERS_CLI_MAX_ATTEMPTS_RENAME_FILE`
defines a maximum number of attempts to rename a file when the user restores the file with `--option keep-both` to existing destination with the same name.

The ID sources:
- personal 'spaceID' in a `https://{host}/graph/v1.0/me/drives?$filter=driveType+eq+personal`
- project 'spaceID' in a `https://{host}/graph/v1.0/me/drives?$filter=driveType+eq+project`

```bash
NAME:
ocis storage-users trash-bin list - Print a list of all trash-bin items of a space.

USAGE:
ocis storage-users trash-bin list command [command options] ['spaceID' required]

COMMANDS:
help, h Shows a list of commands or help for one command

OPTIONS:
--verbose, -v Get more verbose output (default: false)
--help, -h show help

```

```bash
NAME:
ocis storage-users trash-bin restore-all - Restore all trash-bin items for a space.

USAGE:
ocis storage-users trash-bin restore-all command [command options] ['spaceID' required]

COMMANDS:
help, h Shows a list of commands or help for one command

OPTIONS:
--option value, -o value The restore option defines the behavior for a file to be restored, where the file name already already exists in the target space. Supported values are: 'skip', 'replace' and 'keep-both'. (default: The default value is 'skip' overwriting an existing file)
--verbose, -v Get more verbose output (default: false)
--yes, -y Automatic yes to prompts. Assume 'yes' as answer to all prompts and run non-interactively. (default: false)
--help, -h show help

```
```bash
NAME:
ocis storage-users trash-bin restore - Restore a trash-bin item by ID.

USAGE:
ocis storage-users trash-bin restore command [command options] ['spaceID' required] ['itemID' required]

COMMANDS:
help, h Shows a list of commands or help for one command

OPTIONS:
--option value, -o value The restore option defines the behavior for a file to be restored, where the file name already already exists in the target space. Supported values are: 'skip', 'replace' and 'keep-both'. (default: The default value is 'skip' overwriting an existing file)
--verbose, -v Get more verbose output (default: false)
--help, -h show help
```
## Caching
The `storage-users` service caches stat, metadata and uuids of files and folders via the configured store in `STORAGE_USERS_STAT_CACHE_STORE`, `STORAGE_USERS_FILEMETADATA_CACHE_STORE` and `STORAGE_USERS_ID_CACHE_STORE`. Possible stores are:
Expand Down
Loading

0 comments on commit 367f1ff

Please sign in to comment.