This repository has been archived by the owner on Aug 5, 2020. It is now read-only.
forked from okta/terraform-provider-okta
/
inline_hooks.go
131 lines (111 loc) · 3.5 KB
/
inline_hooks.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package sdk
import (
"fmt"
"github.com/okta/okta-sdk-golang/okta"
"github.com/okta/okta-sdk-golang/okta/query"
)
type (
InlineHookAuthScheme struct {
Key string `json:"key,omitempty"`
Type string `json:"type,omitempty"`
Value string `json:"value,omitempty"`
}
InlineHookChannel struct {
Config *InlineHookChannelConfig `json:"config"`
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
}
InlineHookChannelConfig struct {
AuthScheme *InlineHookAuthScheme `json:"authScheme,omitempty"`
Headers []*InlineHookHeader `json:"headers,omitempty"`
URI string `json:"uri,omitempty"`
Method string `json:"method,omitempty"`
}
InlineHookHeader struct {
Key string `json:"key,omitempty"`
Value string `json:"value,omitempty"`
}
InlineHook struct {
Channel *InlineHookChannel `json:"channel"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
}
)
func (m *ApiSupplement) ActivateInlineHook(id string) (*okta.Response, error) {
url := fmt.Sprintf("/api/v1/inlineHooks/%s/lifecycle/activate", id)
req, err := m.RequestExecutor.NewRequest("POST", url, nil)
if err != nil {
return nil, err
}
return m.RequestExecutor.Do(req, nil)
}
func (m *ApiSupplement) DeactivateInlineHook(id string) (*okta.Response, error) {
url := fmt.Sprintf("/api/v1/inlineHooks/%s/lifecycle/deactivate", id)
req, err := m.RequestExecutor.NewRequest("POST", url, nil)
if err != nil {
return nil, err
}
return m.RequestExecutor.Do(req, nil)
}
func (m *ApiSupplement) DeleteInlineHook(id string) (*okta.Response, error) {
url := fmt.Sprintf("/api/v1/inlineHooks/%s", id)
req, err := m.RequestExecutor.NewRequest("DELETE", url, nil)
if err != nil {
return nil, err
}
return m.RequestExecutor.Do(req, nil)
}
func (m *ApiSupplement) ListInlineHooks() ([]*InlineHook, *okta.Response, error) {
req, err := m.RequestExecutor.NewRequest("GET", "/api/v1/inlineHooks", nil)
if err != nil {
return nil, nil, err
}
var auth []*InlineHook
resp, err := m.RequestExecutor.Do(req, &auth)
return auth, resp, err
}
func (m *ApiSupplement) CreateInlineHook(body InlineHook, qp *query.Params) (*InlineHook, *okta.Response, error) {
url := "/api/v1/inlineHooks"
if qp != nil {
url += qp.String()
}
req, err := m.RequestExecutor.NewRequest("POST", url, body)
if err != nil {
return nil, nil, err
}
hook := body
resp, err := m.RequestExecutor.Do(req, &hook)
return &hook, resp, err
}
func (m *ApiSupplement) UpdateInlineHook(id string, body InlineHook, qp *query.Params) (*InlineHook, *okta.Response, error) {
url := fmt.Sprintf("/api/v1/inlineHooks/%s", id)
if qp != nil {
url += qp.String()
}
req, err := m.RequestExecutor.NewRequest("PUT", url, body)
if err != nil {
return nil, nil, err
}
hook := body
resp, err := m.RequestExecutor.Do(req, &hook)
if err != nil {
return nil, resp, err
}
return &hook, resp, nil
}
func (m *ApiSupplement) GetInlineHook(id string) (*InlineHook, *okta.Response, error) {
url := fmt.Sprintf("/api/v1/inlineHooks/%s", id)
req, err := m.RequestExecutor.NewRequest("GET", url, nil)
if err != nil {
return nil, nil, err
}
hook := &InlineHook{}
resp, err := m.RequestExecutor.Do(req, &hook)
if err != nil {
return nil, resp, err
}
return hook, resp, nil
}