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 5ab82bb

Browse files
committedMar 13, 2025·
feat(api): manual updates (#4019)
1 parent d416373 commit 5ab82bb

7 files changed

+231
-1
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1605
1+
configured_endpoints: 1607
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0f0082a0942d9f9edb37ef99423f7cdf16d0bfeb57c6ee5728e830b2a9ebff87.yml

‎api.md

+12
Original file line numberDiff line numberDiff line change
@@ -7881,12 +7881,24 @@ Methods:
78817881

78827882
Response Types:
78837883

7884+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagNewResponse">ThreatEventEventTagNewResponse</a>
78847885
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagDeleteResponse">ThreatEventEventTagDeleteResponse</a>
78857886

78867887
Methods:
78877888

7889+
- <code title="post /accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}/create">client.CloudforceOne.ThreatEvents.EventTags.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, eventID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagNewParams">ThreatEventEventTagNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagNewResponse">ThreatEventEventTagNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
78887890
- <code title="delete /accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}">client.CloudforceOne.ThreatEvents.EventTags.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, eventID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagDeleteParams">ThreatEventEventTagDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventEventTagDeleteResponse">ThreatEventEventTagDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
78897891

7892+
### Tags
7893+
7894+
Response Types:
7895+
7896+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventTagNewResponse">ThreatEventTagNewResponse</a>
7897+
7898+
Methods:
7899+
7900+
- <code title="post /accounts/{account_id}/cloudforce-one/events/tags/create">client.CloudforceOne.ThreatEvents.Tags.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventTagService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventTagNewParams">ThreatEventTagNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventTagNewResponse">ThreatEventTagNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7901+
78907902
### TargetIndustries
78917903

78927904
Response Types:

‎cloudforce_one/threatevent.go

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type ThreatEventService struct {
3232
Raw *ThreatEventRawService
3333
Relate *ThreatEventRelateService
3434
EventTags *ThreatEventEventTagService
35+
Tags *ThreatEventTagService
3536
TargetIndustries *ThreatEventTargetIndustryService
3637
Insights *ThreatEventInsightService
3738
}
@@ -51,6 +52,7 @@ func NewThreatEventService(opts ...option.RequestOption) (r *ThreatEventService)
5152
r.Raw = NewThreatEventRawService(opts...)
5253
r.Relate = NewThreatEventRelateService(opts...)
5354
r.EventTags = NewThreatEventEventTagService(opts...)
55+
r.Tags = NewThreatEventTagService(opts...)
5456
r.TargetIndustries = NewThreatEventTargetIndustryService(opts...)
5557
r.Insights = NewThreatEventInsightService(opts...)
5658
return

‎cloudforce_one/threateventeventtag.go

+71
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ func NewThreatEventEventTagService(opts ...option.RequestOption) (r *ThreatEvent
3333
return
3434
}
3535

36+
// Adds a tag to an event
37+
func (r *ThreatEventEventTagService) New(ctx context.Context, eventID string, params ThreatEventEventTagNewParams, opts ...option.RequestOption) (res *ThreatEventEventTagNewResponse, err error) {
38+
var env ThreatEventEventTagNewResponseEnvelope
39+
opts = append(r.Options[:], opts...)
40+
if eventID == "" {
41+
err = errors.New("missing required event_id parameter")
42+
return
43+
}
44+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/event_tag/%s/create", params.AccountID, eventID)
45+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...)
46+
if err != nil {
47+
return
48+
}
49+
res = &env.Result
50+
return
51+
}
52+
3653
// Removes a tag from an event
3754
func (r *ThreatEventEventTagService) Delete(ctx context.Context, eventID string, body ThreatEventEventTagDeleteParams, opts ...option.RequestOption) (res *ThreatEventEventTagDeleteResponse, err error) {
3855
var env ThreatEventEventTagDeleteResponseEnvelope
@@ -50,6 +67,27 @@ func (r *ThreatEventEventTagService) Delete(ctx context.Context, eventID string,
5067
return
5168
}
5269

70+
type ThreatEventEventTagNewResponse struct {
71+
Success bool `json:"success,required"`
72+
JSON threatEventEventTagNewResponseJSON `json:"-"`
73+
}
74+
75+
// threatEventEventTagNewResponseJSON contains the JSON metadata for the struct
76+
// [ThreatEventEventTagNewResponse]
77+
type threatEventEventTagNewResponseJSON struct {
78+
Success apijson.Field
79+
raw string
80+
ExtraFields map[string]apijson.Field
81+
}
82+
83+
func (r *ThreatEventEventTagNewResponse) UnmarshalJSON(data []byte) (err error) {
84+
return apijson.UnmarshalRoot(data, r)
85+
}
86+
87+
func (r threatEventEventTagNewResponseJSON) RawJSON() string {
88+
return r.raw
89+
}
90+
5391
type ThreatEventEventTagDeleteResponse struct {
5492
Success bool `json:"success,required"`
5593
JSON threatEventEventTagDeleteResponseJSON `json:"-"`
@@ -71,6 +109,39 @@ func (r threatEventEventTagDeleteResponseJSON) RawJSON() string {
71109
return r.raw
72110
}
73111

112+
type ThreatEventEventTagNewParams struct {
113+
// Account ID
114+
AccountID param.Field[float64] `path:"account_id,required"`
115+
Tags param.Field[[]string] `json:"tags,required"`
116+
}
117+
118+
func (r ThreatEventEventTagNewParams) MarshalJSON() (data []byte, err error) {
119+
return apijson.MarshalRoot(r)
120+
}
121+
122+
type ThreatEventEventTagNewResponseEnvelope struct {
123+
Result ThreatEventEventTagNewResponse `json:"result,required"`
124+
Success bool `json:"success,required"`
125+
JSON threatEventEventTagNewResponseEnvelopeJSON `json:"-"`
126+
}
127+
128+
// threatEventEventTagNewResponseEnvelopeJSON contains the JSON metadata for the
129+
// struct [ThreatEventEventTagNewResponseEnvelope]
130+
type threatEventEventTagNewResponseEnvelopeJSON struct {
131+
Result apijson.Field
132+
Success apijson.Field
133+
raw string
134+
ExtraFields map[string]apijson.Field
135+
}
136+
137+
func (r *ThreatEventEventTagNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
138+
return apijson.UnmarshalRoot(data, r)
139+
}
140+
141+
func (r threatEventEventTagNewResponseEnvelopeJSON) RawJSON() string {
142+
return r.raw
143+
}
144+
74145
type ThreatEventEventTagDeleteParams struct {
75146
// Account ID
76147
AccountID param.Field[float64] `path:"account_id,required"`

‎cloudforce_one/threateventeventtag_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@ import (
1414
"github.com/cloudflare/cloudflare-go/v4/option"
1515
)
1616

17+
func TestThreatEventEventTagNew(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.EventTags.New(
31+
context.TODO(),
32+
"event_id",
33+
cloudforce_one.ThreatEventEventTagNewParams{
34+
AccountID: cloudflare.F(0.000000),
35+
Tags: cloudflare.F([]string{"botnet"}),
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+
1747
func TestThreatEventEventTagDelete(t *testing.T) {
1848
baseURL := "http://localhost:4010"
1949
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

‎cloudforce_one/threateventtag.go

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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/param"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
13+
"github.com/cloudflare/cloudflare-go/v4/option"
14+
)
15+
16+
// ThreatEventTagService contains methods and other services that help with
17+
// interacting with the cloudflare API.
18+
//
19+
// Note, unlike clients, this service does not read variables from the environment
20+
// automatically. You should not instantiate this service directly, and instead use
21+
// the [NewThreatEventTagService] method instead.
22+
type ThreatEventTagService struct {
23+
Options []option.RequestOption
24+
}
25+
26+
// NewThreatEventTagService generates a new service that applies the given options
27+
// to each request. These options are applied after the parent client's options (if
28+
// there is one), and before any request-specific options.
29+
func NewThreatEventTagService(opts ...option.RequestOption) (r *ThreatEventTagService) {
30+
r = &ThreatEventTagService{}
31+
r.Options = opts
32+
return
33+
}
34+
35+
// Creates a new tag
36+
func (r *ThreatEventTagService) New(ctx context.Context, params ThreatEventTagNewParams, opts ...option.RequestOption) (res *ThreatEventTagNewResponse, err error) {
37+
opts = append(r.Options[:], opts...)
38+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/tags/create", params.AccountID)
39+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
40+
return
41+
}
42+
43+
type ThreatEventTagNewResponse struct {
44+
Name string `json:"name,required"`
45+
UUID string `json:"uuid,required"`
46+
JSON threatEventTagNewResponseJSON `json:"-"`
47+
}
48+
49+
// threatEventTagNewResponseJSON contains the JSON metadata for the struct
50+
// [ThreatEventTagNewResponse]
51+
type threatEventTagNewResponseJSON struct {
52+
Name apijson.Field
53+
UUID apijson.Field
54+
raw string
55+
ExtraFields map[string]apijson.Field
56+
}
57+
58+
func (r *ThreatEventTagNewResponse) UnmarshalJSON(data []byte) (err error) {
59+
return apijson.UnmarshalRoot(data, r)
60+
}
61+
62+
func (r threatEventTagNewResponseJSON) RawJSON() string {
63+
return r.raw
64+
}
65+
66+
type ThreatEventTagNewParams struct {
67+
// Account ID
68+
AccountID param.Field[float64] `path:"account_id,required"`
69+
Name param.Field[string] `json:"name,required"`
70+
}
71+
72+
func (r ThreatEventTagNewParams) MarshalJSON() (data []byte, err error) {
73+
return apijson.MarshalRoot(r)
74+
}

‎cloudforce_one/threateventtag_test.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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(context.TODO(), cloudforce_one.ThreatEventTagNewParams{
31+
AccountID: cloudflare.F(0.000000),
32+
Name: cloudflare.F("name"),
33+
})
34+
if err != nil {
35+
var apierr *cloudflare.Error
36+
if errors.As(err, &apierr) {
37+
t.Log(string(apierr.DumpRequest(true)))
38+
}
39+
t.Fatalf("err should be nil: %s", err.Error())
40+
}
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.