Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 7, 2024
1 parent 69b2516 commit 70fd793
Show file tree
Hide file tree
Showing 28 changed files with 231 additions and 540 deletions.
28 changes: 0 additions & 28 deletions addressing/prefixbgpbinding.go
Expand Up @@ -179,34 +179,6 @@ func (r ServiceBindingProvisioningState) IsKnown() bool {
return false
}

type ServiceBindingParam struct {
// IP Prefix in Classless Inter-Domain Routing format.
CIDR param.Field[string] `json:"cidr"`
// Status of a Service Binding's deployment to the Cloudflare network
Provisioning param.Field[ServiceBindingProvisioningParam] `json:"provisioning"`
// Identifier
ServiceID param.Field[string] `json:"service_id"`
// Name of a service running on the Cloudflare network
ServiceName param.Field[string] `json:"service_name"`
}

func (r ServiceBindingParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

func (r ServiceBindingParam) implementsWorkersBindingUnionParam() {}

// Status of a Service Binding's deployment to the Cloudflare network
type ServiceBindingProvisioningParam struct {
// When a binding has been deployed to a majority of Cloudflare datacenters, the
// binding will become active and can be used with its associated service.
State param.Field[ServiceBindingProvisioningState] `json:"state"`
}

func (r ServiceBindingProvisioningParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type PrefixBGPBindingDeleteResponse struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Expand Down
87 changes: 61 additions & 26 deletions alerting/policy.go
Expand Up @@ -110,9 +110,68 @@ func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGe
return
}

type Mechanism map[string][]Mechanism
type Mechanism map[string][]MechanismItem

type MechanismParam map[string][]MechanismParam
type MechanismItem struct {
// UUID
ID MechanismItemIDUnion `json:"id"`
JSON mechanismItemJSON `json:"-"`
}

// mechanismItemJSON contains the JSON metadata for the struct [MechanismItem]
type mechanismItemJSON struct {
ID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *MechanismItem) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r mechanismItemJSON) RawJSON() string {
return r.raw
}

// UUID
//
// Union satisfied by [shared.UnionString] or [shared.UnionString].
type MechanismItemIDUnion interface {
ImplementsAlertingMechanismItemIDUnion()
}

