forked from 1Password/onepassword-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecrets.go
41 lines (34 loc) · 1.15 KB
/
secrets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Code generated by op-codegen - DO NOT EDIT
package onepassword
import (
"context"
"encoding/json"
"github.com/1password/onepassword-sdk-go/internal"
)
// The Secrets API includes all operations the SDK client can perform on secrets.
// Use secret reference URIs to securely load secrets from 1Password: op://<vault-name>/<item-name>[/<section-name>]/<field-name>
type SecretsAPI interface {
// Resolve returns the secret the provided secret reference points to.
Resolve(ctx context.Context, secretReference string) (string, error)
}
type SecretsSource struct {
internal.InnerClient
}
func NewSecretsSource(inner internal.InnerClient) *SecretsSource {
return &SecretsSource{inner}
}
// Resolve returns the secret the provided secret reference points to.
func (s SecretsSource) Resolve(ctx context.Context, secretReference string) (string, error) {
resultString, err := clientInvoke(ctx, s.InnerClient, "SecretsResolve", map[string]interface{}{
"secret_reference": secretReference,
})
if err != nil {
return "", err
}
var result string
err = json.Unmarshal([]byte(*resultString), &result)
if err != nil {
return "", err
}
return result, nil
}