diff --git a/accounts/member.go b/accounts/member.go index 28cdcf290c..f6f2d5f859 100644 --- a/accounts/member.go +++ b/accounts/member.go @@ -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"` diff --git a/acm/totaltls.go b/acm/totaltls.go index 6a60926d92..ae6836eeea 100644 --- a/acm/totaltls.go +++ b/acm/totaltls.go @@ -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"` @@ -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 @@ -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"` @@ -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 @@ -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"` diff --git a/acm/totaltls_test.go b/acm/totaltls_test.go index 87496fef01..58acf876d7 100644 --- a/acm/totaltls_test.go +++ b/acm/totaltls_test.go @@ -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 diff --git a/addressing/addressmap.go b/addressing/addressmap.go index 44aa60b6d6..5f5bed0647 100644 --- a/addressing/addressmap.go +++ b/addressing/addressmap.go @@ -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"` @@ -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 @@ -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"` @@ -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"` @@ -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 @@ -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 @@ -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 { @@ -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"` @@ -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 @@ -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 @@ -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"` @@ -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"` diff --git a/addressing/addressmap_test.go b/addressing/addressmap_test.go index 5687a20130..c55a6b76aa 100644 --- a/addressing/addressmap_test.go +++ b/addressing/addressmap_test.go @@ -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), }, diff --git a/api.md b/api.md index 0c838a51c7..6c879c8f87 100644 --- a/api.md +++ b/api.md @@ -39,6 +39,7 @@ Methods: Response Types: +- accounts.MemberStatus - accounts.UserWithInviteCode - accounts.MemberListResponse - accounts.MemberDeleteResponse @@ -1269,8 +1270,13 @@ Methods: ## TotalTLS +Params Types: + +- acm.TotalTLSCertificateAuthority + Response Types: +- acm.TotalTLSCertificateAuthority - acm.TotalTLSNewResponse - acm.TotalTLSGetResponse @@ -2989,6 +2995,7 @@ Methods: Response Types: - addressing.AddressMap +- addressing.AddressMapKind - addressing.AddressMapNewResponse - addressing.AddressMapDeleteResponse - addressing.AddressMapGetResponse diff --git a/custom_certificates/customcertificate.go b/custom_certificates/customcertificate.go index 3c3d3fbe06..9c06f33271 100644 --- a/custom_certificates/customcertificate.go +++ b/custom_certificates/customcertificate.go @@ -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 diff --git a/custom_certificates/customcertificate_test.go b/custom_certificates/customcertificate_test.go index f0ee1cfcb3..1f4a58aa30 100644 --- a/custom_certificates/customcertificate_test.go +++ b/custom_certificates/customcertificate_test.go @@ -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 diff --git a/custom_hostnames/customhostname.go b/custom_hostnames/customhostname.go index a997b6957a..54d19acd62 100644 --- a/custom_hostnames/customhostname.go +++ b/custom_hostnames/customhostname.go @@ -190,7 +190,7 @@ type CustomHostnameNewResponse struct { // name or the string ':request_host_header:' which will cause the host header in // the request to be used as SNI. Not configurable with default/fallback origin // server. - CustomOriginSni string `json:"custom_origin_sni"` + CustomOriginSNI string `json:"custom_origin_sni"` // This is a record which can be placed to activate a hostname. OwnershipVerification CustomHostnameNewResponseOwnershipVerification `json:"ownership_verification"` // This presents the token to be served by the given http url to activate a @@ -212,7 +212,7 @@ type customHostnameNewResponseJSON struct { CreatedAt apijson.Field CustomMetadata apijson.Field CustomOriginServer apijson.Field - CustomOriginSni apijson.Field + CustomOriginSNI apijson.Field OwnershipVerification apijson.Field OwnershipVerificationHTTP apijson.Field Status apijson.Field @@ -652,7 +652,7 @@ type CustomHostnameListResponse struct { // name or the string ':request_host_header:' which will cause the host header in // the request to be used as SNI. Not configurable with default/fallback origin // server. - CustomOriginSni string `json:"custom_origin_sni"` + CustomOriginSNI string `json:"custom_origin_sni"` // This is a record which can be placed to activate a hostname. OwnershipVerification CustomHostnameListResponseOwnershipVerification `json:"ownership_verification"` // This presents the token to be served by the given http url to activate a @@ -674,7 +674,7 @@ type customHostnameListResponseJSON struct { CreatedAt apijson.Field CustomMetadata apijson.Field CustomOriginServer apijson.Field - CustomOriginSni apijson.Field + CustomOriginSNI apijson.Field OwnershipVerification apijson.Field OwnershipVerificationHTTP apijson.Field Status apijson.Field @@ -1136,7 +1136,7 @@ type CustomHostnameEditResponse struct { // name or the string ':request_host_header:' which will cause the host header in // the request to be used as SNI. Not configurable with default/fallback origin // server. - CustomOriginSni string `json:"custom_origin_sni"` + CustomOriginSNI string `json:"custom_origin_sni"` // This is a record which can be placed to activate a hostname. OwnershipVerification CustomHostnameEditResponseOwnershipVerification `json:"ownership_verification"` // This presents the token to be served by the given http url to activate a @@ -1158,7 +1158,7 @@ type customHostnameEditResponseJSON struct { CreatedAt apijson.Field CustomMetadata apijson.Field CustomOriginServer apijson.Field - CustomOriginSni apijson.Field + CustomOriginSNI apijson.Field OwnershipVerification apijson.Field OwnershipVerificationHTTP apijson.Field Status apijson.Field @@ -1598,7 +1598,7 @@ type CustomHostnameGetResponse struct { // name or the string ':request_host_header:' which will cause the host header in // the request to be used as SNI. Not configurable with default/fallback origin // server. - CustomOriginSni string `json:"custom_origin_sni"` + CustomOriginSNI string `json:"custom_origin_sni"` // This is a record which can be placed to activate a hostname. OwnershipVerification CustomHostnameGetResponseOwnershipVerification `json:"ownership_verification"` // This presents the token to be served by the given http url to activate a @@ -1620,7 +1620,7 @@ type customHostnameGetResponseJSON struct { CreatedAt apijson.Field CustomMetadata apijson.Field CustomOriginServer apijson.Field - CustomOriginSni apijson.Field + CustomOriginSNI apijson.Field OwnershipVerification apijson.Field OwnershipVerificationHTTP apijson.Field Status apijson.Field @@ -2319,7 +2319,7 @@ type CustomHostnameEditParams struct { // name or the string ':request_host_header:' which will cause the host header in // the request to be used as SNI. Not configurable with default/fallback origin // server. - CustomOriginSni param.Field[string] `json:"custom_origin_sni"` + CustomOriginSNI param.Field[string] `json:"custom_origin_sni"` // SSL properties used when creating the custom hostname. SSL param.Field[CustomHostnameEditParamsSSL] `json:"ssl"` } diff --git a/custom_hostnames/customhostname_test.go b/custom_hostnames/customhostname_test.go index 58e35a9121..555dbd77e7 100644 --- a/custom_hostnames/customhostname_test.go +++ b/custom_hostnames/customhostname_test.go @@ -143,7 +143,7 @@ func TestCustomHostnameEditWithOptionalParams(t *testing.T) { Key: cloudflare.F("value"), }), CustomOriginServer: cloudflare.F("origin2.example.com"), - CustomOriginSni: cloudflare.F("sni.example.com"), + CustomOriginSNI: cloudflare.F("sni.example.com"), SSL: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSL{ BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), CertificateAuthority: cloudflare.F(ssl.CertificatePackCAGoogle), diff --git a/rulesets/rule.go b/rulesets/rule.go index 4bfabe41fa..3f6bb6ea59 100644 --- a/rulesets/rule.go +++ b/rulesets/rule.go @@ -2522,7 +2522,7 @@ type RouteRuleActionParameters struct { // Override the IP/TCP destination. Origin RouteRuleActionParametersOrigin `json:"origin"` // Override the Server Name Indication (SNI). - Sni RouteRuleActionParametersSni `json:"sni"` + SNI RouteRuleActionParametersSNI `json:"sni"` JSON routeRuleActionParametersJSON `json:"-"` } @@ -2531,7 +2531,7 @@ type RouteRuleActionParameters struct { type routeRuleActionParametersJSON struct { HostHeader apijson.Field Origin apijson.Field - Sni apijson.Field + SNI apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -2571,25 +2571,25 @@ func (r routeRuleActionParametersOriginJSON) RawJSON() string { } // Override the Server Name Indication (SNI). -type RouteRuleActionParametersSni struct { +type RouteRuleActionParametersSNI struct { // The SNI override. Value string `json:"value,required"` - JSON routeRuleActionParametersSniJSON `json:"-"` + JSON routeRuleActionParametersSNIJSON `json:"-"` } -// routeRuleActionParametersSniJSON contains the JSON metadata for the struct -// [RouteRuleActionParametersSni] -type routeRuleActionParametersSniJSON struct { +// routeRuleActionParametersSNIJSON contains the JSON metadata for the struct +// [RouteRuleActionParametersSNI] +type routeRuleActionParametersSNIJSON struct { Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RouteRuleActionParametersSni) UnmarshalJSON(data []byte) (err error) { +func (r *RouteRuleActionParametersSNI) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r routeRuleActionParametersSniJSON) RawJSON() string { +func (r routeRuleActionParametersSNIJSON) RawJSON() string { return r.raw } @@ -2629,7 +2629,7 @@ type RouteRuleActionParametersParam struct { // Override the IP/TCP destination. Origin param.Field[RouteRuleActionParametersOriginParam] `json:"origin"` // Override the Server Name Indication (SNI). - Sni param.Field[RouteRuleActionParametersSniParam] `json:"sni"` + SNI param.Field[RouteRuleActionParametersSNIParam] `json:"sni"` } func (r RouteRuleActionParametersParam) MarshalJSON() (data []byte, err error) { @@ -2649,12 +2649,12 @@ func (r RouteRuleActionParametersOriginParam) MarshalJSON() (data []byte, err er } // Override the Server Name Indication (SNI). -type RouteRuleActionParametersSniParam struct { +type RouteRuleActionParametersSNIParam struct { // The SNI override. Value param.Field[string] `json:"value,required"` } -func (r RouteRuleActionParametersSniParam) MarshalJSON() (data []byte, err error) { +func (r RouteRuleActionParametersSNIParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } diff --git a/user/organization.go b/user/organization.go index c971b63d0f..31deefc16e 100644 --- a/user/organization.go +++ b/user/organization.go @@ -9,6 +9,7 @@ import ( "net/url" "reflect" + "github.com/cloudflare/cloudflare-go/v2/accounts" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" @@ -91,8 +92,8 @@ type Organization struct { // List of roles that a user has within an organization. Roles []string `json:"roles"` // Whether the user is a member of the organization or has an inivitation pending. - Status OrganizationStatus `json:"status"` - JSON organizationJSON `json:"-"` + Status accounts.MemberStatus `json:"status"` + JSON organizationJSON `json:"-"` } // organizationJSON contains the JSON metadata for the struct [Organization] @@ -114,22 +115,6 @@ func (r organizationJSON) RawJSON() string { return r.raw } -// Whether the user is a member of the organization or has an inivitation pending. -type OrganizationStatus string - -const ( - OrganizationStatusMember OrganizationStatus = "member" - OrganizationStatusInvited OrganizationStatus = "invited" -) - -func (r OrganizationStatus) IsKnown() bool { - switch r { - case OrganizationStatusMember, OrganizationStatusInvited: - return true - } - return false -} - type OrganizationDeleteResponse struct { // Identifier ID string `json:"id"`