Skip to content

Commit

Permalink
Merge pull request #178 from Seekatar/add-membership-functions
Browse files Browse the repository at this point in the history
add membership functions
  • Loading branch information
DarqueWarrior authored Aug 6, 2019
2 parents 868f799 + f454a22 commit fbc3a09
Show file tree
Hide file tree
Showing 63 changed files with 1,335 additions and 146 deletions.
49 changes: 49 additions & 0 deletions .docs/Add-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- #include "./common/header.md" -->

# Add-VSTeamMembership

## SYNOPSIS

<!-- #include "./synopsis/Add-VSTeamMembership.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Add-VSTeamMembership.md" -->

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------

```PowerShell
PS C:\> $user = Get-VSTeamUser | ? DisplayName -eq 'Test User'
PS C:\> $group = Get-VSTeamGroup | ? DisplayName -eq 'Endpoint Administrators'
PS C:\> Add-VSTeamMembership -MemberDescriptor $user.Descriptor -ContainerDescriptor $group.Descriptor
```

Adds Test User to the Endpoint Administrators group.

## PARAMETERS

<!-- #include "./params/memberDescriptor.md" -->

<!-- #include "./params/containerDescriptor.md" -->

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS

[Get-VsTeamUser](Get-VsTeamUser.md)

[Get-VsTeamGroup](Get-VsTeamGroup.md)

[Get-VsTeamMembership](Get-VsTeamMembership.md)

[Remove-VsTeamMembership](Remove-VsTeamMembership.md)

[Test-VsTeamMembership](Test-VsTeamMembership.md)
8 changes: 8 additions & 0 deletions .docs/Get-VSTeamGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------

```PowerShell
PS C:\> $group = Get-VSTeamGroup | ? DisplayName -eq 'Endpoint Administrators'
```

Assigns Endpoint Administrators group to $group variable.

## PARAMETERS

<!-- #include "./params/projectName.md" -->
Expand Down
73 changes: 73 additions & 0 deletions .docs/Get-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!-- #include "./common/header.md" -->

# Get-VSTeamMembership

## SYNOPSIS

<!-- #include "./synopsis/Get-VSTeamMembership.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Get-VSTeamMembership.md" -->

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------

```PowerShell
(Get-VSTeamMembership -MemberDescriptor $user.ID).value | % { Get-VSTeamGroup -Descriptor $_.containerDescriptor }
```

Get all the groups for a user

### -------------------------- EXAMPLE 2 --------------------------

```PowerShell
(Get-VSTeamMembership -ContainerDescriptor $group.id).value | % {Get-VSTeamUser -Descriptor $_.memberDescriptor }
```

Get all the members for a group

## PARAMETERS

### -ContainerDescriptor

A container descriptor retrieved by Get-VsTeamGroup

```yaml
Type: String
Required: True
Parameter Sets: ByContainerId
Position: 0
```
### -MemberDescriptor
A member descriptor retrieved by Get-VsTeamUser
```yaml
Type: String
Required: True
Parameter Sets: ByMemberId
Position: 0
```
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS
[Get-VsTeamUser](Get-VsTeamUser.md)
[Get-VsTeamGroup](Get-VsTeamGroup.md)
[Add-VsTeamMembership](Add-VsTeamMembership.md)
[Remove-VsTeamMembership](Remove-VsTeamMembership.md)
[Test-VsTeamMembership](Test-VsTeamMembership.md)
49 changes: 49 additions & 0 deletions .docs/Remove-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- #include "./common/header.md" -->

# Remove-VSTeamMembership

## SYNOPSIS

<!-- #include "./synopsis/Remove-VSTeamMembership.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Remove-VSTeamMembership.md" -->

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------

```PowerShell
PS C:\> $user = Get-VSTeamUser | ? DisplayName -eq 'Test User'
PS C:\> $group = Get-VSTeamGroup | ? DisplayName -eq 'Endpoint Administrators'
PS C:\> Remove-VSTeamMembership -MemberDescriptor $user.Descriptor -ContainerDescriptor $group.Descriptor
```

Removes Test User from the Endpoint Administrators group.

## PARAMETERS

<!-- #include "./params/memberDescriptor.md" -->

<!-- #include "./params/containerDescriptor.md" -->

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS

[Get-VsTeamUser](Get-VsTeamUser.md)

[Get-VsTeamGroup](Get-VsTeamGroup.md)

[Add-VsTeamMembership](Add-VsTeamMembership.md)

[Get-VsTeamMembership](Get-VsTeamMembership.md)

[Test-VsTeamMembership](Test-VsTeamMembership.md)
41 changes: 41 additions & 0 deletions .docs/Test-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- #include "./common/header.md" -->

# Test-VSTeamMembership

## SYNOPSIS

<!-- #include "./synopsis/Test-VSTeamMembership.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Test-VSTeamMembership.md" -->

## EXAMPLES

## PARAMETERS

<!-- #include "./params/memberDescriptor.md" -->

<!-- #include "./params/containerDescriptor.md" -->

