Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 795c296

Browse files
committedMar 13, 2025
feat(api): manual updates (#4006)
1 parent f6c7489 commit 795c296

27 files changed

+3509
-4
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1571
1+
configured_endpoints: 1603
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-90e340b831573a4b2cb1327a72bdb7ac34d744f89ab29828978c0c3abcff1441.yml

‎api.md

+160
Large diffs are not rendered by default.

‎cloudforce_one/cloudforceone.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import (
1313
// automatically. You should not instantiate this service directly, and instead use
1414
// the [NewCloudforceOneService] method instead.
1515
type CloudforceOneService struct {
16-
Options []option.RequestOption
17-
Scans *ScanService
18-
Requests *RequestService
16+
Options []option.RequestOption
17+
Scans *ScanService
18+
Requests *RequestService
19+
ThreatEvents *ThreatEventService
1920
}
2021

2122
// NewCloudforceOneService generates a new service that applies the given options
@@ -26,5 +27,6 @@ func NewCloudforceOneService(opts ...option.RequestOption) (r *CloudforceOneServ
2627
r.Options = opts
2728
r.Scans = NewScanService(opts...)
2829
r.Requests = NewRequestService(opts...)
30+
r.ThreatEvents = NewThreatEventService(opts...)
2931
return
3032
}

‎cloudforce_one/threatevent.go

+510
Large diffs are not rendered by default.

‎cloudforce_one/threatevent_test.go

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
"time"
11+
12+
"github.com/cloudflare/cloudflare-go/v4"
13+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
14+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
15+
"github.com/cloudflare/cloudflare-go/v4/option"
16+
)
17+
18+
func TestThreatEventNewWithOptionalParams(t *testing.T) {
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.CloudforceOne.ThreatEvents.New(
32+
context.TODO(),
33+
0.000000,
34+
cloudforce_one.ThreatEventNewParams{
35+
Attacker: cloudflare.F("Flying Yeti"),
36+
AttackerCountry: cloudflare.F("CN"),
37+
Category: cloudflare.F("Domain Resolution"),
38+
Date: cloudflare.F(time.Now()),
39+
Event: cloudflare.F("An attacker registered the domain domain.com"),
40+
IndicatorType: cloudflare.F("domain"),
41+
Raw: cloudflare.F(cloudforce_one.ThreatEventNewParamsRaw{
42+
Data: cloudflare.F[any](map[string]interface{}{}),
43+
Source: cloudflare.F("example.com"),
44+
TLP: cloudflare.F("amber"),
45+
}),
46+
TLP: cloudflare.F("amber"),
47+
AccountID: cloudflare.F(123456.000000),
48+
DatasetID: cloudflare.F("durableObjectName"),
49+
Indicator: cloudflare.F("domain.com"),
50+
Tags: cloudflare.F([]string{"malware"}),
51+
TargetCountry: cloudflare.F("US"),
52+
TargetIndustry: cloudflare.F("Agriculture"),
53+
},
54+
)
55+
if err != nil {
56+
var apierr *cloudflare.Error
57+
if errors.As(err, &apierr) {
58+
t.Log(string(apierr.DumpRequest(true)))
59+
}
60+
t.Fatalf("err should be nil: %s", err.Error())
61+
}
62+
}
63+
64+
func TestThreatEventUpdateWithOptionalParams(t *testing.T) {
65+
baseURL := "http://localhost:4010"
66+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
67+
baseURL = envURL
68+
}
69+
if !testutil.CheckTestServer(t, baseURL) {
70+
return
71+
}
72+
client := cloudflare.NewClient(
73+
option.WithBaseURL(baseURL),
74+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
75+
option.WithAPIEmail("user@example.com"),
76+
)
77+
_, err := client.CloudforceOne.ThreatEvents.Update(
78+
context.TODO(),
79+
0.000000,
80+
"eventId",
81+
cloudforce_one.ThreatEventUpdateParams{
82+
Attacker: cloudflare.F("Flying Yeti"),
83+
AttackerCountry: cloudflare.F("CN"),
84+
Category: cloudflare.F("Domain Resolution"),
85+
Date: cloudflare.F(time.Now()),
86+
Event: cloudflare.F("An attacker registered the domain domain.com"),
87+
Indicator: cloudflare.F("domain2.com"),
88+
IndicatorType: cloudflare.F("sha256"),
89+
TargetCountry: cloudflare.F("US"),
90+
TargetIndustry: cloudflare.F("Insurance"),
91+
TLP: cloudflare.F("amber"),
92+
},
93+
)
94+
if err != nil {
95+
var apierr *cloudflare.Error
96+
if errors.As(err, &apierr) {
97+
t.Log(string(apierr.DumpRequest(true)))
98+
}
99+
t.Fatalf("err should be nil: %s", err.Error())
100+
}
101+
}
102+
103+
func TestThreatEventDelete(t *testing.T) {
104+
baseURL := "http://localhost:4010"
105+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
106+
baseURL = envURL
107+
}
108+
if !testutil.CheckTestServer(t, baseURL) {
109+
return
110+
}
111+
client := cloudflare.NewClient(
112+
option.WithBaseURL(baseURL),
113+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
114+
option.WithAPIEmail("user@example.com"),
115+
)
116+
_, err := client.CloudforceOne.ThreatEvents.Delete(
117+
context.TODO(),
118+
0.000000,
119+
"eventId",
120+
)
121+
if err != nil {
122+
var apierr *cloudflare.Error
123+
if errors.As(err, &apierr) {
124+
t.Log(string(apierr.DumpRequest(true)))
125+
}
126+
t.Fatalf("err should be nil: %s", err.Error())
127+
}
128+
}
129+
130+
func TestThreatEventBulkNew(t *testing.T) {
131+
baseURL := "http://localhost:4010"
132+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
133+
baseURL = envURL
134+
}
135+
if !testutil.CheckTestServer(t, baseURL) {
136+
return
137+
}
138+
client := cloudflare.NewClient(
139+
option.WithBaseURL(baseURL),
140+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
141+
option.WithAPIEmail("user@example.com"),
142+
)
143+
_, err := client.CloudforceOne.ThreatEvents.BulkNew(
144+
context.TODO(),
145+
0.000000,
146+
cloudforce_one.ThreatEventBulkNewParams{
147+
Data: cloudflare.F([]cloudforce_one.ThreatEventBulkNewParamsData{{
148+
Attacker: cloudflare.F("Flying Yeti"),
149+
AttackerCountry: cloudflare.F("CN"),
150+
Category: cloudflare.F("Domain Resolution"),
151+
Date: cloudflare.F(time.Now()),
152+
Event: cloudflare.F("An attacker registered the domain domain.com"),
153+
IndicatorType: cloudflare.F("domain"),
154+
Raw: cloudflare.F(cloudforce_one.ThreatEventBulkNewParamsDataRaw{
155+
Data: cloudflare.F[any](map[string]interface{}{}),
156+
Source: cloudflare.F("example.com"),
157+
TLP: cloudflare.F("amber"),
158+
}),
159+
TLP: cloudflare.F("amber"),
160+
AccountID: cloudflare.F(123456.000000),
161+
DatasetID: cloudflare.F("durableObjectName"),
162+
Indicator: cloudflare.F("domain.com"),
163+
Tags: cloudflare.F([]string{"malware"}),
164+
TargetCountry: cloudflare.F("US"),
165+
TargetIndustry: cloudflare.F("Agriculture"),
166+
}}),
167+
DatasetID: cloudflare.F("durableObjectName"),
168+
},
169+
)
170+
if err != nil {
171+
var apierr *cloudflare.Error
172+
if errors.As(err, &apierr) {
173+
t.Log(string(apierr.DumpRequest(true)))
174+
}
175+
t.Fatalf("err should be nil: %s", err.Error())
176+
}
177+
}
178+
179+
func TestThreatEventGet(t *testing.T) {
180+
baseURL := "http://localhost:4010"
181+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
182+
baseURL = envURL
183+
}
184+
if !testutil.CheckTestServer(t, baseURL) {
185+
return
186+
}
187+
client := cloudflare.NewClient(
188+
option.WithBaseURL(baseURL),
189+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
190+
option.WithAPIEmail("user@example.com"),
191+
)
192+
_, err := client.CloudforceOne.ThreatEvents.Get(
193+
context.TODO(),
194+
0.000000,
195+
"eventId",
196+
)
197+
if err != nil {
198+
var apierr *cloudflare.Error
199+
if errors.As(err, &apierr) {
200+
t.Log(string(apierr.DumpRequest(true)))
201+
}
202+
t.Fatalf("err should be nil: %s", err.Error())
203+
}
204+
}

‎cloudforce_one/threateventattacker.go

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"net/http"
9+
10+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
11+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
12+
"github.com/cloudflare/cloudflare-go/v4/option"
13+
)
14+
15+
// ThreatEventAttackerService contains methods and other services that help with
16+
// interacting with the cloudflare API.
17+
//
18+
// Note, unlike clients, this service does not read variables from the environment
19+
// automatically. You should not instantiate this service directly, and instead use
20+
// the [NewThreatEventAttackerService] method instead.
21+
type ThreatEventAttackerService struct {
22+
Options []option.RequestOption
23+
}
24+
25+
// NewThreatEventAttackerService generates a new service that applies the given
26+
// options to each request. These options are applied after the parent client's
27+
// options (if there is one), and before any request-specific options.
28+
func NewThreatEventAttackerService(opts ...option.RequestOption) (r *ThreatEventAttackerService) {
29+
r = &ThreatEventAttackerService{}
30+
r.Options = opts
31+
return
32+
}
33+
34+
// Lists attackers
35+
func (r *ThreatEventAttackerService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *ThreatEventAttackerListResponse, err error) {
36+
opts = append(r.Options[:], opts...)
37+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/attackers", accountID)
38+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
39+
return
40+
}
41+
42+
type ThreatEventAttackerListResponse struct {
43+
Items ThreatEventAttackerListResponseItems `json:"items,required"`
44+
Type string `json:"type,required"`
45+
JSON threatEventAttackerListResponseJSON `json:"-"`
46+
}
47+
48+
// threatEventAttackerListResponseJSON contains the JSON metadata for the struct
49+
// [ThreatEventAttackerListResponse]
50+
type threatEventAttackerListResponseJSON struct {
51+
Items apijson.Field
52+
Type apijson.Field
53+
raw string
54+
ExtraFields map[string]apijson.Field
55+
}
56+
57+
func (r *ThreatEventAttackerListResponse) UnmarshalJSON(data []byte) (err error) {
58+
return apijson.UnmarshalRoot(data, r)
59+
}
60+
61+
func (r threatEventAttackerListResponseJSON) RawJSON() string {
62+
return r.raw
63+
}
64+
65+
type ThreatEventAttackerListResponseItems struct {
66+
Type string `json:"type,required"`
67+
JSON threatEventAttackerListResponseItemsJSON `json:"-"`
68+
}
69+
70+
// threatEventAttackerListResponseItemsJSON contains the JSON metadata for the
71+
// struct [ThreatEventAttackerListResponseItems]
72+
type threatEventAttackerListResponseItemsJSON struct {
73+
Type apijson.Field
74+
raw string
75+
ExtraFields map[string]apijson.Field
76+
}
77+
78+
func (r *ThreatEventAttackerListResponseItems) UnmarshalJSON(data []byte) (err error) {
79+
return apijson.UnmarshalRoot(data, r)
80+
}
81+
82+
func (r threatEventAttackerListResponseItemsJSON) RawJSON() string {
83+
return r.raw
84+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/option"
14+
)
15+
16+
func TestThreatEventAttackerList(t *testing.T) {
17+
baseURL := "http://localhost:4010"
18+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
19+
baseURL = envURL
20+
}
21+
if !testutil.CheckTestServer(t, baseURL) {
22+
return
23+
}
24+
client := cloudflare.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
27+
option.WithAPIEmail("user@example.com"),
28+
)
29+
_, err := client.CloudforceOne.ThreatEvents.Attackers.List(context.TODO(), 0.000000)
30+
if err != nil {
31+
var apierr *cloudflare.Error
32+
if errors.As(err, &apierr) {
33+
t.Log(string(apierr.DumpRequest(true)))
34+
}
35+
t.Fatalf("err should be nil: %s", err.Error())
36+
}
37+
}

