feat(resource): add expiry support (--expired, --clear-expired)

This commit is contained in:
Enbiya 2025-08-19 12:13:09 +03:00
parent 43cc96a43d
commit 072ae89378
No known key found for this signature in database
GPG key ID: 59B22A6690E7A29C
3 changed files with 69 additions and 0 deletions

29
resource/expiry.go Normal file
View 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
}