Skip to content

Commit 7882eee

Browse files
committed
go: Add operational webhook endpoint API
1 parent 0238111 commit 7882eee

File tree

2 files changed

+133
-8
lines changed

2 files changed

+133
-8
lines changed

go/operational_webhook_endpoint.go

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package svix
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
"github.com/svix/svix-webhooks/go/internal/openapi"
8+
)
9+
10+
type (
11+
ListResponseOperationalWebhookEndpointOut = openapi.ListResponseOperationalWebhookEndpointOut
12+
OperationalWebhookEndpointIn = openapi.OperationalWebhookEndpointIn
13+
OperationalWebhookEndpointUpdate = openapi.OperationalWebhookEndpointUpdate
14+
OperationalWebhookEndpointOut = openapi.OperationalWebhookEndpointOut
15+
OperationalWebhookEndpointPatch = openapi.OperationalWebhookEndpointPatch
16+
OperationalWebhookEndpointSecretOut = openapi.OperationalWebhookEndpointSecretOut
17+
OperationalWebhookEndpointSecretIn = openapi.OperationalWebhookEndpointSecretIn
18+
Ordering = openapi.Ordering
19+
)
20+
21+
type OperationalWebhookEndpoint struct {
22+
api *openapi.APIClient
23+
}
24+
25+
type OperationalWebhookEndpointListOptions struct {
26+
Iterator *string
27+
Limit *int32
28+
Order *Ordering
29+
}
30+
31+
func (e *OperationalWebhookEndpoint) List(ctx context.Context, options *OperationalWebhookEndpointListOptions) (*ListResponseOperationalWebhookEndpointOut, error) {
32+
req := e.api.OperationalWebhookEndpointAPI.listOperationalWebhookEndpoint(ctx)
33+
if options != nil {
34+
if options.Iterator != nil {
35+
req = req.Iterator(*options.Iterator)
36+
}
37+
if options.Limit != nil {
38+
req = req.Limit(*options.Limit)
39+
}
40+
if options.Order != nil {
41+
req = req.Order(*options.Order)
42+
}
43+
}
44+
ret, res, err := req.Execute()
45+
if err != nil {
46+
return nil, wrapError(err, res)
47+
}
48+
return ret, nil
49+
}
50+
51+
func (e *OperationalWebhookEndpoint) Create(ctx context.Context, endpointIn *OperationalWebhookEndpointIn) (*OperationalWebhookEndpointOut, error) {
52+
return e.CreateWithOptions(ctx, endpointIn, nil)
53+
}
54+
55+
func (e *OperationalWebhookEndpoint) CreateWithOptions(ctx context.Context, endpointIn *OperationalWebhookEndpointIn, options *PostOptions) (*OperationalWebhookEndpointOut, error) {
56+
req := e.api.OperationalWebhookEndpointAPI.createOperationalWebhookEndpoint(ctx)
57+
req = req.OperationalWebhookEndpointIn(*endpointIn)
58+
if options != nil {
59+
if options.IdempotencyKey != nil {
60+
req = req.IdempotencyKey(*options.IdempotencyKey)
61+
}
62+
}
63+
ret, res, err := req.Execute()
64+
if err != nil {
65+
return nil, wrapError(err, res)
66+
}
67+
return ret, nil
68+
}
69+
70+
func (e *OperationalWebhookEndpoint) Get(ctx context.Context, endpointId string) (*OperationalWebhookEndpointOut, error) {
71+
req := e.api.OperationalWebhookEndpointAPI.getOperationalWebhookEndpoint(ctx, endpointId)
72+
ret, res, err := req.Execute()
73+
if err != nil {
74+
return nil, wrapError(err, res)
75+
}
76+
return ret, nil
77+
}
78+
79+
func (e *OperationalWebhookEndpoint) Update(ctx context.Context, endpointId string, endpointUpdate *OperationalWebhookEndpointUpdate) (*OperationalWebhookEndpointOut, error) {
80+
req := e.api.OperationalWebhookEndpointAPI.updateOperationalWebhookEndpoint(ctx, endpointId)
81+
req = req.OperationalWebhookEndpointUpdate(*endpointUpdate)
82+
ret, res, err := req.Execute()
83+
if err != nil {
84+
return nil, wrapError(err, res)
85+
}
86+
return ret, nil
87+
}
88+
89+
func (e *OperationalWebhookEndpoint) Delete(ctx context.Context, endpointId string) error {
90+
req := e.api.OperationalWebhookEndpointAPI.V1OperationalWebhookEndpointDelete(ctx, endpointId)
91+
res, err := req.Execute()
92+
return wrapError(err, res)
93+
}
94+
95+
func (e *OperationalWebhookEndpoint) GetSecret(ctx context.Context, endpointId string) (*OperationalWebhookEndpointSecretOut, error) {
96+
req := e.api.OperationalWebhookEndpointAPI.getOperationalWebhookEndpointSecret(ctx, endpointId)
97+
ret, res, err := req.Execute()
98+
if err != nil {
99+
return nil, wrapError(err, res)
100+
}
101+
return ret, nil
102+
}
103+
104+
func (e *OperationalWebhookEndpoint) RotateSecret(ctx context.Context, endpointId string, endpointSecretRotateIn *OperationalWebhookEndpointSecretIn) error {
105+
return e.RotateSecretWithOptions(ctx, endpointId, endpointSecretRotateIn, nil)
106+
}
107+
108+
func (e *OperationalWebhookEndpoint) RotateSecretWithOptions(ctx context.Context, endpointId string, endpointSecretRotateIn *OperationalWebhookEndpointSecretIn, options *PostOptions) error {
109+
req := e.api.OperationalWebhookEndpointAPI.rotateOperationalWebhookEndpointSecret(ctx, endpointId)
110+
req = req.OperationalWebhookEndpointSecretIn(*endpointSecretRotateIn)
111+
if options != nil {
112+
if options.IdempotencyKey != nil {
113+
req = req.IdempotencyKey(*options.IdempotencyKey)
114+
}
115+
}
116+
res, err := req.Execute()
117+
if err != nil {
118+
return wrapError(err, res)
119+
}
120+
return nil
121+
}

go/svix.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ type (
2020
HTTPClient *http.Client
2121
}
2222
Svix struct {
23-
Authentication *Authentication
24-
Application *Application
25-
Endpoint *Endpoint
26-
EventType *EventType
27-
Integration *Integration
28-
Message *Message
29-
MessageAttempt *MessageAttempt
30-
Statistics *Statistics
23+
Authentication *Authentication
24+
Application *Application
25+
Endpoint *Endpoint
26+
EventType *EventType
27+
Integration *Integration
28+
Message *Message
29+
MessageAttempt *MessageAttempt
30+
Statistics *Statistics
31+
OperationalWebhookEndpoint *OperationalWebhookEndpoint
3132
}
3233
)
3334

@@ -108,5 +109,8 @@ func New(token string, options *SvixOptions) *Svix {
108109
Statistics: &Statistics{
109110
api: apiClient,
110111
},
112+
OperationalWebhookEndpoint: &OperationalWebhookEndpoint{
113+
api: apiClient,
114+
},
111115
}
112116
}

0 commit comments

Comments
 (0)