-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathoperational_webhook_endpoint.go
250 lines (233 loc) · 6.56 KB
/
operational_webhook_endpoint.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// Package svix this file is @generated DO NOT EDIT
package svix
import (
"context"
"github.com/svix/svix-webhooks/go/internal"
"github.com/svix/svix-webhooks/go/models"
)
type OperationalWebhookEndpoint struct {
client *internal.SvixHttpClient
}
func newOperationalWebhookEndpoint(client *internal.SvixHttpClient) *OperationalWebhookEndpoint {
return &OperationalWebhookEndpoint{
client: client,
}
}
type OperationalWebhookEndpointListOptions struct {
// Limit the number of returned items
Limit *uint64
// The iterator returned from a prior invocation
Iterator *string
// The sorting order of the returned items
Order *models.Ordering
}
type OperationalWebhookEndpointCreateOptions struct {
IdempotencyKey *string
}
type OperationalWebhookEndpointRotateSecretOptions struct {
IdempotencyKey *string
}
// List operational webhook endpoints.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) List(
ctx context.Context,
o *OperationalWebhookEndpointListOptions,
) (*models.ListResponseOperationalWebhookEndpointOut, error) {
queryMap := map[string]string{}
var err error
if o != nil {
internal.SerializeParamToMap("limit", o.Limit, queryMap, &err)
internal.SerializeParamToMap("iterator", o.Iterator, queryMap, &err)
internal.SerializeParamToMap("order", o.Order, queryMap, &err)
if err != nil {
return nil, err
}
}
return internal.ExecuteRequest[any, models.ListResponseOperationalWebhookEndpointOut](
ctx,
operationalWebhookEndpoint.client,
"GET",
"/api/v1/operational-webhook/endpoint",
nil,
queryMap,
nil,
nil,
)
}
// Create an operational webhook endpoint.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Create(
ctx context.Context,
operationalWebhookEndpointIn models.OperationalWebhookEndpointIn,
o *OperationalWebhookEndpointCreateOptions,
) (*models.OperationalWebhookEndpointOut, error) {
headerMap := map[string]string{}
var err error
if o != nil {
internal.SerializeParamToMap("idempotency-key", o.IdempotencyKey, headerMap, &err)
if err != nil {
return nil, err
}
}
return internal.ExecuteRequest[models.OperationalWebhookEndpointIn, models.OperationalWebhookEndpointOut](
ctx,
operationalWebhookEndpoint.client,
"POST",
"/api/v1/operational-webhook/endpoint",
nil,
nil,
headerMap,
&operationalWebhookEndpointIn,
)
}
// Get an operational webhook endpoint.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Get(
ctx context.Context,
endpointId string,
) (*models.OperationalWebhookEndpointOut, error) {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
return internal.ExecuteRequest[any, models.OperationalWebhookEndpointOut](
ctx,
operationalWebhookEndpoint.client,
"GET",
"/api/v1/operational-webhook/endpoint/{endpoint_id}",
pathMap,
nil,
nil,
nil,
)
}
// Update an operational webhook endpoint.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Update(
ctx context.Context,
endpointId string,
operationalWebhookEndpointUpdate models.OperationalWebhookEndpointUpdate,
) (*models.OperationalWebhookEndpointOut, error) {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
return internal.ExecuteRequest[models.OperationalWebhookEndpointUpdate, models.OperationalWebhookEndpointOut](
ctx,
operationalWebhookEndpoint.client,
"PUT",
"/api/v1/operational-webhook/endpoint/{endpoint_id}",
pathMap,
nil,
nil,
&operationalWebhookEndpointUpdate,
)
}
// Delete an operational webhook endpoint.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Delete(
ctx context.Context,
endpointId string,
) error {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
_, err := internal.ExecuteRequest[any, any](
ctx,
operationalWebhookEndpoint.client,
"DELETE",
"/api/v1/operational-webhook/endpoint/{endpoint_id}",
pathMap,
nil,
nil,
nil,
)
return err
}
// Get the additional headers to be sent with the operational webhook.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) GetHeaders(
ctx context.Context,
endpointId string,
) (*models.OperationalWebhookEndpointHeadersOut, error) {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
return internal.ExecuteRequest[any, models.OperationalWebhookEndpointHeadersOut](
ctx,
operationalWebhookEndpoint.client,
"GET",
"/api/v1/operational-webhook/endpoint/{endpoint_id}/headers",
pathMap,
nil,
nil,
nil,
)
}
// Set the additional headers to be sent with the operational webhook.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) UpdateHeaders(
ctx context.Context,
endpointId string,
operationalWebhookEndpointHeadersIn models.OperationalWebhookEndpointHeadersIn,
) error {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
_, err := internal.ExecuteRequest[models.OperationalWebhookEndpointHeadersIn, any](
ctx,
operationalWebhookEndpoint.client,
"PUT",
"/api/v1/operational-webhook/endpoint/{endpoint_id}/headers",
pathMap,
nil,
nil,
&operationalWebhookEndpointHeadersIn,
)
return err
}
// Get an operational webhook endpoint's signing secret.
//
// This is used to verify the authenticity of the webhook.
// For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) GetSecret(
ctx context.Context,
endpointId string,
) (*models.OperationalWebhookEndpointSecretOut, error) {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
return internal.ExecuteRequest[any, models.OperationalWebhookEndpointSecretOut](
ctx,
operationalWebhookEndpoint.client,
"GET",
"/api/v1/operational-webhook/endpoint/{endpoint_id}/secret",
pathMap,
nil,
nil,
nil,
)
}
// Rotates an operational webhook endpoint's signing secret.
//
// The previous secret will remain valid for the next 24 hours.
func (operationalWebhookEndpoint *OperationalWebhookEndpoint) RotateSecret(
ctx context.Context,
endpointId string,
operationalWebhookEndpointSecretIn models.OperationalWebhookEndpointSecretIn,
o *OperationalWebhookEndpointRotateSecretOptions,
) error {
pathMap := map[string]string{
"endpoint_id": endpointId,
}
headerMap := map[string]string{}
var err error
if o != nil {
internal.SerializeParamToMap("idempotency-key", o.IdempotencyKey, headerMap, &err)
if err != nil {
return err
}
}
_, err = internal.ExecuteRequest[models.OperationalWebhookEndpointSecretIn, any](
ctx,
operationalWebhookEndpoint.client,
"POST",
"/api/v1/operational-webhook/endpoint/{endpoint_id}/secret/rotate",
pathMap,
nil,
headerMap,
&operationalWebhookEndpointSecretIn,
)
return err
}