-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathAdd-VSTeamPolicy.ps1
More file actions
52 lines (45 loc) · 1.49 KB
/
Add-VSTeamPolicy.ps1
File metadata and controls
52 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Adds a new policy to the specified project.
#
# Get-VSTeamOption 'policy' 'configurations'
# id : dad91cbe-d183-45f8-9c6e-9c1164472121
# area : policy
# resourceName : configurations
# routeTemplate : {project}/_apis/{area}/{resource}/{configurationId}
# http://bit.ly/Add-VSTeamPolicy
function Add-VSTeamPolicy {
[CmdletBinding(HelpUri='https://methodsandpractices.github.io/vsteam-docs/modules/vsteam/Add-VSTeamPolicy')]
param(
[Parameter(Mandatory = $true)]
[guid] $type,
[switch] $enabled,
[switch] $blocking,
[Parameter(Mandatory = $true)]
[hashtable] $settings,
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)
process {
$body = @{
isEnabled = $enabled.IsPresent;
isBlocking = $blocking.IsPresent;
type = @{
id = $type
};
settings = $settings
} | ConvertTo-Json -Depth 10 -Compress
try {
# Call the REST API
$resp = _callAPI -Method POST -ProjectName $ProjectName `
-Area "policy" `
-Resource "configurations" `
-Body $body `
-Version $(_getApiVersion Policy)
Write-Output $resp
}
catch {
_handleException $_
}
}
}