‎cloudforce_one/threateventcategory.go

+245
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
// ThreatEventCategoryService contains methods and other services that help with
18+
// interacting with the cloudflare API.
19+
//
20+
// Note, unlike clients, this service does not read variables from the environment
21+
// automatically. You should not instantiate this service directly, and instead use
22+
// the [NewThreatEventCategoryService] method instead.
23+
type ThreatEventCategoryService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventCategoryService generates a new service that applies the given
28+
// options to each request. These options are applied after the parent client's
29+
// options (if there is one), and before any request-specific options.
30+
func NewThreatEventCategoryService(opts ...option.RequestOption) (r *ThreatEventCategoryService) {
31+
r = &ThreatEventCategoryService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Creates a new category
37+
func (r *ThreatEventCategoryService) New(ctx context.Context, accountID float64, body ThreatEventCategoryNewParams, opts ...option.RequestOption) (res *ThreatEventCategoryNewResponse, err error) {
38+
opts = append(r.Options[:], opts...)
39+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/categories/create", accountID)
40+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
41+
return
42+
}
43+
44+
// Updates a category
45+
func (r *ThreatEventCategoryService) Update(ctx context.Context, accountID float64, categoryID string, body ThreatEventCategoryUpdateParams, opts ...option.RequestOption) (res *ThreatEventCategoryUpdateResponse, err error) {
46+
opts = append(r.Options[:], opts...)
47+
if categoryID == "" {
48+
err = errors.New("missing required categoryId parameter")
49+
return
50+
}
51+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/categories/%s", accountID, categoryID)
52+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
53+
return
54+
}
55+
56+
// Lists categories
57+
func (r *ThreatEventCategoryService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *[]ThreatEventCategoryListResponse, err error) {
58+
opts = append(r.Options[:], opts...)
59+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/categories", accountID)
60+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
61+
return
62+
}
63+
64+
// Deletes a category
65+
func (r *ThreatEventCategoryService) Delete(ctx context.Context, accountID float64, categoryID string, opts ...option.RequestOption) (res *ThreatEventCategoryDeleteResponse, err error) {
66+
opts = append(r.Options[:], opts...)
67+
if categoryID == "" {
68+
err = errors.New("missing required categoryId parameter")
69+
return
70+
}
71+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/categories/%s", accountID, categoryID)
72+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
73+
return
74+
}
75+
76+
// Reads a category
77+
func (r *ThreatEventCategoryService) Get(ctx context.Context, accountID float64, categoryID string, opts ...option.RequestOption) (res *ThreatEventCategoryGetResponse, err error) {
78+
opts = append(r.Options[:], opts...)
79+
if categoryID == "" {
80+
err = errors.New("missing required categoryId parameter")
81+
return
82+
}
83+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/categories/%s", accountID, categoryID)
84+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
85+
return
86+
}
87+
88+
type ThreatEventCategoryNewResponse struct {
89+
KillChain float64 `json:"killChain,required"`
90+
Name string `json:"name,required"`
91+
UUID string `json:"uuid,required"`
92+
MitreAttack []string `json:"mitreAttack"`
93+
Shortname string `json:"shortname"`
94+
JSON threatEventCategoryNewResponseJSON `json:"-"`
95+
}
96+
97+
// threatEventCategoryNewResponseJSON contains the JSON metadata for the struct
98+
// [ThreatEventCategoryNewResponse]
99+
type threatEventCategoryNewResponseJSON struct {
100+
KillChain apijson.Field
101+
Name apijson.Field
102+
UUID apijson.Field
103+
MitreAttack apijson.Field
104+
Shortname apijson.Field
105+
raw string
106+
ExtraFields map[string]apijson.Field
107+
}
108+
109+
func (r *ThreatEventCategoryNewResponse) UnmarshalJSON(data []byte) (err error) {
110+
return apijson.UnmarshalRoot(data, r)
111+
}
112+
113+
func (r threatEventCategoryNewResponseJSON) RawJSON() string {
114+
return r.raw
115+
}
116+
117+
type ThreatEventCategoryUpdateResponse struct {
118+
KillChain float64 `json:"killChain,required"`
119+
Name string `json:"name,required"`
120+
UUID string `json:"uuid,required"`
121+
MitreAttack []string `json:"mitreAttack"`
122+
Shortname string `json:"shortname"`
123+
JSON threatEventCategoryUpdateResponseJSON `json:"-"`
124+
}
125+
126+
// threatEventCategoryUpdateResponseJSON contains the JSON metadata for the struct
127+
// [ThreatEventCategoryUpdateResponse]
128+
type threatEventCategoryUpdateResponseJSON struct {
129+
KillChain apijson.Field
130+
Name apijson.Field
131+
UUID apijson.Field
132+
MitreAttack apijson.Field
133+
Shortname apijson.Field
134+
raw string
135+
ExtraFields map[string]apijson.Field
136+
}
137+
138+
func (r *ThreatEventCategoryUpdateResponse) UnmarshalJSON(data []byte) (err error) {
139+
return apijson.UnmarshalRoot(data, r)
140+
}
141+
142+
func (r threatEventCategoryUpdateResponseJSON) RawJSON() string {
143+
return r.raw
144+
}
145+
146+
type ThreatEventCategoryListResponse struct {
147+
KillChain float64 `json:"killChain,required"`
148+
Name string `json:"name,required"`
149+
UUID string `json:"uuid,required"`
150+
MitreAttack []string `json:"mitreAttack"`
151+
Shortname string `json:"shortname"`
152+
JSON threatEventCategoryListResponseJSON `json:"-"`
153+
}
154+
155+
// threatEventCategoryListResponseJSON contains the JSON metadata for the struct
156+
// [ThreatEventCategoryListResponse]
157+
type threatEventCategoryListResponseJSON struct {
158+
KillChain apijson.Field
159+
Name apijson.Field
160+
UUID apijson.Field
161+
MitreAttack apijson.Field
162+
Shortname apijson.Field
163+
raw string
164+
ExtraFields map[string]apijson.Field
165+
}
166+
167+
func (r *ThreatEventCategoryListResponse) UnmarshalJSON(data []byte) (err error) {
168+
return apijson.UnmarshalRoot(data, r)
169+
}
170+
171+
func (r threatEventCategoryListResponseJSON) RawJSON() string {
172+
return r.raw
173+
}
174+
175+
type ThreatEventCategoryDeleteResponse struct {
176+
UUID string `json:"uuid,required"`
177+
JSON threatEventCategoryDeleteResponseJSON `json:"-"`
178+
}
179+
180+
// threatEventCategoryDeleteResponseJSON contains the JSON metadata for the struct
181+
// [ThreatEventCategoryDeleteResponse]
182+
type threatEventCategoryDeleteResponseJSON struct {
183+
UUID apijson.Field
184+
raw string
185+
ExtraFields map[string]apijson.Field
186+
}
187+
188+
func (r *ThreatEventCategoryDeleteResponse) UnmarshalJSON(data []byte) (err error) {
189+
return apijson.UnmarshalRoot(data, r)
190+
}
191+
192+
func (r threatEventCategoryDeleteResponseJSON) RawJSON() string {
193+
return r.raw
194+
}
195+
196+
type ThreatEventCategoryGetResponse struct {
197+
KillChain float64 `json:"killChain,required"`
198+
Name string `json:"name,required"`
199+
UUID string `json:"uuid,required"`
200+
MitreAttack []string `json:"mitreAttack"`
201+
Shortname string `json:"shortname"`
202+
JSON threatEventCategoryGetResponseJSON `json:"-"`
203+
}
204+
205+
// threatEventCategoryGetResponseJSON contains the JSON metadata for the struct
206+
// [ThreatEventCategoryGetResponse]
207+
type threatEventCategoryGetResponseJSON struct {
208+
KillChain apijson.Field
209+
Name apijson.Field
210+
UUID apijson.Field
211+
MitreAttack apijson.Field
212+
Shortname apijson.Field
213+
raw string
214+
ExtraFields map[string]apijson.Field
215+
}
216+
217+
func (r *ThreatEventCategoryGetResponse) UnmarshalJSON(data []byte) (err error) {
218+
return apijson.UnmarshalRoot(data, r)
219+
}
220+
221+
func (r threatEventCategoryGetResponseJSON) RawJSON() string {
222+
return r.raw
223+
}
224+
225+
type ThreatEventCategoryNewParams struct {
226+
KillChain param.Field[float64] `json:"killChain,required"`
227+
Name param.Field[string] `json:"name,required"`
228+
MitreAttack param.Field[[]string] `json:"mitreAttack"`
229+
Shortname param.Field[string] `json:"shortname"`
230+
}
231+
232+
func (r ThreatEventCategoryNewParams) MarshalJSON() (data []byte, err error) {
233+
return apijson.MarshalRoot(r)
234+
}
235+
236+
type ThreatEventCategoryUpdateParams struct {
237+
KillChain param.Field[float64] `json:"killChain"`
238+
MitreAttack param.Field[[]string] `json:"mitreAttack"`
239+
Name param.Field[string] `json:"name"`
240+
Shortname param.Field[string] `json:"shortname"`
241+
}
242+
243+
func (r ThreatEventCategoryUpdateParams) MarshalJSON() (data []byte, err error) {
244+
return apijson.MarshalRoot(r)
245+
}
+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestThreatEventCategoryNewWithOptionalParams(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.CloudforceOne.ThreatEvents.Categories.New(
31+
context.TODO(),
32+
0.000000,
33+
cloudforce_one.ThreatEventCategoryNewParams{
34+
KillChain: cloudflare.F(0.000000),
35+
Name: cloudflare.F("name"),
36+
MitreAttack: cloudflare.F([]string{"T1234"}),
37+
Shortname: cloudflare.F("shortname"),
38+
},
39+
)
40+
if err != nil {
41+
var apierr *cloudflare.Error
42+
if errors.As(err, &apierr) {
43+
t.Log(string(apierr.DumpRequest(true)))
44+
}
45+
t.Fatalf("err should be nil: %s", err.Error())
46+
}
47+
}
48+
49+
func TestThreatEventCategoryUpdateWithOptionalParams(t *testing.T) {
50+
baseURL := "http://localhost:4010"
51+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
52+
baseURL = envURL
53+
}
54+
if !testutil.CheckTestServer(t, baseURL) {
55+
return
56+
}
57+
client := cloudflare.NewClient(
58+
option.WithBaseURL(baseURL),
59+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
60+
option.WithAPIEmail("user@example.com"),
61+
)
62+
_, err := client.CloudforceOne.ThreatEvents.Categories.Update(
63+
context.TODO(),
64+
0.000000,
65+
"categoryId",
66+
cloudforce_one.ThreatEventCategoryUpdateParams{
67+
KillChain: cloudflare.F(0.000000),
68+
MitreAttack: cloudflare.F([]string{"T1234"}),
69+
Name: cloudflare.F("name"),
70+
Shortname: cloudflare.F("shortname"),
71+
},
72+
)
73+
if err != nil {
74+
var apierr *cloudflare.Error
75+
if errors.As(err, &apierr) {
76+
t.Log(string(apierr.DumpRequest(true)))
77+
}
78+
t.Fatalf("err should be nil: %s", err.Error())
79+
}
80+
}
81+
82+
func TestThreatEventCategoryList(t *testing.T) {
83+
baseURL := "http://localhost:4010"
84+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
85+
baseURL = envURL
86+
}
87+
if !testutil.CheckTestServer(t, baseURL) {
88+
return
89+
}
90+
client := cloudflare.NewClient(
91+
option.WithBaseURL(baseURL),
92+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
93+
option.WithAPIEmail("user@example.com"),
94+
)
95+
_, err := client.CloudforceOne.ThreatEvents.Categories.List(context.TODO(), 0.000000)
96+
if err != nil {
97+
var apierr *cloudflare.Error
98+
if errors.As(err, &apierr) {
99+
t.Log(string(apierr.DumpRequest(true)))
100+
}
101+
t.Fatalf("err should be nil: %s", err.Error())
102+
}
103+
}
104+
105+
func TestThreatEventCategoryDelete(t *testing.T) {
106+
baseURL := "http://localhost:4010"
107+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
108+
baseURL = envURL
109+
}
110+
if !testutil.CheckTestServer(t, baseURL) {
111+
return
112+
}
113+
client := cloudflare.NewClient(
114+
option.WithBaseURL(baseURL),
115+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
116+
option.WithAPIEmail("user@example.com"),
117+
)
118+
_, err := client.CloudforceOne.ThreatEvents.Categories.Delete(
119+
context.TODO(),
120+
0.000000,
121+
"categoryId",
122+
)
123+
if err != nil {
124+
var apierr *cloudflare.Error
125+
if errors.As(err, &apierr) {
126+
t.Log(string(apierr.DumpRequest(true)))
127+
}
128+
t.Fatalf("err should be nil: %s", err.Error())
129+
}
130+
}
131+
132+
func TestThreatEventCategoryGet(t *testing.T) {
133+
baseURL := "http://localhost:4010"
134+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
135+
baseURL = envURL
136+
}
137+
if !testutil.CheckTestServer(t, baseURL) {
138+
return
139+
}
140+
client := cloudflare.NewClient(
141+
option.WithBaseURL(baseURL),
142+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
143+
option.WithAPIEmail("user@example.com"),
144+
)
145+
_, err := client.CloudforceOne.ThreatEvents.Categories.Get(
146+
context.TODO(),
147+
0.000000,
148+
"categoryId",
149+
)
150+
if err != nil {
151+
var apierr *cloudflare.Error
152+
if errors.As(err, &apierr) {
153+
t.Log(string(apierr.DumpRequest(true)))
154+
}
155+
t.Fatalf("err should be nil: %s", err.Error())
156+
}
157+
}

