diff --git a/.stats.yml b/.stats.yml index d0e375fdcb3..ae473c1891a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1256 +configured_endpoints: 1259 diff --git a/api.md b/api.md index 36ffe60e7ea..ad583b9c13f 100644 --- a/api.md +++ b/api.md @@ -6814,3 +6814,29 @@ Methods: - client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityDeleteResponseUnion, error) - client.CloudforceOne.Requests.Priority.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.Item, error) - client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.Quota, error) + +# EventNotifications + +## R2 + +### Configuration + +Response Types: + +- event_notifications.R2ConfigurationGetResponse + +Methods: + +- client.EventNotifications.R2.Configuration.Get(ctx context.Context, bucketName string, query event_notifications.R2ConfigurationGetParams) (event_notifications.R2ConfigurationGetResponse, error) + +#### Queues + +Response Types: + +- event_notifications.R2ConfigurationQueueUpdateResponse +- event_notifications.R2ConfigurationQueueDeleteResponseUnion + +Methods: + +- client.EventNotifications.R2.Configuration.Queues.Update(ctx context.Context, bucketName string, queueID string, params event_notifications.R2ConfigurationQueueUpdateParams) (event_notifications.R2ConfigurationQueueUpdateResponse, error) +- client.EventNotifications.R2.Configuration.Queues.Delete(ctx context.Context, bucketName string, queueID string, body event_notifications.R2ConfigurationQueueDeleteParams) (event_notifications.R2ConfigurationQueueDeleteResponseUnion, error) diff --git a/client.go b/client.go index e00f1bb1d84..d3385f9e12d 100644 --- a/client.go +++ b/client.go @@ -32,6 +32,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/dnssec" "github.com/cloudflare/cloudflare-go/v2/durable_objects" "github.com/cloudflare/cloudflare-go/v2/email_routing" + "github.com/cloudflare/cloudflare-go/v2/event_notifications" "github.com/cloudflare/cloudflare-go/v2/filters" "github.com/cloudflare/cloudflare-go/v2/firewall" "github.com/cloudflare/cloudflare-go/v2/healthchecks" @@ -176,6 +177,7 @@ type Client struct { Snippets *snippets.SnippetService Calls *calls.CallService CloudforceOne *cloudforce_one.CloudforceOneService + EventNotifications *event_notifications.EventNotificationService } // NewClient generates a new client with the default option read from the @@ -281,6 +283,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) { r.Snippets = snippets.NewSnippetService(opts...) r.Calls = calls.NewCallService(opts...) r.CloudforceOne = cloudforce_one.NewCloudforceOneService(opts...) + r.EventNotifications = event_notifications.NewEventNotificationService(opts...) return } diff --git a/event_notifications/aliases.go b/event_notifications/aliases.go new file mode 100644 index 00000000000..873cd0b5755 --- /dev/null +++ b/event_notifications/aliases.go @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications + +import ( + "github.com/cloudflare/cloudflare-go/v2/internal/apierror" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" +) + +type Error = apierror.Error + +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + +// This is an alias to an internal type. +type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/event_notifications/eventnotification.go b/event_notifications/eventnotification.go new file mode 100644 index 00000000000..3ca9d36aab4 --- /dev/null +++ b/event_notifications/eventnotification.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications + +import ( + "github.com/cloudflare/cloudflare-go/v2/option" +) + +// EventNotificationService contains methods and other services that help with +// interacting with the cloudflare API. Note, unlike clients, this service does not +// read variables from the environment automatically. You should not instantiate +// this service directly, and instead use the [NewEventNotificationService] method +// instead. +type EventNotificationService struct { + Options []option.RequestOption + R2 *R2Service +} + +// NewEventNotificationService generates a new service that applies the given +// options to each request. These options are applied after the parent client's +// options (if there is one), and before any request-specific options. +func NewEventNotificationService(opts ...option.RequestOption) (r *EventNotificationService) { + r = &EventNotificationService{} + r.Options = opts + r.R2 = NewR2Service(opts...) + return +} diff --git a/event_notifications/r2.go b/event_notifications/r2.go new file mode 100644 index 00000000000..5ef22865c00 --- /dev/null +++ b/event_notifications/r2.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications + +import ( + "github.com/cloudflare/cloudflare-go/v2/option" +) + +// R2Service contains methods and other services that help with interacting with +// the cloudflare API. Note, unlike clients, this service does not read variables +// from the environment automatically. You should not instantiate this service +// directly, and instead use the [NewR2Service] method instead. +type R2Service struct { + Options []option.RequestOption + Configuration *R2ConfigurationService +} + +// NewR2Service generates a new service that applies the given options to each +// request. These options are applied after the parent client's options (if there +// is one), and before any request-specific options. +func NewR2Service(opts ...option.RequestOption) (r *R2Service) { + r = &R2Service{} + r.Options = opts + r.Configuration = NewR2ConfigurationService(opts...) + return +} diff --git a/event_notifications/r2configuration.go b/event_notifications/r2configuration.go new file mode 100644 index 00000000000..23c06736f8c --- /dev/null +++ b/event_notifications/r2configuration.go @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" + "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" + "github.com/cloudflare/cloudflare-go/v2/option" +) + +// R2ConfigurationService contains methods and other services that help with +// interacting with the cloudflare API. Note, unlike clients, this service does not +// read variables from the environment automatically. You should not instantiate +// this service directly, and instead use the [NewR2ConfigurationService] method +// instead. +type R2ConfigurationService struct { + Options []option.RequestOption + Queues *R2ConfigurationQueueService +} + +// NewR2ConfigurationService generates a new service that applies the given options +// to each request. These options are applied after the parent client's options (if +// there is one), and before any request-specific options. +func NewR2ConfigurationService(opts ...option.RequestOption) (r *R2ConfigurationService) { + r = &R2ConfigurationService{} + r.Options = opts + r.Queues = NewR2ConfigurationQueueService(opts...) + return +} + +// Returns all notification rules for each queue for which bucket notifications are +// produced. +func (r *R2ConfigurationService) Get(ctx context.Context, bucketName string, query R2ConfigurationGetParams, opts ...option.RequestOption) (res *R2ConfigurationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env R2ConfigurationGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/event_notifications/r2/%s/configuration", query.AccountID, bucketName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type R2ConfigurationGetResponse map[string]map[string]R2ConfigurationGetResponse + +type R2ConfigurationGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type R2ConfigurationGetResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result R2ConfigurationGetResponse `json:"result,required"` + // Whether the API call was successful + Success R2ConfigurationGetResponseEnvelopeSuccess `json:"success,required"` + JSON r2ConfigurationGetResponseEnvelopeJSON `json:"-"` +} + +// r2ConfigurationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [R2ConfigurationGetResponseEnvelope] +type r2ConfigurationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2ConfigurationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2ConfigurationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type R2ConfigurationGetResponseEnvelopeSuccess bool + +const ( + R2ConfigurationGetResponseEnvelopeSuccessTrue R2ConfigurationGetResponseEnvelopeSuccess = true +) + +func (r R2ConfigurationGetResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case R2ConfigurationGetResponseEnvelopeSuccessTrue: + return true + } + return false +} diff --git a/event_notifications/r2configuration_test.go b/event_notifications/r2configuration_test.go new file mode 100644 index 00000000000..b8893110b45 --- /dev/null +++ b/event_notifications/r2configuration_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go/v2" + "github.com/cloudflare/cloudflare-go/v2/event_notifications" + "github.com/cloudflare/cloudflare-go/v2/internal/testutil" + "github.com/cloudflare/cloudflare-go/v2/option" +) + +func TestR2ConfigurationGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + _, err := client.EventNotifications.R2.Configuration.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + event_notifications.R2ConfigurationGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/event_notifications/r2configurationqueue.go b/event_notifications/r2configurationqueue.go new file mode 100644 index 00000000000..f1d4c6f5adb --- /dev/null +++ b/event_notifications/r2configurationqueue.go @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" + "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" + "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" +) + +// R2ConfigurationQueueService contains methods and other services that help with +// interacting with the cloudflare API. Note, unlike clients, this service does not +// read variables from the environment automatically. You should not instantiate +// this service directly, and instead use the [NewR2ConfigurationQueueService] +// method instead. +type R2ConfigurationQueueService struct { + Options []option.RequestOption +} + +// NewR2ConfigurationQueueService generates a new service that applies the given +// options to each request. These options are applied after the parent client's +// options (if there is one), and before any request-specific options. +func NewR2ConfigurationQueueService(opts ...option.RequestOption) (r *R2ConfigurationQueueService) { + r = &R2ConfigurationQueueService{} + r.Options = opts + return +} + +// Define the rules for a given queue which will determine event notification +// production. +func (r *R2ConfigurationQueueService) Update(ctx context.Context, bucketName string, queueID string, params R2ConfigurationQueueUpdateParams, opts ...option.RequestOption) (res *R2ConfigurationQueueUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env R2ConfigurationQueueUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/event_notifications/r2/%s/configuration/queues/%s", params.AccountID, bucketName, queueID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Turn off all event notifications configured for delivery to a given queue. No +// further notifications will be produced for the queue once complete. +func (r *R2ConfigurationQueueService) Delete(ctx context.Context, bucketName string, queueID string, body R2ConfigurationQueueDeleteParams, opts ...option.RequestOption) (res *R2ConfigurationQueueDeleteResponseUnion, err error) { + opts = append(r.Options[:], opts...) + var env R2ConfigurationQueueDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/event_notifications/r2/%s/configuration/queues/%s", body.AccountID, bucketName, queueID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type R2ConfigurationQueueUpdateResponse struct { + EventNotificationDetailID string `json:"event_notification_detail_id"` + JSON r2ConfigurationQueueUpdateResponseJSON `json:"-"` +} + +// r2ConfigurationQueueUpdateResponseJSON contains the JSON metadata for the struct +// [R2ConfigurationQueueUpdateResponse] +type r2ConfigurationQueueUpdateResponseJSON struct { + EventNotificationDetailID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2ConfigurationQueueUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2ConfigurationQueueUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by +// [event_notifications.R2ConfigurationQueueDeleteResponseUnknown], +// [event_notifications.R2ConfigurationQueueDeleteResponseArray] or +// [shared.UnionString]. +type R2ConfigurationQueueDeleteResponseUnion interface { + ImplementsEventNotificationsR2ConfigurationQueueDeleteResponseUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*R2ConfigurationQueueDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(R2ConfigurationQueueDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type R2ConfigurationQueueDeleteResponseArray []interface{} + +func (r R2ConfigurationQueueDeleteResponseArray) ImplementsEventNotificationsR2ConfigurationQueueDeleteResponseUnion() { +} + +type R2ConfigurationQueueUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Array of rules to drive notifications + Rules param.Field[[]R2ConfigurationQueueUpdateParamsRule] `json:"rules"` +} + +func (r R2ConfigurationQueueUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type R2ConfigurationQueueUpdateParamsRule struct { + // Array of R2 object actions that will trigger notifications + Actions param.Field[[]R2ConfigurationQueueUpdateParamsRulesAction] `json:"actions,required"` + // Notifications will be sent only for objects with this prefix + Prefix param.Field[string] `json:"prefix"` + // Notifications will be sent only for objects with this suffix + Suffix param.Field[string] `json:"suffix"` +} + +func (r R2ConfigurationQueueUpdateParamsRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type R2ConfigurationQueueUpdateParamsRulesAction string + +const ( + R2ConfigurationQueueUpdateParamsRulesActionPutObject R2ConfigurationQueueUpdateParamsRulesAction = "PutObject" + R2ConfigurationQueueUpdateParamsRulesActionCopyObject R2ConfigurationQueueUpdateParamsRulesAction = "CopyObject" + R2ConfigurationQueueUpdateParamsRulesActionDeleteObject R2ConfigurationQueueUpdateParamsRulesAction = "DeleteObject" + R2ConfigurationQueueUpdateParamsRulesActionCompleteMultipartUpload R2ConfigurationQueueUpdateParamsRulesAction = "CompleteMultipartUpload" + R2ConfigurationQueueUpdateParamsRulesActionAbortMultipartUpload R2ConfigurationQueueUpdateParamsRulesAction = "AbortMultipartUpload" +) + +func (r R2ConfigurationQueueUpdateParamsRulesAction) IsKnown() bool { + switch r { + case R2ConfigurationQueueUpdateParamsRulesActionPutObject, R2ConfigurationQueueUpdateParamsRulesActionCopyObject, R2ConfigurationQueueUpdateParamsRulesActionDeleteObject, R2ConfigurationQueueUpdateParamsRulesActionCompleteMultipartUpload, R2ConfigurationQueueUpdateParamsRulesActionAbortMultipartUpload: + return true + } + return false +} + +type R2ConfigurationQueueUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result R2ConfigurationQueueUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success R2ConfigurationQueueUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON r2ConfigurationQueueUpdateResponseEnvelopeJSON `json:"-"` +} + +// r2ConfigurationQueueUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [R2ConfigurationQueueUpdateResponseEnvelope] +type r2ConfigurationQueueUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2ConfigurationQueueUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2ConfigurationQueueUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type R2ConfigurationQueueUpdateResponseEnvelopeSuccess bool + +const ( + R2ConfigurationQueueUpdateResponseEnvelopeSuccessTrue R2ConfigurationQueueUpdateResponseEnvelopeSuccess = true +) + +func (r R2ConfigurationQueueUpdateResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case R2ConfigurationQueueUpdateResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type R2ConfigurationQueueDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type R2ConfigurationQueueDeleteResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result R2ConfigurationQueueDeleteResponseUnion `json:"result,required"` + // Whether the API call was successful + Success R2ConfigurationQueueDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON r2ConfigurationQueueDeleteResponseEnvelopeJSON `json:"-"` +} + +// r2ConfigurationQueueDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [R2ConfigurationQueueDeleteResponseEnvelope] +type r2ConfigurationQueueDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2ConfigurationQueueDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2ConfigurationQueueDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type R2ConfigurationQueueDeleteResponseEnvelopeSuccess bool + +const ( + R2ConfigurationQueueDeleteResponseEnvelopeSuccessTrue R2ConfigurationQueueDeleteResponseEnvelopeSuccess = true +) + +func (r R2ConfigurationQueueDeleteResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case R2ConfigurationQueueDeleteResponseEnvelopeSuccessTrue: + return true + } + return false +} diff --git a/event_notifications/r2configurationqueue_test.go b/event_notifications/r2configurationqueue_test.go new file mode 100644 index 00000000000..5186b21985c --- /dev/null +++ b/event_notifications/r2configurationqueue_test.go @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package event_notifications_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go/v2" + "github.com/cloudflare/cloudflare-go/v2/event_notifications" + "github.com/cloudflare/cloudflare-go/v2/internal/testutil" + "github.com/cloudflare/cloudflare-go/v2/option" +) + +func TestR2ConfigurationQueueUpdateWithOptionalParams(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + _, err := client.EventNotifications.R2.Configuration.Queues.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + event_notifications.R2ConfigurationQueueUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Rules: cloudflare.F([]event_notifications.R2ConfigurationQueueUpdateParamsRule{{ + Actions: cloudflare.F([]event_notifications.R2ConfigurationQueueUpdateParamsRulesAction{event_notifications.R2ConfigurationQueueUpdateParamsRulesActionPutObject, event_notifications.R2ConfigurationQueueUpdateParamsRulesActionCopyObject}), + Prefix: cloudflare.F("img/"), + Suffix: cloudflare.F(".jpeg"), + }, { + Actions: cloudflare.F([]event_notifications.R2ConfigurationQueueUpdateParamsRulesAction{event_notifications.R2ConfigurationQueueUpdateParamsRulesActionPutObject, event_notifications.R2ConfigurationQueueUpdateParamsRulesActionCopyObject}), + Prefix: cloudflare.F("img/"), + Suffix: cloudflare.F(".jpeg"), + }, { + Actions: cloudflare.F([]event_notifications.R2ConfigurationQueueUpdateParamsRulesAction{event_notifications.R2ConfigurationQueueUpdateParamsRulesActionPutObject, event_notifications.R2ConfigurationQueueUpdateParamsRulesActionCopyObject}), + Prefix: cloudflare.F("img/"), + Suffix: cloudflare.F(".jpeg"), + }}), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestR2ConfigurationQueueDelete(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + _, err := client.EventNotifications.R2.Configuration.Queues.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + event_notifications.R2ConfigurationQueueDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/internal/shared/union.go b/internal/shared/union.go index 3ce4c02ece4..36dc904895c 100644 --- a/internal/shared/union.go +++ b/internal/shared/union.go @@ -178,12 +178,13 @@ func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncrypt } func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponseUnion() { } -func (UnionString) ImplementsHostnamesSettingValueUnionParam() {} -func (UnionString) ImplementsHostnamesSettingValueUnion() {} -func (UnionString) ImplementsSnippetsSnippetDeleteResponseUnion() {} -func (UnionString) ImplementsCloudforceOneRequestDeleteResponseUnion() {} -func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponseUnion() {} -func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() {} +func (UnionString) ImplementsHostnamesSettingValueUnionParam() {} +func (UnionString) ImplementsHostnamesSettingValueUnion() {} +func (UnionString) ImplementsSnippetsSnippetDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() {} +func (UnionString) ImplementsEventNotificationsR2ConfigurationQueueDeleteResponseUnion() {} type UnionInt int64