Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 8, 2024
1 parent 04cc9b2 commit 300bee6
Show file tree
Hide file tree
Showing 57 changed files with 2,010 additions and 2,654 deletions.
5 changes: 3 additions & 2 deletions accounts/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"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/cloudflare/cloudflare-go/v2/user"
)

// RoleService contains methods and other services that help with interacting with
Expand Down Expand Up @@ -107,8 +108,8 @@ type Role struct {
// Role Name.
Name string `json:"name,required"`
// Access permissions for this User.
Permissions []string `json:"permissions,required"`
JSON roleJSON `json:"-"`
Permissions []user.PermissionItem `json:"permissions,required"`
JSON roleJSON `json:"-"`
}

// roleJSON contains the JSON metadata for the struct [Role]
Expand Down
113 changes: 58 additions & 55 deletions api.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions challenges/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ type Widget struct {
// challenge clearance, this setting can determine the clearance level to be set
ClearanceLevel WidgetClearanceLevel `json:"clearance_level,required"`
// When the widget was created.
CreatedOn time.Time `json:"created_on,required" format:"date-time"`
Domains []string `json:"domains,required"`
CreatedOn time.Time `json:"created_on,required" format:"date-time"`
Domains []WidgetDomainItem `json:"domains,required"`
// Widget Mode
Mode WidgetMode `json:"mode,required"`
// When the widget was modified.
Expand Down Expand Up @@ -241,8 +241,8 @@ type WidgetDomain struct {
// challenge clearance, this setting can determine the clearance level to be set
ClearanceLevel WidgetDomainClearanceLevel `json:"clearance_level,required"`
// When the widget was created.
CreatedOn time.Time `json:"created_on,required" format:"date-time"`
Domains []string `json:"domains,required"`
CreatedOn time.Time `json:"created_on,required" format:"date-time"`
Domains []WidgetDomainItem `json:"domains,required"`
// Widget Mode
Mode WidgetDomainMode `json:"mode,required"`
// When the widget was modified.
Expand Down
2 changes: 1 addition & 1 deletion cloudforce_one/requestpriority.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type Priority struct {
// Priority creation time
Created time.Time `json:"created,required" format:"date-time"`
// List of labels
Labels []string `json:"labels,required"`
Labels []LabelItem `json:"labels,required"`
// Priority
Priority int64 `json:"priority,required"`
// Requirement
Expand Down
4 changes: 2 additions & 2 deletions custom_certificates/customcertificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ type CustomCertificate struct {
// only to U.S. data centers, only to E.U. data centers, or only to highest
// security data centers. Default distribution is to all Cloudflare datacenters,
// for optimal performance.
GeoRestrictions GeoRestrictions `json:"geo_restrictions"`
KeylessServer keyless_certificates.Hostname `json:"keyless_server"`
GeoRestrictions GeoRestrictions `json:"geo_restrictions"`
KeylessServer keyless_certificates.KeylessCertificate `json:"keyless_server"`
// Specify the policy that determines the region where your private key will be
// held locally. HTTPS connections to any excluded data center will still be fully
// encrypted, but will incur some latency while Keyless SSL is used to complete the
Expand Down
155 changes: 35 additions & 120 deletions custom_hostnames/customhostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewCustomHostnameService(opts ...option.RequestOption) (r *CustomHostnameSe
// plus hostmaster, postmaster, webmaster, admin, administrator. If http is used
// and the domain is not already pointing to the Managed CNAME host, the PATCH
// method must be used once it is (to complete validation).
func (r *CustomHostnameService) New(ctx context.Context, params CustomHostnameNewParams, opts ...option.RequestOption) (res *CustomHostnameNewResponse, err error) {
func (r *CustomHostnameService) New(ctx context.Context, params CustomHostnameNewParams, opts ...option.RequestOption) (res *CustomHostname, err error) {
opts = append(r.Options[:], opts...)
var env CustomHostnameNewResponseEnvelope
path := fmt.Sprintf("zones/%s/custom_hostnames", params.ZoneID)
Expand All @@ -58,7 +58,7 @@ func (r *CustomHostnameService) New(ctx context.Context, params CustomHostnameNe
}

// List, search, sort, and filter all of your custom hostnames.
func (r *CustomHostnameService) List(ctx context.Context, params CustomHostnameListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[CustomHostnameListResponse], err error) {
func (r *CustomHostnameService) List(ctx context.Context, params CustomHostnameListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[CustomHostname], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -76,7 +76,7 @@ func (r *CustomHostnameService) List(ctx context.Context, params CustomHostnameL
}

// List, search, sort, and filter all of your custom hostnames.
func (r *CustomHostnameService) ListAutoPaging(ctx context.Context, params CustomHostnameListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[CustomHostnameListResponse] {
func (r *CustomHostnameService) ListAutoPaging(ctx context.Context, params CustomHostnameListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[CustomHostname] {
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...))
}

Expand All @@ -92,7 +92,7 @@ func (r *CustomHostnameService) Delete(ctx context.Context, customHostnameID str
// matches existing config, used to indicate that hostname should pass domain
// control validation (DCV). Can also be used to change validation type, e.g., from
// 'http' to 'email'.
func (r *CustomHostnameService) Edit(ctx context.Context, customHostnameID string, params CustomHostnameEditParams, opts ...option.RequestOption) (res *CustomHostnameEditResponse, err error) {
func (r *CustomHostnameService) Edit(ctx context.Context, customHostnameID string, params CustomHostnameEditParams, opts ...option.RequestOption) (res *CustomHostname, err error) {
opts = append(r.Options[:], opts...)
var env CustomHostnameEditResponseEnvelope
path := fmt.Sprintf("zones/%s/custom_hostnames/%s", params.ZoneID, customHostnameID)
Expand All @@ -105,7 +105,7 @@ func (r *CustomHostnameService) Edit(ctx context.Context, customHostnameID strin
}

// Custom Hostname Details
func (r *CustomHostnameService) Get(ctx context.Context, customHostnameID string, query CustomHostnameGetParams, opts ...option.RequestOption) (res *CustomHostnameGetResponse, err error) {
func (r *CustomHostnameService) Get(ctx context.Context, customHostnameID string, query CustomHostnameGetParams, opts ...option.RequestOption) (res *CustomHostname, err error) {
opts = append(r.Options[:], opts...)
var env CustomHostnameGetResponseEnvelope
path := fmt.Sprintf("zones/%s/custom_hostnames/%s", query.ZoneID, customHostnameID)
Expand All @@ -117,6 +117,33 @@ func (r *CustomHostnameService) Get(ctx context.Context, customHostnameID string
return
}

type CustomHostname struct {
// Identifier
ID string `json:"id,required"`
// The custom hostname that will point to your hostname via CNAME.
Hostname string `json:"hostname,required"`
// SSL properties for the custom hostname.
SSL SSL `json:"ssl,required"`
JSON customHostnameJSON `json:"-"`
}

// customHostnameJSON contains the JSON metadata for the struct [CustomHostname]
type customHostnameJSON struct {
ID apijson.Field
Hostname apijson.Field
SSL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// SSL properties for the custom hostname.
type SSL struct {
// Custom hostname SSL identifier tag.
Expand Down Expand Up @@ -464,118 +491,6 @@ func (r UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1) IsKnown() bool {
return false
}

type CustomHostnameNewResponse struct {
// Identifier
ID string `json:"id,required"`
// The custom hostname that will point to your hostname via CNAME.
Hostname string `json:"hostname,required"`
// SSL properties for the custom hostname.
SSL SSL `json:"ssl,required"`
JSON customHostnameNewResponseJSON `json:"-"`
}

// customHostnameNewResponseJSON contains the JSON metadata for the struct
// [CustomHostnameNewResponse]
type customHostnameNewResponseJSON struct {
ID apijson.Field
Hostname apijson.Field
SSL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type CustomHostnameListResponse struct {
// Identifier
ID string `json:"id,required"`
// The custom hostname that will point to your hostname via CNAME.
Hostname string `json:"hostname,required"`
// SSL properties for the custom hostname.
SSL SSL `json:"ssl,required"`
JSON customHostnameListResponseJSON `json:"-"`
}

// customHostnameListResponseJSON contains the JSON metadata for the struct
// [CustomHostnameListResponse]
type customHostnameListResponseJSON struct {
ID apijson.Field
Hostname apijson.Field
SSL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type CustomHostnameEditResponse struct {
// Identifier
ID string `json:"id,required"`
// The custom hostname that will point to your hostname via CNAME.
Hostname string `json:"hostname,required"`
// SSL properties for the custom hostname.
SSL SSL `json:"ssl,required"`
JSON customHostnameEditResponseJSON `json:"-"`
}

// customHostnameEditResponseJSON contains the JSON metadata for the struct
// [CustomHostnameEditResponse]
type customHostnameEditResponseJSON struct {
ID apijson.Field
Hostname apijson.Field
SSL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type CustomHostnameGetResponse struct {
// Identifier
ID string `json:"id,required"`
// The custom hostname that will point to your hostname via CNAME.
Hostname string `json:"hostname,required"`
// SSL properties for the custom hostname.
SSL SSL `json:"ssl,required"`
JSON customHostnameGetResponseJSON `json:"-"`
}

// customHostnameGetResponseJSON contains the JSON metadata for the struct
// [CustomHostnameGetResponse]
type customHostnameGetResponseJSON struct {
ID apijson.Field
Hostname apijson.Field
SSL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type CustomHostnameNewParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
Expand Down Expand Up @@ -734,7 +649,7 @@ func (r CustomHostnameNewParamsCustomMetadata) MarshalJSON() (data []byte, err e
type CustomHostnameNewResponseEnvelope struct {
Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"`
Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"`
Result CustomHostnameNewResponse `json:"result,required"`
Result CustomHostname `json:"result,required"`
// Whether the API call was successful
Success CustomHostnameNewResponseEnvelopeSuccess `json:"success,required"`
JSON customHostnameNewResponseEnvelopeJSON `json:"-"`
Expand Down Expand Up @@ -1028,7 +943,7 @@ func (r CustomHostnameEditParamsSSLSettingsTLS1_3) IsKnown() bool {
type CustomHostnameEditResponseEnvelope struct {
Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"`
Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"`
Result CustomHostnameEditResponse `json:"result,required"`
Result CustomHostname `json:"result,required"`
// Whether the API call was successful
Success CustomHostnameEditResponseEnvelopeSuccess `json:"success,required"`
JSON customHostnameEditResponseEnvelopeJSON `json:"-"`
Expand Down Expand Up @@ -1076,7 +991,7 @@ type CustomHostnameGetParams struct {
type CustomHostnameGetResponseEnvelope struct {
Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"`
Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"`
Result CustomHostnameGetResponse `json:"result,required"`
Result CustomHostname `json:"result,required"`
// Whether the API call was successful
Success CustomHostnameGetResponseEnvelopeSuccess `json:"success,required"`
JSON customHostnameGetResponseEnvelopeJSON `json:"-"`
Expand Down
52 changes: 4 additions & 48 deletions dns/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ type Firewall struct {
// Identifier
ID string `json:"id,required"`
// Deprecate the response to ANY requests.
DeprecateAnyRequests bool `json:"deprecate_any_requests,required"`
DNSFirewallIPs []FirewallDNSFirewallIPsUnion `json:"dns_firewall_ips,required" format:"ipv4"`
DeprecateAnyRequests bool `json:"deprecate_any_requests,required"`
DNSFirewallIPs []FirewallIPsItemUnion `json:"dns_firewall_ips,required" format:"ipv4"`
// Forward client IP (resolver) subnet if no EDNS Client Subnet is sent.
EcsFallback bool `json:"ecs_fallback,required"`
// Maximum DNS Cache TTL.
Expand All @@ -169,8 +169,8 @@ type Firewall struct {
// Last modification of DNS Firewall cluster.
ModifiedOn time.Time `json:"modified_on,required" format:"date-time"`
// DNS Firewall Cluster Name.
Name string `json:"name,required"`
UpstreamIPs []FirewallUpstreamIPsUnion `json:"upstream_ips,required" format:"ipv4"`
Name string `json:"name,required"`
UpstreamIPs []UpstreamIPsItemsUnion `json:"upstream_ips,required" format:"ipv4"`
// Attack mitigation settings.
AttackMitigation AttackMitigation `json:"attack_mitigation,nullable"`
// Negative DNS Cache TTL.
Expand Down Expand Up @@ -211,50 +211,6 @@ func (r firewallJSON) RawJSON() string {
return r.raw
}

// Cloudflare-assigned DNS IPv4 Address.
//
// Union satisfied by [shared.UnionString] or [shared.UnionString].
type FirewallDNSFirewallIPsUnion interface {
ImplementsDNSFirewallDNSFirewallIPsUnion()
}

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

// Upstream DNS Server IPv4 Address.
//
// Union satisfied by [shared.UnionString] or [shared.UnionString].
type FirewallUpstreamIPsUnion interface {
ImplementsDNSFirewallUpstreamIPsUnion()
}

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

// Cloudflare-assigned DNS IPv4 Address.
//
// Union satisfied by [shared.UnionString] or [shared.UnionString].
Expand Down
Loading

0 comments on commit 300bee6

Please sign in to comment.