-
Notifications
You must be signed in to change notification settings - Fork 6
/
folders.go
66 lines (49 loc) · 1.61 KB
/
folders.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
package infisical
import (
api "github.com/infisical/go-sdk/packages/api/folders"
"github.com/infisical/go-sdk/packages/models"
)
type ListFoldersOptions = api.ListFoldersV1Request
type UpdateFolderOptions = api.UpdateFolderV1Request
type CreateFolderOptions = api.CreateFolderV1Request
type DeleteFolderOptions = api.DeleteFolderV1Request
type FoldersInterface interface {
List(options ListFoldersOptions) ([]models.Folder, error)
Update(options UpdateFolderOptions) (models.Folder, error)
Create(options CreateFolderOptions) (models.Folder, error)
Delete(options DeleteFolderOptions) (models.Folder, error)
}
type Folders struct {
client *InfisicalClient
}
func (f *Folders) List(options ListFoldersOptions) ([]models.Folder, error) {
res, err := api.CallListFoldersV1(f.client.httpClient, options)
if err != nil {
return nil, err
}
return res.Folders, nil
}
func (f *Folders) Update(options UpdateFolderOptions) (models.Folder, error) {
res, err := api.CallUpdateFolderV1(f.client.httpClient, options)
if err != nil {
return models.Folder{}, err
}
return res.Folder, nil
}
func (f *Folders) Create(options CreateFolderOptions) (models.Folder, error) {
res, err := api.CallCreateFolderV1(f.client.httpClient, options)
if err != nil {
return models.Folder{}, err
}
return res.Folder, nil
}
func (f *Folders) Delete(options DeleteFolderOptions) (models.Folder, error) {
res, err := api.CallDeleteFolderV1(f.client.httpClient, options)
if err != nil {
return models.Folder{}, err
}
return res.Folder, nil
}
func NewFolders(client *InfisicalClient) FoldersInterface {
return &Folders{client: client}
}