Skip to content

Commit

Permalink
feat: adding support for chaining c8y userreferences addUserToGroup
Browse files Browse the repository at this point in the history
… using pipeline

docs: `c8y userreferences` adding more examples and fixing some existing
  • Loading branch information
reubenmiller committed May 19, 2021
1 parent 0215e81 commit 35255ec
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 28 deletions.
27 changes: 20 additions & 7 deletions api/spec/json/userReferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"information": {
"name": "userReferences",
"name": "userreferences",
"description": "Cumulocity user references",
"descriptionLong": "REST endpoint to interact with Cumulocity user references",
"link": "https://cumulocity.com/guides/reference/users/#user-reference-collection"
Expand Down Expand Up @@ -33,8 +33,12 @@
],
"go": [
{
"description": "List the users within a user group",
"command": "c8y userReferences addUserToGroup --group 1 --user myuser"
"description": "Add a user to a user group",
"command": "c8y userreferences addUserToGroup --group 1 --user myuser"
},
{
"description": "Add a list of users to business and admins group using pipeline",
"command": "c8y users list | c8y userreferences addUserToGroup --group business | c8y userreferences addUserToGroup --group admins"
}
]
},
Expand All @@ -61,6 +65,7 @@
"property": "user.self",
"description": "User id",
"pipelineAliases": [
"user.id",
"id",
"self"
]
Expand All @@ -81,7 +86,7 @@
"examples": {
"powershell": [
{
"description": "Add a user to a user group",
"description": "From a user from a user group",
"beforeEach": [
"$User = New-TestUser",
"$Group = Get-UserGroupByName -Name \"business\"",
Expand All @@ -95,8 +100,12 @@
],
"go": [
{
"description": "List the users within a user group",
"command": "c8y userReferences deleteUserFromGroup --group 1 --user myuser"
"description": "From a user from a user group",
"command": "c8y userreferences deleteUserFromGroup --group 1 --user myuser"
},
{
"description": "From a user from a user group (using pipeline)",
"command": "c8y users get --id myuser | c8y userreferences deleteUserFromGroup --group 1"
}
]
},
Expand Down Expand Up @@ -165,7 +174,11 @@
"go": [
{
"description": "List the users within a user group",
"command": "c8y userReferences listGroupMembership --group 1"
"command": "c8y userreferences listGroupMembership --group 1"
},
{
"description": "List users in user groups (via pipeline)",
"command": "c8y usergroups list | c8y userreferences listGroupMembership"
}
]
},
Expand Down
24 changes: 17 additions & 7 deletions api/spec/yaml/userReferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---

information:
name: userReferences
name: userreferences
description: Cumulocity user references
descriptionLong: 'REST endpoint to interact with Cumulocity user references'
link: https://cumulocity.com/guides/reference/users/#user-reference-collection
Expand All @@ -27,8 +27,11 @@ endpoints:
afterEach:
- Remove-User -Id $User.id
go:
- description: List the users within a user group
command: c8y userReferences addUserToGroup --group 1 --user myuser
- description: Add a user to a user group
command: c8y userreferences addUserToGroup --group 1 --user myuser

- description: Add a list of users to business and admins group using pipeline
command: c8y users list | c8y userreferences addUserToGroup --group business | c8y userreferences addUserToGroup --group admins
pathParameters:
- name: group
type: '[]usergroup'
Expand All @@ -48,6 +51,7 @@ endpoints:
property: user.self
description: User id
pipelineAliases:
- user.id
- id
- self

Expand All @@ -63,7 +67,7 @@ endpoints:
powershell: Remove-UserFromGroup
examples:
powershell:
- description: Add a user to a user group
- description: From a user from a user group
beforeEach:
- $User = New-TestUser
- $Group = Get-UserGroupByName -Name "business"
Expand All @@ -72,8 +76,11 @@ endpoints:
afterEach:
- Remove-User -Id $User.id
go:
- description: List the users within a user group
command: c8y userReferences deleteUserFromGroup --group 1 --user myuser
- description: From a user from a user group
command: c8y userreferences deleteUserFromGroup --group 1 --user myuser

- description: From a user from a user group (using pipeline)
command: c8y users get --id myuser | c8y userreferences deleteUserFromGroup --group 1
pathParameters:
- name: group
type: '[]usergroup'
Expand Down Expand Up @@ -123,7 +130,10 @@ endpoints:
- Remove-User -Id $User.id
go:
- description: List the users within a user group
command: c8y userReferences listGroupMembership --group 1
command: c8y userreferences listGroupMembership --group 1

- description: List users in user groups (via pipeline)
command: c8y usergroups list | c8y userreferences listGroupMembership
pathParameters:
- name: id
type: '[]usergroup'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ c8y userreferences addUserToGroup [flags]
### Examples

```
$ c8y userReferences addUserToGroup --group 1 --user myuser
List the users within a user group
$ c8y userreferences addUserToGroup --group 1 --user myuser
Add a user to a user group
$ c8y users list | c8y userreferences addUserToGroup --group business | c8y userreferences addUserToGroup --group admins
Add a list of users to business and admins group using pipeline
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ c8y userreferences deleteUserFromGroup [flags]
### Examples

```
$ c8y userReferences deleteUserFromGroup --group 1 --user myuser
List the users within a user group
$ c8y userreferences deleteUserFromGroup --group 1 --user myuser
From a user from a user group
$ c8y users get --id myuser | c8y userreferences deleteUserFromGroup --group 1
From a user from a user group (using pipeline)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ c8y userreferences listGroupMembership [flags]
### Examples

```
$ c8y userReferences listGroupMembership --group 1
$ c8y userreferences listGroupMembership --group 1
List the users within a user group
$ c8y usergroups list | c8y userreferences listGroupMembership
List users in user groups (via pipeline)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Delete an existing user from a user group
Remove-UserFromGroup -Group $Group.id -User $User.id
```

Add a user to a user group
From a user from a user group

## PARAMETERS

Expand Down
9 changes: 6 additions & 3 deletions pkg/cmd/userreferences/addusertogroup/addUserToGroup.auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/PSc8y/Public/Remove-UserFromGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ https://reubenmiller.github.io/go-c8y-cli/docs/cli/c8y/userreferences_deleteUser
.EXAMPLE
PS> Remove-UserFromGroup -Group $Group.id -User $User.id
Add a user to a user group
From a user from a user group
#>
Expand Down
2 changes: 1 addition & 1 deletion tools/PSc8y/Tests/Remove-UserFromGroup.auto.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Describe -Name "Remove-UserFromGroup" {

}

It "Add a user to a user group" {
It "From a user from a user group" {
$Response = PSc8y\Remove-UserFromGroup -Group $Group.id -User $User.id
$LASTEXITCODE | Should -Be 0
}
Expand Down

0 comments on commit 35255ec

Please sign in to comment.