Skip to content

Commit

Permalink
globus group update --terms-and-conditions (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
derek-globus authored Oct 15, 2024
1 parent 3f4261a commit 35f4ad1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

### Enhancements

* Added a `--terms-and-conditions` option to the `globus group update` command.
1 change: 1 addition & 0 deletions src/globus_cli/commands/group/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"my_memberships[].role",
formatter=formatters.SortedArray,
),
Field("Terms and Conditions", "terms_and_conditions", wrap_enabled=True),
]
GROUP_FIELDS = [Field("Group ID", "id")] + _BASE_GROUP_RECORD_FIELDS
GROUP_FIELDS_W_SUBSCRIPTION = (
Expand Down
14 changes: 11 additions & 3 deletions src/globus_cli/commands/group/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
@group_id_arg
@click.option("--name", help="Name for the group")
@click.option("--description", help="Description for the group")
@click.option(
"--terms-and-conditions", help="Terms and conditions for group membership"
)
@LoginManager.requires_login("groups")
def group_update(
login_manager: LoginManager,
*,
group_id: uuid.UUID,
name: str | None,
description: str | None,
terms_and_conditions: str | None,
) -> None:
"""Update an existing group."""
groups_client = login_manager.get_groups_client()
Expand All @@ -30,10 +34,14 @@ def group_update(
group = groups_client.get_group(group_id)

# assemble put data using existing values for any field not given
# note that the API does not accept the full group document, so we must
# specify name and description instead of just iterating kwargs
# note that the API only allows modification of certain fields
# https://groups.api.globus.org/redoc#tag/groups/operation/update_group_v2_groups__group_id__put
data = {}
for attrname, argval in (("name", name), ("description", description)):
for attrname, argval in (
("name", name),
("description", description),
("terms_and_conditions", terms_and_conditions),
):
if argval is not None:
data[attrname] = argval
else:
Expand Down
1 change: 1 addition & 0 deletions tests/files/api_fixtures/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ groups:
"id": "8b7d57bc-1666-11ec-88b2-f50515619d57",
"name": "Group 1",
"description": "The first group.",
"terms_and_conditions": null,
"group_type": "regular",
"enforce_session": false,
"my_memberships": [
Expand Down
25 changes: 20 additions & 5 deletions tests/functional/groups/test_group_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@
@pytest.mark.parametrize(
"add_args, payload_contains",
(
(["--name", "New Name"], {"name": "New Name"}),
(["--description", "New Description"], {"description": "New Description"}),
(("--name", "New Name"), {"name": "New Name"}),
(("--description", "New Description"), {"description": "New Description"}),
(
["--name", "New Name", "--description", "New Description"],
{"description": "New Description", "name": "New Name"},
("--terms-and-conditions", "New Terms and Conditions"),
{"terms_and_conditions": "New Terms and Conditions"},
),
(
(
"--name",
"New Name",
"--description",
"New Description",
"--terms-and-conditions",
"New Terms and Conditions",
),
{
"description": "New Description",
"name": "New Name",
"terms_and_conditions": "New Terms and Conditions",
},
),
),
)
Expand All @@ -28,7 +43,7 @@ def test_group_update(run_line, add_args, payload_contains):
group1_description = meta["group1_description"]

# update name
result = run_line(["globus", "group", "update", group1_id] + add_args)
result = run_line(("globus", "group", "update", group1_id) + add_args)
assert "Group updated successfully" in result.output

# confirm that 'name' and 'description' are both always sent,
Expand Down

0 comments on commit 35f4ad1

Please sign in to comment.