Skip to content

Commit 338e920

Browse files
feat(infrastructure_targets): swap DELETE handler to new endpoint
1 parent 9291f94 commit 338e920

File tree

7 files changed

+162
-14
lines changed

7 files changed

+162
-14
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1741
1+
configured_endpoints: 1742
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f49df4d8a7f775cdca0044a946f1d28f8d276e82e443b856a430ddaad809d20.yml
33
openapi_spec_hash: 6b84a57ef92b8257081b32a496821094
4-
config_hash: f6c4a93139a93cfd16a678e54b5fb249
4+
config_hash: 85703bb37ad4f7b8bfeea6f128f351a0

api.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5196,7 +5196,7 @@ Methods:
51965196
- <code title="put /accounts/{account_id}/infrastructure/targets/{target_id}">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, targetID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetUpdateParams">AccessInfrastructureTargetUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetUpdateResponse">AccessInfrastructureTargetUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
51975197
- <code title="get /accounts/{account_id}/infrastructure/targets">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.List">List</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/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetListParams">AccessInfrastructureTargetListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetListResponse">AccessInfrastructureTargetListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
51985198
- <code title="delete /accounts/{account_id}/infrastructure/targets/{target_id}">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, targetID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetDeleteParams">AccessInfrastructureTargetDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
5199-
- <code title="post /accounts/{account_id}/infrastructure/targets/batch_delete">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.BulkDelete">BulkDelete</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/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetBulkDeleteParams">AccessInfrastructureTargetBulkDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
5199+
- <code title="delete /accounts/{account_id}/infrastructure/targets/batch">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.BulkDelete">BulkDelete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetBulkDeleteParams">AccessInfrastructureTargetBulkDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
52005200
- <code title="put /accounts/{account_id}/infrastructure/targets/batch">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.BulkUpdate">BulkUpdate</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/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetBulkUpdateParams">AccessInfrastructureTargetBulkUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetBulkUpdateResponse">AccessInfrastructureTargetBulkUpdateResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
52015201
- <code title="get /accounts/{account_id}/infrastructure/targets/{target_id}">client.ZeroTrust.Access.Infrastructure.Targets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, targetID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetGetParams">AccessInfrastructureTargetGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zero_trust#AccessInfrastructureTargetGetResponse">AccessInfrastructureTargetGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
52025202

@@ -8164,6 +8164,16 @@ Methods:
81648164
- <code title="get /accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}">client.CloudforceOne.ThreatEvents.Datasets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventDatasetService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, datasetID <a href="https://pkg.go.dev/builtin#string">string</a>, query <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#ThreatEventDatasetGetParams">ThreatEventDatasetGetParams</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#ThreatEventDatasetGetResponse">ThreatEventDatasetGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
81658165
- <code title="get /accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}">client.CloudforceOne.ThreatEvents.Datasets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventDatasetService.Raw">Raw</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, datasetID <a href="https://pkg.go.dev/builtin#string">string</a>, eventID <a href="https://pkg.go.dev/builtin#string">string</a>, query <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#ThreatEventDatasetRawParams">ThreatEventDatasetRawParams</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#ThreatEventDatasetRawResponse">ThreatEventDatasetRawResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
81668166

8167+
#### Health
8168+
8169+
Response Types:
8170+
8171+
- <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#ThreatEventDatasetHealthGetResponse">ThreatEventDatasetHealthGetResponse</a>
8172+
8173+
Methods:
8174+
8175+
- <code title="get /accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}/health">client.CloudforceOne.ThreatEvents.Datasets.Health.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/cloudforce_one#ThreatEventDatasetHealthService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, datasetID <a href="https://pkg.go.dev/builtin#string">string</a>, query <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#ThreatEventDatasetHealthGetParams">ThreatEventDatasetHealthGetParams</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#ThreatEventDatasetHealthGetResponse">ThreatEventDatasetHealthGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
8176+
81678177
### IndicatorTypes
81688178

81698179
Response Types:

cloudforce_one/threateventdataset.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
// the [NewThreatEventDatasetService] method instead.
2323
type ThreatEventDatasetService struct {
2424
Options []option.RequestOption
25+
Health *ThreatEventDatasetHealthService
2526
}
2627