## INPUTS

## OUTPUTS

### System.Boolean

## NOTES

## RELATED LINKS

[Get-VsTeamUser](Get-VsTeamUser.md)

[Get-VsTeamGroup](Get-VsTeamGroup.md)

[Add-VsTeamMembership](Add-VsTeamMembership.md)

[Get-VsTeamMembership](Get-VsTeamMembership.md)

[Remove-VsTeamMembership](Remove-VsTeamMembership.md)
9 changes: 9 additions & 0 deletions .docs/params/containerDescriptor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### -ContainerDescriptor

A container descriptor retrieved by Get-VsTeamGroup

```yaml
Type: String
Required: True
Position: 1
```
9 changes: 9 additions & 0 deletions .docs/params/memberDescriptor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### -MemberDescriptor

A member descriptor retrieved by Get-VsTeamUser

```yaml
Type: String
Required: True
Position: 0
```
1 change: 1 addition & 0 deletions .docs/synopsis/Add-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds a membership to a container.
1 change: 1 addition & 0 deletions .docs/synopsis/Get-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gets a memberships for a container or member.
1 change: 1 addition & 0 deletions .docs/synopsis/Remove-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removes a membership to a container.
1 change: 1 addition & 0 deletions .docs/synopsis/Test-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tests the membership in a container.
16 changes: 15 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,19 @@
"vsrm",
"vssgp",
"vssps"
]
],
"workbench.colorCustomizations": {
"activityBar.background": "#007699",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#ff80e2",
"activityBarBadge.foreground": "#15202b",
"titleBar.activeBackground": "#004f66",
"titleBar.inactiveBackground": "#004f6699",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799",
"statusBar.background": "#004f66",
"statusBarItem.hoverBackground": "#007699",
"statusBar.foreground": "#e7e7e7"
}
}
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 6.3.1

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/178) from [Jim W](https://github.com/Seekatar) which included the following:

- Add-VSTeamMembership
- Remove-VSTeamMembership
- Get-VSTeamMembership
- Test-VSTeamMembership

## 6.3.0

Added support for the following:
Expand All @@ -21,10 +30,10 @@ Updated help to refer to Add-VSTeamProfile instead of Set-VSTeamProfile
Added support for Get-VSTeamJobRequest. The provider was extended to show the Job Request under the Agent.

- Account
- Agent Pools
- Pool1
- Agent1
- JobRequest1
- Agent Pools
- Pool1
- Agent1
- JobRequest1

## 6.2.7

Expand Down
3 changes: 2 additions & 1 deletion Merge-File.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Merge-Format {
$fileContents = Get-Content $file
$newFileContents = ($fileContents -replace '<!--.+-->', '')
[xml]$xml = $newFileContents

$finalXml += $xml.Configuration.ViewDefinitions.InnerXml
}

Expand Down Expand Up @@ -173,6 +173,7 @@ function Merge-Class {
process {
$usingsSb = New-Object System.Text.StringBuilder
$contents = New-Object System.Text.StringBuilder
$usings = @()

ForEach ($file in $files) {
Write-Verbose -Message "Merging from $file"
Expand Down
33 changes: 33 additions & 0 deletions Source/Private/callMembershipAPI.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

function _callMembershipAPI {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $Id,
[ValidateSet('Get', 'Post', 'Patch', 'Delete', 'Options', 'Put', 'Default', 'Head', 'Merge', 'Trace')]
[string] $Method,
[ValidateSet('', 'Up', 'Down')]
[string] $Direction
)
Set-StrictMode -Version Latest

# This will throw if this account does not support the graph API
_supportsGraph

Write-Verbose "Getting members for $Id"

$query = @{}
if ($Direction) {
$query['direction'] = $Direction
}

# Call the REST API
$resp = _callAPI -Area 'graph' -Resource 'memberships' `
-Id $Id `
-SubDomain "vssps" `
-Method $Method `
-Version $([VSTeamVersions]::Graph) `
-QueryString $query

return $resp
}
4 changes: 4 additions & 0 deletions Source/Private/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@ $profilesPath = "$HOME/vsteam_profiles.json"
# Not all versions support the name features.

function _supportsGraph {
_hasAccount
if (-not [VSTeamVersions]::Graph) {
throw 'This account does not support the graph API.'
}
}

function _supportsFeeds {
_hasAccount
if (-not [VSTeamVersions]::Packaging) {
throw 'This account does not support packages.'
}
}

function _supportsSecurityNamespace {
_hasAccount
if (([VSTeamVersions]::Version -ne "VSTS") -and ([VSTeamVersions]::Version -ne "AzD")) {
throw 'Security Namespaces are currently only supported in Azure DevOps Service (Online)'
}
}

function _supportsMemberEntitlementManagement {
_hasAccount
if (-not [VSTeamVersions]::MemberEntitlementManagement) {
throw 'This account does not support Member Entitlement.'
}
Expand Down
Loading

0 comments on commit fbc3a09

Please sign in to comment.