Skip to content

Commit 7325dbd

Browse files
gm0dGuillermo DiazSebastianSchuetze
authored
Added Wiki cmdlets (#414)
* Added Wiki cmdlets * added test case, fixed casing, removed extralines * added shouldprocess support * fixed type on help files Co-authored-by: Guillermo Diaz <guillermo.diaz@mandiant.com> Co-authored-by: Sebastian Schütze <sebastian.schuetze@razorspoint.com>
1 parent e331ff8 commit 7325dbd

16 files changed

+653
-2
lines changed

.docs/Add-VSTeamWiki.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!-- #include "./common/header.md" -->
2+
3+
# Add-VSTeamWiki
4+
5+
## SYNOPSIS
6+
7+
<!-- #include "./synopsis/Add-VSTeamWiki.md" -->
8+
9+
## SYNTAX
10+
11+
## DESCRIPTION
12+
13+
Publish a code or project wiki in to the selected repo
14+
15+
You must call Set-VSTeamAccount before calling this function.
16+
17+
## EXAMPLES
18+
19+
### Example 1
20+
21+
```powershell
22+
Add-VSTeamWiki -ProjectName myProject -Name myProjectWiki
23+
```
24+
25+
This will create a project wiki
26+
27+
### Example 2
28+
29+
```powershell
30+
Add-VSTeamWiki -ProjectName myProject -Name myCodeWiki -repositoryId 00000000-0000-0000-0000-000000000000 -branch main -mappedPath '/.Docs'
31+
```
32+
33+
This will create a code wiki from main branch and publish '.Docs' folder
34+
35+
## PARAMETERS
36+
37+
<!-- #include "./params/projectName.md" -->
38+
39+
### Name
40+
41+
Name or ID of the Wiki to return
42+
43+
```yaml
44+
Type: String
45+
Required: True
46+
Position: named
47+
```
48+
49+
### RepositoryId
50+
51+
ID of the repository to publish from
52+
53+
```yaml
54+
Type: String
55+
Required: True
56+
Position: named
57+
Parameter Sets: codeWiki
58+
```
59+
60+
### Branch
61+
62+
Name of the branch in the repo to publish from
63+
64+
```yaml
65+
Type: String
66+
Required: False
67+
Position: named
68+
Parameter Sets: codeWiki
69+
```
70+
71+
### mappedPath
72+
73+
Path inside the repo to publish
74+
75+
```yaml
76+
Type: String
77+
Required: True
78+
Position: named
79+
Parameter Sets: codeWiki
80+
```
81+
82+
## INPUTS
83+
84+
## OUTPUTS
85+
86+
## NOTES
87+
88+
<!-- #include "./common/prerequisites.md" -->
89+
90+
## RELATED LINKS
91+
92+
<!-- #include "./common/related.md" -->
93+
94+
[Get-VSTeamWiki](Get-VSTeamWiki.md)
95+
96+
[Remove-VSTeamWiki](Remove-VSTeamWiki.md)

.docs/Get-VSTeamWiki.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!-- #include "./common/header.md" -->
2+
3+
# Get-VSTeamWiki
4+
5+
## SYNOPSIS
6+
7+
<!-- #include "./synopsis/Get-VSTeamWiki.md" -->
8+
9+
## SYNTAX
10+
11+
## DESCRIPTION
12+
13+
Returns a list of wikis in a project
14+
15+
A single wiki can be returned by providing the wiki namd or Id
16+
17+
You must call Set-VSTeamAccount before calling this function.
18+
19+
## EXAMPLES
20+
21+
### Example 1
22+
23+
```powershell
24+
Get-VSTeamWiki
25+
```
26+
27+
This will return a list of all the wikis for all the projects
28+
29+
### Example 2
30+
31+
```powershell
32+
Get-VSTeamWiki -ProjectName myProject
33+
```
34+
35+
This will return all the wikis for the specified project
36+
37+
### Example 3
38+
39+
```powershell
40+
Get-VSTeamWiki -ProjectName myProject -WikiName my-code-wiki
41+
```
42+
43+
This will return the specified wiki in the project provided
44+
45+
## PARAMETERS
46+
47+
<!-- #include "./params/projectName.md" -->
48+
49+
### Name
50+
51+
Name or ID of the Wiki to return
52+
53+
```yaml
54+
Type: String
55+
Required: True
56+
Position: named
57+
Aliases: WikiName, WikiId
58+
Parameter Sets: ByIdentifier
59+
```
60+
61+
## INPUTS
62+
63+
## OUTPUTS
64+
65+
## NOTES
66+
67+
<!-- #include "./common/prerequisites.md" -->
68+
69+
## RELATED LINKS
70+
71+
<!-- #include "./common/related.md" -->
72+
73+
[Add-VSTeamWiki](Add-VSTeamWiki.md)
74+
75+
[Remove-VSTeamWiki](Remove-VSTeamWiki.md)

.docs/Remove-VSTeamWiki.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!-- #include "./common/header.md" -->
2+
3+
# Remove-VSTeamWiki
4+
5+
## SYNOPSIS
6+
7+
<!-- #include "./synopsis/Remove-VSTeamWiki.md" -->
8+
9+
## SYNTAX
10+
11+
## DESCRIPTION
12+
13+
Un-publish a code or project wiki in to the selected repo
14+
15+
You must call Set-VSTeamAccount before calling this function.
16+
17+
## EXAMPLES
18+
19+
### Example 1
20+
21+
```powershell
22+
Remove-VSTeamWiki -ProjectName myProject -WikiName myWikiName
23+
```
24+
25+
This will Un-publish a wiki by name, project name required
26+
27+
### Example 2
28+
29+
```powershell
30+
Remove-VSTeamWiki -WikiId 00000000-0000-0000-0000-000000000000
31+
```
32+
33+
This will Un-publish a wiki by Id
34+
35+
## PARAMETERS
36+
37+
<!-- #include "./params/projectName.md" -->
38+
39+
### WikiName
40+
41+
Name of the Wiki to Un-publish
42+
43+
```yaml
44+
Type: String
45+
Required: True
46+
Position: named
47+
Aliases: Name
48+
Parameter Sets: ByName
49+
```
50+
51+
### WikiId
52+
53+
Id of the Wiki to Un-publish
54+
55+
```yaml
56+
Type: String
57+
Required: True
58+
Position: named
59+
Aliases: Id
60+
Parameter Sets: ById
61+
```
62+
63+
## INPUTS
64+
65+
## OUTPUTS
66+
67+
## NOTES
68+
69+
<!-- #include "./common/prerequisites.md" -->
70+
71+
## RELATED LINKS
72+
73+
<!-- #include "./common/related.md" -->
74+
75+
[Get-VSTeamWiki](Get-VSTeamWiki.md)
76+
77+
[Add-VSTeamWiki](Add-VSTeamWiki.md)

.docs/synopsis/Add-VSTeamWiki.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Publish a project or code wiki in the project provided

.docs/synopsis/Get-VSTeamWiki.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Returns a list of wikis for the selected project.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unpublish a project or code wiki in the project provided

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 7.5.0
4+
5+
Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/414) from [Guillermo Diaz](https://github.com/gm0d) which included the following:
6+
7+
- Added Get-VSTeamWiki, Add-VSTeamWiki, Remove-VSTeamWiki, for interacting with Wikis
8+
39
## 7.4.0
410

511
Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/400) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:

Source/Classes/Versions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public enum APIs
77
Build, Release, Core, Git, DistributedTask, DistributedTaskReleased,
88
VariableGroups, Tfvc, Packaging, MemberEntitlementManagement,
99
ExtensionsManagement, ServiceEndpoints, Graph, TaskGroups, Policy,
10-
Processes, Version, HierarchyQuery, Pipelines, Billing
10+
Processes, Version, HierarchyQuery, Pipelines, Billing, Wiki
1111
}
1212

1313
public static class Versions
@@ -73,6 +73,9 @@ public static void SetApiVersion(APIs service, string version)
7373
case APIs.Processes:
7474
Processes = version;
7575
break;
76+
case APIs.Wiki:
77+
Wiki = version;
78+
break;
7679
}
7780
}
7881

@@ -118,6 +121,8 @@ public static string GetApiVersion(APIs service)
118121
return Policy;
119122
case APIs.Processes:
120123
return Processes;
124+
case APIs.Wiki:
125+
return Wiki;
121126
default:
122127
return Version;
123128
}
@@ -155,5 +160,6 @@ public static string GetApiVersion(APIs service)
155160
public static string Graph { get; set; } = "";
156161
public static string Policy { get; set; } = "3.0";
157162
public static string Processes { get; set; } = "";
163+
public static string Wiki { get; set; } = "6.0";
158164
}
159165
}

Source/Private/common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function _getApiVersion {
200200
'DistributedTaskReleased', 'VariableGroups', 'Tfvc',
201201
'Packaging', 'MemberEntitlementManagement',
202202
'ExtensionsManagement', 'ServiceEndpoints', 'Graph',
203-
'TaskGroups', 'Policy', 'Processes', 'HierarchyQuery', 'Pipelines', 'Billing')]
203+
'TaskGroups', 'Policy', 'Processes', 'HierarchyQuery', 'Pipelines', 'Billing', 'Wiki')]
204204
[string] $Service,
205205

206206
[parameter(ParameterSetName = 'Target')]

Source/Public/Add-VSTeamWiki.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function Add-VSTeamWiki {
2+
[CmdletBinding(DefaultParameterSetName = 'projectWiki',
3+
HelpUri='https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Add-VSTeamWiki')]
4+
param(
5+
[Parameter(Mandatory = $true)]
6+
[Alias('WikiName')]
7+
[string] $Name,
8+
9+
[Parameter(Mandatory = $true, ParameterSetName = 'codeWiki')]
10+
[string] $RepositoryId,
11+
12+
[Parameter(Mandatory = $true, ParameterSetName = 'codeWiki')]
13+
[string] $Branch,
14+
15+
[Parameter(Mandatory = $true, ParameterSetName = 'codeWiki')]
16+
[string] $MappedPath,
17+
18+
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true )]
19+
[vsteam_lib.ProjectValidateAttribute($false)]
20+
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
21+
[string] $ProjectName
22+
)
23+
process {
24+
# Create the body for a projectWiki type
25+
$body = [ordered]@{
26+
type = $PSCmdlet.ParameterSetName
27+
name = $Name
28+
projectId = (Get-VSTeamProject -Name $ProjectName).id
29+
}
30+
31+
# if its a code wiki include additional properties
32+
if ($PSCmdlet.ParameterSetName -eq 'codeWiki'){
33+
$body+= [ordered]@{
34+
Version = @{
35+
Version = $Branch
36+
}
37+
repositoryId = $RepositoryId
38+
mappedPath = $MappedPath
39+
}
40+
}
41+
42+
$commonArgs = [ordered]@{
43+
Method = 'POST'
44+
Area = 'wiki'
45+
Resource = 'wikis'
46+
Body = $($body | ConvertTo-Json -Depth 100 -compress)
47+
ContentType = 'application/json'
48+
Version = $(_getApiVersion Wiki)
49+
}
50+
51+
$resp = _callAPI @commonArgs
52+
Write-Output $resp
53+
}
54+
}

0 commit comments

Comments
 (0)