Skip to content

Commit fe3eb4e

Browse files
chore(api): update composite API spec
1 parent 38a87ce commit fe3eb4e

File tree

201 files changed

+18358
-5558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+18358
-5558
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1857
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ca8fbfa82d19dca400ec61b8c93392de1acd157860e435419f9a5e9ec8c586e0.yml
3-
openapi_spec_hash: 77d55c70bc3824ac61bd056e2319ee18
1+
configured_endpoints: 1883
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c17ba1999aa95652686a2474ad415475d728e5c831b79be5e540a82887b024a0.yml
3+
openapi_spec_hash: b68c7fcf549383e09823c071b1f2e037
44
config_hash: 4b8075dcc6a5884435b2e16c80fc020f

abuse_reports/abusereport.go

Lines changed: 1125 additions & 0 deletions
Large diffs are not rendered by default.

abuse_reports/abusereport_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package abuse_reports_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v6"
12+
"github.com/cloudflare/cloudflare-go/v6/abuse_reports"
13+
"github.com/cloudflare/cloudflare-go/v6/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v6/option"
15+
)
16+
17+
func TestAbuseReportNewWithOptionalParams(t *testing.T) {
18+
t.Skip("TODO: investigate unauthorized HTTP response")
19+
baseURL := "http://localhost:4010"
20+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
21+
baseURL = envURL
22+
}
23+
if !testutil.CheckTestServer(t, baseURL) {
24+
return
25+
}
26+
client := cloudflare.NewClient(
27+
option.WithBaseURL(baseURL),
28+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
29+
option.WithAPIEmail("user@example.com"),
30+
)
31+
_, err := client.AbuseReports.New(
32+
context.TODO(),
33+
"report_param",
34+
abuse_reports.AbuseReportNewParams{
35+
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
36+
Body: abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReport{
37+
Act: cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportActAbuseDmca),
38+
Address1: cloudflare.F("x"),
39+
AgentName: cloudflare.F("x"),
40+
Agree: cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportAgree1),
41+
City: cloudflare.F("x"),
42+
Country: cloudflare.F("x"),
43+
Email: cloudflare.F("email"),
44+
Email2: cloudflare.F("email2"),
45+
HostNotification: cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportHostNotificationSend),
46+
Name: cloudflare.F("x"),
47+
OriginalWork: cloudflare.F("x"),
48+
OwnerNotification: cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportOwnerNotificationSend),
49+
Signature: cloudflare.F("signature"),
50+
State: cloudflare.F("x"),
51+
URLs: cloudflare.F("urls"),
52+
Comments: cloudflare.F("x"),
53+
Company: cloudflare.F("x"),
54+
ReportedCountry: cloudflare.F("xx"),
55+
ReportedUserAgent: cloudflare.F("x"),
56+
Tele: cloudflare.F("x"),
57+
Title: cloudflare.F("x"),
58+
},
59+
},
60+
)
61+
if err != nil {
62+
var apierr *cloudflare.Error
63+
if errors.As(err, &apierr) {
64+
t.Log(string(apierr.DumpRequest(true)))
65+
}
66+
t.Fatalf("err should be nil: %s", err.Error())
67+
}
68+
}