func init() {
apijson.RegisterUnion(
reflect.TypeOf((*MechanismItemIDUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
)
}

type MechanismParam map[string][]MechanismItemParam

type MechanismItemParam struct {
// UUID
ID param.Field[MechanismItemIDUnionParam] `json:"id"`
}

func (r MechanismItemParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// UUID
//
// Satisfied by [shared.UnionString], [shared.UnionString].
type MechanismItemIDUnionParam interface {
ImplementsAlertingMechanismItemIDUnionParam()
}

type Policy struct {
// The unique identifier of a notification policy
Expand Down Expand Up @@ -233,30 +292,6 @@ func (r PolicyAlertType) IsKnown() bool {
return false
}

type PolicyParam struct {
// Refers to which event will trigger a Notification dispatch. You can use the
// endpoint to get available alert types which then will give you a list of
// possible values.
AlertType param.Field[PolicyAlertType] `json:"alert_type"`
// Optional description for the Notification policy.
Description param.Field[string] `json:"description"`
// Whether or not the Notification policy is enabled.
Enabled param.Field[bool] `json:"enabled"`
// Optional filters that allow you to be alerted only on a subset of events for
// that alert type based on some criteria. This is only available for select alert
// types. See alert type documentation for more details.
Filters param.Field[PolicyFilterParam] `json:"filters"`
// List of IDs that will be used when dispatching a notification. IDs for email
// type will be the email address.
Mechanisms param.Field[MechanismParam] `json:"mechanisms"`
// Name of the policy.
Name param.Field[string] `json:"name"`
}

func (r PolicyParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Optional filters that allow you to be alerted only on a subset of events for
// that alert type based on some criteria. This is only available for select alert
// types. See alert type documentation for more details.
Expand Down
24 changes: 12 additions & 12 deletions alerting/policy_test.go
Expand Up @@ -34,14 +34,14 @@ func TestPolicyNewWithOptionalParams(t *testing.T) {
AlertType: cloudflare.F(alerting.PolicyNewParamsAlertTypeUniversalSSLEventType),
Enabled: cloudflare.F(true),
Mechanisms: cloudflare.F(alerting.MechanismParam{
"email": []alerting.MechanismParam{{
ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("test@example.com")),
"email": []alerting.MechanismItemParam{{
ID: cloudflare.F[alerting.MechanismItemIDUnionParam](shared.UnionString("test@example.com")),
}},
"pagerduty": []alerting.MechanismParam{{
ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")),
"pagerduty": []alerting.MechanismItemParam{{
ID: cloudflare.F[alerting.MechanismItemIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")),
}},
"webhooks": []alerting.MechanismParam{{
ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")),
"webhooks": []alerting.MechanismItemParam{{
ID: cloudflare.F[alerting.MechanismItemIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")),
}},
}),
Name: cloudflare.F("SSL Notification Event Policy"),
Expand Down Expand Up @@ -163,14 +163,14 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) {
Zones: cloudflare.F([]string{"string", "string", "string"}),
}),
Mechanisms: cloudflare.F(alerting.MechanismParam{
"email": []alerting.MechanismParam{{
ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("test@example.com")),
"email": []alerting.MechanismItemParam{{
ID: cloudflare.F[alerting.MechanismItemIDUnionParam](shared.UnionString("test@example.com")),
}},
"pagerduty": []alerting.MechanismParam{{
ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")),
"pagerduty": []alerting.MechanismItemParam{{
ID: cloudflare.F[alerting.MechanismItemIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")),
}},
"webhooks": []alerting.MechanismParam{{
ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")),
"webhooks": []alerting.MechanismItemParam{{
ID: cloudflare.F[alerting.MechanismItemIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")),
}},
}),
Name: cloudflare.F("SSL Notification Event Policy"),
Expand Down
51 changes: 0 additions & 51 deletions api.md
Expand Up @@ -210,7 +210,6 @@ Params Types:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user">user</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user#Policy">Policy</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user">user</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user#TokenNewResponse">TokenNewResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user">user</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user#TokenUpdateResponseUnion">TokenUpdateResponseUnion</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user">user</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/user#TokenListResponse">TokenListResponse</a>
Expand Down Expand Up @@ -1311,10 +1310,6 @@ Methods:

# RatePlans

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_plans">rate_plans</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_plans#RatePlanParam">RatePlanParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_plans">rate_plans</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_plans#RatePlan">RatePlan</a>
Expand Down Expand Up @@ -1688,10 +1683,6 @@ Methods:

## Lockdowns

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/firewall">firewall</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/firewall#ConfigurationUnionParam">ConfigurationUnionParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/firewall">firewall</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/firewall#Configuration">Configuration</a>
Expand Down Expand Up @@ -2063,7 +2054,6 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth">origin_tls_client_auth</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth#Certificate">Certificate</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth">origin_tls_client_auth</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth#HostnameCertificateNewResponse">HostnameCertificateNewResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth">origin_tls_client_auth</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth#HostnameCertificateDeleteResponse">HostnameCertificateDeleteResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth">origin_tls_client_auth</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/origin_tls_client_auth#HostnameCertificateGetResponse">HostnameCertificateGetResponse</a>
Expand Down Expand Up @@ -2126,10 +2116,6 @@ Methods:

# RateLimits

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_limits">rate_limits</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_limits#Action">Action</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_limits">rate_limits</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rate_limits#Action">Action</a>
Expand Down Expand Up @@ -2352,7 +2338,6 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms">waiting_rooms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms#Setting">Setting</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms">waiting_rooms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms#SettingUpdateResponse">SettingUpdateResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms">waiting_rooms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms#SettingEditResponse">SettingEditResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms">waiting_rooms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/waiting_rooms#SettingGetResponse">SettingGetResponse</a>
Expand All @@ -2367,10 +2352,6 @@ Methods:

## Hostnames

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameParam">HostnameParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#Hostname">Hostname</a>
Expand Down Expand Up @@ -2478,10 +2459,6 @@ Methods:

### Schedules

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#ScheduleParam">ScheduleParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#Schedule">Schedule</a>
Expand Down Expand Up @@ -2754,10 +2731,6 @@ Methods:

## Policies

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/page_shield">page_shield</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/page_shield#PolicyParam">PolicyParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/page_shield">page_shield</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/page_shield#Policy">Policy</a>
Expand Down Expand Up @@ -3096,10 +3069,6 @@ Methods:

#### Bindings

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/addressing">addressing</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/addressing#ServiceBindingParam">ServiceBindingParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/addressing">addressing</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/addressing#ServiceBinding">ServiceBinding</a>
Expand Down Expand Up @@ -3301,10 +3270,6 @@ Methods:

## DNS

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel">intel</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel#DNSParam">DNSParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel">intel</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel#DNS">DNS</a>
Expand Down Expand Up @@ -3578,7 +3543,6 @@ Methods:

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#ACLParam">ACLParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#ACLConfigurationParam">ACLConfigurationParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#AllowedProtocol">AllowedProtocol</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#SubnetUnionParam">SubnetUnionParam</a>
Expand Down Expand Up @@ -3648,10 +3612,6 @@ Methods:

## Configs

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_network_monitoring">magic_network_monitoring</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_network_monitoring#ConfigurationParam">ConfigurationParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_network_monitoring">magic_network_monitoring</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_network_monitoring#Configuration">Configuration</a>
Expand Down Expand Up @@ -3904,7 +3864,6 @@ Methods:
Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListCursor">ListCursor</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItem">ListItem</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemNewResponse">ListItemNewResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemUpdateResponse">ListItemUpdateResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemListResponse">ListItemListResponse</a>
Expand Down Expand Up @@ -4197,7 +4156,6 @@ Methods:
Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/alerting">alerting</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/alerting#MechanismParam">MechanismParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/alerting">alerting</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/alerting#PolicyParam">PolicyParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/alerting">alerting</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/alerting#PolicyFilterParam">PolicyFilterParam</a>

Response Types:
Expand Down Expand Up @@ -4791,7 +4749,6 @@ Methods:
Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#ApprovalGroupParam">ApprovalGroupParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#PolicyParam">PolicyParam</a>

Response Types:

Expand Down Expand Up @@ -5477,10 +5434,6 @@ Methods:

### Routes

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#RouteParam">RouteParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#Route">Route</a>
Expand Down Expand Up @@ -6661,10 +6614,6 @@ Methods:

## Schedule

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/speed">speed</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/speed#ScheduleParam">ScheduleParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/speed">speed</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/speed#Schedule">Schedule</a>
Expand Down

0 comments on commit 70fd793

Please sign in to comment.