3
3
from __future__ import annotations
4
4
5
5
from typing import Any , Type , Iterable , Optional , cast
6
- from typing_extensions import overload
7
6
8
7
import httpx
9
8
10
9
from ....._types import NOT_GIVEN , Body , Query , Headers , NotGiven
11
- from ....._utils import required_args , maybe_transform , async_maybe_transform
10
+ from ....._utils import maybe_transform , async_maybe_transform
12
11
from ....._compat import cached_property
13
12
from ....._resource import SyncAPIResource , AsyncAPIResource
14
13
from ....._response import (
22
21
from .....types .zero_trust .dlp .profile import Profile
23
22
from .....types .zero_trust .dlp .profiles import custom_create_params , custom_update_params
24
23
from .....types .zero_trust .dlp .context_awareness_param import ContextAwarenessParam
25
- from .....types .zero_trust .dlp .profiles .custom_create_response import CustomCreateResponse
26
24
27
25
__all__ = ["CustomResource" , "AsyncCustomResource" ]
28
26
@@ -47,54 +45,26 @@ def with_streaming_response(self) -> CustomResourceWithStreamingResponse:
47
45
"""
48
46
return CustomResourceWithStreamingResponse (self )
49
47
50
- @overload
51
48
def create (
52
49
self ,
53
50
* ,
54
51
account_id : str ,
55
- profiles : Iterable [custom_create_params .Variant0Profile ],
56
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
57
- # The extra values given here take precedence over values defined on the client or passed to this method.
58
- extra_headers : Headers | None = None ,
59
- extra_query : Query | None = None ,
60
- extra_body : Body | None = None ,
61
- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
62
- ) -> Optional [CustomCreateResponse ]:
63
- """
64
- Creates a DLP custom profile.
65
-
66
- Args:
67
- extra_headers: Send extra headers
68
-
69
- extra_query: Add additional query parameters to the request
70
-
71
- extra_body: Add additional JSON properties to the request
72
-
73
- timeout: Override the client-level default timeout for this request, in seconds
74
- """
75
- ...
76
-
77
- @overload
78
- def create (
79
- self ,
80
- * ,
81
- account_id : str ,
82
- entries : Iterable [custom_create_params .DLPNewCustomProfileEntry ],
52
+ entries : Iterable [custom_create_params .Entry ],
83
53
name : str ,
84
54
ai_context_enabled : bool | NotGiven = NOT_GIVEN ,
85
55
allowed_match_count : int | NotGiven = NOT_GIVEN ,
86
56
confidence_threshold : Optional [str ] | NotGiven = NOT_GIVEN ,
87
57
context_awareness : ContextAwarenessParam | NotGiven = NOT_GIVEN ,
88
58
description : Optional [str ] | NotGiven = NOT_GIVEN ,
89
59
ocr_enabled : bool | NotGiven = NOT_GIVEN ,
90
- shared_entries : Iterable [custom_create_params .DLPNewCustomProfileSharedEntry ] | NotGiven = NOT_GIVEN ,
60
+ shared_entries : Iterable [custom_create_params .SharedEntry ] | NotGiven = NOT_GIVEN ,
91
61
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
92
62
# The extra values given here take precedence over values defined on the client or passed to this method.
93
63
extra_headers : Headers | None = None ,
94
64
extra_query : Query | None = None ,
95
65
extra_body : Body | None = None ,
96
66
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
97
- ) -> Optional [CustomCreateResponse ]:
67
+ ) -> Optional [Profile ]:
98
68
"""
99
69
Creates a DLP custom profile.
100
70
@@ -117,39 +87,14 @@ def create(
117
87
118
88
timeout: Override the client-level default timeout for this request, in seconds
119
89
"""
120
- ...
121
-
122
- @required_args (["account_id" , "profiles" ], ["account_id" , "entries" , "name" ])
123
- def create (
124
- self ,
125
- * ,
126
- account_id : str ,
127
- profiles : Iterable [custom_create_params .Variant0Profile ] | NotGiven = NOT_GIVEN ,
128
- entries : Iterable [custom_create_params .DLPNewCustomProfileEntry ] | NotGiven = NOT_GIVEN ,
129
- name : str | NotGiven = NOT_GIVEN ,
130
- ai_context_enabled : bool | NotGiven = NOT_GIVEN ,
131
- allowed_match_count : int | NotGiven = NOT_GIVEN ,
132
- confidence_threshold : Optional [str ] | NotGiven = NOT_GIVEN ,
133
- context_awareness : ContextAwarenessParam | NotGiven = NOT_GIVEN ,
134
- description : Optional [str ] | NotGiven = NOT_GIVEN ,
135
- ocr_enabled : bool | NotGiven = NOT_GIVEN ,
136
- shared_entries : Iterable [custom_create_params .DLPNewCustomProfileSharedEntry ] | NotGiven = NOT_GIVEN ,
137
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
138
- # The extra values given here take precedence over values defined on the client or passed to this method.
139
- extra_headers : Headers | None = None ,
140
- extra_query : Query | None = None ,
141
- extra_body : Body | None = None ,
142
- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
143
- ) -> Optional [CustomCreateResponse ]:
144
90
if not account_id :
145
91
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
146
92
return cast (
147
- Optional [CustomCreateResponse ],
93
+ Optional [Profile ],
148
94
self ._post (
149
95
f"/accounts/{ account_id } /dlp/profiles/custom" ,
150
96
body = maybe_transform (
151
97
{
152
- "profiles" : profiles ,
153
98
"entries" : entries ,
154
99
"name" : name ,
155
100
"ai_context_enabled" : ai_context_enabled ,
@@ -167,10 +112,10 @@ def create(
167
112
extra_query = extra_query ,
168
113
extra_body = extra_body ,
169
114
timeout = timeout ,
170
- post_parser = ResultWrapper [Optional [CustomCreateResponse ]]._unwrapper ,
115
+ post_parser = ResultWrapper [Optional [Profile ]]._unwrapper ,
171
116
),
172
117
cast_to = cast (
173
- Any , ResultWrapper [CustomCreateResponse ]
118
+ Any , ResultWrapper [Profile ]
174
119
), # Union types cannot be passed in as arguments in the type system
175
120
),
176
121
)
@@ -359,54 +304,26 @@ def with_streaming_response(self) -> AsyncCustomResourceWithStreamingResponse:
359
304
"""
360
305
return AsyncCustomResourceWithStreamingResponse (self )
361
306
362
- @overload
363
307
async def create (
364
308
self ,
365
309
* ,
366
310
account_id : str ,
367
- profiles : Iterable [custom_create_params .Variant0Profile ],
368
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
369
- # The extra values given here take precedence over values defined on the client or passed to this method.
370
- extra_headers : Headers | None = None ,
371
- extra_query : Query | None = None ,
372
- extra_body : Body | None = None ,
373
- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
374
- ) -> Optional [CustomCreateResponse ]:
375
- """
376
- Creates a DLP custom profile.
377
-
378
- Args:
379
- extra_headers: Send extra headers
380
-
381
- extra_query: Add additional query parameters to the request
382
-
383
- extra_body: Add additional JSON properties to the request
384
-
385
- timeout: Override the client-level default timeout for this request, in seconds
386
- """
387
- ...
388
-
389
- @overload
390
- async def create (
391
- self ,
392
- * ,
393
- account_id : str ,
394
- entries : Iterable [custom_create_params .DLPNewCustomProfileEntry ],
311
+ entries : Iterable [custom_create_params .Entry ],
395
312
name : str ,
396
313
ai_context_enabled : bool | NotGiven = NOT_GIVEN ,
397
314
allowed_match_count : int | NotGiven = NOT_GIVEN ,
398
315
confidence_threshold : Optional [str ] | NotGiven = NOT_GIVEN ,
399
316
context_awareness : ContextAwarenessParam | NotGiven = NOT_GIVEN ,
400
317
description : Optional [str ] | NotGiven = NOT_GIVEN ,
401
318
ocr_enabled : bool | NotGiven = NOT_GIVEN ,
402
- shared_entries : Iterable [custom_create_params .DLPNewCustomProfileSharedEntry ] | NotGiven = NOT_GIVEN ,
319
+ shared_entries : Iterable [custom_create_params .SharedEntry ] | NotGiven = NOT_GIVEN ,
403
320
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
404
321
# The extra values given here take precedence over values defined on the client or passed to this method.
405
322
extra_headers : Headers | None = None ,
406
323
extra_query : Query | None = None ,
407
324
extra_body : Body | None = None ,
408
325
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
409
- ) -> Optional [CustomCreateResponse ]:
326
+ ) -> Optional [Profile ]:
410
327
"""
411
328
Creates a DLP custom profile.
412
329
@@ -429,39 +346,14 @@ async def create(
429
346
430
347
timeout: Override the client-level default timeout for this request, in seconds
431
348
"""
432
- ...
433
-
434
- @required_args (["account_id" , "profiles" ], ["account_id" , "entries" , "name" ])
435
- async def create (
436
- self ,
437
- * ,
438
- account_id : str ,
439
- profiles : Iterable [custom_create_params .Variant0Profile ] | NotGiven = NOT_GIVEN ,
440
- entries : Iterable [custom_create_params .DLPNewCustomProfileEntry ] | NotGiven = NOT_GIVEN ,
441
- name : str | NotGiven = NOT_GIVEN ,
442
- ai_context_enabled : bool | NotGiven = NOT_GIVEN ,
443
- allowed_match_count : int | NotGiven = NOT_GIVEN ,
444
- confidence_threshold : Optional [str ] | NotGiven = NOT_GIVEN ,
445
- context_awareness : ContextAwarenessParam | NotGiven = NOT_GIVEN ,
446
- description : Optional [str ] | NotGiven = NOT_GIVEN ,
447
- ocr_enabled : bool | NotGiven = NOT_GIVEN ,
448
- shared_entries : Iterable [custom_create_params .DLPNewCustomProfileSharedEntry ] | NotGiven = NOT_GIVEN ,
449
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
450
- # The extra values given here take precedence over values defined on the client or passed to this method.
451
- extra_headers : Headers | None = None ,
452
- extra_query : Query | None = None ,
453
- extra_body : Body | None = None ,
454
- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
455
- ) -> Optional [CustomCreateResponse ]:
456
349
if not account_id :
457
350
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
458
351
return cast (
459
- Optional [CustomCreateResponse ],
352
+ Optional [Profile ],
460
353
await self ._post (
461
354
f"/accounts/{ account_id } /dlp/profiles/custom" ,
462
355
body = await async_maybe_transform (
463
356
{
464
- "profiles" : profiles ,
465
357
"entries" : entries ,
466
358
"name" : name ,
467
359
"ai_context_enabled" : ai_context_enabled ,
@@ -479,10 +371,10 @@ async def create(
479
371
extra_query = extra_query ,
480
372
extra_body = extra_body ,
481
373
timeout = timeout ,
482
- post_parser = ResultWrapper [Optional [CustomCreateResponse ]]._unwrapper ,
374
+ post_parser = ResultWrapper [Optional [Profile ]]._unwrapper ,
483
375
),
484
376
cast_to = cast (
485
- Any , ResultWrapper [CustomCreateResponse ]
377
+ Any , ResultWrapper [Profile ]
486
378
), # Union types cannot be passed in as arguments in the type system
487
379
),
488
380
)
0 commit comments