‎cloudforce_one/threateventcountry.go

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"net/http"
9+
10+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
11+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
12+
"github.com/cloudflare/cloudflare-go/v4/option"
13+
)
14+
15+
// ThreatEventCountryService contains methods and other services that help with
16+
// interacting with the cloudflare API.
17+
//
18+
// Note, unlike clients, this service does not read variables from the environment
19+
// automatically. You should not instantiate this service directly, and instead use
20+
// the [NewThreatEventCountryService] method instead.
21+
type ThreatEventCountryService struct {
22+
Options []option.RequestOption
23+
}
24+
25+
// NewThreatEventCountryService generates a new service that applies the given
26+
// options to each request. These options are applied after the parent client's
27+
// options (if there is one), and before any request-specific options.
28+
func NewThreatEventCountryService(opts ...option.RequestOption) (r *ThreatEventCountryService) {
29+
r = &ThreatEventCountryService{}
30+
r.Options = opts
31+
return
32+
}
33+
34+
// Retrieves countries information for all countries
35+
func (r *ThreatEventCountryService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *[]ThreatEventCountryListResponse, err error) {
36+
opts = append(r.Options[:], opts...)
37+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/countries", accountID)
38+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
39+
return
40+
}
41+
42+
type ThreatEventCountryListResponse struct {
43+
Result []ThreatEventCountryListResponseResult `json:"result,required"`
44+
Success string `json:"success,required"`
45+
JSON threatEventCountryListResponseJSON `json:"-"`
46+
}
47+
48+
// threatEventCountryListResponseJSON contains the JSON metadata for the struct
49+
// [ThreatEventCountryListResponse]
50+
type threatEventCountryListResponseJSON struct {
51+
Result apijson.Field
52+
Success apijson.Field
53+
raw string
54+
ExtraFields map[string]apijson.Field
55+
}
56+
57+
func (r *ThreatEventCountryListResponse) UnmarshalJSON(data []byte) (err error) {
58+
return apijson.UnmarshalRoot(data, r)
59+
}
60+
61+
func (r threatEventCountryListResponseJSON) RawJSON() string {
62+
return r.raw
63+
}
64+
65+
type ThreatEventCountryListResponseResult struct {
66+
Alpha3 string `json:"alpha3,required"`
67+
Name string `json:"name,required"`
68+
JSON threatEventCountryListResponseResultJSON `json:"-"`
69+
}
70+
71+
// threatEventCountryListResponseResultJSON contains the JSON metadata for the
72+
// struct [ThreatEventCountryListResponseResult]
73+
type threatEventCountryListResponseResultJSON struct {
74+
Alpha3 apijson.Field
75+
Name apijson.Field
76+
raw string
77+
ExtraFields map[string]apijson.Field
78+
}
79+
80+
func (r *ThreatEventCountryListResponseResult) UnmarshalJSON(data []byte) (err error) {
81+
return apijson.UnmarshalRoot(data, r)
82+
}
83+
84+
func (r threatEventCountryListResponseResultJSON) RawJSON() string {
85+
return r.raw
86+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/option"
14+
)
15+
16+
func TestThreatEventCountryList(t *testing.T) {
17+
baseURL := "http://localhost:4010"
18+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
19+
baseURL = envURL
20+
}
21+
if !testutil.CheckTestServer(t, baseURL) {
22+
return
23+
}
24+
client := cloudflare.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
27+
option.WithAPIEmail("user@example.com"),
28+
)
29+
_, err := client.CloudforceOne.ThreatEvents.Countries.List(context.TODO(), 0.000000)
30+
if err != nil {
31+
var apierr *cloudflare.Error
32+
if errors.As(err, &apierr) {
33+
t.Log(string(apierr.DumpRequest(true)))
34+
}
35+
t.Fatalf("err should be nil: %s", err.Error())
36+
}
37+
}

‎cloudforce_one/threateventcron.go

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"net/http"
9+
10+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
11+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
12+
"github.com/cloudflare/cloudflare-go/v4/option"
13+
)
14+
15+
// ThreatEventCronService contains methods and other services that help with
16+
// interacting with the cloudflare API.
17+
//
18+
// Note, unlike clients, this service does not read variables from the environment
19+
// automatically. You should not instantiate this service directly, and instead use
20+
// the [NewThreatEventCronService] method instead.
21+
type ThreatEventCronService struct {
22+
Options []option.RequestOption
23+
}
24+
25+
// NewThreatEventCronService generates a new service that applies the given options
26+
// to each request. These options are applied after the parent client's options (if
27+
// there is one), and before any request-specific options.
28+
func NewThreatEventCronService(opts ...option.RequestOption) (r *ThreatEventCronService) {
29+
r = &ThreatEventCronService{}
30+
r.Options = opts
31+
return
32+
}
33+
34+
// Reads the last cron update time
35+
func (r *ThreatEventCronService) New(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *ThreatEventCronNewResponse, err error) {
36+
opts = append(r.Options[:], opts...)
37+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/cron", accountID)
38+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
39+
return
40+
}
41+
42+
// Reads the last cron update time
43+
func (r *ThreatEventCronService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *ThreatEventCronListResponse, err error) {
44+
opts = append(r.Options[:], opts...)
45+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/cron", accountID)
46+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
47+
return
48+
}
49+
50+
type ThreatEventCronNewResponse struct {
51+
ID float64 `json:"id,required"`
52+
Update string `json:"update,required"`
53+
JSON threatEventCronNewResponseJSON `json:"-"`
54+
}
55+
56+
// threatEventCronNewResponseJSON contains the JSON metadata for the struct
57+
// [ThreatEventCronNewResponse]
58+
type threatEventCronNewResponseJSON struct {
59+
ID apijson.Field
60+
Update apijson.Field
61+
raw string
62+
ExtraFields map[string]apijson.Field
63+
}
64+
65+
func (r *ThreatEventCronNewResponse) UnmarshalJSON(data []byte) (err error) {
66+
return apijson.UnmarshalRoot(data, r)
67+
}
68+
69+
func (r threatEventCronNewResponseJSON) RawJSON() string {
70+
return r.raw
71+
}
72+
73+
type ThreatEventCronListResponse struct {
74+
Update string `json:"update,required"`
75+
JSON threatEventCronListResponseJSON `json:"-"`
76+
}
77+
78+
// threatEventCronListResponseJSON contains the JSON metadata for the struct
79+
// [ThreatEventCronListResponse]
80+
type threatEventCronListResponseJSON struct {
81+
Update apijson.Field
82+
raw string
83+
ExtraFields map[string]apijson.Field
84+
}
85+
86+
func (r *ThreatEventCronListResponse) UnmarshalJSON(data []byte) (err error) {
87+
return apijson.UnmarshalRoot(data, r)
88+
}
89+
90+
func (r threatEventCronListResponseJSON) RawJSON() string {
91+
return r.raw
92+
}
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/option"
14+
)
15+
16+
func TestThreatEventCronNew(t *testing.T) {
17+
baseURL := "http://localhost:4010"
18+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
19+
baseURL = envURL
20+
}
21+
if !testutil.CheckTestServer(t, baseURL) {
22+
return
23+
}
24+
client := cloudflare.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
27+
option.WithAPIEmail("user@example.com"),
28+
)
29+
_, err := client.CloudforceOne.ThreatEvents.Cron.New(context.TODO(), 0.000000)
30+
if err != nil {
31+
var apierr *cloudflare.Error
32+
if errors.As(err, &apierr) {
33+
t.Log(string(apierr.DumpRequest(true)))
34+
}
35+
t.Fatalf("err should be nil: %s", err.Error())
36+
}
37+
}
38+
39+
func TestThreatEventCronList(t *testing.T) {
40+
baseURL := "http://localhost:4010"
41+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
42+
baseURL = envURL
43+
}
44+
if !testutil.CheckTestServer(t, baseURL) {
45+
return
46+
}
47+
client := cloudflare.NewClient(
48+
option.WithBaseURL(baseURL),
49+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
50+
option.WithAPIEmail("user@example.com"),
51+
)
52+
_, err := client.CloudforceOne.ThreatEvents.Cron.List(context.TODO(), 0.000000)
53+
if err != nil {
54+
var apierr *cloudflare.Error
55+
if errors.As(err, &apierr) {
56+
t.Log(string(apierr.DumpRequest(true)))
57+
}
58+
t.Fatalf("err should be nil: %s", err.Error())
59+
}
60+
}

‎cloudforce_one/threateventdataset.go