2728
// NewThreatEventDatasetService generates a new service that applies the given
@@ -30,6 +31,7 @@ type ThreatEventDatasetService struct {
3031
func NewThreatEventDatasetService(opts ...option.RequestOption) (r *ThreatEventDatasetService) {
3132
r = &ThreatEventDatasetService{}
3233
r.Options = opts
34+
r.Health = NewThreatEventDatasetHealthService(opts...)
3335
return
3436
}
3537

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
// ThreatEventDatasetHealthService contains methods and other services that help
18+
// with 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 [NewThreatEventDatasetHealthService] method instead.
23+
type ThreatEventDatasetHealthService struct {
24+
Options []option.RequestOption
25+
}
26+
27+
// NewThreatEventDatasetHealthService generates a new service that applies the
28+
// given options to each request. These options are applied after the parent
29+
// client's options (if there is one), and before any request-specific options.
30+
func NewThreatEventDatasetHealthService(opts ...option.RequestOption) (r *ThreatEventDatasetHealthService) {
31+
r = &ThreatEventDatasetHealthService{}
32+
r.Options = opts
33+
return
34+
}
35+
36+
// Benchmark Durable Object warmup
37+
func (r *ThreatEventDatasetHealthService) Get(ctx context.Context, datasetID string, query ThreatEventDatasetHealthGetParams, opts ...option.RequestOption) (res *ThreatEventDatasetHealthGetResponse, err error) {
38+
opts = append(r.Options[:], opts...)
39+
if !query.AccountID.Present {
40+
err = errors.New("missing required account_id parameter")
41+
return
42+
}
43+
if datasetID == "" {
44+
err = errors.New("missing required dataset_id parameter")
45+
return
46+
}
47+
path := fmt.Sprintf("accounts/%v/cloudforce-one/events/dataset/%s/health", query.AccountID, datasetID)
48+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
49+
return
50+
}
51+
52+
type ThreatEventDatasetHealthGetResponse struct {
53+
Items ThreatEventDatasetHealthGetResponseItems `json:"items,required"`
54+
Type string `json:"type,required"`
55+
JSON threatEventDatasetHealthGetResponseJSON `json:"-"`
56+
}
57+
58+
// threatEventDatasetHealthGetResponseJSON contains the JSON metadata for the
59+
// struct [ThreatEventDatasetHealthGetResponse]
60+
type threatEventDatasetHealthGetResponseJSON struct {
61+
Items apijson.Field
62+
Type apijson.Field
63+
raw string
64+
ExtraFields map[string]apijson.Field
65+
}
66+
67+
func (r *ThreatEventDatasetHealthGetResponse) UnmarshalJSON(data []byte) (err error) {
68+
return apijson.UnmarshalRoot(data, r)
69+
}
70+
71+
func (r threatEventDatasetHealthGetResponseJSON) RawJSON() string {
72+
return r.raw
73+
}
74+
75+
type ThreatEventDatasetHealthGetResponseItems struct {
76+
Type string `json:"type,required"`
77+
JSON threatEventDatasetHealthGetResponseItemsJSON `json:"-"`
78+
}
79+
80+
// threatEventDatasetHealthGetResponseItemsJSON contains the JSON metadata for the
81+
// struct [ThreatEventDatasetHealthGetResponseItems]
82+
type threatEventDatasetHealthGetResponseItemsJSON struct {
83+
Type apijson.Field
84+
raw string
85+
ExtraFields map[string]apijson.Field
86+
}
87+
88+
func (r *ThreatEventDatasetHealthGetResponseItems) UnmarshalJSON(data []byte) (err error) {
89+
return apijson.UnmarshalRoot(data, r)
90+
}
91+
92+
func (r threatEventDatasetHealthGetResponseItemsJSON) RawJSON() string {
93+
return r.raw
94+
}
95+
96+
type ThreatEventDatasetHealthGetParams struct {
97+
// Account ID.
98+
AccountID param.Field[float64] `path:"account_id,required"`
99+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 TestThreatEventDatasetHealthGet(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.Datasets.Health.Get(
31+
context.TODO(),
32+
"dataset_id",
33+
cloudforce_one.ThreatEventDatasetHealthGetParams{
34+
AccountID: cloudflare.F(0.000000),
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+
}

zero_trust/accessinfrastructuretarget.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ func (r *AccessInfrastructureTargetService) Delete(ctx context.Context, targetID
122122
}
123123

124124
// Removes one or more targets.
125-
func (r *AccessInfrastructureTargetService) BulkDelete(ctx context.Context, params AccessInfrastructureTargetBulkDeleteParams, opts ...option.RequestOption) (err error) {
125+
func (r *AccessInfrastructureTargetService) BulkDelete(ctx context.Context, body AccessInfrastructureTargetBulkDeleteParams, opts ...option.RequestOption) (err error) {
126126
opts = append(r.Options[:], opts...)
127127
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
128-
if params.AccountID.Value == "" {
128+
if body.AccountID.Value == "" {
129129
err = errors.New("missing required account_id parameter")
130130
return
131131
}
132-
path := fmt.Sprintf("accounts/%s/infrastructure/targets/batch_delete", params.AccountID)
133-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...)
132+
path := fmt.Sprintf("accounts/%s/infrastructure/targets/batch", body.AccountID)
133+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
134134
return
135135
}
136136

@@ -1242,12 +1242,6 @@ type AccessInfrastructureTargetDeleteParams struct {
12421242
type AccessInfrastructureTargetBulkDeleteParams struct {
12431243
// Account identifier
12441244
AccountID param.Field[string] `path:"account_id,required"`
1245-
// List of target IDs to bulk delete
1246-
TargetIDs param.Field[[]string] `json:"target_ids,required" format:"uuid"`
1247-
}
1248-
1249-
func (r AccessInfrastructureTargetBulkDeleteParams) MarshalJSON() (data []byte, err error) {
1250-
return apijson.MarshalRoot(r)
12511245
}
12521246

12531247
type AccessInfrastructureTargetBulkUpdateParams struct {

zero_trust/accessinfrastructuretarget_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ func TestAccessInfrastructureTargetBulkDelete(t *testing.T) {
180180
)
181181
err := client.ZeroTrust.Access.Infrastructure.Targets.BulkDelete(context.TODO(), zero_trust.AccessInfrastructureTargetBulkDeleteParams{
182182
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
183-
TargetIDs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
184183
})
185184
if err != nil {
186185
var apierr *cloudflare.Error

0 commit comments

Comments
 (0)