-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(internal): codegen related update (#3024)
- Loading branch information
1 parent
581f621
commit e41904d
Showing
1,138 changed files
with
201,338 additions
and
206,060 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,154 +3,154 @@ | |
package accounts_test | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
"testing" | ||
"context" | ||
"errors" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cloudflare/cloudflare-go/v2" | ||
"github.com/cloudflare/cloudflare-go/v2/accounts" | ||
"github.com/cloudflare/cloudflare-go/v2/internal/testutil" | ||
"github.com/cloudflare/cloudflare-go/v2/option" | ||
"github.com/cloudflare/cloudflare-go/v2" | ||
"github.com/cloudflare/cloudflare-go/v2/accounts" | ||
"github.com/cloudflare/cloudflare-go/v2/internal/testutil" | ||
"github.com/cloudflare/cloudflare-go/v2/option" | ||
) | ||
|
||
func TestAccountNewWithOptionalParams(t *testing.T) { | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.New(context.TODO(), accounts.AccountNewParams{ | ||
Name: cloudflare.F("name"), | ||
Type: cloudflare.F(accounts.AccountNewParamsTypeStandard), | ||
Unit: cloudflare.F(accounts.AccountNewParamsUnit{ | ||
ID: cloudflare.F("f267e341f3dd4697bd3b9f71dd96247f"), | ||
}), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.New(context.TODO(), accounts.AccountNewParams{ | ||
Name: cloudflare.F("name"), | ||
Type: cloudflare.F(accounts.AccountNewParamsTypeStandard), | ||
Unit: cloudflare.F(accounts.AccountNewParamsUnit{ | ||
ID: cloudflare.F("f267e341f3dd4697bd3b9f71dd96247f"), | ||
}), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
} | ||
|
||
func TestAccountUpdateWithOptionalParams(t *testing.T) { | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.Update(context.TODO(), accounts.AccountUpdateParams{ | ||
AccountID: cloudflare.F("eb78d65290b24279ba6f44721b3ea3c4"), | ||
Account: accounts.AccountParam{ | ||
Name: cloudflare.F("Demo Account"), | ||
Settings: cloudflare.F(accounts.AccountSettingsParam{ | ||
AbuseContactEmail: cloudflare.F("abuse_contact_email"), | ||
DefaultNameservers: cloudflare.F(accounts.AccountSettingsDefaultNameserversCloudflareStandard), | ||
EnforceTwofactor: cloudflare.F(true), | ||
UseAccountCustomNSByDefault: cloudflare.F(true), | ||
}), | ||
}, | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.Update(context.TODO(), accounts.AccountUpdateParams{ | ||
AccountID: cloudflare.F("eb78d65290b24279ba6f44721b3ea3c4"), | ||
Account: accounts.AccountParam{ | ||
Name: cloudflare.F("Demo Account"), | ||
Settings: cloudflare.F(accounts.AccountSettingsParam{ | ||
AbuseContactEmail: cloudflare.F("abuse_contact_email"), | ||
DefaultNameservers: cloudflare.F(accounts.AccountSettingsDefaultNameserversCloudflareStandard), | ||
EnforceTwofactor: cloudflare.F(true), | ||
UseAccountCustomNSByDefault: cloudflare.F(true), | ||
}), | ||
}, | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
} | ||
|
||
func TestAccountListWithOptionalParams(t *testing.T) { | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{ | ||
Direction: cloudflare.F(accounts.AccountListParamsDirectionAsc), | ||
Name: cloudflare.F("example.com"), | ||
Page: cloudflare.F(1.000000), | ||
PerPage: cloudflare.F(5.000000), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{ | ||
Direction: cloudflare.F(accounts.AccountListParamsDirectionAsc), | ||
Name: cloudflare.F("example.com"), | ||
Page: cloudflare.F(1.000000), | ||
PerPage: cloudflare.F(5.000000), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
} | ||
|
||
func TestAccountDelete(t *testing.T) { | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.Delete(context.TODO(), accounts.AccountDeleteParams{ | ||
AccountID: cloudflare.F("account_id"), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.Delete(context.TODO(), accounts.AccountDeleteParams{ | ||
AccountID: cloudflare.F("account_id"), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
} | ||
|
||
func TestAccountGet(t *testing.T) { | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.Get(context.TODO(), accounts.AccountGetParams{ | ||
AccountID: cloudflare.F("eb78d65290b24279ba6f44721b3ea3c4"), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), | ||
option.WithAPIEmail("[email protected]"), | ||
) | ||
_, err := client.Accounts.Get(context.TODO(), accounts.AccountGetParams{ | ||
AccountID: cloudflare.F("eb78d65290b24279ba6f44721b3ea3c4"), | ||
}) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
} |
Oops, something went wrong.