+245
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
// ThreatEventDatasetService contains methods and other services that help with
18+
// interacting with the cloudflare API.
19+
//
20+
// Note, unlike clients, this service does not read variables from the environment
21+
// automatically. You should not instantiate this service directly, and instead use
22+
// the [NewThreatEventDatasetService] method instead.
23+
type ThreatEventDatasetService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventDatasetService generates a new service that applies the given
28+
// options to each request. These options are applied after the parent client's
29+
// options (if there is one), and before any request-specific options.
30+
func NewThreatEventDatasetService(opts ...option.RequestOption) (r *ThreatEventDatasetService) {
31+
r = &ThreatEventDatasetService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Creates a dataset
37+
func (r *ThreatEventDatasetService) New(ctx context.Context, accountID float64, body ThreatEventDatasetNewParams, opts ...option.RequestOption) (res *ThreatEventDatasetNewResponse, err error) {
38+
opts = append(r.Options[:], opts...)
39+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/dataset/create", accountID)
40+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
41+
return
42+
}
43+
44+
// Updates an existing dataset
45+
func (r *ThreatEventDatasetService) Update(ctx context.Context, accountID float64, datasetID string, body ThreatEventDatasetUpdateParams, opts ...option.RequestOption) (res *ThreatEventDatasetUpdateResponse, err error) {
46+
opts = append(r.Options[:], opts...)
47+
if datasetID == "" {
48+
err = errors.New("missing required datasetId parameter")
49+
return
50+
}
51+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/dataset/%s", accountID, datasetID)
52+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
53+
return
54+
}
55+
56+
// Lists all datasets in an account
57+
func (r *ThreatEventDatasetService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *[]ThreatEventDatasetListResponse, err error) {
58+
opts = append(r.Options[:], opts...)
59+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/dataset", accountID)
60+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
61+
return
62+
}
63+
64+
// Reads a dataset
65+
func (r *ThreatEventDatasetService) Get(ctx context.Context, accountID float64, datasetID string, opts ...option.RequestOption) (res *ThreatEventDatasetGetResponse, err error) {
66+
opts = append(r.Options[:], opts...)
67+
if datasetID == "" {
68+
err = errors.New("missing required datasetId parameter")
69+
return
70+
}
71+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/dataset/%s", accountID, datasetID)
72+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
73+
return
74+
}
75+
76+
// Reads data for a raw event
77+
func (r *ThreatEventDatasetService) Raw(ctx context.Context, accountID float64, datasetID string, eventID string, opts ...option.RequestOption) (res *ThreatEventDatasetRawResponse, err error) {
78+
opts = append(r.Options[:], opts...)
79+
if datasetID == "" {
80+
err = errors.New("missing required datasetId parameter")
81+
return
82+
}
83+
if eventID == "" {
84+
err = errors.New("missing required eventId parameter")
85+
return
86+
}
87+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/raw/%s/%s", accountID, datasetID, eventID)
88+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
89+
return
90+
}
91+
92+
type ThreatEventDatasetNewResponse struct {
93+
IsPublic bool `json:"isPublic,required"`
94+
Name string `json:"name,required"`
95+
UUID string `json:"uuid,required"`
96+
JSON threatEventDatasetNewResponseJSON `json:"-"`
97+
}
98+
99+
// threatEventDatasetNewResponseJSON contains the JSON metadata for the struct
100+
// [ThreatEventDatasetNewResponse]
101+
type threatEventDatasetNewResponseJSON struct {
102+
IsPublic apijson.Field
103+
Name apijson.Field
104+
UUID apijson.Field
105+
raw string
106+
ExtraFields map[string]apijson.Field
107+
}
108+
109+
func (r *ThreatEventDatasetNewResponse) UnmarshalJSON(data []byte) (err error) {
110+
return apijson.UnmarshalRoot(data, r)
111+
}
112+
113+
func (r threatEventDatasetNewResponseJSON) RawJSON() string {
114+
return r.raw
115+
}
116+
117+
type ThreatEventDatasetUpdateResponse struct {
118+
IsPublic bool `json:"isPublic,required"`
119+
Name string `json:"name,required"`
120+
UUID string `json:"uuid,required"`
121+
JSON threatEventDatasetUpdateResponseJSON `json:"-"`
122+
}
123+
124+
// threatEventDatasetUpdateResponseJSON contains the JSON metadata for the struct
125+
// [ThreatEventDatasetUpdateResponse]
126+
type threatEventDatasetUpdateResponseJSON struct {
127+
IsPublic apijson.Field
128+
Name apijson.Field
129+
UUID apijson.Field
130+
raw string
131+
ExtraFields map[string]apijson.Field
132+
}
133+
134+
func (r *ThreatEventDatasetUpdateResponse) UnmarshalJSON(data []byte) (err error) {
135+
return apijson.UnmarshalRoot(data, r)
136+
}
137+
138+
func (r threatEventDatasetUpdateResponseJSON) RawJSON() string {
139+
return r.raw
140+
}
141+
142+
type ThreatEventDatasetListResponse struct {
143+
IsPublic bool `json:"isPublic,required"`
144+
Name string `json:"name,required"`
145+
UUID string `json:"uuid,required"`
146+
JSON threatEventDatasetListResponseJSON `json:"-"`
147+
}
148+
149+
// threatEventDatasetListResponseJSON contains the JSON metadata for the struct
150+
// [ThreatEventDatasetListResponse]
151+
type threatEventDatasetListResponseJSON struct {
152+
IsPublic apijson.Field
153+
Name apijson.Field
154+
UUID apijson.Field
155+
raw string
156+
ExtraFields map[string]apijson.Field
157+
}
158+
159+
func (r *ThreatEventDatasetListResponse) UnmarshalJSON(data []byte) (err error) {
160+
return apijson.UnmarshalRoot(data, r)
161+
}
162+
163+
func (r threatEventDatasetListResponseJSON) RawJSON() string {
164+
return r.raw
165+
}
166+
167+
type ThreatEventDatasetGetResponse struct {
168+
IsPublic bool `json:"isPublic,required"`
169+
Name string `json:"name,required"`
170+
UUID string `json:"uuid,required"`
171+
JSON threatEventDatasetGetResponseJSON `json:"-"`
172+
}
173+
174+
// threatEventDatasetGetResponseJSON contains the JSON metadata for the struct
175+
// [ThreatEventDatasetGetResponse]
176+
type threatEventDatasetGetResponseJSON struct {
177+
IsPublic apijson.Field
178+
Name apijson.Field
179+
UUID apijson.Field
180+
raw string
181+
ExtraFields map[string]apijson.Field
182+
}
183+
184+
func (r *ThreatEventDatasetGetResponse) UnmarshalJSON(data []byte) (err error) {
185+
return apijson.UnmarshalRoot(data, r)
186+
}
187+
188+
func (r threatEventDatasetGetResponseJSON) RawJSON() string {
189+
return r.raw
190+
}
191+
192+
type ThreatEventDatasetRawResponse struct {
193+
ID string `json:"id,required"`
194+
AccountID float64 `json:"accountId,required"`
195+
Created string `json:"created,required"`
196+
Data interface{} `json:"data,required"`
197+
Source string `json:"source,required"`
198+
TLP string `json:"tlp,required"`
199+
JSON threatEventDatasetRawResponseJSON `json:"-"`
200+
}
201+
202+
// threatEventDatasetRawResponseJSON contains the JSON metadata for the struct
203+
// [ThreatEventDatasetRawResponse]
204+
type threatEventDatasetRawResponseJSON struct {
205+
ID apijson.Field
206+
AccountID apijson.Field
207+
Created apijson.Field
208+
Data apijson.Field
209+
Source apijson.Field
210+
TLP apijson.Field
211+
raw string
212+
ExtraFields map[string]apijson.Field
213+
}
214+
215+
func (r *ThreatEventDatasetRawResponse) UnmarshalJSON(data []byte) (err error) {
216+
return apijson.UnmarshalRoot(data, r)
217+
}
218+
219+
func (r threatEventDatasetRawResponseJSON) RawJSON() string {
220+
return r.raw
221+
}
222+
223+
type ThreatEventDatasetNewParams struct {
224+
// If true, then anyone can search the dataset. If false, then its limited to the
225+
// account.
226+
IsPublic param.Field[bool] `json:"isPublic,required"`
227+
// Used to describe the dataset within the account context
228+
Name param.Field[string] `json:"name,required"`
229+
}
230+
231+
func (r ThreatEventDatasetNewParams) MarshalJSON() (data []byte, err error) {
232+
return apijson.MarshalRoot(r)
233+
}
234+
235+
type ThreatEventDatasetUpdateParams struct {
236+
// If true, then anyone can search the dataset. If false, then its limited to the
237+
// account.
238+
IsPublic param.Field[bool] `json:"isPublic,required"`
239+
// Used to describe the dataset within the account context
240+
Name param.Field[string] `json:"name,required"`
241+
}
242+
243+
func (r ThreatEventDatasetUpdateParams) MarshalJSON() (data []byte, err error) {
244+
return apijson.MarshalRoot(r)
245+
}
+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestThreatEventDatasetNew(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.CloudforceOne.ThreatEvents.Dataset.New(
31+
context.TODO(),
32+
0.000000,
33+
cloudforce_one.ThreatEventDatasetNewParams{
34+
IsPublic: cloudflare.F(true),
35+
Name: cloudflare.F("x"),
36+
},
37+
)
38+
if err != nil {
39+
var apierr *cloudflare.Error
40+
if errors.As(err, &apierr) {
41+
t.Log(string(apierr.DumpRequest(true)))
42+
}
43+
t.Fatalf("err should be nil: %s", err.Error())
44+
}
45+
}
46+
47+
func TestThreatEventDatasetUpdate(t *testing.T) {
48+
baseURL := "http://localhost:4010"
49+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
50+
baseURL = envURL
51+
}
52+
if !testutil.CheckTestServer(t, baseURL) {
53+
return
54+
}
55+
client := cloudflare.NewClient(
56+
option.WithBaseURL(baseURL),
57+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
58+
option.WithAPIEmail("user@example.com"),
59+
)
60+
_, err := client.CloudforceOne.ThreatEvents.Dataset.Update(
61+
context.TODO(),
62+
0.000000,
63+
"datasetId",
64+
cloudforce_one.ThreatEventDatasetUpdateParams{
65+
IsPublic: cloudflare.F(true),
66+
Name: cloudflare.F("x"),
67+
},
68+
)
69+
if err != nil {
70+
var apierr *cloudflare.Error
71+
if errors.As(err, &apierr) {
72+
t.Log(string(apierr.DumpRequest(true)))
73+
}
74+
t.Fatalf("err should be nil: %s", err.Error())
75+
}
76+
}
77+
78+
func TestThreatEventDatasetList(t *testing.T) {
79+
baseURL := "http://localhost:4010"
80+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
81+
baseURL = envURL
82+
}
83+
if !testutil.CheckTestServer(t, baseURL) {
84+
return
85+
}
86+
client := cloudflare.NewClient(
87+
option.WithBaseURL(baseURL),
88+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
89+
option.WithAPIEmail("user@example.com"),
90+
)
91+
_, err := client.CloudforceOne.ThreatEvents.Dataset.List(context.TODO(), 0.000000)
92+
if err != nil {
93+
var apierr *cloudflare.Error
94+
if errors.As(err, &apierr) {
95+
t.Log(string(apierr.DumpRequest(true)))
96+
}
97+
t.Fatalf("err should be nil: %s", err.Error())
98+
}
99+
}
100+
101+
func TestThreatEventDatasetGet(t *testing.T) {
102+
baseURL := "http://localhost:4010"
103+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
104+
baseURL = envURL
105+
}
106+
if !testutil.CheckTestServer(t, baseURL) {
107+
return
108+
}
109+
client := cloudflare.NewClient(
110+
option.WithBaseURL(baseURL),
111+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
112+
option.WithAPIEmail("user@example.com"),
113+
)
114+
_, err := client.CloudforceOne.ThreatEvents.Dataset.Get(
115+
context.TODO(),
116+
0.000000,
117+
"datasetId",
118+
)
119+
if err != nil {
120+
var apierr *cloudflare.Error
121+
if errors.As(err, &apierr) {
122+
t.Log(string(apierr.DumpRequest(true)))
123+
}
124+
t.Fatalf("err should be nil: %s", err.Error())
125+
}
126+
}
127+
128+
func TestThreatEventDatasetRaw(t *testing.T) {
129+
baseURL := "http://localhost:4010"
130+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
131+
baseURL = envURL
132+
}
133+
if !testutil.CheckTestServer(t, baseURL) {
134+
return
135+
}
136+
client := cloudflare.NewClient(
137+
option.WithBaseURL(baseURL),
138+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
139+
option.WithAPIEmail("user@example.com"),
140+
)
141+
_, err := client.CloudforceOne.ThreatEvents.Dataset.Raw(
142+
context.TODO(),
143+
0.000000,
144+
"datasetId",
145+
"eventId",
146+
)
147+
if err != nil {
148+
var apierr *cloudflare.Error
149+
if errors.As(err, &apierr) {
150+
t.Log(string(apierr.DumpRequest(true)))
151+
}
152+
t.Fatalf("err should be nil: %s", err.Error())
153+
}
154+
}
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"net/http"
9+
10+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
11+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
12+
"github.com/cloudflare/cloudflare-go/v4/option"
13+
)
14+
15+
// ThreatEventIndicatorTypeService contains methods and other services that help
16+
// with interacting with the cloudflare API.
17+
//
18+
// Note, unlike clients, this service does not read variables from the environment
19+
// automatically. You should not instantiate this service directly, and instead use
20+
// the [NewThreatEventIndicatorTypeService] method instead.
21+
type ThreatEventIndicatorTypeService struct {
22+
Options []option.RequestOption
23+
}
24+
25+
// NewThreatEventIndicatorTypeService generates a new service that applies the
26+
// given options to each request. These options are applied after the parent
27+
// client's options (if there is one), and before any request-specific options.
28+
func NewThreatEventIndicatorTypeService(opts ...option.RequestOption) (r *ThreatEventIndicatorTypeService) {
29+
r = &ThreatEventIndicatorTypeService{}
30+
r.Options = opts
31+
return
32+
}
33+
34+
// Lists all indicator types
35+
func (r *ThreatEventIndicatorTypeService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *ThreatEventIndicatorTypeListResponse, err error) {
36+
opts = append(r.Options[:], opts...)
37+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/indicatorTypes", accountID)
38+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
39+
return
40+
}
41+
42+
type ThreatEventIndicatorTypeListResponse struct {
43+
Items ThreatEventIndicatorTypeListResponseItems `json:"items,required"`
44+
Type string `json:"type,required"`
45+
JSON threatEventIndicatorTypeListResponseJSON `json:"-"`
46+
}
47+
48+
// threatEventIndicatorTypeListResponseJSON contains the JSON metadata for the
49+
// struct [ThreatEventIndicatorTypeListResponse]
50+
type threatEventIndicatorTypeListResponseJSON struct {
51+
Items apijson.Field
52+
Type apijson.Field
53+
raw string
54+
ExtraFields map[string]apijson.Field
55+
}
56+
57+
func (r *ThreatEventIndicatorTypeListResponse) UnmarshalJSON(data []byte) (err error) {
58+
return apijson.UnmarshalRoot(data, r)
59+
}
60+
61+
func (r threatEventIndicatorTypeListResponseJSON) RawJSON() string {
62+
return r.raw
63+
}
64+
65+
type ThreatEventIndicatorTypeListResponseItems struct {
66+
Type string `json:"type,required"`
67+
JSON threatEventIndicatorTypeListResponseItemsJSON `json:"-"`
68+
}
69+
70+
// threatEventIndicatorTypeListResponseItemsJSON contains the JSON metadata for the
71+
// struct [ThreatEventIndicatorTypeListResponseItems]
72+
type threatEventIndicatorTypeListResponseItemsJSON struct {
73+
Type apijson.Field
74+
raw string
75+
ExtraFields map[string]apijson.Field
76+
}
77+
78+
func (r *ThreatEventIndicatorTypeListResponseItems) UnmarshalJSON(data []byte) (err error) {
79+
return apijson.UnmarshalRoot(data, r)
80+
}
81+
82+
func (r threatEventIndicatorTypeListResponseItemsJSON) RawJSON() string {
83+
return r.raw
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/option"
14+
)
15+
16+
func TestThreatEventIndicatorTypeList(t *testing.T) {
17+
baseURL := "http://localhost:4010"
18+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
19+
baseURL = envURL
20+
}
21+
if !testutil.CheckTestServer(t, baseURL) {
22+
return
23+
}
24+
client := cloudflare.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
27+
option.WithAPIEmail("user@example.com"),
28+
)
29+
_, err := client.CloudforceOne.ThreatEvents.IndicatorTypes.List(context.TODO(), 0.000000)
30+
if err != nil {
31+
var apierr *cloudflare.Error
32+
if errors.As(err, &apierr) {
33+
t.Log(string(apierr.DumpRequest(true)))
34+
}
35+
t.Fatalf("err should be nil: %s", err.Error())
36+
}
37+
}

