Skip to content

Commit 117dbde

Browse files
feat(api): Add new bulk deletion endpoint for ZT infra targets
1 parent 459884e commit 117dbde

10 files changed

+76
-37
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1751
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-411828654ba9f71c06be10985d2328b174497e826108c74e4537f9fc36538690.yml
3-
openapi_spec_hash: 696058d2e96a27a14330444b1975cde9
4-
config_hash: 259b5eeae0358ea7d7756b294847f140
1+
configured_endpoints: 1752
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8af681407f6a8347fb5b5bb6cf6276123fd59a3930c0d41f0e0969a2460dbd72.yml
3+
openapi_spec_hash: 27a07fe056598eaa2505f33b35c23616
4+
config_hash: 135c41c52147f104907327e028f831e2

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,6 +5195,7 @@ Methods:
51955195
- <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>
51965196
- <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>
51975197
- <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>
5198+
- <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.BulkDeleteV2">BulkDeleteV2</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#AccessInfrastructureTargetBulkDeleteV2Params">AccessInfrastructureTargetBulkDeleteV2Params</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
51985199
- <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>
51995200
- <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>
52005201

zero_trust/accessinfrastructuretarget.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ func (r *AccessInfrastructureTargetService) BulkDelete(ctx context.Context, body
136136
return
137137
}
138138

