@@ -298,3 +298,175 @@ Each entry in `errors` would then be a dictionary giving
298298the command that failed, the target user it failed on,
299299and server information about the reason for the failure.
300300
301+ # Performing Operations on User Groups
302+
303+ User group operations work similarly to user operations. The
304+ UserGroupAction class has a similar interface to the UserAction class.
305+ Currently, the UserGroupAction interface supports the following
306+ operations :
307+
308+ * `create()` - create a new user group
309+ * `update()` - update the name and/or description of an existing user
310+ group
311+ * `delete()` - delete a user group
312+ * `add_users()` - add users to a user group
313+ * `remove_users()` - remove users from a user group
314+ * `add_to_products()` - add one or more product profiles to a user group
315+ * `remove_from_products()` - remove one or more product profiles from
316+ a user group
317+
318+ # # Step 1: Specify the User Group
319+
320+ The group name is required to create new UserGroupAction object. For a
321+ new user group, this should be the name of the new group. To perform
322+ an operation on an existing group, specify the name of that group.
323+
324+ Group names :
325+
326+ * Must be unique to the Adobe organization
327+ * May not start with an underscore ("_") - groups with names that begin
328+ with an underscore are reserved for Adobe use
329+ * Must be no longer than 255 characters
330+
331+ Group name is the only required parameter. An optional `requestID` can
332+ be passed to make it easier to connect action requests with API
333+ responses.
334+
335+ ` ` ` python
336+ from umapi_client import UserGroupAction
337+ group = UserGroupAction(group_name="Employees")
338+ ` ` `
339+
340+ # # Step 2: Specify the Operations
341+
342+ # ## Create a New Group
343+
344+ User Groups are created with `UserGroupAction.create()`. Two
345+ optional parameters can be passed :
346+
347+ * `description` - a short description of the group
348+ * `option` - an option specifying how to handle existing groups with
349+ the same name. Specify one of two `IfAlreadyExistsOptions` variants :
350+ * `ignoreIfAlreadyExists` - do not attempt to create the group if a
351+ group with the same name already exists. Other operations for the
352+ UserGroupAction object will be performed.
353+ * `updateIfAlreadyExists` - update the description if it is different
354+ than the description currently applied to the user group
355+ * **Default**: `ignoreIfAlreadyExists`
356+
357+ Example :
358+
359+ ` ` ` python
360+ group = UserGroupAction(group_name="Employees")
361+ group.create(description="A user group just for employees",
362+ option=IfAlreadyExistsOptions.updateIfAlreadyExists)
363+ ` ` `
364+
365+ # ## Update a Group
366+
367+ Updates are done using `UserGroupAction.update()`. Two optional
368+ parameters can be passed :
369+
370+ * `name` - the new name of the user group
371+ * `description` - the new description of the user group
372+
373+ Both parameters default to `None`. If either parameter is omitted,
374+ that field will not be updated. If neither parameter is specified,
375+ ` update()` will throw an `ArgumentException`.
376+
377+ Example :
378+
379+ ` ` ` python
380+ group = UserGroupAction(group_name="Employees")
381+ group.update(name="Employees and Contractors",
382+ description="Full-time Employees and Contractors")
383+ ` ` `
384+
385+ # ## Delete a Group
386+
387+ User groups can be deleted with `UserGroupAction.delete()`. The
388+ ` delete()` method takes no parameters.
389+
390+ ` ` ` python
391+ group = UserGroupAction(group_name="Employees and Contractors")
392+ group.delete()
393+ ` ` `
394+
395+ # ## Manage Users in Group
396+
397+ The User Management API supports the bulk management of users for a
398+ specific group. This functionality is exposed in the
399+ ` UserGroupAction` methods `add_users()` and `remove_users()`.
400+
401+ A list of user IDs to add or remove must to provided to either method.
402+
403+ Add users example :
404+
405+ ` ` ` python
406+ group = UserGroupAction(group_name="Employees and Contractors")
407+ 408+ group.add_users(users=add_users)
409+ ` ` `
410+
411+ Remove users example :
412+
413+ ` ` ` python
414+ group = UserGroupAction(group_name="Employees and Contractors")
415+ 416+ group.remove_users(users=remove_users)
417+ ` ` `
418+
419+ # ## Manage Product Profiles for a Group
420+
421+ The `UserGroupAction` interface can also be used to manage the product
422+ profiles associated with a user group. Adding a product profile to a
423+ group will grant all members of that group access to the profile's
424+ associated product plan.
425+
426+ The `add_to_products()` method adds one or more product profiles to a
427+ user group. `remove_from_products()` removes one or more profiles from
428+ a user group.
429+
430+ Both methods take two parameters. These are mutually exclusive -
431+ either method will throw an `ArgumentError` if both parameters are
432+ specified (also, if neither are specified).
433+
434+ * `products` list of product profiles to add/remove
435+ * `all_products` boolean that will add/remove all product profiles to a
436+ user group
437+
438+ Add profile example :
439+
440+ ` ` ` python
441+ group = UserGroupAction(group_name="Employees and Contractors")
442+ profiles_to_add = ["Default All Apps plan - 100 GB configuration",
443+ "Default Acrobat Pro DC configuration"]
444+ group.add_to_products(products=profiles_to_add)
445+ ` ` `
446+
447+ Remove profile example :
448+
449+ ` ` ` python
450+ group = UserGroupAction(group_name="Employees and Contractors")
451+ profiles_to_remove = ["Default All Apps plan - 100 GB configuration",
452+ "Default Acrobat Pro DC configuration"]
453+ group.remove_from_products(products=profiles_to_add)
454+ ` ` `
455+
456+ # # Step 3: Submit to the UMAPI server
457+
458+ ` UserGroupAction` objects can be used with the same conn methods as
459+ ` UserAction` objects. See "Step 3" in the User Management section of
460+ this document for more information.
461+
462+ Here is a complete example that creates a new user group and adds a
463+ list of users to it :
464+
465+ ` ` ` python
466+ group = UserGroupAction(group_name="New User Group")
467+ group.create(description="A new user group",
468+ option=IfAlreadyExistsOptions.updateIfAlreadyExists)
469+ 470+
471+ result = conn.execute_single(group)
472+ ` ` `
0 commit comments