Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
wip: data policy definition builder endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Sep 11, 2023
1 parent e9bfcf6 commit 9e1662c
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ PUT /v1/feature-profile/sdwan/system/{system_id}/aaa/{parcel_id}|>=20.9|[**Confi
POST /v1/config-group|>=20.9|[**ConfigurationGroup.create_config_group**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L49)|[**ConfigGroupCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L21)|[**ConfigGroupCreationResponse**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L35)|
DELETE /v1/config-group/{config_group_id}|>=20.9|[**ConfigurationGroup.delete_config_group**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L54)||None|
PUT /v1/config-group/{config_group_id}|>=20.9|[**ConfigurationGroup.edit_config_group**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L59)|[**ConfigGroupEditPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L28)|[**ConfigGroupEditResponse**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_group.py#L43)|
POST /template/policy/definition/data||[**ConfigurationPolicyDataDefinitionBuilder.create_policy_definition**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L32)|[**DataDefinitionCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L19)|[**PolicyDefinitionId**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_definition.py#L11)|
GET /template/policy/definition/data||[**ConfigurationPolicyDataDefinitionBuilder.get_definitions**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L48)||DataSequence[[**DataDefinition**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L27)]|
GET /template/policy/definition/data/{id}||[**ConfigurationPolicyDataDefinitionBuilder.get_policy_definition**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L53)||[**DataDefinition**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L27)|
POST /template/policy/definition/data/preview||[**ConfigurationPolicyDataDefinitionBuilder.preview_policy_definition**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L57)|[**DataDefinitionCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L19)|[**PolicyDefinitionPreview**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_definition.py#L42)|
GET /template/policy/definition/data/preview/{id}||[**ConfigurationPolicyDataDefinitionBuilder.preview_policy_definition_by_id**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_definition_builder.py#L61)||[**PolicyDefinitionPreview**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_definition.py#L42)|
POST /template/policy/list/dataprefix||[**ConfigurationPolicyDataPrefixListBuilder.create_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L43)|[**DataPrefixListCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L30)|[**PolicyListId**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L11)|
DELETE /template/policy/list/dataprefix/{id}||[**ConfigurationPolicyDataPrefixListBuilder.delete_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L47)||None|
DELETE /template/policy/list/dataprefix||[**ConfigurationPolicyDataPrefixListBuilder.delete_policy_lists_with_info_tag**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L51)||None|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# mypy: disable-error-code="empty-body"
from pydantic import BaseModel, Field

from vmngclient.endpoints import APIEndpoints, get, post
from vmngclient.model.policy_definition import (
PolicyDefinition,
PolicyDefinitionCreationPayload,
PolicyDefinitionEditPayload,
PolicyDefinitionId,
PolicyDefinitionPreview,
)
from vmngclient.typed_list import DataSequence


class Data(BaseModel):
type: str = Field(default="data", const=True)


class DataDefinitionCreationPayload(Data, PolicyDefinitionCreationPayload):
pass


class DataDefinitionEditPayload(Data, PolicyDefinitionEditPayload):
pass


class DataDefinition(Data, PolicyDefinition):
pass


class ConfigurationPolicyDataDefinitionBuilder(APIEndpoints):
@post("/template/policy/definition/data")
def create_policy_definition(self, payload: DataDefinitionCreationPayload) -> PolicyDefinitionId:
...

def delete_policy_definition(self):
# DELETE /template/policy/definition/data/{id}
...

def edit_multiple_policy_definition(self):
# PUT /template/policy/definition/data/multiple/{id}
...

def edit_policy_definition(self):
# PUT /template/policy/definition/data/{id}
...

@get("/template/policy/definition/data", "data")
def get_definitions(self) -> DataSequence[DataDefinition]:
# GET /template/policy/definition/data
...

@get("/template/policy/definition/data/{id}")
def get_policy_definition(self, id: str) -> DataDefinition:
...

@post("/template/policy/definition/data/preview")
def preview_policy_definition(self, payload: DataDefinitionCreationPayload) -> PolicyDefinitionPreview:
...

@get("/template/policy/definition/data/preview/{id}")
def preview_policy_definition_by_id(self, id: str) -> PolicyDefinitionPreview:
...

def save_policy_definition_in_bulk15(self):
# PUT /template/policy/definition/data/bulk
...
2 changes: 2 additions & 0 deletions vmngclient/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from vmngclient.endpoints.configuration_device_template import ConfigurationDeviceTemplate
from vmngclient.endpoints.configuration_feature_profile import ConfigurationFeatureProfile
from vmngclient.endpoints.configuration_group import ConfigurationGroup
from vmngclient.endpoints.configuration_policy_data_definition_builder import ConfigurationPolicyDataDefinitionBuilder
from vmngclient.endpoints.configuration_policy_data_prefix_list_builder import ConfigurationPolicyDataPrefixListBuilder
from vmngclient.endpoints.configuration_policy_site_list_builder import ConfigurationPolicySiteListBuilder
from vmngclient.endpoints.configuration_policy_vpn_list_builder import ConfigurationPolicyVPNListBuilder
Expand All @@ -37,6 +38,7 @@ def __init__(self, session: vManageSession):
self.configuration_device_actions = ConfigurationDeviceActions(session)
self.configuration_device_software_update = ConfigurationDeviceSoftwareUpdate(session)
self.configuration_device_template = ConfigurationDeviceTemplate(session)
self.configuration_policy_data_definition_builder = ConfigurationPolicyDataDefinitionBuilder(session)
self.configuration_policy_data_prefix_list_builder = ConfigurationPolicyDataPrefixListBuilder(session)
self.configuration_policy_site_list_builder = ConfigurationPolicySiteListBuilder(session)
self.configuration_policy_vpn_list_builder = ConfigurationPolicyVPNListBuilder(session)
Expand Down
43 changes: 43 additions & 0 deletions vmngclient/model/policy_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import datetime
from typing import List, Optional

from pydantic import BaseModel, Field


class InfoTag(BaseModel):
info_tag: Optional[str] = Field("", alias="infoTag")


class PolicyDefinitionId(BaseModel):
definition_id: str = Field(alias="definitionId")


class PolicyReference(BaseModel):
id: str
property: str


class PolicyDefinitionCreationPayload(BaseModel):
name: str = Field(
regex="^[a-zA-Z0-9_-]{1,128}$",
description="Can include only alpha-numeric characters, hyphen '-' or underscore '_'; maximum 128 characters",
)
description: str
type: str


class PolicyDefinitionEditPayload(PolicyDefinitionCreationPayload, PolicyDefinitionId):
pass


class PolicyDefinition(PolicyDefinitionEditPayload, InfoTag):
last_updated: datetime.datetime = Field(alias="lastUpdated")
owner: str
mode: str
optimized: str
reference_count: int = Field(alias="referenceCount")
references: List[PolicyReference]


class PolicyDefinitionPreview(BaseModel):
preview: str

0 comments on commit 9e1662c

Please sign in to comment.