‎cloudforce_one/threateventinsight.go

+312
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,312 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
// ThreatEventInsightService contains methods and other services that help with
18+
// interacting with the cloudflare API.
19+
//
20+
// Note, unlike clients, this service does not read variables from the environment
21+
// automatically. You should not instantiate this service directly, and instead use
22+
// the [NewThreatEventInsightService] method instead.
23+
type ThreatEventInsightService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventInsightService generates a new service that applies the given
28+
// options to each request. These options are applied after the parent client's
29+
// options (if there is one), and before any request-specific options.
30+
func NewThreatEventInsightService(opts ...option.RequestOption) (r *ThreatEventInsightService) {
31+
r = &ThreatEventInsightService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Updates an event insight
37+
func (r *ThreatEventInsightService) Update(ctx context.Context, accountID float64, eventID string, insightID string, body ThreatEventInsightUpdateParams, opts ...option.RequestOption) (res *ThreatEventInsightUpdateResponse, err error) {
38+
var env ThreatEventInsightUpdateResponseEnvelope
39+
opts = append(r.Options[:], opts...)
40+
if eventID == "" {
41+
err = errors.New("missing required eventId parameter")
42+
return
43+
}
44+
if insightID == "" {
45+
err = errors.New("missing required insightId parameter")
46+
return
47+
}
48+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/%s", accountID, eventID, insightID)
49+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
50+
if err != nil {
51+
return
52+
}
53+
res = &env.Result
54+
return
55+
}
56+
57+
// Deletes an event insight
58+
func (r *ThreatEventInsightService) Delete(ctx context.Context, accountID float64, eventID string, insightID string, opts ...option.RequestOption) (res *ThreatEventInsightDeleteResponse, err error) {
59+
var env ThreatEventInsightDeleteResponseEnvelope
60+
opts = append(r.Options[:], opts...)
61+
if eventID == "" {
62+
err = errors.New("missing required eventId parameter")
63+
return
64+
}
65+
if insightID == "" {
66+
err = errors.New("missing required insightId parameter")
67+
return
68+
}
69+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/%s", accountID, eventID, insightID)
70+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
71+
if err != nil {
72+
return
73+
}
74+
res = &env.Result
75+
return
76+
}
77+
78+
// Adds an insight to an event
79+
func (r *ThreatEventInsightService) Creat(ctx context.Context, accountID float64, eventID string, body ThreatEventInsightCreatParams, opts ...option.RequestOption) (res *ThreatEventInsightCreatResponse, err error) {
80+
var env ThreatEventInsightCreatResponseEnvelope
81+
opts = append(r.Options[:], opts...)
82+
if eventID == "" {
83+
err = errors.New("missing required eventId parameter")
84+
return
85+
}
86+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/create", accountID, eventID)
87+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
88+
if err != nil {
89+
return
90+
}
91+
res = &env.Result
92+
return
93+
}
94+
95+
// Reads an event insight
96+
func (r *ThreatEventInsightService) Get(ctx context.Context, accountID float64, eventID string, insightID string, opts ...option.RequestOption) (res *ThreatEventInsightGetResponse, err error) {
97+
var env ThreatEventInsightGetResponseEnvelope
98+
opts = append(r.Options[:], opts...)
99+
if eventID == "" {
100+
err = errors.New("missing required eventId parameter")
101+
return
102+
}
103+
if insightID == "" {
104+
err = errors.New("missing required insightId parameter")
105+
return
106+
}
107+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/%s", accountID, eventID, insightID)
108+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
109+
if err != nil {
110+
return
111+
}
112+
res = &env.Result
113+
return
114+
}
115+
116+
type ThreatEventInsightUpdateResponse struct {
117+
Content string `json:"content,required"`
118+
UUID string `json:"uuid,required"`
119+
JSON threatEventInsightUpdateResponseJSON `json:"-"`
120+
}
121+
122+
// threatEventInsightUpdateResponseJSON contains the JSON metadata for the struct
123+
// [ThreatEventInsightUpdateResponse]
124+
type threatEventInsightUpdateResponseJSON struct {
125+
Content apijson.Field
126+
UUID apijson.Field
127+
raw string
128+
ExtraFields map[string]apijson.Field
129+
}
130+
131+
func (r *ThreatEventInsightUpdateResponse) UnmarshalJSON(data []byte) (err error) {
132+
return apijson.UnmarshalRoot(data, r)
133+
}
134+
135+
func (r threatEventInsightUpdateResponseJSON) RawJSON() string {
136+
return r.raw
137+
}
138+
139+
type ThreatEventInsightDeleteResponse struct {
140+
Success bool `json:"success,required"`
141+
JSON threatEventInsightDeleteResponseJSON `json:"-"`
142+
}
143+
144+
// threatEventInsightDeleteResponseJSON contains the JSON metadata for the struct
145+
// [ThreatEventInsightDeleteResponse]
146+
type threatEventInsightDeleteResponseJSON struct {
147+
Success apijson.Field
148+
raw string
149+
ExtraFields map[string]apijson.Field
150+
}
151+
152+
func (r *ThreatEventInsightDeleteResponse) UnmarshalJSON(data []byte) (err error) {
153+
return apijson.UnmarshalRoot(data, r)
154+
}
155+
156+
func (r threatEventInsightDeleteResponseJSON) RawJSON() string {
157+
return r.raw
158+
}
159+
160+
type ThreatEventInsightCreatResponse struct {
161+
Content string `json:"content,required"`
162+
UUID string `json:"uuid,required"`
163+
JSON threatEventInsightCreatResponseJSON `json:"-"`
164+
}
165+
166+
// threatEventInsightCreatResponseJSON contains the JSON metadata for the struct
167+
// [ThreatEventInsightCreatResponse]
168+
type threatEventInsightCreatResponseJSON struct {
169+
Content apijson.Field
170+
UUID apijson.Field
171+
raw string
172+
ExtraFields map[string]apijson.Field
173+
}
174+
175+
func (r *ThreatEventInsightCreatResponse) UnmarshalJSON(data []byte) (err error) {
176+
return apijson.UnmarshalRoot(data, r)
177+
}
178+
179+
func (r threatEventInsightCreatResponseJSON) RawJSON() string {
180+
return r.raw
181+
}
182+
183+
type ThreatEventInsightGetResponse struct {
184+
Content string `json:"content,required"`
185+
UUID string `json:"uuid,required"`
186+
JSON threatEventInsightGetResponseJSON `json:"-"`
187+
}
188+
189+
// threatEventInsightGetResponseJSON contains the JSON metadata for the struct
190+
// [ThreatEventInsightGetResponse]
191+
type threatEventInsightGetResponseJSON struct {
192+
Content apijson.Field
193+
UUID apijson.Field
194+
raw string
195+
ExtraFields map[string]apijson.Field
196+
}
197+
198+
func (r *ThreatEventInsightGetResponse) UnmarshalJSON(data []byte) (err error) {
199+
return apijson.UnmarshalRoot(data, r)
200+
}
201+
202+
func (r threatEventInsightGetResponseJSON) RawJSON() string {
203+
return r.raw
204+
}
205+
206+
type ThreatEventInsightUpdateParams struct {
207+
Content param.Field[string] `json:"content,required"`
208+
}
209+
210+
func (r ThreatEventInsightUpdateParams) MarshalJSON() (data []byte, err error) {
211+
return apijson.MarshalRoot(r)
212+
}
213+
214+
type ThreatEventInsightUpdateResponseEnvelope struct {
215+
Result ThreatEventInsightUpdateResponse `json:"result,required"`
216+
Success bool `json:"success,required"`
217+
JSON threatEventInsightUpdateResponseEnvelopeJSON `json:"-"`
218+
}
219+
220+
// threatEventInsightUpdateResponseEnvelopeJSON contains the JSON metadata for the
221+
// struct [ThreatEventInsightUpdateResponseEnvelope]
222+
type threatEventInsightUpdateResponseEnvelopeJSON struct {
223+
Result apijson.Field
224+
Success apijson.Field
225+
raw string
226+
ExtraFields map[string]apijson.Field
227+
}
228+
229+
func (r *ThreatEventInsightUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
230+
return apijson.UnmarshalRoot(data, r)
231+
}
232+
233+
func (r threatEventInsightUpdateResponseEnvelopeJSON) RawJSON() string {
234+
return r.raw
235+
}
236+
237+
type ThreatEventInsightDeleteResponseEnvelope struct {
238+
Result ThreatEventInsightDeleteResponse `json:"result,required"`
239+
Success bool `json:"success,required"`
240+
JSON threatEventInsightDeleteResponseEnvelopeJSON `json:"-"`
241+
}
242+
243+
// threatEventInsightDeleteResponseEnvelopeJSON contains the JSON metadata for the
244+
// struct [ThreatEventInsightDeleteResponseEnvelope]
245+
type threatEventInsightDeleteResponseEnvelopeJSON struct {
246+
Result apijson.Field
247+
Success apijson.Field
248+
raw string
249+
ExtraFields map[string]apijson.Field
250+
}
251+
252+
func (r *ThreatEventInsightDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
253+
return apijson.UnmarshalRoot(data, r)
254+
}
255+
256+
func (r threatEventInsightDeleteResponseEnvelopeJSON) RawJSON() string {
257+
return r.raw
258+
}
259+
260+
type ThreatEventInsightCreatParams struct {
261+
Content param.Field[string] `json:"content,required"`
262+
}
263+
264+
func (r ThreatEventInsightCreatParams) MarshalJSON() (data []byte, err error) {
265+
return apijson.MarshalRoot(r)
266+
}
267+
268+
type ThreatEventInsightCreatResponseEnvelope struct {
269+
Result ThreatEventInsightCreatResponse `json:"result,required"`
270+
Success bool `json:"success,required"`
271+
JSON threatEventInsightCreatResponseEnvelopeJSON `json:"-"`
272+
}
273+
274+
// threatEventInsightCreatResponseEnvelopeJSON contains the JSON metadata for the
275+
// struct [ThreatEventInsightCreatResponseEnvelope]
276+
type threatEventInsightCreatResponseEnvelopeJSON struct {
277+
Result apijson.Field
278+
Success apijson.Field
279+
raw string
280+
ExtraFields map[string]apijson.Field
281+
}
282+
283+
func (r *ThreatEventInsightCreatResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
284+
return apijson.UnmarshalRoot(data, r)
285+
}
286+
287+
func (r threatEventInsightCreatResponseEnvelopeJSON) RawJSON() string {
288+
return r.raw
289+
}
290+
291+
type ThreatEventInsightGetResponseEnvelope struct {
292+
Result ThreatEventInsightGetResponse `json:"result,required"`
293+
Success bool `json:"success,required"`
294+
JSON threatEventInsightGetResponseEnvelopeJSON `json:"-"`
295+
}
296+
297+
// threatEventInsightGetResponseEnvelopeJSON contains the JSON metadata for the
298+
// struct [ThreatEventInsightGetResponseEnvelope]
299+
type threatEventInsightGetResponseEnvelopeJSON struct {
300+
Result apijson.Field
301+
Success apijson.Field
302+
raw string
303+
ExtraFields map[string]apijson.Field
304+
}
305+
306+
func (r *ThreatEventInsightGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
307+
return apijson.UnmarshalRoot(data, r)
308+
}
309+
310+
func (r threatEventInsightGetResponseEnvelopeJSON) RawJSON() string {
311+
return r.raw
312+
}
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestThreatEventInsightUpdate(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.CloudforceOne.ThreatEvents.Insight.Update(
31+
context.TODO(),
32+
0.000000,
33+
"eventId",
34+
"insightId",
35+
cloudforce_one.ThreatEventInsightUpdateParams{
36+
Content: cloudflare.F("Updated: Here is some additional context _in markdown_"),
37+
},
38+
)
39+
if err != nil {
40+
var apierr *cloudflare.Error
41+
if errors.As(err, &apierr) {
42+
t.Log(string(apierr.DumpRequest(true)))
43+
}
44+
t.Fatalf("err should be nil: %s", err.Error())
45+
}
46+
}
47+
48+
func TestThreatEventInsightDelete(t *testing.T) {
49+
baseURL := "http://localhost:4010"
50+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
51+
baseURL = envURL
52+
}
53+
if !testutil.CheckTestServer(t, baseURL) {
54+
return
55+
}
56+
client := cloudflare.NewClient(
57+
option.WithBaseURL(baseURL),
58+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
59+
option.WithAPIEmail("user@example.com"),
60+
)
61+
_, err := client.CloudforceOne.ThreatEvents.Insight.Delete(
62+
context.TODO(),
63+
0.000000,
64+
"eventId",
65+
"insightId",
66+
)
67+
if err != nil {
68+
var apierr *cloudflare.Error
69+
if errors.As(err, &apierr) {
70+
t.Log(string(apierr.DumpRequest(true)))
71+
}
72+
t.Fatalf("err should be nil: %s", err.Error())
73+
}
74+
}
75+
76+
func TestThreatEventInsightCreat(t *testing.T) {
77+
baseURL := "http://localhost:4010"
78+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
79+
baseURL = envURL
80+
}
81+
if !testutil.CheckTestServer(t, baseURL) {
82+
return
83+
}
84+
client := cloudflare.NewClient(
85+
option.WithBaseURL(baseURL),
86+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
87+
option.WithAPIEmail("user@example.com"),
88+
)
89+
_, err := client.CloudforceOne.ThreatEvents.Insight.Creat(
90+
context.TODO(),
91+
0.000000,
92+
"eventId",
93+
cloudforce_one.ThreatEventInsightCreatParams{
94+
Content: cloudflare.F("Here is some additional context _in markdown_"),
95+
},
96+
)
97+
if err != nil {
98+
var apierr *cloudflare.Error
99+
if errors.As(err, &apierr) {
100+
t.Log(string(apierr.DumpRequest(true)))
101+
}
102+
t.Fatalf("err should be nil: %s", err.Error())
103+
}
104+
}
105+
106+
func TestThreatEventInsightGet(t *testing.T) {
107+
baseURL := "http://localhost:4010"
108+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
109+
baseURL = envURL
110+
}
111+
if !testutil.CheckTestServer(t, baseURL) {
112+
return
113+
}
114+
client := cloudflare.NewClient(
115+
option.WithBaseURL(baseURL),
116+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
117+
option.WithAPIEmail("user@example.com"),
118+
)
119+
_, err := client.CloudforceOne.ThreatEvents.Insight.Get(
120+
context.TODO(),
121+
0.000000,
122+
"eventId",
123+
"insightId",
124+
)
125+
if err != nil {
126+
var apierr *cloudflare.Error
127+
if errors.As(err, &apierr) {
128+
t.Log(string(apierr.DumpRequest(true)))
129+
}
130+
t.Fatalf("err should be nil: %s", err.Error())
131+
}
132+
}

