Skip to content

feat: add Shield Lists APIs (box/box-openapi#528) #601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "20cb559", "specHash": "a54170e", "version": "1.14.0" }
{ "engineHash": "20cb559", "specHash": "630fc85", "version": "1.14.0" }
5 changes: 5 additions & 0 deletions box_sdk_gen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@

from box_sdk_gen.managers.docgen import DocgenManager

from box_sdk_gen.managers.shield_lists import ShieldListsManager

from box_sdk_gen.networking.auth import Authentication

from box_sdk_gen.networking.network import NetworkSession
Expand Down Expand Up @@ -417,6 +419,9 @@ def __init__(self, auth: Authentication, *, network_session: NetworkSession = No
self.docgen = DocgenManager(
auth=self.auth, network_session=self.network_session
)
self.shield_lists = ShieldListsManager(
auth=self.auth, network_session=self.network_session
)

def make_request(self, fetch_options: FetchOptions) -> FetchResponse:
"""
Expand Down
2 changes: 2 additions & 0 deletions box_sdk_gen/managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,5 @@
from box_sdk_gen.managers.docgen_template import *

from box_sdk_gen.managers.docgen import *

from box_sdk_gen.managers.shield_lists import *
284 changes: 284 additions & 0 deletions box_sdk_gen/managers/shield_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
from typing import Optional

from typing import Dict

from box_sdk_gen.internal.utils import to_string

from box_sdk_gen.serialization.json import deserialize

from box_sdk_gen.serialization.json import serialize

from box_sdk_gen.networking.fetch_options import ResponseFormat

from box_sdk_gen.schemas.v2025_r0.shield_list_content_request_v2025_r0 import (
ShieldListContentRequestV2025R0,
)

from box_sdk_gen.schemas.v2025_r0.shield_lists_v2025_r0 import ShieldListsV2025R0

from box_sdk_gen.parameters.v2025_r0.box_version_header_v2025_r0 import (
BoxVersionHeaderV2025R0,
)

from box_sdk_gen.schemas.v2025_r0.shield_list_v2025_r0 import ShieldListV2025R0

from box_sdk_gen.schemas.v2025_r0.client_error_v2025_r0 import ClientErrorV2025R0

from box_sdk_gen.schemas.v2025_r0.shield_lists_create_v2025_r0 import (
ShieldListsCreateV2025R0,
)

from box_sdk_gen.schemas.v2025_r0.shield_lists_update_v2025_r0 import (
ShieldListsUpdateV2025R0,
)

from box_sdk_gen.box.errors import BoxSDKError

from box_sdk_gen.networking.auth import Authentication

from box_sdk_gen.networking.network import NetworkSession

from box_sdk_gen.networking.fetch_options import FetchOptions

from box_sdk_gen.networking.fetch_response import FetchResponse

from box_sdk_gen.internal.utils import prepare_params

from box_sdk_gen.internal.utils import to_string

from box_sdk_gen.internal.utils import ByteStream

from box_sdk_gen.serialization.json import sd_to_json

from box_sdk_gen.serialization.json import SerializedData


class ShieldListsManager:
def __init__(
self,
*,
auth: Optional[Authentication] = None,
network_session: NetworkSession = None
):
if network_session is None:
network_session = NetworkSession()
self.auth = auth
self.network_session = network_session

def get_shield_lists_v2025_r0(
self,
*,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> ShieldListsV2025R0:
"""
Retrieves all shield lists in the enterprise.
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
response: FetchResponse = self.network_session.network_client.fetch(
FetchOptions(
url=''.join(
[self.network_session.base_urls.base_url, '/2.0/shield_lists']
),
method='GET',
headers=headers_map,
response_format=ResponseFormat.JSON,
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, ShieldListsV2025R0)

def create_shield_list_v2025_r0(
self,
name: str,
content: ShieldListContentRequestV2025R0,
*,
description: Optional[str] = None,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> ShieldListV2025R0:
"""
Creates a shield list.
:param name: The name of the shield list.
:type name: str
:param description: Description of Shield List: Optional., defaults to None
:type description: Optional[str], optional
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
request_body: Dict = {
'name': name,
'description': description,
'content': content,
}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
response: FetchResponse = self.network_session.network_client.fetch(
FetchOptions(
url=''.join(
[self.network_session.base_urls.base_url, '/2.0/shield_lists']
),
method='POST',
headers=headers_map,
data=serialize(request_body),
content_type='application/json',
response_format=ResponseFormat.JSON,
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, ShieldListV2025R0)

def get_shield_list_by_id_v2025_r0(
self,
shield_list_id: str,
*,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> ShieldListV2025R0:
"""
Retrieves a single shield list by its ID.
:param shield_list_id: The unique identifier that represents a shield list.
The ID for any Shield List can be determined by the response from the endpoint
fetching all shield lists for the enterprise.
Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
:type shield_list_id: str
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
response: FetchResponse = self.network_session.network_client.fetch(
FetchOptions(
url=''.join(
[
self.network_session.base_urls.base_url,
'/2.0/shield_lists/',
to_string(shield_list_id),
]
),
method='GET',
headers=headers_map,
response_format=ResponseFormat.JSON,
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, ShieldListV2025R0)

def delete_shield_list_by_id_v2025_r0(
self,
shield_list_id: str,
*,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> None:
"""
Delete a single shield list by its ID.
:param shield_list_id: The unique identifier that represents a shield list.
The ID for any Shield List can be determined by the response from the endpoint
fetching all shield lists for the enterprise.
Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
:type shield_list_id: str
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
response: FetchResponse = self.network_session.network_client.fetch(
FetchOptions(
url=''.join(
[
self.network_session.base_urls.base_url,
'/2.0/shield_lists/',
to_string(shield_list_id),
]
),
method='DELETE',
headers=headers_map,
response_format=ResponseFormat.NO_CONTENT,
auth=self.auth,
network_session=self.network_session,
)
)
return None

def update_shield_list_by_id_v2025_r0(
self,
shield_list_id: str,
name: str,
content: ShieldListContentRequestV2025R0,
*,
description: Optional[str] = None,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> ShieldListV2025R0:
"""
Updates a shield list.
:param shield_list_id: The unique identifier that represents a shield list.
The ID for any Shield List can be determined by the response from the endpoint
fetching all shield lists for the enterprise.
Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
:type shield_list_id: str
:param name: The name of the shield list.
:type name: str
:param description: Description of Shield List: Optional., defaults to None
:type description: Optional[str], optional
:param box_version: Version header, defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
request_body: Dict = {
'name': name,
'description': description,
'content': content,
}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
response: FetchResponse = self.network_session.network_client.fetch(
FetchOptions(
url=''.join(
[
self.network_session.base_urls.base_url,
'/2.0/shield_lists/',
to_string(shield_list_id),
]
),
method='PUT',
headers=headers_map,
data=serialize(request_body),
content_type='application/json',
response_format=ResponseFormat.JSON,
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, ShieldListV2025R0)
24 changes: 24 additions & 0 deletions box_sdk_gen/schemas/v2025_r0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@

from box_sdk_gen.schemas.v2025_r0.doc_gen_batch_create_request_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_mini_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_lists_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_country_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_domain_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_email_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_integration_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_ip_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_request_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_lists_update_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_lists_create_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_content_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.shield_list_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.user_base_v2025_r0 import *

from box_sdk_gen.schemas.v2025_r0.doc_gen_job_full_v2025_r0 import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from enum import Enum

from typing import List

from box_sdk_gen.internal.base_object import BaseObject

from box_sdk_gen.box.errors import BoxSDKError


class ShieldListContentCountryV2025R0TypeField(str, Enum):
COUNTRY = 'country'


class ShieldListContentCountryV2025R0(BaseObject):
_discriminator = 'type', {'country'}

def __init__(
self,
country_codes: List[str],
*,
type: ShieldListContentCountryV2025R0TypeField = ShieldListContentCountryV2025R0TypeField.COUNTRY,
**kwargs
):
"""
:param country_codes: List of country codes values.
:type country_codes: List[str]
:param type: The type of content in the shield list., defaults to ShieldListContentCountryV2025R0TypeField.COUNTRY
:type type: ShieldListContentCountryV2025R0TypeField, optional
"""
super().__init__(**kwargs)
self.country_codes = country_codes
self.type = type
Loading
Loading