Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #1962

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions accounts/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGe
return
}

// Whether the user is a member of the organization or has an inivitation pending.
type MemberStatus string

const (
MemberStatusMember MemberStatus = "member"
MemberStatusInvited MemberStatus = "invited"
)

func (r MemberStatus) IsKnown() bool {
switch r {
case MemberStatusMember, MemberStatusInvited:
return true
}
return false
}

type UserWithInviteCode struct {
// Membership identifier tag.
ID string `json:"id,required"`
Expand Down
70 changes: 19 additions & 51 deletions acm/totaltls.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,25 @@ func (r *TotalTLSService) Get(ctx context.Context, query TotalTLSGetParams, opts
return
}

// The Certificate Authority that Total TLS certificates will be issued through.
type TotalTLSCertificateAuthority string

const (
TotalTLSCertificateAuthorityGoogle TotalTLSCertificateAuthority = "google"
TotalTLSCertificateAuthorityLetsEncrypt TotalTLSCertificateAuthority = "lets_encrypt"
)

func (r TotalTLSCertificateAuthority) IsKnown() bool {
switch r {
case TotalTLSCertificateAuthorityGoogle, TotalTLSCertificateAuthorityLetsEncrypt:
return true
}
return false
}

type TotalTLSNewResponse struct {
// The Certificate Authority that Total TLS certificates will be issued through.
CertificateAuthority TotalTLSNewResponseCertificateAuthority `json:"certificate_authority"`
CertificateAuthority TotalTLSCertificateAuthority `json:"certificate_authority"`
// If enabled, Total TLS will order a hostname specific TLS certificate for any
// proxied A, AAAA, or CNAME record in your zone.
Enabled bool `json:"enabled"`
Expand All @@ -86,22 +102,6 @@ func (r totalTLSNewResponseJSON) RawJSON() string {
return r.raw
}

// The Certificate Authority that Total TLS certificates will be issued through.
type TotalTLSNewResponseCertificateAuthority string

const (
TotalTLSNewResponseCertificateAuthorityGoogle TotalTLSNewResponseCertificateAuthority = "google"
TotalTLSNewResponseCertificateAuthorityLetsEncrypt TotalTLSNewResponseCertificateAuthority = "lets_encrypt"
)

func (r TotalTLSNewResponseCertificateAuthority) IsKnown() bool {
switch r {
case TotalTLSNewResponseCertificateAuthorityGoogle, TotalTLSNewResponseCertificateAuthorityLetsEncrypt:
return true
}
return false
}

// The validity period in days for the certificates ordered via Total TLS.
type TotalTLSNewResponseValidityDays int64

Expand All @@ -119,7 +119,7 @@ func (r TotalTLSNewResponseValidityDays) IsKnown() bool {

type TotalTLSGetResponse struct {
// The Certificate Authority that Total TLS certificates will be issued through.
CertificateAuthority TotalTLSGetResponseCertificateAuthority `json:"certificate_authority"`
CertificateAuthority TotalTLSCertificateAuthority `json:"certificate_authority"`
// If enabled, Total TLS will order a hostname specific TLS certificate for any
// proxied A, AAAA, or CNAME record in your zone.
Enabled bool `json:"enabled"`
Expand All @@ -146,22 +146,6 @@ func (r totalTLSGetResponseJSON) RawJSON() string {
return r.raw
}

// The Certificate Authority that Total TLS certificates will be issued through.
type TotalTLSGetResponseCertificateAuthority string

const (
TotalTLSGetResponseCertificateAuthorityGoogle TotalTLSGetResponseCertificateAuthority = "google"
TotalTLSGetResponseCertificateAuthorityLetsEncrypt TotalTLSGetResponseCertificateAuthority = "lets_encrypt"
)

func (r TotalTLSGetResponseCertificateAuthority) IsKnown() bool {
switch r {
case TotalTLSGetResponseCertificateAuthorityGoogle, TotalTLSGetResponseCertificateAuthorityLetsEncrypt:
return true
}
return false
}

// The validity period in days for the certificates ordered via Total TLS.
type TotalTLSGetResponseValidityDays int64

Expand All @@ -184,29 +168,13 @@ type TotalTLSNewParams struct {
// proxied A, AAAA, or CNAME record in your zone.
Enabled param.Field[bool] `json:"enabled,required"`
// The Certificate Authority that Total TLS certificates will be issued through.
CertificateAuthority param.Field[TotalTLSNewParamsCertificateAuthority] `json:"certificate_authority"`
CertificateAuthority param.Field[TotalTLSCertificateAuthority] `json:"certificate_authority"`
}

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

// The Certificate Authority that Total TLS certificates will be issued through.
type TotalTLSNewParamsCertificateAuthority string

const (
TotalTLSNewParamsCertificateAuthorityGoogle TotalTLSNewParamsCertificateAuthority = "google"
TotalTLSNewParamsCertificateAuthorityLetsEncrypt TotalTLSNewParamsCertificateAuthority = "lets_encrypt"
)

func (r TotalTLSNewParamsCertificateAuthority) IsKnown() bool {
switch r {
case TotalTLSNewParamsCertificateAuthorityGoogle, TotalTLSNewParamsCertificateAuthorityLetsEncrypt:
return true
}
return false
}

type TotalTLSNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Expand Down
2 changes: 1 addition & 1 deletion acm/totaltls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestTotalTLSNewWithOptionalParams(t *testing.T) {
_, err := client.ACM.TotalTLS.New(context.TODO(), acm.TotalTLSNewParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Enabled: cloudflare.F(true),
CertificateAuthority: cloudflare.F(acm.TotalTLSNewParamsCertificateAuthorityGoogle),
CertificateAuthority: cloudflare.F(acm.TotalTLSCertificateAuthorityGoogle),
})
if err != nil {
var apierr *cloudflare.Error
Expand Down
70 changes: 27 additions & 43 deletions addressing/addressmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type AddressMap struct {
// handshake from a client without an SNI, it will respond with the default SNI on
// those IPs. The default SNI can be any valid zone or subdomain owned by the
// account.
DefaultSni string `json:"default_sni,nullable"`
DefaultSNI string `json:"default_sni,nullable"`
// An optional description field which may be used to describe the types of IPs or
// zones on the map.
Description string `json:"description,nullable"`
Expand All @@ -147,7 +147,7 @@ type addressMapJSON struct {
CanDelete apijson.Field
CanModifyIPs apijson.Field
CreatedAt apijson.Field
DefaultSni apijson.Field
DefaultSNI apijson.Field
Description apijson.Field
Enabled apijson.Field
ModifiedAt apijson.Field
Expand All @@ -163,6 +163,22 @@ func (r addressMapJSON) RawJSON() string {
return r.raw
}

// The type of the membership.
type AddressMapKind string

const (
AddressMapKindZone AddressMapKind = "zone"
AddressMapKindAccount AddressMapKind = "account"
)

func (r AddressMapKind) IsKnown() bool {
switch r {
case AddressMapKindZone, AddressMapKindAccount:
return true
}
return false
}

type AddressMapNewResponse struct {
// Identifier
ID string `json:"id"`
Expand All @@ -178,7 +194,7 @@ type AddressMapNewResponse struct {
// handshake from a client without an SNI, it will respond with the default SNI on
// those IPs. The default SNI can be any valid zone or subdomain owned by the
// account.
DefaultSni string `json:"default_sni,nullable"`
DefaultSNI string `json:"default_sni,nullable"`
// An optional description field which may be used to describe the types of IPs or
// zones on the map.
Description string `json:"description,nullable"`
Expand All @@ -201,7 +217,7 @@ type addressMapNewResponseJSON struct {
CanDelete apijson.Field
CanModifyIPs apijson.Field
CreatedAt apijson.Field
DefaultSni apijson.Field
DefaultSNI apijson.Field
Description apijson.Field
Enabled apijson.Field
IPs apijson.Field
Expand Down Expand Up @@ -250,8 +266,8 @@ type AddressMapNewResponseMembership struct {
// Identifier
Identifier string `json:"identifier"`
// The type of the membership.
Kind AddressMapNewResponseMembershipsKind `json:"kind"`
JSON addressMapNewResponseMembershipJSON `json:"-"`
Kind AddressMapKind `json:"kind"`
JSON addressMapNewResponseMembershipJSON `json:"-"`
}

// addressMapNewResponseMembershipJSON contains the JSON metadata for the struct
Expand All @@ -273,22 +289,6 @@ func (r addressMapNewResponseMembershipJSON) RawJSON() string {
return r.raw
}

// The type of the membership.
type AddressMapNewResponseMembershipsKind string

const (
AddressMapNewResponseMembershipsKindZone AddressMapNewResponseMembershipsKind = "zone"
AddressMapNewResponseMembershipsKindAccount AddressMapNewResponseMembershipsKind = "account"
)

func (r AddressMapNewResponseMembershipsKind) IsKnown() bool {
switch r {
case AddressMapNewResponseMembershipsKindZone, AddressMapNewResponseMembershipsKindAccount:
return true
}
return false
}

type AddressMapDeleteResponse = interface{}

type AddressMapGetResponse struct {
Expand All @@ -306,7 +306,7 @@ type AddressMapGetResponse struct {
// handshake from a client without an SNI, it will respond with the default SNI on
// those IPs. The default SNI can be any valid zone or subdomain owned by the
// account.
DefaultSni string `json:"default_sni,nullable"`
DefaultSNI string `json:"default_sni,nullable"`
// An optional description field which may be used to describe the types of IPs or
// zones on the map.
Description string `json:"description,nullable"`
Expand All @@ -329,7 +329,7 @@ type addressMapGetResponseJSON struct {
CanDelete apijson.Field
CanModifyIPs apijson.Field
CreatedAt apijson.Field
DefaultSni apijson.Field
DefaultSNI apijson.Field
Description apijson.Field
Enabled apijson.Field
IPs apijson.Field
Expand Down Expand Up @@ -378,8 +378,8 @@ type AddressMapGetResponseMembership struct {
// Identifier
Identifier string `json:"identifier"`
// The type of the membership.
Kind AddressMapGetResponseMembershipsKind `json:"kind"`
JSON addressMapGetResponseMembershipJSON `json:"-"`
Kind AddressMapKind `json:"kind"`
JSON addressMapGetResponseMembershipJSON `json:"-"`
}

// addressMapGetResponseMembershipJSON contains the JSON metadata for the struct
Expand All @@ -401,22 +401,6 @@ func (r addressMapGetResponseMembershipJSON) RawJSON() string {
return r.raw
}

// The type of the membership.
type AddressMapGetResponseMembershipsKind string

const (
AddressMapGetResponseMembershipsKindZone AddressMapGetResponseMembershipsKind = "zone"
AddressMapGetResponseMembershipsKindAccount AddressMapGetResponseMembershipsKind = "account"
)

func (r AddressMapGetResponseMembershipsKind) IsKnown() bool {
switch r {
case AddressMapGetResponseMembershipsKindZone, AddressMapGetResponseMembershipsKindAccount:
return true
}
return false
}

type AddressMapNewParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
Expand Down Expand Up @@ -569,7 +553,7 @@ type AddressMapEditParams struct {
// handshake from a client without an SNI, it will respond with the default SNI on
// those IPs. The default SNI can be any valid zone or subdomain owned by the
// account.
DefaultSni param.Field[string] `json:"default_sni"`
DefaultSNI param.Field[string] `json:"default_sni"`
// An optional description field which may be used to describe the types of IPs or
// zones on the map.
Description param.Field[string] `json:"description"`
Expand Down
2 changes: 1 addition & 1 deletion addressing/addressmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestAddressMapEditWithOptionalParams(t *testing.T) {
"023e105f4ecef8ad9ca31a8372d0c353",
addressing.AddressMapEditParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
DefaultSni: cloudflare.F("*.example.com"),
DefaultSNI: cloudflare.F("*.example.com"),
Description: cloudflare.F("My Ecommerce zones"),
Enabled: cloudflare.F(true),
},
Expand Down
7 changes: 7 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberStatus">MemberStatus</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#UserWithInviteCode">UserWithInviteCode</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberListResponse">MemberListResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberDeleteResponse">MemberDeleteResponse</a>
Expand Down Expand Up @@ -1269,8 +1270,13 @@ Methods:

## TotalTLS

Params Types:

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

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/acm">acm</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/acm#TotalTLSCertificateAuthority">TotalTLSCertificateAuthority</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/acm">acm</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/acm#TotalTLSNewResponse">TotalTLSNewResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/acm">acm</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/acm#TotalTLSGetResponse">TotalTLSGetResponse</a>

Expand Down Expand Up @@ -2989,6 +2995,7 @@ Methods:
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#AddressMap">AddressMap</a>
- <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#AddressMapKind">AddressMapKind</a>
- <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#AddressMapNewResponse">AddressMapNewResponse</a>
- <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#AddressMapDeleteResponse">AddressMapDeleteResponse</a>
- <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#AddressMapGetResponse">AddressMapGetResponse</a>
Expand Down
4 changes: 2 additions & 2 deletions custom_certificates/customcertificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,12 @@ type CustomCertificateNewParamsType string

const (
CustomCertificateNewParamsTypeLegacyCustom CustomCertificateNewParamsType = "legacy_custom"
CustomCertificateNewParamsTypeSniCustom CustomCertificateNewParamsType = "sni_custom"
CustomCertificateNewParamsTypeSNICustom CustomCertificateNewParamsType = "sni_custom"
)

func (r CustomCertificateNewParamsType) IsKnown() bool {
switch r {
case CustomCertificateNewParamsTypeLegacyCustom, CustomCertificateNewParamsTypeSniCustom:
case CustomCertificateNewParamsTypeLegacyCustom, CustomCertificateNewParamsTypeSNICustom:
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion custom_certificates/customcertificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestCustomCertificateNewWithOptionalParams(t *testing.T) {
Label: cloudflare.F(custom_certificates.GeoRestrictionsLabelUs),
}),
Policy: cloudflare.F("(country: US) or (region: EU)"),
Type: cloudflare.F(custom_certificates.CustomCertificateNewParamsTypeSniCustom),
Type: cloudflare.F(custom_certificates.CustomCertificateNewParamsTypeSNICustom),
})
if err != nil {
var apierr *cloudflare.Error
Expand Down