‎cloudforce_one/threateventraw.go

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
// ThreatEventRawService contains methods and other services that help with
18+
// interacting with the cloudflare API.
19+
//
20+
// Note, unlike clients, this service does not read variables from the environment
21+
// automatically. You should not instantiate this service directly, and instead use
22+
// the [NewThreatEventRawService] method instead.
23+
type ThreatEventRawService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventRawService generates a new service that applies the given options
28+
// to each request. These options are applied after the parent client's options (if
29+
// there is one), and before any request-specific options.
30+
func NewThreatEventRawService(opts ...option.RequestOption) (r *ThreatEventRawService) {
31+
r = &ThreatEventRawService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Updates a raw event
37+
func (r *ThreatEventRawService) Update(ctx context.Context, accountID float64, eventID string, rawID string, body ThreatEventRawUpdateParams, opts ...option.RequestOption) (res *ThreatEventRawUpdateResponse, err error) {
38+
opts = append(r.Options[:], opts...)
39+
if eventID == "" {
40+
err = errors.New("missing required eventId parameter")
41+
return
42+
}
43+
if rawID == "" {
44+
err = errors.New("missing required rawId parameter")
45+
return
46+
}
47+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/raw/%s", accountID, eventID, rawID)
48+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
49+
return
50+
}
51+
52+
// Reads data for a raw event
53+
func (r *ThreatEventRawService) Get(ctx context.Context, accountID float64, eventID string, rawID string, opts ...option.RequestOption) (res *ThreatEventRawGetResponse, err error) {
54+
opts = append(r.Options[:], opts...)
55+
if eventID == "" {
56+
err = errors.New("missing required eventId parameter")
57+
return
58+
}
59+
if rawID == "" {
60+
err = errors.New("missing required rawId parameter")
61+
return
62+
}
63+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/raw/%s", accountID, eventID, rawID)
64+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
65+
return
66+
}
67+
68+
type ThreatEventRawUpdateResponse struct {
69+
ID string `json:"id,required"`
70+
Data interface{} `json:"data,required"`
71+
JSON threatEventRawUpdateResponseJSON `json:"-"`
72+
}
73+
74+
// threatEventRawUpdateResponseJSON contains the JSON metadata for the struct
75+
// [ThreatEventRawUpdateResponse]
76+
type threatEventRawUpdateResponseJSON struct {
77+
ID apijson.Field
78+
Data apijson.Field
79+
raw string
80+
ExtraFields map[string]apijson.Field
81+
}
82+
83+
func (r *ThreatEventRawUpdateResponse) UnmarshalJSON(data []byte) (err error) {
84+
return apijson.UnmarshalRoot(data, r)
85+
}
86+
87+
func (r threatEventRawUpdateResponseJSON) RawJSON() string {
88+
return r.raw
89+
}
90+
91+
type ThreatEventRawGetResponse struct {
92+
ID string `json:"id,required"`
93+
AccountID float64 `json:"accountId,required"`
94+
Created string `json:"created,required"`
95+
Data interface{} `json:"data,required"`
96+
Source string `json:"source,required"`
97+
TLP string `json:"tlp,required"`
98+
JSON threatEventRawGetResponseJSON `json:"-"`
99+
}
100+
101+
// threatEventRawGetResponseJSON contains the JSON metadata for the struct
102+
// [ThreatEventRawGetResponse]
103+
type threatEventRawGetResponseJSON struct {
104+
ID apijson.Field
105+
AccountID apijson.Field
106+
Created apijson.Field
107+
Data apijson.Field
108+
Source apijson.Field
109+
TLP apijson.Field
110+
raw string
111+
ExtraFields map[string]apijson.Field
112+
}
113+
114+
func (r *ThreatEventRawGetResponse) UnmarshalJSON(data []byte) (err error) {
115+
return apijson.UnmarshalRoot(data, r)
116+
}
117+
118+
func (r threatEventRawGetResponseJSON) RawJSON() string {
119+
return r.raw
120+
}
121+
122+
type ThreatEventRawUpdateParams struct {
123+
Data param.Field[interface{}] `json:"data"`
124+
Source param.Field[string] `json:"source"`
125+
TLP param.Field[string] `json:"tlp"`
126+
}
127+
128+
func (r ThreatEventRawUpdateParams) MarshalJSON() (data []byte, err error) {
129+
return apijson.MarshalRoot(r)
130+
}

‎cloudforce_one/threateventraw_test.go

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestThreatEventRawUpdateWithOptionalParams(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.CloudforceOne.ThreatEvents.Raw.Update(
31+
context.TODO(),
32+
0.000000,
33+
"eventId",
34+
"rawId",
35+
cloudforce_one.ThreatEventRawUpdateParams{
36+
Data: cloudflare.F[any](map[string]interface{}{}),
37+
Source: cloudflare.F("example.com"),
38+
TLP: cloudflare.F("amber"),
39+
},
40+
)
41+
if err != nil {
42+
var apierr *cloudflare.Error
43+
if errors.As(err, &apierr) {
44+
t.Log(string(apierr.DumpRequest(true)))
45+
}
46+
t.Fatalf("err should be nil: %s", err.Error())
47+
}
48+
}
49+
50+
func TestThreatEventRawGet(t *testing.T) {
51+
baseURL := "http://localhost:4010"
52+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
53+
baseURL = envURL
54+
}
55+
if !testutil.CheckTestServer(t, baseURL) {
56+
return
57+
}
58+
client := cloudflare.NewClient(
59+
option.WithBaseURL(baseURL),
60+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
61+
option.WithAPIEmail("user@example.com"),
62+
)
63+
_, err := client.CloudforceOne.ThreatEvents.Raw.Get(
64+
context.TODO(),
65+
0.000000,
66+
"eventId",
67+
"rawId",
68+
)
69+
if err != nil {
70+
var apierr *cloudflare.Error
71+
if errors.As(err, &apierr) {
72+
t.Log(string(apierr.DumpRequest(true)))
73+
}
74+
t.Fatalf("err should be nil: %s", err.Error())
75+
}
76+
}

