Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Get-VSTeamGroup / Get-VSTeamDescriptor #140

Merged
merged 12 commits into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .docs/Get-VSTeamDescriptor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- #include "./common/header.md" -->

# Get-VSTeamExtension

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

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

## EXAMPLES

## PARAMETERS

### -StorageKey

Storage key of the subject (user, group, scope, etc.) to resolve

```yaml
Type: String
Required: True
Parameter Sets: ByStorageKey
```

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS
47 changes: 47 additions & 0 deletions .docs/Get-VSTeamGroup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!-- #include "./common/header.md" -->

# Get-VSTeamGroup

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

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

## EXAMPLES

## PARAMETERS

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

### -ScopeDescriptor

Specify a non-default scope (collection, project) to search for groups.

```yaml
Type: String
Required: False
Parameter Sets: List
```

### -Descriptor

The descriptor of the desired graph group.

```yaml
Type: String
Required: False
Parameter Sets: ByGroupDescriptor
```

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS
1 change: 1 addition & 0 deletions .docs/synopsis/Get-VSTeamDescriptor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolve a storage key to a descriptor.
1 change: 1 addition & 0 deletions .docs/synopsis/Get-VSTeamGroup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Returns a Group or List of Groups.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.0.2

Added Get-VSTeamGroup to retrieve Groups
Added Get-VSTeamDescriptor to resolve ID's to Descriptors

## 6.0.1

