Skip to content

Commit 90367e6

Browse files
feat: feat: DLP-3878 Switch DLP Predefined Profile endpoints
* feat: DLP-3878 Switch DLP Predefined Profile endpoints The new endpoints contain a new field `enabled_entries` which will be the preferred way to manage entries within a predefined profile. The existing `entries` field will be supported but now be computed optional
1 parent 5e23502 commit 90367e6

File tree

6 files changed

+27
-135
lines changed

6 files changed

+27
-135
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: 1908
1+
configured_endpoints: 1907
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cc732ca8d1d7f1c11a1ee579060ddfd8f953a3ad94fd5053056b53370129d040.yml
33
openapi_spec_hash: a3e1e833dfe13845abd1e2227993a979
4-
config_hash: 0c4384f215154a287ab7fbe937bf1621
4+
config_hash: 6b8d4cb6cfb2bdcc28988fb6e9769676

api.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5886,10 +5886,9 @@ Types:
58865886

58875887
Methods:
58885888

5889-
- <code title="post /accounts/{account_id}/dlp/profiles/predefined">client.zeroTrust.dlp.profiles.predefined.<a href="./src/resources/zero-trust/dlp/profiles/predefined.ts">create</a>({ ...params }) -> Profile</code>
5890-
- <code title="put /accounts/{account_id}/dlp/profiles/predefined/{profile_id}">client.zeroTrust.dlp.profiles.predefined.<a href="./src/resources/zero-trust/dlp/profiles/predefined.ts">update</a>(profileId, { ...params }) -> Profile</code>
5889+
- <code title="put /accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config">client.zeroTrust.dlp.profiles.predefined.<a href="./src/resources/zero-trust/dlp/profiles/predefined.ts">update</a>(profileId, { ...params }) -> PredefinedProfile</code>
58915890
- <code title="delete /accounts/{account_id}/dlp/profiles/predefined/{profile_id}">client.zeroTrust.dlp.profiles.predefined.<a href="./src/resources/zero-trust/dlp/profiles/predefined.ts">delete</a>(profileId, { ...params }) -> PredefinedDeleteResponse | null</code>
5892-
- <code title="get /accounts/{account_id}/dlp/profiles/predefined/{profile_id}">client.zeroTrust.dlp.profiles.predefined.<a href="./src/resources/zero-trust/dlp/profiles/predefined.ts">get</a>(profileId, { ...params }) -> Profile</code>
5891+
- <code title="get /accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config">client.zeroTrust.dlp.profiles.predefined.<a href="./src/resources/zero-trust/dlp/profiles/predefined.ts">get</a>(profileId, { ...params }) -> PredefinedProfile</code>
58935892

58945893
### Limits
58955894