accounts/account.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ type Account struct {
149149
Type AccountType `json:"type,required"`
150150
// Timestamp for the creation of the account
151151
CreatedOn time.Time `json:"created_on" format:"date-time"`
152+
// Parent container details
153+
ManagedBy AccountManagedBy `json:"managed_by"`
152154
// Account settings
153155
Settings AccountSettings `json:"settings"`
154156
JSON accountJSON `json:"-"`
@@ -160,6 +162,7 @@ type accountJSON struct {
160162
Name apijson.Field
161163
Type apijson.Field
162164
CreatedOn apijson.Field
165+
ManagedBy apijson.Field
163166
Settings apijson.Field
164167
raw string
165168
ExtraFields map[string]apijson.Field
@@ -188,6 +191,32 @@ func (r AccountType) IsKnown() bool {
188191
return false
189192
}
190193

194+
// Parent container details
195+
type AccountManagedBy struct {
196+
// ID of the parent Organization, if one exists
197+
ParentOrgID string `json:"parent_org_id"`
198+
// Name of the parent Organization, if one exists
199+
ParentOrgName string `json:"parent_org_name"`
200+
JSON accountManagedByJSON `json:"-"`
201+
}
202+
203+
// accountManagedByJSON contains the JSON metadata for the struct
204+
// [AccountManagedBy]
205+
type accountManagedByJSON struct {
206+
ParentOrgID apijson.Field
207+
ParentOrgName apijson.Field
208+
raw string
209+
ExtraFields map[string]apijson.Field
210+
}
211+
212+
func (r *AccountManagedBy) UnmarshalJSON(data []byte) (err error) {
213+
return apijson.UnmarshalRoot(data, r)
214+
}
215+
216+
func (r accountManagedByJSON) RawJSON() string {
217+
return r.raw
218+
}
219+
191220
// Account settings
192221
type AccountSettings struct {
193222
// Sets an abuse contact email to notify for abuse reports.
@@ -220,6 +249,8 @@ type AccountParam struct {
220249
// Account name
221250
Name param.Field[string] `json:"name,required"`
222251
Type param.Field[AccountType] `json:"type,required"`
252+
// Parent container details
253+
ManagedBy param.Field[AccountManagedByParam] `json:"managed_by"`
223254
// Account settings
224255
Settings param.Field[AccountSettingsParam] `json:"settings"`
225256
}
@@ -228,6 +259,14 @@ func (r AccountParam) MarshalJSON() (data []byte, err error) {
228259
return apijson.MarshalRoot(r)
229260
}
230261

262+
// Parent container details
263+
type AccountManagedByParam struct {
264+
}
265+
266+
func (r AccountManagedByParam) MarshalJSON() (data []byte, err error) {
267+
return apijson.MarshalRoot(r)
268+
}
269+
231270
// Account settings
232271
type AccountSettingsParam struct {
233272
// Sets an abuse contact email to notify for abuse reports.

accounts/account_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ func TestAccountUpdateWithOptionalParams(t *testing.T) {
5959
_, err := client.Accounts.Update(context.TODO(), accounts.AccountUpdateParams{
6060
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
6161
Account: accounts.AccountParam{
62-
ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
63-
Name: cloudflare.F("Demo Account"),
64-
Type: cloudflare.F(accounts.AccountTypeStandard),
62+
ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
63+
Name: cloudflare.F("Demo Account"),
64+
Type: cloudflare.F(accounts.AccountTypeStandard),
65+
ManagedBy: cloudflare.F(accounts.AccountManagedByParam{}),
6566
Settings: cloudflare.F(accounts.AccountSettingsParam{
6667
AbuseContactEmail: cloudflare.F("abuse_contact_email"),
6768
EnforceTwofactor: cloudflare.F(true),

accounts/accountorganization.go

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/cloudflare/cloudflare-go/v6/internal/param"
1414
"github.com/cloudflare/cloudflare-go/v6/internal/requestconfig"
1515
"github.com/cloudflare/cloudflare-go/v6/option"
16+
"github.com/cloudflare/cloudflare-go/v6/shared"
1617
)
1718

1819
// AccountOrganizationService contains methods and other services that help with
@@ -35,19 +36,49 @@ func NewAccountOrganizationService(opts ...option.RequestOption) (r *AccountOrga
3536
}
3637

3738
// Move an account within an organization hierarchy or an account outside an
38-
// organization.
39-
func (r *AccountOrganizationService) New(ctx context.Context, params AccountOrganizationNewParams, opts ...option.RequestOption) (err error) {
39+
// organization. (Currently in Closed Beta - see
40+
// https://developers.cloudflare.com/fundamentals/organizations/)
41+
func (r *AccountOrganizationService) New(ctx context.Context, params AccountOrganizationNewParams, opts ...option.RequestOption) (res *AccountOrganizationNewResponse, err error) {
42+
var env AccountOrganizationNewResponseEnvelope
4043
opts = slices.Concat(r.Options, opts)
41-
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
4244
if params.AccountID.Value == "" {
4345
err = errors.New("missing required account_id parameter")
4446
return
4547
}
4648
path := fmt.Sprintf("accounts/%s/move", params.AccountID)
47-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...)
49+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...)
50+
if err != nil {
51+
return
52+
}
53+
res = &env.Result
4854
return
4955
}
5056

57+
type AccountOrganizationNewResponse struct {
58+
AccountID string `json:"account_id,required"`
59+
DestinationOrganizationID string `json:"destination_organization_id,required"`
60+
SourceOrganizationID string `json:"source_organization_id,required"`
61+
JSON accountOrganizationNewResponseJSON `json:"-"`
62+
}
63+
64+
// accountOrganizationNewResponseJSON contains the JSON metadata for the struct
65+
// [AccountOrganizationNewResponse]
66+
type accountOrganizationNewResponseJSON struct {
67+
AccountID apijson.Field
68+
DestinationOrganizationID apijson.Field
69+
SourceOrganizationID apijson.Field
70+
raw string
71+
ExtraFields map[string]apijson.Field
72+
}
73+
74+
func (r *AccountOrganizationNewResponse) UnmarshalJSON(data []byte) (err error) {
75+
return apijson.UnmarshalRoot(data, r)
76+
}
77+
78+
func (r accountOrganizationNewResponseJSON) RawJSON() string {
79+
return r.raw
80+
}
81+
5182
type AccountOrganizationNewParams struct {
5283
AccountID param.Field[string] `path:"account_id,required"`
5384
DestinationOrganizationID param.Field[string] `json:"destination_organization_id,required"`
@@ -56,3 +87,44 @@ type AccountOrganizationNewParams struct {
5687
func (r AccountOrganizationNewParams) MarshalJSON() (data []byte, err error) {
5788
return apijson.MarshalRoot(r)
5889
}
90+
91+
type AccountOrganizationNewResponseEnvelope struct {
92+
Errors []interface{} `json:"errors,required"`
93+
Messages []shared.ResponseInfo `json:"messages,required"`
94+
Result AccountOrganizationNewResponse `json:"result,required"`
95+
Success AccountOrganizationNewResponseEnvelopeSuccess `json:"success,required"`
96+
JSON accountOrganizationNewResponseEnvelopeJSON `json:"-"`
97+
}
98+
99+
// accountOrganizationNewResponseEnvelopeJSON contains the JSON metadata for the
100+
// struct [AccountOrganizationNewResponseEnvelope]
101+
type accountOrganizationNewResponseEnvelopeJSON struct {
102+
Errors apijson.Field
103+
Messages apijson.Field
104+
Result apijson.Field
105+
Success apijson.Field
106+
raw string
107+
ExtraFields map[string]apijson.Field
108+
}
109+
110+
func (r *AccountOrganizationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
111+
return apijson.UnmarshalRoot(data, r)
112+
}
113+
114+
func (r accountOrganizationNewResponseEnvelopeJSON) RawJSON() string {
115+
return r.raw
116+
}
117+
118+
type AccountOrganizationNewResponseEnvelopeSuccess bool
119+
120+
const (
121+
AccountOrganizationNewResponseEnvelopeSuccessTrue AccountOrganizationNewResponseEnvelopeSuccess = true
122+
)
123+
124+
func (r AccountOrganizationNewResponseEnvelopeSuccess) IsKnown() bool {
125+
switch r {
126+
case AccountOrganizationNewResponseEnvelopeSuccessTrue:
127+
return true
128+
}
129+
return false
130+
}

accounts/accountorganization_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestAccountOrganizationNew(t *testing.T) {
2727
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
2828
option.WithAPIEmail("user@example.com"),
2929
)
30-
err := client.Accounts.AccountOrganizations.New(context.TODO(), accounts.AccountOrganizationNewParams{
30+
_, err := client.Accounts.AccountOrganizations.New(context.TODO(), accounts.AccountOrganizationNewParams{
3131
AccountID: cloudflare.F("account_id"),
3232
DestinationOrganizationID: cloudflare.F("destination_organization_id"),
3333
})

0 commit comments

Comments
 (0)