‎cloudforce_one/threateventrelate.go

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
// ThreatEventRelateService contains methods and other services that help with
18+
// interacting with the cloudflare API.
19+
//
20+
// Note, unlike clients, this service does not read variables from the environment
21+
// automatically. You should not instantiate this service directly, and instead use
22+
// the [NewThreatEventRelateService] method instead.
23+
type ThreatEventRelateService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventRelateService generates a new service that applies the given
28+
// options to each request. These options are applied after the parent client's
29+
// options (if there is one), and before any request-specific options.
30+
func NewThreatEventRelateService(opts ...option.RequestOption) (r *ThreatEventRelateService) {
31+
r = &ThreatEventRelateService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Creates event references for a event
37+
func (r *ThreatEventRelateService) Update(ctx context.Context, accountID float64, eventID string, body ThreatEventRelateUpdateParams, opts ...option.RequestOption) (res *ThreatEventRelateUpdateResponse, err error) {
38+
var env ThreatEventRelateUpdateResponseEnvelope
39+
opts = append(r.Options[:], opts...)
40+
if eventID == "" {
41+
err = errors.New("missing required eventId parameter")
42+
return
43+
}
44+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/relate/%s", accountID, eventID)
45+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
46+
if err != nil {
47+
return
48+
}
49+
res = &env.Result
50+
return
51+
}
52+
53+
// Removes an event refence
54+
func (r *ThreatEventRelateService) Delete(ctx context.Context, accountID float64, eventID string, opts ...option.RequestOption) (res *ThreatEventRelateDeleteResponse, err error) {
55+
var env ThreatEventRelateDeleteResponseEnvelope
56+
opts = append(r.Options[:], opts...)
57+
if eventID == "" {
58+
err = errors.New("missing required eventId parameter")
59+
return
60+
}
61+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/relate/%s", accountID, eventID)
62+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
63+
if err != nil {
64+
return
65+
}
66+
res = &env.Result
67+
return
68+
}
69+
70+
type ThreatEventRelateUpdateResponse struct {
71+
Success bool `json:"success,required"`
72+
JSON threatEventRelateUpdateResponseJSON `json:"-"`
73+
}
74+
75+
// threatEventRelateUpdateResponseJSON contains the JSON metadata for the struct
76+
// [ThreatEventRelateUpdateResponse]
77+
type threatEventRelateUpdateResponseJSON struct {
78+
Success apijson.Field
79+
raw string
80+
ExtraFields map[string]apijson.Field
81+
}
82+
83+
func (r *ThreatEventRelateUpdateResponse) UnmarshalJSON(data []byte) (err error) {
84+
return apijson.UnmarshalRoot(data, r)
85+
}
86+
87+
func (r threatEventRelateUpdateResponseJSON) RawJSON() string {
88+
return r.raw
89+
}
90+
91+
type ThreatEventRelateDeleteResponse struct {
92+
Success bool `json:"success,required"`
93+
JSON threatEventRelateDeleteResponseJSON `json:"-"`
94+
}
95+
96+
// threatEventRelateDeleteResponseJSON contains the JSON metadata for the struct
97+
// [ThreatEventRelateDeleteResponse]
98+
type threatEventRelateDeleteResponseJSON struct {
99+
Success apijson.Field
100+
raw string
101+
ExtraFields map[string]apijson.Field
102+
}
103+
104+
func (r *ThreatEventRelateDeleteResponse) UnmarshalJSON(data []byte) (err error) {
105+
return apijson.UnmarshalRoot(data, r)
106+
}
107+
108+
func (r threatEventRelateDeleteResponseJSON) RawJSON() string {
109+
return r.raw
110+
}
111+
112+
type ThreatEventRelateUpdateParams struct {
113+
Events param.Field[[]string] `json:"events,required"`
114+
}
115+
116+
func (r ThreatEventRelateUpdateParams) MarshalJSON() (data []byte, err error) {
117+
return apijson.MarshalRoot(r)
118+
}
119+
120+
type ThreatEventRelateUpdateResponseEnvelope struct {
121+
Result ThreatEventRelateUpdateResponse `json:"result,required"`
122+
Success bool `json:"success,required"`
123+
JSON threatEventRelateUpdateResponseEnvelopeJSON `json:"-"`
124+
}
125+
126+
// threatEventRelateUpdateResponseEnvelopeJSON contains the JSON metadata for the
127+
// struct [ThreatEventRelateUpdateResponseEnvelope]
128+
type threatEventRelateUpdateResponseEnvelopeJSON struct {
129+
Result apijson.Field
130+
Success apijson.Field
131+
raw string
132+
ExtraFields map[string]apijson.Field
133+
}
134+
135+
func (r *ThreatEventRelateUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
136+
return apijson.UnmarshalRoot(data, r)
137+
}
138+
139+
func (r threatEventRelateUpdateResponseEnvelopeJSON) RawJSON() string {
140+
return r.raw
141+
}
142+
143+
type ThreatEventRelateDeleteResponseEnvelope struct {
144+
Result ThreatEventRelateDeleteResponse `json:"result,required"`
145+
Success bool `json:"success,required"`
146+
JSON threatEventRelateDeleteResponseEnvelopeJSON `json:"-"`
147+
}
148+
149+
// threatEventRelateDeleteResponseEnvelopeJSON contains the JSON metadata for the
150+
// struct [ThreatEventRelateDeleteResponseEnvelope]
151+
type threatEventRelateDeleteResponseEnvelopeJSON struct {
152+
Result apijson.Field
153+
Success apijson.Field
154+
raw string
155+
ExtraFields map[string]apijson.Field
156+
}
157+
158+
func (r *ThreatEventRelateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
159+
return apijson.UnmarshalRoot(data, r)
160+
}
161+
162+
func (r threatEventRelateDeleteResponseEnvelopeJSON) RawJSON() string {
163+
return r.raw
164+
}
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestThreatEventRelateUpdate(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.CloudforceOne.ThreatEvents.Relate.Update(
31+
context.TODO(),
32+
0.000000,
33+
"eventId",
34+
cloudforce_one.ThreatEventRelateUpdateParams{
35+
Events: cloudflare.F([]string{"88888888-4444-4444-4444-121212121212"}),
36+
},
37+
)
38+
if err != nil {
39+
var apierr *cloudflare.Error
40+
if errors.As(err, &apierr) {
41+
t.Log(string(apierr.DumpRequest(true)))
42+
}
43+
t.Fatalf("err should be nil: %s", err.Error())
44+
}
45+
}
46+
47+
func TestThreatEventRelateDelete(t *testing.T) {
48+
baseURL := "http://localhost:4010"
49+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
50+
baseURL = envURL
51+
}
52+
if !testutil.CheckTestServer(t, baseURL) {
53+
return
54+
}
55+
client := cloudflare.NewClient(
56+
option.WithBaseURL(baseURL),
57+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
58+
option.WithAPIEmail("user@example.com"),
59+
)
60+
_, err := client.CloudforceOne.ThreatEvents.Relate.Delete(
61+
context.TODO(),
62+
0.000000,
63+
"eventId",
64+
)
65+
if err != nil {
66+
var apierr *cloudflare.Error
67+
if errors.As(err, &apierr) {
68+
t.Log(string(apierr.DumpRequest(true)))
69+
}
70+
t.Fatalf("err should be nil: %s", err.Error())
71+
}
72+
}