src/resources/zero-trust/dlp/profiles/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export {
1414
Predefined,
1515
type PredefinedProfile,
1616
type PredefinedDeleteResponse,
17-
type PredefinedCreateParams,
1817
type PredefinedUpdateParams,
1918
type PredefinedDeleteParams,
2019
type PredefinedGetParams,

src/resources/zero-trust/dlp/profiles/predefined.ts

Lines changed: 22 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,16 @@
33
import { APIResource } from '../../../../resource';
44
import * as Core from '../../../../core';
55
import * as CustomAPI from './custom';
6-
import * as ProfilesAPI from './profiles';
76

87
export class Predefined extends APIResource {
98
/**
10-
* Creates a DLP predefined profile. Only supports enabling/disabling entries.
9+
* This is similar to `update_predefined` but only returns entries that are
10+
* enabled. This is needed for our terraform API Updates a DLP predefined profile.
11+
* Only supports enabling/disabling entries.
1112
*
1213
* @example
1314
* ```ts
14-
* const profile =
15-
* await client.zeroTrust.dlp.profiles.predefined.create({
16-
* account_id: 'account_id',
17-
* profile_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
18-
* });
19-
* ```
20-
*/
21-
create(
22-
params: PredefinedCreateParams,
23-
options?: Core.RequestOptions,
24-
): Core.APIPromise<ProfilesAPI.Profile> {
25-
const { account_id, ...body } = params;
26-
return (
27-
this._client.post(`/accounts/${account_id}/dlp/profiles/predefined`, {
28-
body,
29-
...options,
30-
}) as Core.APIPromise<{ result: ProfilesAPI.Profile }>
31-
)._thenUnwrap((obj) => obj.result);
32-
}
33-
34-
/**
35-
* Updates a DLP predefined profile. Only supports enabling/disabling entries.
36-
*
37-
* @example
38-
* ```ts
39-
* const profile =
15+
* const predefinedProfile =
4016
* await client.zeroTrust.dlp.profiles.predefined.update(
4117
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
4218
* { account_id: 'account_id' },
@@ -47,13 +23,13 @@ export class Predefined extends APIResource {
4723
profileId: string,
4824
params: PredefinedUpdateParams,
4925
options?: Core.RequestOptions,
50-
): Core.APIPromise<ProfilesAPI.Profile> {
26+
): Core.APIPromise<PredefinedProfile> {
5127
const { account_id, ...body } = params;
5228
return (
53-
this._client.put(`/accounts/${account_id}/dlp/profiles/predefined/${profileId}`, {
29+
this._client.put(`/accounts/${account_id}/dlp/profiles/predefined/${profileId}/config`, {
5430
body,
5531
...options,
56-
}) as Core.APIPromise<{ result: ProfilesAPI.Profile }>
32+
}) as Core.APIPromise<{ result: PredefinedProfile }>
5733
)._thenUnwrap((obj) => obj.result);
5834
}
5935

@@ -85,11 +61,12 @@ export class Predefined extends APIResource {
8561
}
8662

8763
/**
88-
* Fetches a predefined DLP profile by id.
64+
* This is similar to `get_predefined` but only returns entries that are enabled.
65+
* This is needed for our terraform API Fetches a predefined DLP profile by id.
8966
*
9067
* @example
9168
* ```ts
92-
* const profile =
69+
* const predefinedProfile =
9370
* await client.zeroTrust.dlp.profiles.predefined.get(
9471
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
9572
* { account_id: 'account_id' },
@@ -100,13 +77,13 @@ export class Predefined extends APIResource {
10077
profileId: string,
10178
params: PredefinedGetParams,
10279
options?: Core.RequestOptions,
103-
): Core.APIPromise<ProfilesAPI.Profile> {
80+
): Core.APIPromise<PredefinedProfile> {
10481
const { account_id } = params;
10582
return (
10683
this._client.get(
107-
`/accounts/${account_id}/dlp/profiles/predefined/${profileId}`,
84+
`/accounts/${account_id}/dlp/profiles/predefined/${profileId}/config`,
10885
options,
109-
) as Core.APIPromise<{ result: ProfilesAPI.Profile }>
86+
) as Core.APIPromise<{ result: PredefinedProfile }>
11087
)._thenUnwrap((obj) => obj.result);
11188
}
11289
}
@@ -119,6 +96,13 @@ export interface PredefinedProfile {
11996

12097
allowed_match_count: number;
12198

99+
confidence_threshold: string | null;
100+
101+
enabled_entries: Array<string>;
102+
103+
/**
104+
* @deprecated
105+
*/
122106
entries: Array<
123107
| PredefinedProfile.CustomEntry
124108
| PredefinedProfile.PredefinedEntry
@@ -135,14 +119,6 @@ export interface PredefinedProfile {
135119

136120
ai_context_enabled?: boolean;
137121

138-
confidence_threshold?: 'low' | 'medium' | 'high' | 'very_high';
139-
140-
/**
141-
* @deprecated Scan the context of predefined entries to only return matches
142-
* surrounded by keywords.
143-
*/
144-
context_awareness?: ProfilesAPI.ContextAwareness;
145-
146122
ocr_enabled?: boolean;
147123

148124
/**
@@ -282,57 +258,6 @@ export namespace PredefinedProfile {
282258

283259
export type PredefinedDeleteResponse = unknown;
284260

285-
export interface PredefinedCreateParams {
286-
/**
287-
* Path param:
288-
*/
289-
account_id: string;
290-
291-
/**
292-
* Body param:
293-
*/
294-
profile_id: string;
295-
296-
/**
297-
* Body param:
298-
*/
299-
ai_context_enabled?: boolean;
300-
301-
/**
302-
* Body param:
303-
*/
304-
allowed_match_count?: number | null;
305-
306-
/**
307-
* Body param:
308-
*/
309-
confidence_threshold?: string | null;
310-
311-
/**
312-
* @deprecated Body param: Scan the context of predefined entries to only return
313-
* matches surrounded by keywords.
314-
*/
315-
context_awareness?: ProfilesAPI.ContextAwarenessParam;
316-
317-
/**
318-
* @deprecated Body param:
319-
*/
320-
entries?: Array<PredefinedCreateParams.Entry>;
321-
322-
/**
323-
* Body param:
324-
*/
325-
ocr_enabled?: boolean;
326-
}
327-
328-
export namespace PredefinedCreateParams {
329-
export interface Entry {
330-
id: string;
331-
332-
enabled: boolean;
333-
}
334-
}
335-
336261
export interface PredefinedUpdateParams {
337262
/**
338263
* Path param:
@@ -355,10 +280,9 @@ export interface PredefinedUpdateParams {
355280
confidence_threshold?: string | null;
356281

357282
/**
358-
* @deprecated Body param: Scan the context of predefined entries to only return
359-
* matches surrounded by keywords.
283+
* Body param:
360284
*/
361-
context_awareness?: ProfilesAPI.ContextAwarenessParam;
285+
enabled_entries?: Array<string> | null;
362286

363287
/**
364288
* @deprecated Body param:
@@ -391,7 +315,6 @@ export declare namespace Predefined {
391315
export {
392316
type PredefinedProfile as PredefinedProfile,
393317
type PredefinedDeleteResponse as PredefinedDeleteResponse,
394-
type PredefinedCreateParams as PredefinedCreateParams,
395318
type PredefinedUpdateParams as PredefinedUpdateParams,
396319
type PredefinedDeleteParams as PredefinedDeleteParams,
397320
type PredefinedGetParams as PredefinedGetParams,

src/resources/zero-trust/dlp/profiles/profiles.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
import * as PredefinedAPI from './predefined';
1818
import {
1919
Predefined,
20-
PredefinedCreateParams,
2120
PredefinedDeleteParams,
2221
PredefinedDeleteResponse,
2322
PredefinedGetParams,
@@ -691,7 +690,6 @@ export declare namespace Profiles {
691690
Predefined as Predefined,
692691
type PredefinedAPIPredefinedProfile as PredefinedProfile,
693692
type PredefinedDeleteResponse as PredefinedDeleteResponse,
694-
type PredefinedCreateParams as PredefinedCreateParams,
695693
type PredefinedUpdateParams as PredefinedUpdateParams,
696694
type PredefinedDeleteParams as PredefinedDeleteParams,
697695
type PredefinedGetParams as PredefinedGetParams,

tests/api-resources/zero-trust/dlp/profiles/predefined.test.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,6 @@ const client = new Cloudflare({
1010
});
1111

1212
describe('resource predefined', () => {
13-
test('create: only required params', async () => {
14-
const responsePromise = client.zeroTrust.dlp.profiles.predefined.create({
15-
account_id: 'account_id',
16-
profile_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
17-
});
18-
const rawResponse = await responsePromise.asResponse();
19-
expect(rawResponse).toBeInstanceOf(Response);
20-
const response = await responsePromise;
21-
expect(response).not.toBeInstanceOf(Response);
22-
const dataAndResponse = await responsePromise.withResponse();
23-
expect(dataAndResponse.data).toBe(response);
24-
expect(dataAndResponse.response).toBe(rawResponse);
25-
});
26-
27-
test('create: required and optional params', async () => {
28-
const response = await client.zeroTrust.dlp.profiles.predefined.create({
29-
account_id: 'account_id',
30-
profile_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
31-
ai_context_enabled: true,
32-
allowed_match_count: 5,
33-
confidence_threshold: 'confidence_threshold',
34-
context_awareness: { enabled: true, skip: { files: true } },
35-
entries: [{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', enabled: true }],
36-
ocr_enabled: true,
37-
});
38-
});
39-
4013
test('update: only required params', async () => {
4114
const responsePromise = client.zeroTrust.dlp.profiles.predefined.update(
4215
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
@@ -59,7 +32,7 @@ describe('resource predefined', () => {
5932
ai_context_enabled: true,
6033
allowed_match_count: 5,
6134
confidence_threshold: 'confidence_threshold',
62-
context_awareness: { enabled: true, skip: { files: true } },
35+
enabled_entries: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'],
6336
entries: [{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', enabled: true }],
6437
ocr_enabled: true,
6538
},

0 commit comments

Comments
 (0)