Skip to content

Commit d6528f7

Browse files
committed
go: Add Environment resource
1 parent 9ade1c3 commit d6528f7

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

codegen.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ output_dir = "java/lib/src/main/java/com/svix/models"
124124
[go]
125125
template_dir = "openapi-templates/go"
126126
extra_shell_commands = [
127-
"rm go/{environment,health,ingest_endpoint,ingest,ingest_source}.go",
127+
"rm go/{health,ingest_endpoint,ingest,ingest_source}.go",
128128
]
129129
[[go.task]]
130130
template = "openapi-templates/go/api_resource.go.jinja"

go/environment.go

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Package svix this file is @generated DO NOT EDIT
2+
package svix
3+
4+
import (
5+
"context"
6+
7+
"github.com/svix/svix-webhooks/go/models"
8+
)
9+
10+
type Environment struct {
11+
client *SvixHttpClient
12+
}
13+
14+
func newEnvironment(client *SvixHttpClient) *Environment {
15+
return &Environment{
16+
client: client,
17+
}
18+
}
19+
20+
type EnvironmentExportOptions struct {
21+
IdempotencyKey *string
22+
}
23+
24+
type EnvironmentImportOptions struct {
25+
IdempotencyKey *string
26+
}
27+
28+
// Download a JSON file containing all org-settings and event types.
29+
func (environment *Environment) Export(
30+
ctx context.Context,
31+
o *EnvironmentExportOptions,
32+
) (*models.EnvironmentOut, error) {
33+
headerMap := map[string]string{}
34+
var err error
35+
if o != nil {
36+
serializeParamToMap("idempotency-key", o.IdempotencyKey, headerMap, &err)
37+
if err != nil {
38+
return nil, err
39+
}
40+
}
41+
return executeRequest[any, models.EnvironmentOut](
42+
ctx,
43+
environment.client,
44+
"POST",
45+
"/api/v1/environment/export",
46+
nil,
47+
nil,
48+
headerMap,
49+
nil,
50+
)
51+
}
52+
53+
// Import a configuration into the active organization.
54+
//
55+
// It doesn't delete anything, only adds / updates what was passed to it.
56+
func (environment *Environment) Import(
57+
ctx context.Context,
58+
environmentIn models.EnvironmentIn,
59+
o *EnvironmentImportOptions,
60+
) error {
61+
headerMap := map[string]string{}
62+
var err error
63+
if o != nil {
64+
serializeParamToMap("idempotency-key", o.IdempotencyKey, headerMap, &err)
65+
if err != nil {
66+
return err
67+
}
68+
}
69+
_, err = executeRequest[models.EnvironmentIn, any](
70+
ctx,
71+
environment.client,
72+
"POST",
73+
"/api/v1/environment/import",
74+
nil,
75+
nil,
76+
headerMap,
77+
&environmentIn,
78+
)
79+
return err
80+
}

go/svix.go

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type (
1919
Authentication *Authentication
2020
Application *Application
2121
Endpoint *Endpoint
22+
Environment *Environment
2223
EventType *EventType
2324
Integration *Integration
2425
Message *Message
@@ -57,6 +58,7 @@ func New(token string, options *SvixOptions) (*Svix, error) {
5758
Authentication: newAuthentication(&svixHttpClient),
5859
Application: newApplication(&svixHttpClient),
5960
Endpoint: newEndpoint(&svixHttpClient),
61+
Environment: newEnvironment(&svixHttpClient),
6062
EventType: newEventType(&svixHttpClient),
6163
Message: newMessage(&svixHttpClient),
6264
Integration: newIntegration(&svixHttpClient),

0 commit comments

Comments
 (0)