Skip to content

Commit 57095b3

Browse files
committed
Pulling changes from release/v2.7.0
1 parent d673541 commit 57095b3

File tree

5 files changed

+40
-20
lines changed

5 files changed

+40
-20
lines changed

virl2_client/models/authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def auth_flow(
130130

131131
def logout(self, clear_all_sessions=False) -> bool:
132132
"""
133-
Log out the user. Invalidates the current token.
133+
Log out the user (invalidate the current token).
134134
135135
:param clear_all_sessions: Whether to clear all sessions.
136136
:returns: Whether the logout succeeded.

virl2_client/models/cl_pyats.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ def _load_pyats_testbed(self, testbed_yaml: str) -> Testbed:
109109

110110
def sync_testbed(self, username: str, password: str) -> None:
111111
"""
112-
Sync the testbed from the server.
113-
This fetches the latest topology data from the server.
112+
Sync the testbed (the latest topology data) from the server.
114113
115114
:param username: The username to be inserted into the testbed data.
116115
:param password: The password to be inserted into the testbed data.

virl2_client/models/groups.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from typing import TYPE_CHECKING
2424

25-
from ..utils import UNCHANGED, get_url_from_template
25+
from ..utils import get_url_from_template
2626

2727
if TYPE_CHECKING:
2828
import httpx
@@ -109,9 +109,9 @@ def update_group(
109109
self,
110110
group_id: str,
111111
name: str | None = None,
112-
description: str | None = UNCHANGED,
113-
members: list[str] | None = UNCHANGED,
114-
labs: list[dict[str, str]] | None = UNCHANGED,
112+
description: str | None = None,
113+
members: list[str] | None = None,
114+
labs: list[dict[str, str]] | None = None,
115115
) -> dict:
116116
"""
117117
Update a group.
@@ -126,11 +126,11 @@ def update_group(
126126
data: dict[str, str | list] = {}
127127
if name is not None:
128128
data["name"] = name
129-
if description is not UNCHANGED:
129+
if description is not None:
130130
data["description"] = description
131-
if members is not UNCHANGED:
131+
if members is not None:
132132
data["members"] = members
133-
if labs is not UNCHANGED:
133+
if labs is not None:
134134
data["labs"] = labs
135135
url = self._url_for("group", group_id=group_id)
136136
return self._session.patch(url, json=data).json()

virl2_client/models/users.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from typing import TYPE_CHECKING, Any
2424

25-
from ..utils import UNCHANGED, get_url_from_template
25+
from ..utils import UNCHANGED, _Sentinel, get_url_from_template
2626

2727
if TYPE_CHECKING:
2828
import httpx
@@ -49,7 +49,7 @@ def _url_for(self, endpoint, **kwargs):
4949
"""
5050
return get_url_from_template(endpoint, self._URL_TEMPLATES, kwargs)
5151

52-
def users(self) -> list[str]:
52+
def users(self) -> list[dict]:
5353
"""
5454
Get the list of available users.
5555
@@ -83,9 +83,12 @@ def create_user(
8383
pwd: str,
8484
fullname: str = "",
8585
description: str = "",
86+
email: str = "",
8687
admin: bool = False,
8788
groups: list[str] | None = None,
8889
resource_pool: str | None = None,
90+
opt_in: bool | None = None,
91+
tour_version: str = "",
8992
) -> dict:
9093
"""
9194
Create a new user.
@@ -94,58 +97,76 @@ def create_user(
9497
:param pwd: Desired password.
9598
:param fullname: Full name.
9699
:param description: Description.
100+
:param email: Email address.
97101
:param admin: Whether to create an admin user.
98102
:param groups: List of groups to which the user should be added.
99103
:param resource_pool: Resource pool to which the user should be added.
104+
:param opt_in: Whether the user has seen the initial contact dialog.
105+
:param tour_version: The version of the Workbench tour the user has completed.
100106
:returns: User object.
101107
"""
102108
data = {
103109
"username": username,
104110
"password": pwd,
105111
"fullname": fullname,
106112
"description": description,
113+
"email": email,
107114
"admin": admin,
108115
"groups": groups or [],
109116
"resource_pool": resource_pool,
117+
"opt_in": opt_in,
118+
"tour_version": tour_version,
110119
}
111120
url = self._url_for("users")
112121
return self._session.post(url, json=data).json()
113122

114123
def update_user(
115124
self,
116125
user_id: str,
117-
fullname: str | None = UNCHANGED,
118-
description: str | None = UNCHANGED,
119-
groups: list[str] | None = UNCHANGED,
126+
fullname: str | None = None,
127+
description: str | None = None,
128+
email: str | None = None,
129+
groups: list[str] | None = None,
120130
admin: bool | None = None,
121131
password_dict: dict[str, str] | None = None,
122-
resource_pool: str | None = UNCHANGED,
132+
resource_pool: str | None | _Sentinel = UNCHANGED,
133+
opt_in: bool | None | _Sentinel = UNCHANGED,
134+
tour_version: str | None = None,
123135
) -> dict:
124136
"""
125137
Update an existing user.
126138
127139
:param user_id: User UUID4.
128140
:param fullname: Full name.
129141
:param description: Description.
142+
:param email: Email address.
130143
:param admin: Whether to create an admin user.
131144
:param groups: List of groups to which the user should be added.
132145
:param password_dict: Dictionary containing old and new passwords.
133146
:param resource_pool: Resource pool to which the user should be added.
147+
:param opt_in: Whether the user has seen the initial contact dialog.
148+
:param tour_version: The version of the Workbench tour the user has completed.
134149
:returns: User object.
135150
"""
136151
data: dict[str, Any] = {}
137-
if fullname is not UNCHANGED:
152+
if fullname is not None:
138153
data["fullname"] = fullname
139-
if description is not UNCHANGED:
154+
if description is not None:
140155
data["description"] = description
156+
if email is not None:
157+
data["email"] = email
141158
if admin is not None:
142159
data["admin"] = admin
143-
if groups is not UNCHANGED:
160+
if groups is not None:
144161
data["groups"] = groups
145162
if password_dict is not None:
146163
data["password"] = password_dict
147164
if resource_pool is not UNCHANGED:
148165
data["resource_pool"] = resource_pool
166+
if opt_in is not UNCHANGED:
167+
data["opt_in"] = opt_in
168+
if tour_version is not None:
169+
data["tour_version"] = tour_version
149170

150171
url = self._url_for("user", user_id=user_id)
151172
return self._session.patch(url, json=data).json()

virl2_client/virl2_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def import_lab(
527527
self,
528528
topology: str,
529529
title: str | None = None,
530-
offline=None,
530+
offline: bool | None = None,
531531
virl_1x: bool = False,
532532
) -> Lab:
533533
"""

0 commit comments

Comments
 (0)