Skip to content

Commit f980f65

Browse files
box-sdk-buildbox-sdk-build
andauthored
feat: add Shield Lists APIs (box/box-openapi#528) (#601)
Co-authored-by: box-sdk-build <[email protected]>
1 parent e29e934 commit f980f65

19 files changed

+882
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "20cb559", "specHash": "a54170e", "version": "1.14.0" }
1+
{ "engineHash": "20cb559", "specHash": "630fc85", "version": "1.14.0" }

box_sdk_gen/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@
172172

173173
from box_sdk_gen.managers.docgen import DocgenManager
174174

175+
from box_sdk_gen.managers.shield_lists import ShieldListsManager
176+
175177
from box_sdk_gen.networking.auth import Authentication
176178

177179
from box_sdk_gen.networking.network import NetworkSession
@@ -417,6 +419,9 @@ def __init__(self, auth: Authentication, *, network_session: NetworkSession = No
417419
self.docgen = DocgenManager(
418420
auth=self.auth, network_session=self.network_session
419421
)
422+
self.shield_lists = ShieldListsManager(
423+
auth=self.auth, network_session=self.network_session
424+
)
420425

421426
def make_request(self, fetch_options: FetchOptions) -> FetchResponse:
422427
"""

box_sdk_gen/managers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@
145145
from box_sdk_gen.managers.docgen_template import *
146146

147147
from box_sdk_gen.managers.docgen import *
148+
149+
from box_sdk_gen.managers.shield_lists import *
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
from typing import Optional
2+
3+
from typing import Dict
4+
5+
from box_sdk_gen.internal.utils import to_string
6+
7+
from box_sdk_gen.serialization.json import deserialize
8+
9+
from box_sdk_gen.serialization.json import serialize
10+
11+
from box_sdk_gen.networking.fetch_options import ResponseFormat
12+
13+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_request_v2025_r0 import (
14+
ShieldListContentRequestV2025R0,
15+
)
16+
17+
from box_sdk_gen.schemas.v2025_r0.shield_lists_v2025_r0 import ShieldListsV2025R0
18+
19+
from box_sdk_gen.parameters.v2025_r0.box_version_header_v2025_r0 import (
20+
BoxVersionHeaderV2025R0,
21+
)
22+
23+
from box_sdk_gen.schemas.v2025_r0.shield_list_v2025_r0 import ShieldListV2025R0
24+
25+
from box_sdk_gen.schemas.v2025_r0.client_error_v2025_r0 import ClientErrorV2025R0
26+
27+
from box_sdk_gen.schemas.v2025_r0.shield_lists_create_v2025_r0 import (
28+
ShieldListsCreateV2025R0,
29+
)
30+
31+
from box_sdk_gen.schemas.v2025_r0.shield_lists_update_v2025_r0 import (
32+
ShieldListsUpdateV2025R0,
33+
)
34+
35+
from box_sdk_gen.box.errors import BoxSDKError
36+
37+
from box_sdk_gen.networking.auth import Authentication
38+
39+
from box_sdk_gen.networking.network import NetworkSession
40+
41+
from box_sdk_gen.networking.fetch_options import FetchOptions
42+
43+
from box_sdk_gen.networking.fetch_response import FetchResponse
44+
45+
from box_sdk_gen.internal.utils import prepare_params
46+
47+
from box_sdk_gen.internal.utils import to_string
48+
49+
from box_sdk_gen.internal.utils import ByteStream
50+
51+
from box_sdk_gen.serialization.json import sd_to_json
52+
53+
from box_sdk_gen.serialization.json import SerializedData
54+
55+
56+
class ShieldListsManager:
57+
def __init__(
58+
self,
59+
*,
60+
auth: Optional[Authentication] = None,
61+
network_session: NetworkSession = None
62+
):
63+
if network_session is None:
64+
network_session = NetworkSession()
65+
self.auth = auth
66+
self.network_session = network_session
67+
68+
def get_shield_lists_v2025_r0(
69+
self,
70+
*,
71+
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
72+
extra_headers: Optional[Dict[str, Optional[str]]] = None
73+
) -> ShieldListsV2025R0:
74+
"""
75+
Retrieves all shield lists in the enterprise.
76+
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
77+
:type box_version: BoxVersionHeaderV2025R0, optional
78+
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
79+
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
80+
"""
81+
if extra_headers is None:
82+
extra_headers = {}
83+
headers_map: Dict[str, str] = prepare_params(
84+
{'box-version': to_string(box_version), **extra_headers}
85+
)
86+
response: FetchResponse = self.network_session.network_client.fetch(
87+
FetchOptions(
88+
url=''.join(
89+
[self.network_session.base_urls.base_url, '/2.0/shield_lists']
90+
),
91+
method='GET',
92+
headers=headers_map,
93+
response_format=ResponseFormat.JSON,
94+
auth=self.auth,
95+
network_session=self.network_session,
96+
)
97+
)
98+
return deserialize(response.data, ShieldListsV2025R0)
99+
100+
def create_shield_list_v2025_r0(
101+
self,
102+
name: str,
103+
content: ShieldListContentRequestV2025R0,
104+
*,
105+
description: Optional[str] = None,
106+
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
107+
extra_headers: Optional[Dict[str, Optional[str]]] = None
108+
) -> ShieldListV2025R0:
109+
"""
110+
Creates a shield list.
111+
:param name: The name of the shield list.
112+
:type name: str
113+
:param description: Description of Shield List: Optional., defaults to None
114+
:type description: Optional[str], optional
115+
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
116+
:type box_version: BoxVersionHeaderV2025R0, optional
117+
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
118+
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
119+
"""
120+
if extra_headers is None:
121+
extra_headers = {}
122+
request_body: Dict = {
123+
'name': name,
124+
'description': description,
125+
'content': content,
126+
}
127+
headers_map: Dict[str, str] = prepare_params(
128+
{'box-version': to_string(box_version), **extra_headers}
129+
)
130+
response: FetchResponse = self.network_session.network_client.fetch(
131+
FetchOptions(
132+
url=''.join(
133+
[self.network_session.base_urls.base_url, '/2.0/shield_lists']
134+
),
135+
method='POST',
136+
headers=headers_map,
137+
data=serialize(request_body),
138+
content_type='application/json',
139+
response_format=ResponseFormat.JSON,
140+
auth=self.auth,
141+
network_session=self.network_session,
142+
)
143+
)
144+
return deserialize(response.data, ShieldListV2025R0)
145+
146+
def get_shield_list_by_id_v2025_r0(
147+
self,
148+
shield_list_id: str,
149+
*,
150+
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
151+
extra_headers: Optional[Dict[str, Optional[str]]] = None
152+
) -> ShieldListV2025R0:
153+
"""
154+
Retrieves a single shield list by its ID.
155+
:param shield_list_id: The unique identifier that represents a shield list.
156+
The ID for any Shield List can be determined by the response from the endpoint
157+
fetching all shield lists for the enterprise.
158+
Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
159+
:type shield_list_id: str
160+
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
161+
:type box_version: BoxVersionHeaderV2025R0, optional
162+
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
163+
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
164+
"""
165+
if extra_headers is None:
166+
extra_headers = {}
167+
headers_map: Dict[str, str] = prepare_params(
168+
{'box-version': to_string(box_version), **extra_headers}
169+
)
170+
response: FetchResponse = self.network_session.network_client.fetch(
171+
FetchOptions(
172+
url=''.join(
173+
[
174+
self.network_session.base_urls.base_url,
175+
'/2.0/shield_lists/',
176+
to_string(shield_list_id),
177+
]
178+
),
179+
method='GET',
180+
headers=headers_map,
181+
response_format=ResponseFormat.JSON,
182+
auth=self.auth,
183+
network_session=self.network_session,
184+
)
185+
)
186+
return deserialize(response.data, ShieldListV2025R0)
187+
188+
def delete_shield_list_by_id_v2025_r0(
189+
self,
190+
shield_list_id: str,
191+
*,
192+
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
193+
extra_headers: Optional[Dict[str, Optional[str]]] = None
194+
) -> None:
195+
"""
196+
Delete a single shield list by its ID.
197+
:param shield_list_id: The unique identifier that represents a shield list.
198+
The ID for any Shield List can be determined by the response from the endpoint
199+
fetching all shield lists for the enterprise.
200+
Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
201+
:type shield_list_id: str
202+
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
203+
:type box_version: BoxVersionHeaderV2025R0, optional
204+
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
205+
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
206+
"""
207+
if extra_headers is None:
208+
extra_headers = {}
209+
headers_map: Dict[str, str] = prepare_params(
210+
{'box-version': to_string(box_version), **extra_headers}
211+
)
212+
response: FetchResponse = self.network_session.network_client.fetch(
213+
FetchOptions(
214+
url=''.join(
215+
[
216+
self.network_session.base_urls.base_url,
217+
'/2.0/shield_lists/',
218+
to_string(shield_list_id),
219+
]
220+
),
221+
method='DELETE',
222+
headers=headers_map,
223+
response_format=ResponseFormat.NO_CONTENT,
224+
auth=self.auth,
225+
network_session=self.network_session,
226+
)
227+
)
228+
return None
229+
230+
def update_shield_list_by_id_v2025_r0(
231+
self,
232+
shield_list_id: str,
233+
name: str,
234+
content: ShieldListContentRequestV2025R0,
235+
*,
236+
description: Optional[str] = None,
237+
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
238+
extra_headers: Optional[Dict[str, Optional[str]]] = None
239+
) -> ShieldListV2025R0:
240+
"""
241+
Updates a shield list.
242+
:param shield_list_id: The unique identifier that represents a shield list.
243+
The ID for any Shield List can be determined by the response from the endpoint
244+
fetching all shield lists for the enterprise.
245+
Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
246+
:type shield_list_id: str
247+
:param name: The name of the shield list.
248+
:type name: str
249+
:param description: Description of Shield List: Optional., defaults to None
250+
:type description: Optional[str], optional
251+
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
252+
:type box_version: BoxVersionHeaderV2025R0, optional
253+
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
254+
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
255+
"""
256+
if extra_headers is None:
257+
extra_headers = {}
258+
request_body: Dict = {
259+
'name': name,
260+
'description': description,
261+
'content': content,
262+
}
263+
headers_map: Dict[str, str] = prepare_params(
264+
{'box-version': to_string(box_version), **extra_headers}
265+
)
266+
response: FetchResponse = self.network_session.network_client.fetch(
267+
FetchOptions(
268+
url=''.join(
269+
[
270+
self.network_session.base_urls.base_url,
271+
'/2.0/shield_lists/',
272+
to_string(shield_list_id),
273+
]
274+
),
275+
method='PUT',
276+
headers=headers_map,
277+
data=serialize(request_body),
278+
content_type='application/json',
279+
response_format=ResponseFormat.JSON,
280+
auth=self.auth,
281+
network_session=self.network_session,
282+
)
283+
)
284+
return deserialize(response.data, ShieldListV2025R0)

box_sdk_gen/schemas/v2025_r0/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@
3232

3333
from box_sdk_gen.schemas.v2025_r0.doc_gen_batch_create_request_v2025_r0 import *
3434

35+
from box_sdk_gen.schemas.v2025_r0.shield_list_mini_v2025_r0 import *
36+
37+
from box_sdk_gen.schemas.v2025_r0.shield_lists_v2025_r0 import *
38+
39+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_country_v2025_r0 import *
40+
41+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_domain_v2025_r0 import *
42+
43+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_email_v2025_r0 import *
44+
45+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_integration_v2025_r0 import *
46+
47+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_ip_v2025_r0 import *
48+
49+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_request_v2025_r0 import *
50+
51+
from box_sdk_gen.schemas.v2025_r0.shield_lists_update_v2025_r0 import *
52+
53+
from box_sdk_gen.schemas.v2025_r0.shield_lists_create_v2025_r0 import *
54+
55+
from box_sdk_gen.schemas.v2025_r0.shield_list_content_v2025_r0 import *
56+
57+
from box_sdk_gen.schemas.v2025_r0.shield_list_v2025_r0 import *
58+
3559
from box_sdk_gen.schemas.v2025_r0.user_base_v2025_r0 import *
3660

3761
from box_sdk_gen.schemas.v2025_r0.doc_gen_job_full_v2025_r0 import *
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from enum import Enum
2+
3+
from typing import List
4+
5+
from box_sdk_gen.internal.base_object import BaseObject
6+
7+
from box_sdk_gen.box.errors import BoxSDKError
8+
9+
10+
class ShieldListContentCountryV2025R0TypeField(str, Enum):
11+
COUNTRY = 'country'
12+
13+
14+
class ShieldListContentCountryV2025R0(BaseObject):
15+
_discriminator = 'type', {'country'}
16+
17+
def __init__(
18+
self,
19+
country_codes: List[str],
20+
*,
21+
type: ShieldListContentCountryV2025R0TypeField = ShieldListContentCountryV2025R0TypeField.COUNTRY,
22+
**kwargs
23+
):
24+
"""
25+
:param country_codes: List of country codes values.
26+
:type country_codes: List[str]
27+
:param type: The type of content in the shield list., defaults to ShieldListContentCountryV2025R0TypeField.COUNTRY
28+
:type type: ShieldListContentCountryV2025R0TypeField, optional
29+
"""
30+
super().__init__(**kwargs)
31+
self.country_codes = country_codes
32+
self.type = type

0 commit comments

Comments
 (0)