Skip to content

Commit 4806174

Browse files
committed
Server compatibility updates for v2.1
* update wire protocol for remove_from_organization with account deletion * fix various typos in docs and doc strings
1 parent e5123c9 commit 4806174

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

HISTORY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ Enhancement release:
3333
* (No issue)
3434
* fix misspellings
3535
* change .gitignore so that .gitignore is not ignored
36+
37+
### Version 2.1
38+
39+
Server-compatibility release:
40+
41+
* (No Issue)
42+
* fix typos in docs
43+
* fix param documentation in functional API
44+
* update wire protocol for remove_from_organization with deletion of account to match server changes

docs/usage-instructions-v2.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ a Python dictionary of its attributes.
9696
The following code enumerates the first 5 users, printing the email of each.
9797
This will only have fetched the first page of results. Then, after the loop,
9898
the `all_results` call will force the fetch of all remaining pages so the
99-
list of all results can be constructed. ()Once the `all_results` call has been made,
99+
list of all results can be constructed. (Once the `all_results` call has been made,
100100
you cannot enumerate again without first calling `reload`.)
101101

102102
```python
103-
users = umapi_client.QueryUsers(conn)
103+
users = umapi_client.UsersQuery(conn)
104104
# print first 5 users
105105
for i, user in enumerate(users):
106106
if i == 5: break
@@ -109,13 +109,22 @@ for i, user in enumerate(users):
109109
user_count = len(users.all_results())
110110
```
111111

112+
You can also query for a particular user by email:
113+
114+
```python
115+
query = umapi_client.UserQuery(conn, "[email protected]")
116+
jruser = query.result()
117+
if jruser:
118+
name = jruser["lastname"] + ", " + jruser["firstname"]
119+
```
120+
112121
## Get a List of Groups
113122

114123
This list of groups will contain both user groups and product license
115124
configuration groups.
116125

117126
```python
118-
groups = umapi_client.QueryGroups(conn)
127+
groups = umapi_client.GroupsQuery(conn)
119128
# print all the group details
120129
for group in groups:
121130
print(group)

tests/test_functional.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,22 @@ def test_remove_role_enterpriseid():
216216
def test_remove_from_organization_federatedid():
217217
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
218218
user.remove_from_organization()
219-
assert user.wire_dict() == {"do": [{"removeFromOrg": {}}],
219+
assert user.wire_dict() == {"do": [{"removeFromOrg": {"deleteAccount": False}}],
220220
"user": "[email protected]"}
221221

222222

223223
def test_remove_from_organization_adobeid():
224224
user = UserAction(id_type='adobeID', email="[email protected]")
225225
user.remove_from_organization()
226-
assert user.wire_dict() == {"do": [{"removeFromOrg": {}}],
226+
assert user.wire_dict() == {"do": [{"removeFromOrg": {"deleteAccount": False}}],
227227
"user": "[email protected]",
228228
"useAdobeID": True}
229229

230230

231231
def test_remove_from_organization_delete_federatedid():
232232
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
233233
user.remove_from_organization(delete_account=True)
234-
assert user.wire_dict() == {"do": [{"removeFromOrg": {}}, {"removeFromDomain": {}}],
234+
assert user.wire_dict() == {"do": [{"removeFromOrg": {"deleteAccount": True}}],
235235
"user": "[email protected]"}
236236

237237

umapi_client/functional.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def add_to_groups(self, groups=None, all_groups=False, group_type=None):
205205
Add user to some (typically PLC) groups. Note that, if you add to no groups, the effect
206206
is simply to do an "add to organization Everybody group", so we let that be done.
207207
:param groups: list of group names the user should be added to
208-
:param all_groups: a boolean meaning remove from all (don't specify groups or group_type in this case)
208+
:param all_groups: a boolean meaning add to all (don't specify groups or group_type in this case)
209209
:param group_type: the type of group (defaults to "product")
210210
:return: the User, so you can do User(...).add_to_groups(...).add_role(...)
211211
"""
@@ -252,8 +252,8 @@ def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
252252
def add_role(self, groups=None, role_type=RoleTypes.admin):
253253
"""
254254
Make user have a role (typically PLC admin) with respect to some PLC groups.
255-
:param groups: list of group names the user should be an admin for
256-
:param role_type: the type of role (defaults to "admin")
255+
:param groups: list of group names the user should have this role for
256+
:param role_type: the role (defaults to "admin")
257257
:return: the User, so you can do User(...).add_role(...).add_to_groups(...)
258258
"""
259259
if not groups:
@@ -268,7 +268,7 @@ def add_role(self, groups=None, role_type=RoleTypes.admin):
268268
def remove_role(self, groups=None, role_type=RoleTypes.admin):
269269
"""
270270
Remove user from a role (typically admin) of some groups.
271-
:param groups: list of group names the user should NOT be an admin for
271+
:param groups: list of group names the user should NOT have this role for
272272
:param role_type: the type of role (defaults to "admin")
273273
:return: the User, so you can do User(...).remove_role(...).remove_from_groups(...)
274274
"""
@@ -288,9 +288,9 @@ def remove_from_organization(self, delete_account=False):
288288
:param delete_account: Whether to delete the account after removing from the organization (default false)
289289
:return: None, because you cannot follow this command with another.
290290
"""
291-
self.append(removeFromOrg={})
292-
if delete_account:
293-
self.delete_account()
291+
if delete_account and self.id_type == IdentityTypes.adobeID:
292+
raise ValueError("You cannot delete an Adobe ID account.")
293+
self.append(removeFromOrg={"deleteAccount": delete_account == True})
294294
return None
295295

296296
def delete_account(self):
@@ -356,9 +356,9 @@ def __init__(self, group_name=None, **kwargs):
356356

357357
def add_to_products(self, products=None, all_products=False):
358358
"""
359-
Add user product to some PLC products.
359+
Add user group to some product license configuration groups (PLCs), or all of them.
360360
:param products: list of product names the user should be added to
361-
:param all_products: a boolean meaning remove from all (don't specify products in this case)
361+
:param all_products: a boolean meaning add to all (don't specify products in this case)
362362
:return: the Group, so you can do Group(...).add_to_products(...).add_users(...)
363363
"""
364364
if all_products:
@@ -373,7 +373,7 @@ def add_to_products(self, products=None, all_products=False):
373373

374374
def remove_from_products(self, products=None, all_products=False):
375375
"""
376-
Remove user group from some PLC products, or all of them.
376+
Remove user group from some product license configuration groups (PLCs), or all of them.
377377
:param products: list of product names the user group should be removed from
378378
:param all_products: a boolean meaning remove from all (don't specify products in this case)
379379
:return: the Group, so you can do Group(...).remove_from_products(...).add_users(...)

umapi_client/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21-
__version__ = "2.0.3"
21+
__version__ = "2.1"

0 commit comments

Comments
 (0)