139+
// Removes one or more targets.
140+
func (r *AccessInfrastructureTargetService) BulkDeleteV2(ctx context.Context, params AccessInfrastructureTargetBulkDeleteV2Params, opts ...option.RequestOption) (err error) {
141+
opts = append(r.Options[:], opts...)
142+
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
143+
if params.AccountID.Value == "" {
144+
err = errors.New("missing required account_id parameter")
145+
return
146+
}
147+
path := fmt.Sprintf("accounts/%s/infrastructure/targets/batch_delete", params.AccountID)
148+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...)
149+
return
150+
}
151+
139152
// Adds one or more targets.
140153
func (r *AccessInfrastructureTargetService) BulkUpdate(ctx context.Context, params AccessInfrastructureTargetBulkUpdateParams, opts ...option.RequestOption) (res *pagination.SinglePage[AccessInfrastructureTargetBulkUpdateResponse], err error) {
141154
var raw *http.Response
@@ -1246,6 +1259,17 @@ type AccessInfrastructureTargetBulkDeleteParams struct {
12461259
AccountID param.Field[string] `path:"account_id,required"`
12471260
}
12481261

1262+
type AccessInfrastructureTargetBulkDeleteV2Params struct {
1263+
// Account identifier
1264+
AccountID param.Field[string] `path:"account_id,required"`
1265+
// List of target IDs to bulk delete
1266+
TargetIDs param.Field[[]string] `json:"target_ids,required" format:"uuid"`
1267+
}
1268+
1269+
func (r AccessInfrastructureTargetBulkDeleteV2Params) MarshalJSON() (data []byte, err error) {
1270+
return apijson.MarshalRoot(r)
1271+
}
1272+
12491273
type AccessInfrastructureTargetBulkUpdateParams struct {
12501274
// Account identifier
12511275
AccountID param.Field[string] `path:"account_id,required"`

zero_trust/accessinfrastructuretarget_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,32 @@ func TestAccessInfrastructureTargetBulkDelete(t *testing.T) {
190190
}
191191
}
192192

193+
func TestAccessInfrastructureTargetBulkDeleteV2(t *testing.T) {
194+
baseURL := "http://localhost:4010"
195+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
196+
baseURL = envURL
197+
}
198+
if !testutil.CheckTestServer(t, baseURL) {
199+
return
200+
}
201+
client := cloudflare.NewClient(
202+
option.WithBaseURL(baseURL),
203+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
204+
option.WithAPIEmail("user@example.com"),
205+
)
206+
err := client.ZeroTrust.Access.Infrastructure.Targets.BulkDeleteV2(context.TODO(), zero_trust.AccessInfrastructureTargetBulkDeleteV2Params{
207+
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
208+
TargetIDs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
209+
})
210+
if err != nil {
211+
var apierr *cloudflare.Error
212+
if errors.As(err, &apierr) {
213+
t.Log(string(apierr.DumpRequest(true)))
214+
}
215+
t.Fatalf("err should be nil: %s", err.Error())
216+
}
217+
}
218+
193219
func TestAccessInfrastructureTargetBulkUpdate(t *testing.T) {
194220
baseURL := "http://localhost:4010"
195221
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

zero_trust/device.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ func NewDeviceService(opts ...option.RequestOption) (r *DeviceService) {
6060
return
6161
}
6262

63-
// List WARP devices. Not supported when
64-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
65-
// is enabled for the account.
63+
// List WARP registrations.
6664
//
6765
// **Deprecated**: please use one of the following endpoints instead:
6866
//
@@ -91,9 +89,7 @@ func (r *DeviceService) List(ctx context.Context, query DeviceListParams, opts .
9189
return res, nil
9290
}
9391

94-
// List WARP devices. Not supported when
95-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
96-
// is enabled for the account.
92+
// List WARP registrations.
9793
//
9894
// **Deprecated**: please use one of the following endpoints instead:
9995
//
@@ -105,9 +101,7 @@ func (r *DeviceService) ListAutoPaging(ctx context.Context, query DeviceListPara
105101
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
106102
}
107103

108-
// Fetches a single WARP device. Not supported when
109-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
110-
// is enabled for the account.
104+
// Fetches a single WARP registration.
111105
//
112106
// **Deprecated**: please use one of the following endpoints instead:
113107
//

zero_trust/devicedevice.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (r *DeviceDeviceService) Get(ctx context.Context, deviceID string, query De
105105
return
106106
}
107107

108-
// Revokes all WARP registrations associated with the specified device.
108+
// Revokes all registrations associated with the specified device.
109109
func (r *DeviceDeviceService) Revoke(ctx context.Context, deviceID string, body DeviceDeviceRevokeParams, opts ...option.RequestOption) (res *DeviceDeviceRevokeResponse, err error) {
110110
var env DeviceDeviceRevokeResponseEnvelope
111111
opts = append(r.Options[:], opts...)
@@ -149,7 +149,7 @@ type DeviceDeviceListResponse struct {
149149
DeviceType string `json:"device_type,nullable"`
150150
// A string that uniquely identifies the hardware or virtual machine (VM).
151151
HardwareID string `json:"hardware_id,nullable"`
152-
// The last user to use the WARP device.
152+
// The last Access user to use the WARP device.
153153
LastSeenUser DeviceDeviceListResponseLastSeenUser `json:"last_seen_user,nullable"`
154154
// The device MAC address.
155155
MacAddress string `json:"mac_address,nullable"`
@@ -202,7 +202,7 @@ func (r deviceDeviceListResponseJSON) RawJSON() string {
202202
return r.raw
203203
}
204204

205-
// The last user to use the WARP device.
205+
// The last Access user to use the WARP device.
206206
type DeviceDeviceListResponseLastSeenUser struct {
207207
// UUID.
208208
ID string `json:"id"`
@@ -256,7 +256,7 @@ type DeviceDeviceGetResponse struct {
256256
DeviceType string `json:"device_type,nullable"`
257257
// A string that uniquely identifies the hardware or virtual machine (VM).
258258
HardwareID string `json:"hardware_id,nullable"`
259-
// The last user to use the WARP device.
259+
// The last Access user to use the WARP device.
260260
LastSeenUser DeviceDeviceGetResponseLastSeenUser `json:"last_seen_user,nullable"`
261261
// The device MAC address.
262262
MacAddress string `json:"mac_address,nullable"`
@@ -309,7 +309,7 @@ func (r deviceDeviceGetResponseJSON) RawJSON() string {
309309
return r.raw
310310
}
311311

312-
// The last user to use the WARP device.
312+
// The last Access user to use the WARP device.
313313
type DeviceDeviceGetResponseLastSeenUser struct {
314314
// UUID.
315315
ID string `json:"id"`

zero_trust/deviceoverridecode.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ func NewDeviceOverrideCodeService(opts ...option.RequestOption) (r *DeviceOverri
3434
return
3535
}
3636

37-
// Fetches a one-time use admin override code for a device. This relies on the
38-
// **Admin Override** setting being enabled in your device configuration. Not
39-
// supported when
40-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
41-
// is enabled for the account. **Deprecated:** please use GET
37+
// Fetches a one-time use admin override code for a registration. This relies on
38+
// the **Admin Override** setting being enabled in your device configuration.
39+
//
40+
// **Deprecated:** please use GET
4241
// /accounts/{account_id}/devices/registrations/{registration_id}/override_codes
4342
// instead.
4443
//
@@ -68,11 +67,10 @@ func (r *DeviceOverrideCodeService) List(ctx context.Context, deviceID string, q
6867
return res, nil
6968
}
7069

71-
// Fetches a one-time use admin override code for a device. This relies on the
72-
// **Admin Override** setting being enabled in your device configuration. Not
73-
// supported when
74-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
75-
// is enabled for the account. **Deprecated:** please use GET
70+
// Fetches a one-time use admin override code for a registration. This relies on
71+
// the **Admin Override** setting being enabled in your device configuration.
72+
//
73+
// **Deprecated:** please use GET
7674
// /accounts/{account_id}/devices/registrations/{registration_id}/override_codes
7775
// instead.
7876
//

zero_trust/deviceregistration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func NewDeviceRegistrationService(opts ...option.RequestOption) (r *DeviceRegist
3636
return
3737
}
3838

39-
// Lists WARP registrations.
39+
// List WARP registrations.
4040
func (r *DeviceRegistrationService) List(ctx context.Context, params DeviceRegistrationListParams, opts ...option.RequestOption) (res *pagination.CursorPagination[DeviceRegistrationListResponse], err error) {
4141
var raw *http.Response
4242
opts = append(r.Options[:], opts...)
@@ -58,7 +58,7 @@ func (r *DeviceRegistrationService) List(ctx context.Context, params DeviceRegis
5858
return res, nil
5959
}
6060

61-
// Lists WARP registrations.
61+
// List WARP registrations.
6262
func (r *DeviceRegistrationService) ListAutoPaging(ctx context.Context, params DeviceRegistrationListParams, opts ...option.RequestOption) *pagination.CursorPaginationAutoPager[DeviceRegistrationListResponse] {
6363
return pagination.NewCursorPaginationAutoPager(r.List(ctx, params, opts...))
6464
}
@@ -491,7 +491,7 @@ func (r DeviceRegistrationListParamsStatus) IsKnown() bool {
491491
}
492492

493493
type DeviceRegistrationListParamsUser struct {
494-
// Filter by user ID.
494+
// Filter by Access user ID.
495495
ID param.Field[[]string] `query:"id"`
496496
}
497497

zero_trust/devicerevoke.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ func NewDeviceRevokeService(opts ...option.RequestOption) (r *DeviceRevokeServic
3434
return
3535
}
3636

37-
// Revokes a list of devices. Not supported when
38-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
39-
// is enabled.
37+
// Revokes a list of registrations.
4038
//
4139
// **Deprecated**: please use POST
4240
// /accounts/{account_id}/devices/registrations/revoke instead.

zero_trust/deviceunrevoke.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ func NewDeviceUnrevokeService(opts ...option.RequestOption) (r *DeviceUnrevokeSe
3434
return
3535
}
3636

37-
// Unrevokes a list of devices. Not supported when
38-
// [multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
39-
// is enabled.
37+
// Unrevokes a list of registrations.
4038
//
4139
// **Deprecated**: please use POST
4240
// /accounts/{account_id}/devices/registrations/unrevoke instead.

0 commit comments

Comments
 (0)