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

Commit

Permalink
fix get templates (#204)
Browse files Browse the repository at this point in the history
* fix

* bump version
  • Loading branch information
tzietkowski authored Mar 29, 2023
1 parent eb5090e commit 48baffa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vmngclient"
version = "0.8.0"
version = "0.8.1"
description = "Universal vManage API"
authors = ["kagorski <[email protected]>"]
readme = "README.md"
Expand Down
7 changes: 5 additions & 2 deletions vmngclient/api/template_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ def get(self, template: Type[CLITemplate]) -> DataSequence[TemplateInfo]: # typ
...

def get(self, template):
if isinstance(template, FeatureTemplate):
return self._get_feature_templates()
if template is FeatureTemplate:
return self._get_feature_templates()

if isinstance(template, (DeviceTemplate, CLITemplate)):
return self._get_device_templates()
if template in [DeviceTemplate, CLITemplate]:
return self._get_device_templates()

Expand Down Expand Up @@ -334,7 +337,7 @@ def create(self, template, debug: bool = False):
template_id: Optional[str] = None # type: ignore
template_type = None

exists = self.get(type(template)).filter(name=template.name)
exists = self.get(template).filter(name=template.name)
if exists:
raise AlreadyExistsError(f"Template with name [{template.name}] already exists.")

Expand Down
2 changes: 1 addition & 1 deletion vmngclient/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ class User(DataclassBase):
class TemplateInfo(DataclassBase):
last_updated_by: str = field(metadata={FIELD_NAME: "lastUpdatedBy"})
resource_group: str = field(metadata={FIELD_NAME: "resourceGroup"})
config_type: TemplateType = field(converter=TemplateType, metadata={FIELD_NAME: "configType"})
id: str = field(metadata={FIELD_NAME: "templateId"})
factory_default: bool = field(metadata={FIELD_NAME: "factoryDefault"})
name: str = field(metadata={FIELD_NAME: "templateName"})
Expand All @@ -239,6 +238,7 @@ class FeatureTemplateInfo(TemplateInfo):
class DeviceTemplateInfo(TemplateInfo):
device_type: str = field(metadata={FIELD_NAME: "deviceType"})
template_class: str = field(metadata={FIELD_NAME: "templateClass"})
config_type: TemplateType = field(converter=TemplateType, metadata={FIELD_NAME: "configType"})
draft_mode: str = field(metadata={FIELD_NAME: "draftMode"})
template_attached: int = field(metadata={FIELD_NAME: "templateAttached"})
device_role: Optional[str] = field(default=None, metadata={FIELD_NAME: "deviceRole"})
Expand Down

0 comments on commit 48baffa

Please sign in to comment.