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

Commit

Permalink
dev-uxmt: introduce runner (#714)
Browse files Browse the repository at this point in the history
* add basic support for policy-group endpoints, introduce runner

* bump dev version
  • Loading branch information
sbasan authored May 29, 2024
1 parent 8018941 commit 08e24c3
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ENDPOINTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**THIS FILE WAS AUTO-GENERATED DO NOT EDIT**

Generated for: catalystwan-0.33.7.dev3
Generated for: catalystwan-0.33.7.dev4

All URIs are relative to */dataservice*
HTTP request | Supported Versions | Method | Payload Type | Return Type | Tenancy Mode
Expand Down Expand Up @@ -533,6 +533,9 @@ PUT /template/policy/vsmart/central/{id}||[**ConfigurationVSmartTemplatePolicy.e
PUT /template/policy/vsmart/{id}||[**ConfigurationVSmartTemplatePolicy.edit_vsmart_template**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/policy/vsmart_template.py#L65)|[**CentralizedPolicyEditPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/policy/centralized.py#L249)|None|
GET /template/policy/vsmart||[**ConfigurationVSmartTemplatePolicy.generate_vsmart_policy_template_list**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/policy/vsmart_template.py#L69)||DataSequence[[**CentralizedPolicyInfo**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/policy/centralized.py#L253)]|
GET /template/policy/vsmart/definition/{id}||[**ConfigurationVSmartTemplatePolicy.get_template_by_policy_id**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/policy/vsmart_template.py#L73)||[**CentralizedPolicy**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/policy/centralized.py#L203)|
POST /v1/policy-group|>=20.12|[**PolicyGroupEndpoints.create_policy_group**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/policy_group.py#L12)|[**PolicyGroup**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/configuration/policy_group.py#L22)|[**PolicyGroupId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/configuration/policy_group.py#L43)|
GET /v1/policy-group|>=20.12|[**PolicyGroupEndpoints.get_all**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/policy_group.py#L17)||DataSequence[[**PolicyGroupId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/configuration/policy_group.py#L43)]|
DELETE /v1/policy-group/{group_id}|>=20.12|[**PolicyGroupEndpoints.delete**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/policy_group.py#L22)||None|
GET /device/action/remote-server||[**ConfigurationSoftwareActions.get_list_of_remote_servers**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L165)||DataSequence[[**RemoteServerInfo**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L70)]|
POST /device/action/remote-server||[**ConfigurationSoftwareActions.add_new_remote_server**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L169)|[**RemoteServer**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L45)|None|
GET /device/action/remote-server/{id}||[**ConfigurationSoftwareActions.get_remote_server**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L173)||[**RemoteServerInfo**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L70)|
Expand Down
8 changes: 8 additions & 0 deletions catalystwan/api/config_group_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,11 @@ def update_variables(self, cg_id: str, solution: Solution, device_variables: lis
payload = ConfigGroupVariablesEditPayload(solution=solution, devices=device_variables)

self._endpoints.update_variables(config_group_id=cg_id, payload=payload)

def delete_all(self) -> None:
"""
Deletes all config-group
"""
config_groups = self.get()
for config_group in config_groups:
self.delete(config_group.id)
80 changes: 80 additions & 0 deletions catalystwan/api/feature_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_transport_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all Transport Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def create_parcel(
self, profile_id: UUID, payload: AnyTransportParcel, vpn_uuid: Optional[UUID] = None
) -> ParcelCreationResponse:
Expand Down Expand Up @@ -339,6 +347,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_sdwan_other_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all Other Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def get(
self,
profile_id: UUID,
Expand Down Expand Up @@ -406,6 +422,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_sdwan_service_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all Service Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def create_parcel(
self, profile_uuid: UUID, payload: AnyServiceParcel, vpn_uuid: Optional[UUID] = None
) -> ParcelCreationResponse:
Expand Down Expand Up @@ -462,6 +486,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_sdwan_system_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all System Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def get_schema(
self,
profile_id: UUID,
Expand Down Expand Up @@ -1225,6 +1257,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_embedded_security_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete Embedded Security Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

@overload
def get_parcels(
self,
Expand Down Expand Up @@ -1335,6 +1375,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all CLI Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def get_parcel_by_id(
self,
profile_id: UUID,
Expand Down Expand Up @@ -1396,6 +1444,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_dns_security_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete DNS Security Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def get_parcels(
self,
profile_id: UUID,
Expand Down Expand Up @@ -1464,6 +1520,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_sig_security_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all SIG Security Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def create_parcel(self, profile_uuid: UUID, payload: SIGParcel) -> ParcelCreationResponse:
"""
Create SIG Security Parcel for selected profile_id
Expand Down Expand Up @@ -1509,6 +1573,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_application_priority_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all Application Priority Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

@overload
def get_parcels(
self,
Expand Down Expand Up @@ -1635,6 +1707,14 @@ def delete_profile(self, profile_id: UUID) -> None:
"""
self.endpoint.delete_topology_feature_profile(profile_id)

def delete_all_profiles(self) -> None:
"""
Delete all Topology Feature Profiles
"""
profiles = self.get_profiles()
for profile in profiles:
self.delete_profile(profile.profile_id)

def create_parcel(self, profile_id: UUID, parcel: AnyTopologyParcel) -> ParcelCreationResponse:
"""
Create Topology Parcel for selected profile_id based on payload type
Expand Down
25 changes: 25 additions & 0 deletions catalystwan/endpoints/configuration/policy_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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, versions
from catalystwan.models.configuration.policy_group import PolicyGroup, PolicyGroupId
from catalystwan.typed_list import DataSequence


class PolicyGroupEndpoints(APIEndpoints):
@post("/v1/policy-group")
@versions(">=20.12")
def create_policy_group(self, payload: PolicyGroup) -> PolicyGroupId:
...

@get("/v1/policy-group")
@versions(">=20.12")
def get_all(self) -> DataSequence[PolicyGroupId]:
...

@delete("/v1/policy-group/{group_id}")
@versions(">=20.12")
def delete(self, group_id: UUID) -> None:
...
2 changes: 2 additions & 0 deletions catalystwan/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
from catalystwan.endpoints.configuration.policy.security_template import ConfigurationSecurityTemplatePolicy
from catalystwan.endpoints.configuration.policy.vedge_template import ConfigurationVEdgeTemplatePolicy
from catalystwan.endpoints.configuration.policy.vsmart_template import ConfigurationVSmartTemplatePolicy
from catalystwan.endpoints.configuration.policy_group import PolicyGroupEndpoints
from catalystwan.endpoints.configuration.software_actions import ConfigurationSoftwareActions
from catalystwan.endpoints.configuration.topology_group import TopologyGroupEndpoints
from catalystwan.endpoints.configuration_dashboard_status import ConfigurationDashboardStatus
Expand Down Expand Up @@ -182,6 +183,7 @@ def __init__(self, session: ManagerSession):
self.policy = ConfigurationPolicyContainer(session)
self.feature_profile = ConfigurationFeatureProfileContainer(session)
self.topology_group = TopologyGroupEndpoints(session)
self.policy_group = PolicyGroupEndpoints(session)


class TroubleshootingToolsContainer:
Expand Down
49 changes: 49 additions & 0 deletions catalystwan/models/configuration/policy_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from typing import List, Literal, Optional
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field


class Profile(BaseModel):
id: UUID


Solution = Literal[
"sd-routing",
"sdwan",
]


class FromPolicyGroup(BaseModel):
model_config = ConfigDict(populate_by_name=True)
copy_: UUID = Field(validation_alias="copy", serialization_alias="copy")


class PolicyGroup(BaseModel):
model_config = ConfigDict(populate_by_name=True)
description: str = Field()
name: str = Field(pattern='^[^&<>! "]+$')
from_policy_group: Optional[FromPolicyGroup] = Field(
default=None, validation_alias="fromPolicyGroup", serialization_alias="fromPolicyGroup"
)
profiles: Optional[List[Profile]] = Field(
default=None, description="list of profile ids that belongs to the policy group"
)
solution: Optional[Solution] = Field(default=None)


class ProfileInfo(BaseModel):
model_config = ConfigDict(populate_by_name=True)
id: str = Field()
profile_type: Optional[Literal["global"]] = Field(
default=None, validation_alias="profileType", serialization_alias="profileType"
)


class PolicyGroupId(BaseModel):
model_config = ConfigDict(populate_by_name=True)
id: UUID
profiles: Optional[List[ProfileInfo]] = Field(
default=None,
description="(Optional - only applicable for AON) List of profile ids that belongs to the policy group",
)
Loading

0 comments on commit 08e24c3

Please sign in to comment.