forked from 1Password/onepassword-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems_shares.go
70 lines (62 loc) · 1.93 KB
/
items_shares.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Code generated by op-codegen - DO NOT EDIT
package onepassword
import (
"context"
"encoding/json"
"github.com/1password/onepassword-sdk-go/internal"
)
type ItemsSharesSource struct {
innerClient internal.InnerClient
}
func NewItemsSharesSource(inner internal.InnerClient) *ItemsSharesSource {
return &ItemsSharesSource{innerClient: inner}
}
// Get the item sharing policy of your account.
func (i ItemsSharesSource) GetAccountPolicy(ctx context.Context, vaultID string, itemID string) (ItemShareAccountPolicy, error) {
resultString, err := clientInvoke(ctx, i.innerClient, "ItemsSharesGetAccountPolicy", map[string]interface{}{
"vault_id": vaultID,
"item_id": itemID,
})
if err != nil {
return ItemShareAccountPolicy{}, err
}
var result ItemShareAccountPolicy
err = json.Unmarshal([]byte(*resultString), &result)
if err != nil {
return ItemShareAccountPolicy{}, err
}
return result, nil
}
// Validate the recipients of an item sharing link.
func (i ItemsSharesSource) ValidateRecipients(ctx context.Context, policy ItemShareAccountPolicy, recipients []string) ([]ValidRecipient, error) {
resultString, err := clientInvoke(ctx, i.innerClient, "ItemsSharesValidateRecipients", map[string]interface{}{
"policy": policy,
"recipients": recipients,
})
if err != nil {
return nil, err
}
var result []ValidRecipient
err = json.Unmarshal([]byte(*resultString), &result)
if err != nil {
return nil, err
}
return result, nil
}
// Create a new item sharing link.
func (i ItemsSharesSource) Create(ctx context.Context, item Item, policy ItemShareAccountPolicy, params ItemShareParams) (string, error) {
resultString, err := clientInvoke(ctx, i.innerClient, "ItemsSharesCreate", map[string]interface{}{
"item": item,
"policy": policy,
"params": params,
})
if err != nil {
return "", err
}
var result string
err = json.Unmarshal([]byte(*resultString), &result)
if err != nil {
return "", err
}
return result, nil
}