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 754f327

Browse files
committedMar 18, 2025·
feat(radar): add compromised credential endpoints (#4049)
1 parent 9ac7110 commit 754f327

8 files changed

+1120
-1
lines changed
 

‎.stats.yml

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

‎api.md

+26
Original file line numberDiff line numberDiff line change
@@ -7506,6 +7506,32 @@ Methods:
75067506

75077507
- <code title="get /radar/robots_txt/top/user_agents/directive">client.Radar.RobotsTXT.Top.UserAgents.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#RobotsTXTTopUserAgentService.Directive">Directive</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#RobotsTXTTopUserAgentDirectiveParams">RobotsTXTTopUserAgentDirectiveParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#RobotsTXTTopUserAgentDirectiveResponse">RobotsTXTTopUserAgentDirectiveResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
75087508

7509+
## LeakedCredentials
7510+
7511+
### Summary
7512+
7513+
Response Types:
7514+
7515+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryBotClassResponse">LeakedCredentialSummaryBotClassResponse</a>
7516+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryCompromisedResponse">LeakedCredentialSummaryCompromisedResponse</a>
7517+
7518+
Methods:
7519+
7520+
- <code title="get /radar/leaked_credential_checks/summary/bot_class">client.Radar.LeakedCredentials.Summary.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryService.BotClass">BotClass</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryBotClassParams">LeakedCredentialSummaryBotClassParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryBotClassResponse">LeakedCredentialSummaryBotClassResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7521+
- <code title="get /radar/leaked_credential_checks/summary/compromised">client.Radar.LeakedCredentials.Summary.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryService.Compromised">Compromised</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryCompromisedParams">LeakedCredentialSummaryCompromisedParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialSummaryCompromisedResponse">LeakedCredentialSummaryCompromisedResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7522+
7523+
### TimeseriesGroups
7524+
7525+
Response Types:
7526+
7527+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupBotClassResponse">LeakedCredentialTimeseriesGroupBotClassResponse</a>
7528+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupCompromisedResponse">LeakedCredentialTimeseriesGroupCompromisedResponse</a>
7529+
7530+
Methods:
7531+
7532+
- <code title="get /radar/leaked_credential_checks/timeseries_groups/bot_class">client.Radar.LeakedCredentials.TimeseriesGroups.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupService.BotClass">BotClass</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupBotClassParams">LeakedCredentialTimeseriesGroupBotClassParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupBotClassResponse">LeakedCredentialTimeseriesGroupBotClassResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7533+
- <code title="get /radar/leaked_credential_checks/timeseries_groups/compromised">client.Radar.LeakedCredentials.TimeseriesGroups.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupService.Compromised">Compromised</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupCompromisedParams">LeakedCredentialTimeseriesGroupCompromisedParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar">radar</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/radar#LeakedCredentialTimeseriesGroupCompromisedResponse">LeakedCredentialTimeseriesGroupCompromisedResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7534+
75097535
# BotManagement
75107536

75117537
Params Types:

‎radar/leakedcredential.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package radar
4+
5+
import (
6+
"github.com/cloudflare/cloudflare-go/v4/option"
7+
)
8+
9+
// LeakedCredentialService contains methods and other services that help with
10+
// interacting with the cloudflare API.
11+
//
12+
// Note, unlike clients, this service does not read variables from the environment
13+
// automatically. You should not instantiate this service directly, and instead use
14+
// the [NewLeakedCredentialService] method instead.
15+
type LeakedCredentialService struct {
16+
Options []option.RequestOption
17+
Summary *LeakedCredentialSummaryService
18+
TimeseriesGroups *LeakedCredentialTimeseriesGroupService
19+
}
20+
21+
// NewLeakedCredentialService generates a new service that applies the given
22+
// options to each request. These options are applied after the parent client's
23+
// options (if there is one), and before any request-specific options.
24+
func NewLeakedCredentialService(opts ...option.RequestOption) (r *LeakedCredentialService) {
25+
r = &LeakedCredentialService{}
26+
r.Options = opts
27+
r.Summary = NewLeakedCredentialSummaryService(opts...)
28+
r.TimeseriesGroups = NewLeakedCredentialTimeseriesGroupService(opts...)
29+
return
30+
}

‎radar/leakedcredentialsummary.go

+536
Large diffs are not rendered by default.

‎radar/leakedcredentialsummary_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 radar_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/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
"github.com/cloudflare/cloudflare-go/v4/radar"
16+
)
17+
18+
func TestLeakedCredentialSummaryBotClassWithOptionalParams(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.Radar.LeakedCredentials.Summary.BotClass(context.TODO(), radar.LeakedCredentialSummaryBotClassParams{
32+
Compromised: cloudflare.F([]radar.LeakedCredentialSummaryBotClassParamsCompromised{radar.LeakedCredentialSummaryBotClassParamsCompromisedClean}),
33+
DateEnd: cloudflare.F([]time.Time{time.Now()}),
34+
DateRange: cloudflare.F([]string{"7d"}),
35+
DateStart: cloudflare.F([]time.Time{time.Now()}),
36+
Format: cloudflare.F(radar.LeakedCredentialSummaryBotClassParamsFormatJson),
37+
Name: cloudflare.F([]string{"main_series"}),
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 TestLeakedCredentialSummaryCompromisedWithOptionalParams(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.Radar.LeakedCredentials.Summary.Compromised(context.TODO(), radar.LeakedCredentialSummaryCompromisedParams{
62+
BotClass: cloudflare.F([]radar.LeakedCredentialSummaryCompromisedParamsBotClass{radar.LeakedCredentialSummaryCompromisedParamsBotClassLikelyAutomated}),
63+
DateEnd: cloudflare.F([]time.Time{time.Now()}),
64+
DateRange: cloudflare.F([]string{"7d"}),
65+
DateStart: cloudflare.F([]time.Time{time.Now()}),
66+
Format: cloudflare.F(radar.LeakedCredentialSummaryCompromisedParamsFormatJson),
67+
Name: cloudflare.F([]string{"main_series"}),
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+
}

‎radar/leakedcredentialtimeseriesgroup.go

+371
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package radar_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/internal/testutil"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
"github.com/cloudflare/cloudflare-go/v4/radar"
16+
)
17+
18+
func TestLeakedCredentialTimeseriesGroupBotClassWithOptionalParams(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.Radar.LeakedCredentials.TimeseriesGroups.BotClass(context.TODO(), radar.LeakedCredentialTimeseriesGroupBotClassParams{
32+
AggInterval: cloudflare.F(radar.LeakedCredentialTimeseriesGroupBotClassParamsAggInterval15m),
33+
Compromised: cloudflare.F([]radar.LeakedCredentialTimeseriesGroupBotClassParamsCompromised{radar.LeakedCredentialTimeseriesGroupBotClassParamsCompromisedClean}),
34+
DateEnd: cloudflare.F([]time.Time{time.Now()}),
35+
DateRange: cloudflare.F([]string{"7d"}),
36+
DateStart: cloudflare.F([]time.Time{time.Now()}),
37+
Format: cloudflare.F(radar.LeakedCredentialTimeseriesGroupBotClassParamsFormatJson),
38+
Name: cloudflare.F([]string{"main_series"}),
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 TestLeakedCredentialTimeseriesGroupCompromisedWithOptionalParams(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.Radar.LeakedCredentials.TimeseriesGroups.Compromised(context.TODO(), radar.LeakedCredentialTimeseriesGroupCompromisedParams{
63+
AggInterval: cloudflare.F(radar.LeakedCredentialTimeseriesGroupCompromisedParamsAggInterval15m),
64+
BotClass: cloudflare.F([]radar.LeakedCredentialTimeseriesGroupCompromisedParamsBotClass{radar.LeakedCredentialTimeseriesGroupCompromisedParamsBotClassLikelyAutomated}),
65+
DateEnd: cloudflare.F([]time.Time{time.Now()}),
66+
DateRange: cloudflare.F([]string{"7d"}),
67+
DateStart: cloudflare.F([]time.Time{time.Now()}),
68+
Format: cloudflare.F(radar.LeakedCredentialTimeseriesGroupCompromisedParamsFormatJson),
69+
Name: cloudflare.F([]string{"main_series"}),
70+
})
71+
if err != nil {
72+
var apierr *cloudflare.Error
73+
if errors.As(err, &apierr) {
74+
t.Log(string(apierr.DumpRequest(true)))
75+
}
76+
t.Fatalf("err should be nil: %s", err.Error())
77+
}
78+
}

‎radar/radar.go

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type RadarService struct {
3232
TrafficAnomalies *TrafficAnomalyService
3333
TCPResetsTimeouts *TCPResetsTimeoutService
3434
RobotsTXT *RobotsTXTService
35+
LeakedCredentials *LeakedCredentialService
3536
}
3637

3738
// NewRadarService generates a new service that applies the given options to each
@@ -58,5 +59,6 @@ func NewRadarService(opts ...option.RequestOption) (r *RadarService) {
5859
r.TrafficAnomalies = NewTrafficAnomalyService(opts...)
5960
r.TCPResetsTimeouts = NewTCPResetsTimeoutService(opts...)
6061
r.RobotsTXT = NewRobotsTXTService(opts...)
62+
r.LeakedCredentials = NewLeakedCredentialService(opts...)
6163
return
6264
}

0 commit comments

Comments
 (0)
Please sign in to comment.