Skip to content

Commit

Permalink
add membership functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Seekatar committed Jul 28, 2019
1 parent 868f799 commit 803cf36
Show file tree
Hide file tree
Showing 61 changed files with 1,287 additions and 141 deletions.
39 changes: 39 additions & 0 deletions .docs/Add-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- #include "./common/header.md" -->

# Add-VSTeamMembership

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

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

## EXAMPLES

## 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)
71 changes: 71 additions & 0 deletions .docs/Get-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!-- #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)
39 changes: 39 additions & 0 deletions .docs/Remove-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- #include "./common/header.md" -->

# Remove-VSTeamMembership

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

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

## EXAMPLES

## 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)
40 changes: 40 additions & 0 deletions .docs/Test-VSTeamMembership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- #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
### $True or $False

## 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"
}
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 6.3.1

Added support for the following:

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

## 6.3.0

Added support for the following:
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
14 changes: 14 additions & 0 deletions Source/Public/Add-VSTeamMembership.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function Add-VSTeamMembership {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $MemberDescriptor,
[Parameter(Mandatory = $true)]
[string] $ContainerDescriptor,
[switch] $DontTest
)

process {
return _callMembershipAPI -Id "$MemberDescriptor/$ContainerDescriptor" -Method Put
}
}
17 changes: 17 additions & 0 deletions Source/Public/Get-VSTeamMembership.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function Get-VSTeamMembership {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline, ValueFromPipelineByPropertyName,ParameterSetName="ByContainerId")]
[string] $ContainerDescriptor,
[Parameter(Mandatory = $true, ValueFromPipeline, ValueFromPipelineByPropertyName,ParameterSetName="ByMemberId")]
[string] $MemberDescriptor
)

process {
if ($MemberDescriptor) {
return _callMembershipAPI -Id $MemberDescriptor -Method Get -Direction Up
} else {
return _callMembershipAPI -Id $ContainerDescriptor -Method Get -Direction Down
}
}
}
13 changes: 13 additions & 0 deletions Source/Public/Remove-VSTeamMembership.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Remove-VSTeamMembership {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $MemberDescriptor,
[Parameter(Mandatory = $true)]
[string] $ContainerDescriptor
)

process {
return _callMembershipAPI -Id "$MemberDescriptor/$ContainerDescriptor" -Method Delete
}
}
Loading

0 comments on commit 803cf36

Please sign in to comment.