mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-09 09:48:20 +00:00
37 lines
1,017 B
Go
37 lines
1,017 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
)
|
|
|
|
// Secret is a Secret
|
|
type Secret struct {
|
|
ID string `json:"id,omitempty"`
|
|
UserID string `json:"user_id,omitempty"`
|
|
ResourceID string `json:"resource_id,omitempty"`
|
|
Data string `json:"data,omitempty"`
|
|
Created *Time `json:"created,omitempty"`
|
|
Modified *Time `json:"modified,omitempty"`
|
|
}
|
|
|
|
// SecretDataTypePasswordAndDescription is the format a secret of resource type "password-and-description" is stored in
|
|
type SecretDataTypePasswordAndDescription struct {
|
|
Password string `json:"password"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
// GetSecret gets a Passbolt Secret
|
|
func (c *Client) GetSecret(ctx context.Context, resourceID string) (*Secret, error) {
|
|
msg, err := c.DoCustomRequest(ctx, "GET", "/secrets/resource/"+resourceID+".json", "v2", nil, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var secret Secret
|
|
err = json.Unmarshal(msg.Body, &secret)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &secret, nil
|
|
}
|