This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Advanced Inspection Profile v1 model (#641)
- Loading branch information
1 parent
ce762f7
commit 37b9888
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
catalystwan/endpoints/configuration/policy/definition/aip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
# mypy: disable-error-code="empty-body" | ||
|
||
from uuid import UUID | ||
|
||
from catalystwan.endpoints import APIEndpoints, delete, get, post, put | ||
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints | ||
from catalystwan.models.policy.definition.aip import ( | ||
AdvancedInspectionProfilePolicy, | ||
AdvancedInspectionProfilePolicyEditPayload, | ||
AdvancedInspectionProfilePolicyGetResponse, | ||
) | ||
from catalystwan.models.policy.policy_definition import ( | ||
PolicyDefinitionEditResponse, | ||
PolicyDefinitionId, | ||
PolicyDefinitionInfo, | ||
PolicyDefinitionPreview, | ||
) | ||
from catalystwan.typed_list import DataSequence | ||
|
||
|
||
class ConfigurationPolicyAIPDefinition(APIEndpoints, PolicyDefinitionEndpoints): | ||
@post("/template/policy/definition/advancedinspectionprofile") | ||
def create_policy_definition(self, payload: AdvancedInspectionProfilePolicy) -> PolicyDefinitionId: | ||
... | ||
|
||
@delete("/template/policy/definition/advancedinspectionprofile/{id}") | ||
def delete_policy_definition(self, id: UUID) -> None: | ||
... | ||
|
||
@put("/template/policy/definition/advancedinspectionprofile/{id}") | ||
def edit_policy_definition( | ||
self, id: UUID, payload: AdvancedInspectionProfilePolicyEditPayload | ||
) -> PolicyDefinitionEditResponse: | ||
... | ||
|
||
@get("/template/policy/definition/advancedinspectionprofile", "data") | ||
def get_definitions(self) -> DataSequence[PolicyDefinitionInfo]: | ||
... | ||
|
||
@get("/template/policy/definition/advancedinspectionprofile/{id}") | ||
def get_policy_definition(self, id: UUID) -> AdvancedInspectionProfilePolicyGetResponse: | ||
... | ||
|
||
@post("/template/policy/definition/advancedinspectionprofile/preview") | ||
def preview_policy_definition(self, payload: AdvancedInspectionProfilePolicy) -> PolicyDefinitionPreview: | ||
... | ||
|
||
@get("/template/policy/definition/advancedinspectionprofile/preview/{id}") | ||
def preview_policy_definition_by_id(self, id: UUID) -> PolicyDefinitionPreview: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
from typing import Literal, Optional | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, model_validator | ||
from typing_extensions import Self | ||
|
||
from catalystwan.models.policy.policy_definition import ( | ||
PolicyDefinitionBase, | ||
PolicyDefinitionGetResponse, | ||
PolicyDefinitionId, | ||
Reference, | ||
) | ||
|
||
TlsDecryptionAction = Literal["decrypt", "neverDecrypt", "skipDecrypt"] | ||
|
||
|
||
class AdvancedInspectionProfileDefinition(BaseModel): | ||
model_config = ConfigDict(populate_by_name=True) | ||
|
||
tls_decryption_action: TlsDecryptionAction = Field( | ||
validation_alias="tlsDecryptionAction", serialization_alias="tlsDecryptionAction" | ||
) | ||
|
||
advanced_malware_protection: Optional[Reference] = Field( | ||
default=None, validation_alias="advancedMalwareProtection", serialization_alias="advancedMalwareProtection" | ||
) | ||
|
||
intrusion_prevention: Optional[Reference] = Field( | ||
default=None, validation_alias="intrusionPrevention", serialization_alias="intrusionPrevention" | ||
) | ||
url_filtering: Optional[Reference] = Field( | ||
default=None, validation_alias="urlFiltering", serialization_alias="urlFiltering" | ||
) | ||
|
||
ssl_utd_decrypt_profile: Optional[Reference] = Field( | ||
default=None, validation_alias="sslUtdDecryptProfile", serialization_alias="sslUtdDecryptProfile" | ||
) | ||
|
||
@model_validator(mode="after") | ||
def check_at_least_one_optional_filled(self) -> Self: | ||
if not any([self.advanced_malware_protection, self.intrusion_prevention, self.url_filtering]): | ||
raise ValueError( | ||
"At least one of Intrusion Prevention, URL Filtering, Advanced Malware Protection shall be filled." | ||
) | ||
return self | ||
|
||
|
||
class AdvancedInspectionProfilePolicy(PolicyDefinitionBase): | ||
type: Literal["advancedInspectionProfile"] = "advancedInspectionProfile" | ||
mode: Literal["unified"] = "unified" | ||
definition: AdvancedInspectionProfileDefinition | ||
|
||
|
||
class AdvancedInspectionProfilePolicyEditPayload(AdvancedInspectionProfilePolicy, PolicyDefinitionId): | ||
pass | ||
|
||
|
||
class AdvancedInspectionProfilePolicyGetResponse(AdvancedInspectionProfilePolicy, PolicyDefinitionGetResponse): | ||
pass |