Skip to content

Commit

Permalink
Merge pull request #1841 from cloudflare/release-please--branches--v2…
Browse files Browse the repository at this point in the history
…--changes--next

release: 2.2.0
  • Loading branch information
jacobbednarz committed May 9, 2024
2 parents 69b2516 + 97ed11d commit de79501
Show file tree
Hide file tree
Showing 971 changed files with 9,748 additions and 8,094 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -21,5 +21,19 @@ jobs:

- run: |
go build ./...
test:
name: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup go
uses: actions/setup-go@v5

- name: Bootstrap
run: ./scripts/bootstrap

- name: Run tests
run: ./scripts/test

2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.repository == 'cloudflare/cloudflare-go' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check release environment
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
codegen.log
Brewfile.lock.json
.idea/
2 changes: 1 addition & 1 deletion .release-please-manifest.json
@@ -1,3 +1,3 @@
{
".": "2.1.0"
".": "2.2.0"
}
3 changes: 2 additions & 1 deletion .stats.yml
@@ -1 +1,2 @@
configured_endpoints: 1266
configured_endpoints: 1274
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-07ec76fab00de3d6227209faf0af1ed586cde9e2f243c13d3db555da20f13d99.yml
137 changes: 137 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -22,7 +22,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/cloudflare/cloudflare-go/v2@v2.1.0'
go get -u 'github.com/cloudflare/cloudflare-go/v2@v2.2.0'
```

<!-- x-release-please-end -->
Expand Down Expand Up @@ -57,7 +57,7 @@ func main() {
ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
}),
Name: cloudflare.F("example.com"),
Type: cloudflare.F(zones.ZoneNewParamsTypeFull),
Type: cloudflare.F(zones.TypeFull),
})
if err != nil {
panic(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion accounts/account.go
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/cloudflare/cloudflare-go/v2/internal/pagination"
"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/cloudflare/cloudflare-go/v2/shared"
"github.com/tidwall/gjson"
)

Expand Down
3 changes: 0 additions & 3 deletions accounts/account_test.go
Expand Up @@ -15,7 +15,6 @@ import (
)

func TestAccountUpdateWithOptionalParams(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
Expand Down Expand Up @@ -49,7 +48,6 @@ func TestAccountUpdateWithOptionalParams(t *testing.T) {
}

func TestAccountListWithOptionalParams(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
Expand Down Expand Up @@ -78,7 +76,6 @@ func TestAccountListWithOptionalParams(t *testing.T) {
}

func TestAccountGet(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
Expand Down
42 changes: 41 additions & 1 deletion accounts/aliases.go
Expand Up @@ -4,7 +4,7 @@ package accounts

import (
"github.com/cloudflare/cloudflare-go/v2/internal/apierror"
"github.com/cloudflare/cloudflare-go/v2/internal/shared"
"github.com/cloudflare/cloudflare-go/v2/shared"
)

type Error = apierror.Error
Expand Down Expand Up @@ -44,6 +44,35 @@ type AuditLogOwner = shared.AuditLogOwner
// This is an alias to an internal type.
type AuditLogResource = shared.AuditLogResource

// The Certificate Authority that will issue the certificate
//
// This is an alias to an internal type.
type CertificateCA = shared.CertificateCA

// This is an alias to an internal value.
const CertificateCADigicert = shared.CertificateCADigicert

// This is an alias to an internal value.
const CertificateCAGoogle = shared.CertificateCAGoogle

// This is an alias to an internal value.
const CertificateCALetsEncrypt = shared.CertificateCALetsEncrypt

// Signature type desired on certificate ("origin-rsa" (rsa), "origin-ecc" (ecdsa),
// or "keyless-certificate" (for Keyless SSL servers).
//
// This is an alias to an internal type.
type CertificateRequestType = shared.CertificateRequestType

// This is an alias to an internal value.
const CertificateRequestTypeOriginRSA = shared.CertificateRequestTypeOriginRSA

// This is an alias to an internal value.
const CertificateRequestTypeOriginECC = shared.CertificateRequestTypeOriginECC

// This is an alias to an internal value.
const CertificateRequestTypeKeylessCertificate = shared.CertificateRequestTypeKeylessCertificate

// A Cloudflare Tunnel that connects your origin to Cloudflare's edge.
//
// This is an alias to an internal type.
Expand Down Expand Up @@ -113,3 +142,14 @@ type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type Role = shared.Role

// Direction to order DNS records in.
//
// This is an alias to an internal type.
type SortDirection = shared.SortDirection

// This is an alias to an internal value.
const SortDirectionAsc = shared.SortDirectionAsc

// This is an alias to an internal value.
const SortDirectionDesc = shared.SortDirectionDesc
47 changes: 29 additions & 18 deletions accounts/member.go
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/cloudflare/cloudflare-go/v2/internal/pagination"
"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/cloudflare/cloudflare-go/v2/shared"
)

// MemberService contains methods and other services that help with interacting
Expand All @@ -38,7 +38,7 @@ func NewMemberService(opts ...option.RequestOption) (r *MemberService) {
func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts ...option.RequestOption) (res *UserWithInviteCode, err error) {
opts = append(r.Options[:], opts...)
var env MemberNewResponseEnvelope
path := fmt.Sprintf("accounts/%v/members", params.AccountID)
path := fmt.Sprintf("accounts/%s/members", params.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...)
if err != nil {
return
Expand All @@ -51,7 +51,7 @@ func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts ..
func (r *MemberService) Update(ctx context.Context, memberID string, params MemberUpdateParams, opts ...option.RequestOption) (res *shared.Member, err error) {
opts = append(r.Options[:], opts...)
var env MemberUpdateResponseEnvelope
path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID)
path := fmt.Sprintf("accounts/%s/members/%s", params.AccountID, memberID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...)
if err != nil {
return
Expand All @@ -65,7 +65,7 @@ func (r *MemberService) List(ctx context.Context, params MemberListParams, opts
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := fmt.Sprintf("accounts/%v/members", params.AccountID)
path := fmt.Sprintf("accounts/%s/members", params.AccountID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
if err != nil {
return nil, err
Expand All @@ -84,10 +84,10 @@ func (r *MemberService) ListAutoPaging(ctx context.Context, params MemberListPar
}

// Remove a member from an account.
func (r *MemberService) Delete(ctx context.Context, memberID string, params MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) {
func (r *MemberService) Delete(ctx context.Context, memberID string, body MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env MemberDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID)
path := fmt.Sprintf("accounts/%s/members/%s", body.AccountID, memberID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand All @@ -100,7 +100,7 @@ func (r *MemberService) Delete(ctx context.Context, memberID string, params Memb
func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGetParams, opts ...option.RequestOption) (res *shared.Member, err error) {
opts = append(r.Options[:], opts...)
var env MemberGetResponseEnvelope
path := fmt.Sprintf("accounts/%v/members/%s", query.AccountID, memberID)
path := fmt.Sprintf("accounts/%s/members/%s", query.AccountID, memberID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
return
Expand All @@ -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 Status string

const (
StatusMember Status = "member"
StatusInvited Status = "invited"
)

func (r Status) IsKnown() bool {
switch r {
case StatusMember, StatusInvited:
return true
}
return false
}

type UserWithInviteCode struct {
// Membership identifier tag.
ID string `json:"id,required"`
Expand Down Expand Up @@ -322,7 +338,7 @@ func (r memberDeleteResponseJSON) RawJSON() string {
}

type MemberNewParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
// The contact email address of the user.
Email param.Field[string] `json:"email,required"`
// Array of roles associated with this member.
Expand Down Expand Up @@ -393,8 +409,8 @@ func (r MemberNewResponseEnvelopeSuccess) IsKnown() bool {
}

type MemberUpdateParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
Member shared.MemberParam `json:"member,required"`
AccountID param.Field[string] `path:"account_id,required"`
Member shared.MemberParam `json:"member,required"`
}

func (r MemberUpdateParams) MarshalJSON() (data []byte, err error) {
Expand Down Expand Up @@ -445,7 +461,7 @@ func (r MemberUpdateResponseEnvelopeSuccess) IsKnown() bool {
}

type MemberListParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
// Direction to order results.
Direction param.Field[MemberListParamsDirection] `query:"direction"`
// Field to order results by.
Expand Down Expand Up @@ -518,12 +534,7 @@ func (r MemberListParamsStatus) IsKnown() bool {
}

type MemberDeleteParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
Body interface{} `json:"body,required"`
}

func (r MemberDeleteParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.Body)
AccountID param.Field[string] `path:"account_id,required"`
}

type MemberDeleteResponseEnvelope struct {
Expand Down Expand Up @@ -570,7 +581,7 @@ func (r MemberDeleteResponseEnvelopeSuccess) IsKnown() bool {
}

type MemberGetParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
}

type MemberGetResponseEnvelope struct {
Expand Down
19 changes: 7 additions & 12 deletions accounts/member_test.go
Expand Up @@ -10,13 +10,12 @@ import (

"github.com/cloudflare/cloudflare-go/v2"
"github.com/cloudflare/cloudflare-go/v2/accounts"
"github.com/cloudflare/cloudflare-go/v2/internal/shared"
"github.com/cloudflare/cloudflare-go/v2/internal/testutil"
"github.com/cloudflare/cloudflare-go/v2/option"
"github.com/cloudflare/cloudflare-go/v2/shared"
)

func TestMemberNewWithOptionalParams(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
Expand All @@ -30,7 +29,7 @@ func TestMemberNewWithOptionalParams(t *testing.T) {
option.WithAPIEmail("user@example.com"),
)
_, err := client.Accounts.Members.New(context.TODO(), accounts.MemberNewParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
AccountID: cloudflare.F("string"),
Email: cloudflare.F("user@example.com"),
Roles: cloudflare.F([]string{"3536bcfad5faccb999b47003c79917fb", "3536bcfad5faccb999b47003c79917fb", "3536bcfad5faccb999b47003c79917fb"}),
Status: cloudflare.F(accounts.MemberNewParamsStatusAccepted),
Expand All @@ -45,7 +44,7 @@ func TestMemberNewWithOptionalParams(t *testing.T) {
}

func TestMemberUpdate(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
t.Skip("TODO: investigate broken test")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand All @@ -62,7 +61,7 @@ func TestMemberUpdate(t *testing.T) {
context.TODO(),
"4536bcfad5faccb111b47003c79917fa",
accounts.MemberUpdateParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
AccountID: cloudflare.F("string"),
Member: shared.MemberParam{
Roles: cloudflare.F([]shared.MemberRoleParam{{
ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"),
Expand All @@ -84,7 +83,6 @@ func TestMemberUpdate(t *testing.T) {
}

func TestMemberListWithOptionalParams(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
Expand All @@ -98,7 +96,7 @@ func TestMemberListWithOptionalParams(t *testing.T) {
option.WithAPIEmail("user@example.com"),
)
_, err := client.Accounts.Members.List(context.TODO(), accounts.MemberListParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
AccountID: cloudflare.F("string"),
Direction: cloudflare.F(accounts.MemberListParamsDirectionDesc),
Order: cloudflare.F(accounts.MemberListParamsOrderStatus),
Page: cloudflare.F(1.000000),
Expand All @@ -115,7 +113,6 @@ func TestMemberListWithOptionalParams(t *testing.T) {
}

func TestMemberDelete(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
Expand All @@ -132,8 +129,7 @@ func TestMemberDelete(t *testing.T) {
context.TODO(),
"4536bcfad5faccb111b47003c79917fa",
accounts.MemberDeleteParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
Body: map[string]interface{}{},
AccountID: cloudflare.F("string"),
},
)
if err != nil {
Expand All @@ -146,7 +142,6 @@ func TestMemberDelete(t *testing.T) {
}

func TestMemberGet(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
Expand All @@ -163,7 +158,7 @@ func TestMemberGet(t *testing.T) {
context.TODO(),
"4536bcfad5faccb111b47003c79917fa",
accounts.MemberGetParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
AccountID: cloudflare.F("string"),
},
)
if err != nil {
Expand Down

0 comments on commit de79501

Please sign in to comment.