Skip to content

Commit

Permalink
Jumping pydantic to version 1.0 and re-generating API references
Browse files Browse the repository at this point in the history
  • Loading branch information
davidban77 committed Nov 3, 2019
1 parent 2a81851 commit c7a19eb
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 50 deletions.
7 changes: 7 additions & 0 deletions docs/content/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ pip install -U gns3fy

# Releases

## 0.6.0

**Enhancement:**

- Added `drawings` attribute. Used to gather information from `Drawing` endpoint, and for that there is also the `get_drawings` method.
- Added `arrange_nodes_circular` method, which as the name indicates it will arrange the nodes configured on a project in a circular fashion.

## 0.5.2

**Enhancement:**
Expand Down
34 changes: 34 additions & 0 deletions docs/content/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ information](http://api.gns3.net/en/2.2/api/v2/controller/project/projects.html)
- `variables` (list): Variables required to run the project
- `zoom` (int): Zoom of the drawing area
- `stats` (dict): Project stats
-.`drawings` (list): List of drawings present on the project
- `nodes` (list): List of `Node` instances present on the project
- `links` (list): List of `Link` instances present on the project

Expand Down Expand Up @@ -1115,3 +1116,36 @@ Restore a snapshot from disk

- `name` or `snapshot_id`

### `Project.arrange_nodes_circular()`

```python
def arrange_nodes_circular(self, radius=120)
```

Re-arrgange the existing nodes
in a circular fashion

**Attributes:**

- project instance created

**Example**

```python
>>> proj = Project(name='project_name', connector=Gns3connector)
>>> proj.arrange_nodes()
```

### `Project.get_drawings()`

```python
def get_drawings(self)
```

Retrieves list of drawings of the project

**Required Project instance attributes:**

- `project_id`
- `connector`

17 changes: 10 additions & 7 deletions gns3fy/gns3fy.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class Link:

@validator("link_type")
def _valid_node_type(cls, value):
if value not in LINK_TYPES:
if value not in LINK_TYPES and value is not None:
raise ValueError(f"Not a valid link_type - {value}")
return value

Expand Down Expand Up @@ -680,27 +680,27 @@ class Node:
y: Optional[int] = None
z: Optional[int] = None
template_id: Optional[str] = None
properties: Dict = field(default_factory=dict)
properties: Optional[Any] = None

template: Optional[str] = None
links: List[Link] = field(default_factory=list, repr=False)
connector: Optional[Any] = field(default=None, repr=False)

@validator("node_type")
def _valid_node_type(cls, value):
if value not in NODE_TYPES:
if value not in NODE_TYPES and value is not None:
raise ValueError(f"Not a valid node_type - {value}")
return value

@validator("console_type")
def _valid_console_type(cls, value):
if value not in CONSOLE_TYPES:
if value not in CONSOLE_TYPES and value is not None:
raise ValueError(f"Not a valid console_type - {value}")
return value

@validator("status")
def _valid_status(cls, value):
if value not in ("stopped", "started", "suspended"):
if value not in ("stopped", "started", "suspended") and value is not None:
raise ValueError(f"Not a valid status - {value}")
return value

Expand Down Expand Up @@ -1116,7 +1116,7 @@ class Project:

@validator("status")
def _valid_status(cls, value):
if value != "opened" and value != "closed":
if value != "opened" and value != "closed" and value is not None:
raise ValueError("status must be opened or closed")
return value

Expand Down Expand Up @@ -1915,6 +1915,7 @@ def arrange_nodes_circular(self, radius=120):
```python
>>> proj = Project(name='project_name', connector=Gns3connector)
>>> proj.arrange_nodes()
```
"""

self.get()
Expand All @@ -1930,8 +1931,10 @@ def arrange_nodes_circular(self, radius=120):

def get_drawings(self):
"""
Retrieves list of drawins of the project
Retrieves list of drawings of the project
**Required Project instance attributes:**
- `project_id`
- `connector`
"""
Expand Down
Loading

0 comments on commit c7a19eb

Please sign in to comment.