This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: data policy definition builder endpoints
- Loading branch information
Showing
4 changed files
with
117 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
67 changes: 67 additions & 0 deletions
67
vmngclient/endpoints/configuration_policy_data_definition_builder.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,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 | ||
... |
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,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 |