‎cloudforce_one/threateventtag.go

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
// ThreatEventTagService contains methods and other services that help with
18+
// interacting with the cloudflare API.
19+
//
20+
// Note, unlike clients, this service does not read variables from the environment
21+
// automatically. You should not instantiate this service directly, and instead use
22+
// the [NewThreatEventTagService] method instead.
23+
type ThreatEventTagService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventTagService generates a new service that applies the given options
28+
// to each request. These options are applied after the parent client's options (if
29+
// there is one), and before any request-specific options.
30+
func NewThreatEventTagService(opts ...option.RequestOption) (r *ThreatEventTagService) {
31+
r = &ThreatEventTagService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Creates a new tag
37+
func (r *ThreatEventTagService) New(ctx context.Context, accountID float64, body ThreatEventTagNewParams, opts ...option.RequestOption) (res *ThreatEventTagNewResponse, err error) {
38+
opts = append(r.Options[:], opts...)
39+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/tags/create", accountID)
40+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
41+
return
42+
}
43+
44+
// Adds a tag to an event
45+
func (r *ThreatEventTagService) Update(ctx context.Context, accountID float64, eventID string, body ThreatEventTagUpdateParams, opts ...option.RequestOption) (res *ThreatEventTagUpdateResponse, err error) {
46+
var env ThreatEventTagUpdateResponseEnvelope
47+
opts = append(r.Options[:], opts...)
48+
if eventID == "" {
49+
err = errors.New("missing required eventId parameter")
50+
return
51+
}
52+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/tag/%s", accountID, eventID)
53+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
54+
if err != nil {
55+
return
56+
}
57+
res = &env.Result
58+
return
59+
}
60+
61+
// Removes a tag from an event
62+
func (r *ThreatEventTagService) Delete(ctx context.Context, accountID float64, eventID string, opts ...option.RequestOption) (res *ThreatEventTagDeleteResponse, err error) {
63+
var env ThreatEventTagDeleteResponseEnvelope
64+
opts = append(r.Options[:], opts...)
65+
if eventID == "" {
66+
err = errors.New("missing required eventId parameter")
67+
return
68+
}
69+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/tag/%s", accountID, eventID)
70+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
71+
if err != nil {
72+
return
73+
}
74+
res = &env.Result
75+
return
76+
}
77+
78+
type ThreatEventTagNewResponse struct {
79+
Name string `json:"name,required"`
80+
UUID string `json:"uuid,required"`
81+
JSON threatEventTagNewResponseJSON `json:"-"`
82+
}
83+
84+
// threatEventTagNewResponseJSON contains the JSON metadata for the struct
85+
// [ThreatEventTagNewResponse]
86+
type threatEventTagNewResponseJSON struct {
87+
Name apijson.Field
88+
UUID apijson.Field
89+
raw string
90+
ExtraFields map[string]apijson.Field
91+
}
92+
93+
func (r *ThreatEventTagNewResponse) UnmarshalJSON(data []byte) (err error) {
94+
return apijson.UnmarshalRoot(data, r)
95+
}
96+
97+
func (r threatEventTagNewResponseJSON) RawJSON() string {
98+
return r.raw
99+
}
100+
101+
type ThreatEventTagUpdateResponse struct {
102+
Success bool `json:"success,required"`
103+
JSON threatEventTagUpdateResponseJSON `json:"-"`
104+
}
105+
106+
// threatEventTagUpdateResponseJSON contains the JSON metadata for the struct
107+
// [ThreatEventTagUpdateResponse]
108+
type threatEventTagUpdateResponseJSON struct {
109+
Success apijson.Field
110+
raw string
111+
ExtraFields map[string]apijson.Field
112+
}
113+
114+
func (r *ThreatEventTagUpdateResponse) UnmarshalJSON(data []byte) (err error) {
115+
return apijson.UnmarshalRoot(data, r)
116+
}
117+
118+
func (r threatEventTagUpdateResponseJSON) RawJSON() string {
119+
return r.raw
120+
}
121+
122+
type ThreatEventTagDeleteResponse struct {
123+
Success bool `json:"success,required"`
124+
JSON threatEventTagDeleteResponseJSON `json:"-"`
125+
}
126+
127+
// threatEventTagDeleteResponseJSON contains the JSON metadata for the struct
128+
// [ThreatEventTagDeleteResponse]
129+
type threatEventTagDeleteResponseJSON struct {
130+
Success apijson.Field
131+
raw string
132+
ExtraFields map[string]apijson.Field
133+
}
134+
135+
func (r *ThreatEventTagDeleteResponse) UnmarshalJSON(data []byte) (err error) {
136+
return apijson.UnmarshalRoot(data, r)
137+
}
138+
139+
func (r threatEventTagDeleteResponseJSON) RawJSON() string {
140+
return r.raw
141+
}
142+
143+
type ThreatEventTagNewParams struct {
144+
Name param.Field[string] `json:"name,required"`
145+
}
146+
147+
func (r ThreatEventTagNewParams) MarshalJSON() (data []byte, err error) {
148+
return apijson.MarshalRoot(r)
149+
}
150+
151+
type ThreatEventTagUpdateParams struct {
152+
Tags param.Field[[]string] `json:"tags,required"`
153+
}
154+
155+
func (r ThreatEventTagUpdateParams) MarshalJSON() (data []byte, err error) {
156+
return apijson.MarshalRoot(r)
157+
}
158+
159+
type ThreatEventTagUpdateResponseEnvelope struct {
160+
Result ThreatEventTagUpdateResponse `json:"result,required"`
161+
Success bool `json:"success,required"`
162+
JSON threatEventTagUpdateResponseEnvelopeJSON `json:"-"`
163+
}
164+
165+
// threatEventTagUpdateResponseEnvelopeJSON contains the JSON metadata for the
166+
// struct [ThreatEventTagUpdateResponseEnvelope]
167+
type threatEventTagUpdateResponseEnvelopeJSON struct {
168+
Result apijson.Field
169+
Success apijson.Field
170+
raw string
171+
ExtraFields map[string]apijson.Field
172+
}
173+
174+
func (r *ThreatEventTagUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
175+
return apijson.UnmarshalRoot(data, r)
176+
}
177+
178+
func (r threatEventTagUpdateResponseEnvelopeJSON) RawJSON() string {
179+
return r.raw
180+
}
181+
182+
type ThreatEventTagDeleteResponseEnvelope struct {
183+
Result ThreatEventTagDeleteResponse `json:"result,required"`
184+
Success bool `json:"success,required"`
185+
JSON threatEventTagDeleteResponseEnvelopeJSON `json:"-"`
186+
}
187+
188+
// threatEventTagDeleteResponseEnvelopeJSON contains the JSON metadata for the
189+
// struct [ThreatEventTagDeleteResponseEnvelope]
190+
type threatEventTagDeleteResponseEnvelopeJSON struct {
191+
Result apijson.Field
192+
Success apijson.Field
193+
raw string
194+
ExtraFields map[string]apijson.Field
195+
}
196+
197+
func (r *ThreatEventTagDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
198+
return apijson.UnmarshalRoot(data, r)
199+
}
200+
201+
func (r threatEventTagDeleteResponseEnvelopeJSON) RawJSON() string {
202+
return r.raw
203+
}

‎cloudforce_one/threateventtag_test.go

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/cloudforce_one"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestThreatEventTagNew(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.CloudforceOne.ThreatEvents.Tags.New(
31+
context.TODO(),
32+
0.000000,
33+
cloudforce_one.ThreatEventTagNewParams{
34+
Name: cloudflare.F("name"),
35+
},
36+
)
37+
if err != nil {
38+
var apierr *cloudflare.Error
39+
if errors.As(err, &apierr) {
40+
t.Log(string(apierr.DumpRequest(true)))
41+
}
42+
t.Fatalf("err should be nil: %s", err.Error())
43+
}
44+
}
45+
46+
func TestThreatEventTagUpdate(t *testing.T) {
47+
baseURL := "http://localhost:4010"
48+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
49+
baseURL = envURL
50+
}
51+
if !testutil.CheckTestServer(t, baseURL) {
52+
return
53+
}
54+
client := cloudflare.NewClient(
55+
option.WithBaseURL(baseURL),
56+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
57+
option.WithAPIEmail("user@example.com"),
58+
)
59+
_, err := client.CloudforceOne.ThreatEvents.Tags.Update(
60+
context.TODO(),
61+
0.000000,
62+
"eventId",
63+
cloudforce_one.ThreatEventTagUpdateParams{
64+
Tags: cloudflare.F([]string{"botnet"}),
65+
},
66+
)
67+
if err != nil {
68+
var apierr *cloudflare.Error
69+
if errors.As(err, &apierr) {
70+
t.Log(string(apierr.DumpRequest(true)))
71+
}
72+
t.Fatalf("err should be nil: %s", err.Error())
73+
}
74+
}
75+
76+
func TestThreatEventTagDelete(t *testing.T) {
77+
baseURL := "http://localhost:4010"
78+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
79+
baseURL = envURL
80+
}
81+
if !testutil.CheckTestServer(t, baseURL) {
82+
return
83+
}
84+
client := cloudflare.NewClient(
85+
option.WithBaseURL(baseURL),
86+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
87+
option.WithAPIEmail("user@example.com"),
88+
)
89+
_, err := client.CloudforceOne.ThreatEvents.Tags.Delete(
90+
context.TODO(),
91+
0.000000,
92+
"eventId",
93+
)
94+
if err != nil {
95+
var apierr *cloudflare.Error
96+
if errors.As(err, &apierr) {
97+
t.Log(string(apierr.DumpRequest(true)))
98+
}
99+
t.Fatalf("err should be nil: %s", err.Error())
100+
}
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"net/http"
9+
10+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
11+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
12+
"github.com/cloudflare/cloudflare-go/v4/option"
13+
)
14+
15+
// ThreatEventTargetIndustryService contains methods and other services that help
16+
// with interacting with the cloudflare API.
17+
//
18+
// Note, unlike clients, this service does not read variables from the environment
19+
// automatically. You should not instantiate this service directly, and instead use
20+
// the [NewThreatEventTargetIndustryService] method instead.
21+
type ThreatEventTargetIndustryService struct {
22+
Options []option.RequestOption
23+
}
24+
25+
// NewThreatEventTargetIndustryService generates a new service that applies the
26+
// given options to each request. These options are applied after the parent
27+
// client's options (if there is one), and before any request-specific options.
28+
func NewThreatEventTargetIndustryService(opts ...option.RequestOption) (r *ThreatEventTargetIndustryService) {
29+
r = &ThreatEventTargetIndustryService{}
30+
r.Options = opts
31+
return
32+
}
33+
34+
// Lists all target industries
35+
func (r *ThreatEventTargetIndustryService) List(ctx context.Context, accountID float64, opts ...option.RequestOption) (res *ThreatEventTargetIndustryListResponse, err error) {
36+
opts = append(r.Options[:], opts...)
37+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/targetIndustries", accountID)
38+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
39+
return
40+
}
41+
42+
type ThreatEventTargetIndustryListResponse struct {
43+
Items ThreatEventTargetIndustryListResponseItems `json:"items,required"`
44+
Type string `json:"type,required"`
45+
JSON threatEventTargetIndustryListResponseJSON `json:"-"`
46+
}
47+
48+
// threatEventTargetIndustryListResponseJSON contains the JSON metadata for the
49+
// struct [ThreatEventTargetIndustryListResponse]
50+
type threatEventTargetIndustryListResponseJSON struct {
51+
Items apijson.Field
52+
Type apijson.Field
53+
raw string
54+
ExtraFields map[string]apijson.Field
55+
}
56+
57+
func (r *ThreatEventTargetIndustryListResponse) UnmarshalJSON(data []byte) (err error) {
58+
return apijson.UnmarshalRoot(data, r)
59+
}
60+
61+
func (r threatEventTargetIndustryListResponseJSON) RawJSON() string {
62+
return r.raw
63+
}
64+
65+
type ThreatEventTargetIndustryListResponseItems struct {
66+
Type string `json:"type,required"`
67+
JSON threatEventTargetIndustryListResponseItemsJSON `json:"-"`
68+
}
69+
70+
// threatEventTargetIndustryListResponseItemsJSON contains the JSON metadata for
71+
// the struct [ThreatEventTargetIndustryListResponseItems]
72+
type threatEventTargetIndustryListResponseItemsJSON struct {
73+
Type apijson.Field
74+
raw string
75+
ExtraFields map[string]apijson.Field
76+
}
77+
78+
func (r *ThreatEventTargetIndustryListResponseItems) UnmarshalJSON(data []byte) (err error) {
79+
return apijson.UnmarshalRoot(data, r)
80+
}
81+
82+
func (r threatEventTargetIndustryListResponseItemsJSON) RawJSON() string {
83+
return r.raw
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cloudforce_one_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/option"
14+
)
15+
16+
func TestThreatEventTargetIndustryList(t *testing.T) {
17+
baseURL := "http://localhost:4010"
18+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
19+
baseURL = envURL
20+
}
21+
if !testutil.CheckTestServer(t, baseURL) {
22+
return
23+
}
24+
client := cloudflare.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
27+
option.WithAPIEmail("user@example.com"),
28+
)
29+
_, err := client.CloudforceOne.ThreatEvents.TargetIndustries.List(context.TODO(), 0.000000)
30+
if err != nil {
31+
var apierr *cloudflare.Error
32+
if errors.As(err, &apierr) {
33+
t.Log(string(apierr.DumpRequest(true)))
34+
}
35+
t.Fatalf("err should be nil: %s", err.Error())
36+
}
37+
}

0 commit comments

Comments
 (0)
Please sign in to comment.