|
| 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 | +} |
0 commit comments