mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 23:09:08 +00:00
feat(resource): add expiry support (--expired, --clear-expired)
This commit is contained in:
parent
43cc96a43d
commit
072ae89378
3 changed files with 69 additions and 0 deletions
29
resource/expiry.go
Normal file
29
resource/expiry.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package resource
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/passbolt/go-passbolt/api"
|
||||
)
|
||||
|
||||
// SetResourceExpiry updates only the expiry date of a resource.
|
||||
func SetResourceExpiry(ctx context.Context, client *api.Client, id string, expired string) error {
|
||||
if expired == "" {
|
||||
return nil
|
||||
}
|
||||
_, _, err := client.DoCustomRequestAndReturnRawResponse(
|
||||
ctx,
|
||||
"PUT",
|
||||
fmt.Sprintf("resources/%s.json", id),
|
||||
"v2",
|
||||
map[string]string{"expired": expired},
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Setting expiry: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue