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

Commit

Permalink
add: site policy list builder endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Sep 5, 2023
1 parent 6981966 commit 0bf9dd8
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
12 changes: 11 additions & 1 deletion ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ PUT /template/policy/list/dataprefix/{id}||[**ConfigurationPolicyDataPrefixListB
GET /template/policy/list/dataprefix/{id}||[**ConfigurationPolicyDataPrefixListBuilder.get_lists_by_id**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L62)||[**DataPrefixList**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L38)|
GET /template/policy/list/dataprefix||[**ConfigurationPolicyDataPrefixListBuilder.get_policy_lists**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L66)||DataSequence[[**DataPrefixList**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L38)]|
GET /template/policy/list/dataprefix/filtered||[**ConfigurationPolicyDataPrefixListBuilder.get_policy_lists_with_info_tag**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L70)||DataSequence[[**DataPrefixList**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L38)]|
POST /template/policy/list/dataprefix/preview||[**ConfigurationPolicyDataPrefixListBuilder.preview_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L77)|[**DataPrefixListCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L30)|None|
POST /template/policy/list/dataprefix/preview||[**ConfigurationPolicyDataPrefixListBuilder.preview_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L77)|[**DataPrefixListCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L30)|[**PolicyListPreview**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L37)|
GET /template/policy/list/dataprefix/preview/{id}||[**ConfigurationPolicyDataPrefixListBuilder.preview_policy_list_by_id**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_data_prefix_list_builder.py#L82)||[**PolicyListPreview**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L37)|
POST /template/policy/list/site/defaultsite||[**ConfigurationPolicySiteListBuilder.create_default_site_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L43)|[**SiteListCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L30)|[**PolicyListId**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L11)|
POST /template/policy/list/site||[**ConfigurationPolicySiteListBuilder.create_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L47)|[**SiteListCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L30)|[**PolicyListId**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L11)|
DELETE /template/policy/list/site/{id}||[**ConfigurationPolicySiteListBuilder.delete_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L51)||None|
DELETE /template/policy/list/site||[**ConfigurationPolicySiteListBuilder.delete_policy_lists_with_info_tag**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L55)||None|
PUT /template/policy/list/site/{id}||[**ConfigurationPolicySiteListBuilder.edit_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L62)|[**SiteListEditPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L34)|None|
GET /template/policy/list/site/{id}||[**ConfigurationPolicySiteListBuilder.get_lists_by_id**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L66)||[**SiteList**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L38)|
GET /template/policy/list/site||[**ConfigurationPolicySiteListBuilder.get_policy_lists**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L70)||DataSequence[[**SiteList**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L38)]|
GET /template/policy/list/site/filtered||[**ConfigurationPolicySiteListBuilder.get_policy_lists_with_info_tag**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L74)||DataSequence[[**SiteList**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L38)]|
POST /template/policy/list/site/preview||[**ConfigurationPolicySiteListBuilder.preview_policy_list**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L81)|[**SiteListCreationPayload**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L30)|[**PolicyListPreview**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L37)|
GET /template/policy/list/site/preview/{id}||[**ConfigurationPolicySiteListBuilder.preview_policy_list_by_id**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_policy_site_list_builder.py#L85)||[**PolicyListPreview**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/model/policy_list.py#L37)|
GET /settings/configuration/{setting_type}||[**ConfigurationSettings.get_configuration_by_setting_type**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_settings.py#L208)||dict|
GET /settings/configuration/organization||[**ConfigurationSettings.get_organizations**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_settings.py#L212)||DataSequence[[**Organization**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_settings.py#L29)]|
GET /settings/configuration/device||[**ConfigurationSettings.get_devices**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_settings.py#L216)||DataSequence[[**Device**](https://github.com/CiscoDevNet/vManage-client/blob/main/vmngclient/endpoints/configuration_settings.py#L35)]|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_policy_lists_with_info_tag(self, params: InfoTag) -> DataSequence[DataPr
...

@post("/template/policy/list/dataprefix/preview")
def preview_policy_list(self, payload: DataPrefixListCreationPayload) -> None:
def preview_policy_list(self, payload: DataPrefixListCreationPayload) -> PolicyListPreview:
# TODO: not working for some reason
...

Expand Down
87 changes: 87 additions & 0 deletions vmngclient/endpoints/configuration_policy_site_list_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# mypy: disable-error-code="empty-body"
from typing import List

from pydantic import BaseModel, Field

from vmngclient.endpoints import APIEndpoints, delete, get, post, put
from vmngclient.model.policy_list import (
InfoTag,
PolicyList,
PolicyListCreationPayload,
PolicyListEditPayload,
PolicyListId,
PolicyListPreview,
)
from vmngclient.typed_list import DataSequence


class SiteListEntry(BaseModel):
class Config:
allow_population_by_field_name = True

site_id: str = Field(alias="siteId")


class SitePayload(BaseModel):
entries: List[SiteListEntry]
type: str = Field(default="site", const=True)


class SiteListCreationPayload(SitePayload, PolicyListCreationPayload):
pass


class SiteListEditPayload(SitePayload, PolicyListEditPayload):
pass


class SiteList(SitePayload, PolicyList):
pass


class ConfigurationPolicySiteListBuilder(APIEndpoints):
@post("/template/policy/list/site/defaultsite")
def create_default_site_list(self, payload: SiteListCreationPayload) -> PolicyListId:
...

@post("/template/policy/list/site")
def create_policy_list(self, payload: SiteListCreationPayload) -> PolicyListId:
...

@delete("/template/policy/list/site/{id}")
def delete_policy_list(self, id: str) -> None:
...

@delete("/template/policy/list/site")
def delete_policy_lists_with_info_tag(self, params: InfoTag) -> None:
# TODO: dont know how to assing tags to check if filter works
# (it is present in GET response but cannot be added to POST, PUT payload)
# for now it was tested with default info tag value == ""
...

@put("/template/policy/list/site/{id}")
def edit_policy_list(self, id: str, payload: SiteListEditPayload) -> None:
...

@get("/template/policy/list/site/{id}")
def get_lists_by_id(self, id: str) -> SiteList:
...

@get("/template/policy/list/site", "data")
def get_policy_lists(self) -> DataSequence[SiteList]:
...

@get("/template/policy/list/site/filtered", "data")
def get_policy_lists_with_info_tag(self, params: InfoTag) -> DataSequence[SiteList]:
# TODO: dont know how to assing tags to check if filter works
# (it is present in GET response but cannot be added to POST, PUT payload)
# for now it was tested with default info tag value == ""
...

@post("/template/policy/list/site/preview")
def preview_policy_list(self, payload: SiteListCreationPayload) -> PolicyListPreview:
...

@get("/template/policy/list/site/preview/{id}")
def preview_policy_list_by_id(self, id: str) -> PolicyListPreview:
...
2 changes: 2 additions & 0 deletions vmngclient/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from vmngclient.endpoints.configuration_feature_profile import ConfigurationFeatureProfile
from vmngclient.endpoints.configuration_group import ConfigurationGroup
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_settings import ConfigurationSettings
from vmngclient.endpoints.monitoring_device_details import MonitoringDeviceDetails
from vmngclient.endpoints.monitoring_status import MonitoringStatus
Expand All @@ -36,6 +37,7 @@ def __init__(self, session: vManageSession):
self.configuration_device_software_update = ConfigurationDeviceSoftwareUpdate(session)
self.configuration_device_template = ConfigurationDeviceTemplate(session)
self.configuration_policy_data_prefix_list_builder = ConfigurationPolicyDataPrefixListBuilder(session)
self.configuration_policy_site_list_builder = ConfigurationPolicySiteListBuilder(session)
self.configuration_settings = ConfigurationSettings(session)
self.monitoring_device_details = MonitoringDeviceDetails(session)
self.monitoring_status = MonitoringStatus(session)
Expand Down

0 comments on commit 0bf9dd8

Please sign in to comment.