Fixing issue with mapping drive.
Expand Down
30 changes: 30 additions & 0 deletions Source/Classes/VSTeamDescriptor.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using namespace Microsoft.PowerShell.SHiPS

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamDescriptor : VSTeamLeaf {

[string]$Descriptor = $null
[hashtable]$Links = $null

VSTeamDescriptor (
[object]$obj
) : base($obj.value, $obj.value, $null) {

$this.Links = @{
'Self' = $obj._links.self.href;
'StorageKey' = $obj._links.storageKey.href;
'Subject'= $obj._links.subject.href;
}

$this.Descriptor = $obj.value

$this._internalObj = $obj

$this.AddTypeName('Team.Descriptor')
}

[string]ToString() {
return $this.Descriptor
}
}
20 changes: 20 additions & 0 deletions Source/Classes/VSTeamGitRepositoryPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://dev.azure.com/<organization>/_apis/securitynamespaces?api-version=5.0
[flags()] Enum ADOGitRepositoryPermissions
{
Administer = 1
GenericRead = 2
GenericContribute = 4
ForcePush = 8
CreateBranch = 16
CreateTag = 32
ManageNote = 64
PolicyExempt = 128
CreateRepository = 256
DeleteRepository = 512
RenameRepository = 1024
EditPolicies = 2048
RemoveOthersLocks = 4096
ManagePermissions = 8192
PullRequestContribute = 16384
PullRequestBypassPolicy = 32768
}
50 changes: 50 additions & 0 deletions Source/Classes/VSTeamGroup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using namespace Microsoft.PowerShell.SHiPS

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamGroup : VSTeamLeaf {

[string]$SubjectKind = $null
[string]$Description = $null
[string]$Domain = $null
[string]$PrincipalName = $null
[string]$MailAddress = $null
[string]$Origin = $null
[string]$OriginID = $null
[string]$DisplayName = $null
[string]$URL = $null
[string]$Descriptor = $null
[hashtable]$Links = $null

VSTeamGroup (
[object]$obj
) : base($obj.displayName, $obj.descriptor, $null) {
$this.SubjectKind = $obj.subjectKind
$this.Description = $obj.description
$this.Domain = $obj.domain
$this.PrincipalName = $obj.principalName
$this.MailAddress = $obj.mailAddress
$this.Origin = $obj.origin
$this.OriginID = $obj.originId
$this.DisplayName = $obj.displayName
$this.ProjectName = $obj.principalName.Split('\')[0].Trim('[',']')

$this.Links = @{
'Self' = $obj._links.self.href;
'Memberships' = $obj._links.memberships.href;
'MembershipState'= $obj._links.membershipState.href;
'StorageKey'= $obj._links.storageKey.href;
}

$this.URL = $obj.url
$this.Descriptor = $obj.descriptor

$this._internalObj = $obj

$this.AddTypeName('Team.Group')
}

[string]ToString() {
return $this.PrincipalName
}
}
10 changes: 10 additions & 0 deletions Source/Classes/VSTeamIdentityPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://dev.azure.com/<organization>/_apis/securitynamespaces?api-version=5.0
[flags()] Enum ADOIdentityPermissions
{
Read = 1
Write = 2
Delete = 4
ManageMembership = 8
CreateScope = 16
RestoreScope = 32
}
28 changes: 28 additions & 0 deletions Source/Classes/VSTeamProjectPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# https://dev.azure.com/<organization>/_apis/securitynamespaces?api-version=5.0
[flags()] Enum ADOProjectPermissions
{
GENERIC_READ = 1
GENERIC_WRITE = 2
DELETE = 4
PUBLISH_TEST_RESULTS = 8
ADMINISTER_BUILD = 16
START_BUILD = 32
EDIT_BUILD_STATUS = 64
UPDATE_BUILD = 128
DELETE_TEST_RESULTS = 256
VIEW_TEST_RESULTS = 512
MANAGE_TEST_ENVIRONMENTS = 2048
MANAGE_TEST_CONFIGURATIONS = 4096
WORK_ITEM_DELETE = 8192
WORK_ITEM_MOVE = 16384
WORK_ITEM_PERMANENTLY_DELETE = 32768
RENAME = 65536
MANAGE_PROPERTIES = 131072
MANAGE_SYSTEM_PROPERTIES = 262144
BYPASS_PROPERTY_CACHE = 524288
BYPASS_RULES = 1048576
SUPPRESS_NOTIFICATIONS = 2097152
UPDATE_VISIBILITY = 4194304
CHANGE_PROCESS = 8388608
AGILETOOLS_BACKLOG = 16777216
}
1 change: 1 addition & 0 deletions Source/Classes/VSTeamVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class VSTeamVersions {
static [string] $ExtensionsManagement = ''
static [string] $ServiceFabricEndpoint = ''
static [string] $ModuleVersion = $null
static [string] $Graph = ''
}
12 changes: 12 additions & 0 deletions Source/Classes/VSTeamWorkItemAreaPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://dev.azure.com/<organization>/_apis/securitynamespaces?api-version=5.0
[flags()] Enum ADOWorkItemAreaPermissions
{
GENERIC_READ = 1
GENERIC_WRITE = 2
CREATE_CHILDREN = 4
DELETE = 8
WORK_ITEM_READ = 16
WORK_ITEM_WRITE = 32
MANAGE_TEST_PLANS = 64
MANAGE_TEST_SUITES = 128
}
8 changes: 8 additions & 0 deletions Source/Classes/VSTeamWorkItemIterationPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://dev.azure.com/<organization>/_apis/securitynamespaces?api-version=5.0
[flags()] Enum ADOWorkItemIterationPermissions
{
GENERIC_READ = 1
GENERIC_WRITE = 2
CREATE_CHILDREN = 4
DELETE = 8
}
14 changes: 13 additions & 1 deletion Source/Classes/classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,17 @@
"VSTeamProcess.ps1",
"VSTeamRef.ps1",
"VSTeamTeam.ps1",
"VSTeamAccount.ps1"
"VSTeamAccount.ps1",
"VSTeamGitRepositoryPermissions.ps1",
"VSTeamIdentityPermissions.ps1",
"VSTeamProjectPermissions.ps1",
"VSTeamWorkItemAreaPermissions.ps1",
"VSTeamWorkItemIterationPermissions.ps1",
"VSTeamGroup.ps1",
"VSTeamGitRepositoryPermissions.ps1",
"VSTeamIdentityPermissions.ps1",
"VSTeamProjectPermissions.ps1",
"VSTeamWorkItemAreaPermissions.ps1",
"VSTeamWorkItemIterationPermissions.ps1",
"VSTeamDescriptor.ps1"
]
1 change: 1 addition & 0 deletions Source/Public/Get-VSTeamAPIVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ function Get-VSTeamAPIVersion {
MemberEntitlementManagement = $([VSTeamVersions]::MemberEntitlementManagement)
ExtensionsManagement = $([VSTeamVersions]::ExtensionsManagement)
ServiceFabricEndpoint = $([VSTeamVersions]::ServiceFabricEndpoint)
Graph = $([VSTeamVersions]::Graph)
}
}
21 changes: 21 additions & 0 deletions Source/Public/Get-VSTeamDescriptor.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function Get-VSTeamDescriptor {
[CmdletBinding(DefaultParameterSetName = 'ByStorageKey')]
param(
[Parameter(ParameterSetName = 'ByStorageKey', Mandatory = $true)]
[string] $StorageKey
)

process {
# Call the REST API
$resp = _callAPI -Area 'graph/descriptors' -id $StorageKey `
-Version $([VSTeamVersions]::Graph) `
-SubDomain 'vssps'

# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
# seemed to be written
$descriptor = [VSTeamDescriptor]::new($resp)

Write-Output $descriptor
}
}
Loading