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

✏️ Added work item tag cmdlets to Get, Remove and Update, also fixed typos and casing #418

Merged
merged 16 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
73 changes: 73 additions & 0 deletions .docs/Get-VSTeamWorkItemTag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!-- #include "./common/header.md" -->

# Get-VSTeamWorkItemTag

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

Returns a list of work item tags in a project.

A single tag can be returned by providing the tag name or id.

## EXAMPLES

### Example 1

```powershell
Get-VSTeamWorkItemTag
```

This will return a list of all the work item tags within the current project

### Example 2

```powershell
Get-VSTeamWorkItemTag -TagId my-tag
```

This will return a specific work item tag

### Example 3

```powershell
Get-VSTeamWorkItemTag -TagName my-tag
```

This will return a specific work item tag

## PARAMETERS

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

### NameOrTagId

Name or ID of the tag to return

```yaml
Type: String
Required: True
Position: named
Aliases: TagName, TagId
Parameter Sets: ByIdentifier
```

## INPUTS

## OUTPUTS

## NOTES

<!-- #include "./common/prerequisites.md" -->

## RELATED LINKS

<!-- #include "./common/related.md" -->

[Update-VSTeamWorkItemTag](Update-VSTeamWorkItemTag.md)

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

# Remove-VSTeamWorkItemTag

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

Removes a work item tag.

## EXAMPLES

### Example 1

```powershell
Remove-VSTeamWorkItemTag -TagName
```

This will remove a specific work item tag within the current project

## PARAMETERS

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

### NameOrTagId

Name or ID of the tag to return

```yaml
Type: String
Required: True
Position: named
Aliases: TagName, TagId
Parameter Sets: ByIdentifier
```

## INPUTS

## OUTPUTS

## NOTES

<!-- #include "./common/prerequisites.md" -->

## RELATED LINKS

<!-- #include "./common/related.md" -->

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

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

# Update-VSTeamWorkItemTag

## SYNOPSIS

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

## SYNTAX

## DESCRIPTION

Updates a work item tag.

## EXAMPLES

### Example 1

```powershell
Update-VSTeamWorkItemTag -TagName
```

This will update a specific work item tag within the current project

## PARAMETERS

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

### NameOrTagId

Name or ID of the tag to return

```yaml
Type: String
Required: True
Position: named
Aliases: TagName, TagId
Parameter Sets: ByIdentifier
```

## INPUTS

## OUTPUTS

## NOTES

<!-- #include "./common/prerequisites.md" -->

## RELATED LINKS

<!-- #include "./common/related.md" -->

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

[Remove-VSTeamWorkItemTag](Remove-VSTeamWorkItemTag.md)
2 changes: 1 addition & 1 deletion .docs/common/prerequisites.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Prerequisites:

Set the account and version that all calls will use with Set-VSTeamAccount. If you do not set the version it default to 3.0, TFS2017. Using the default could limit API functionality.
Set the account and version that all calls will use with Set-VSTeamAccount. If you do not set the version it will default to 3.0, TFS2017. Using the default could limit API functionality.

You can check what version of the API that will be called with Get-VSTeamAPIVersion, or Get-VSTeamInfo.

Expand Down
2 changes: 1 addition & 1 deletion .docs/params/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Specifies the version to use. The acceptable values for this parameter are:
- VSTS
- AzD

If you are on AzD it will default to Azd otherwise it will default to TFS2017.
If you are on AzD it will default to AzD otherwise it will default to TFS2017.

```yaml
Type: String
Expand Down
1 change: 1 addition & 0 deletions .docs/synopsis/Get-VSTeamWorkItemTag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Get a work item tag
1 change: 1 addition & 0 deletions .docs/synopsis/Remove-VSTeamWorkItemTag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update a work item tag
Empty file.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## 7.5.0

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/TBD) from [Sander Holvoet](https://github.com/smholvoet) which included the following:

- Added `Get-VSTeamWorkItemTag`, `Update-VSTeamWorkItemTag` and `Remove-VSTeamWorkItemTag` cmdlets which allow you to [manage work item tags]([#296](https://github.com/DarqueWarrior/vsteam/issues/296).

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/414) from [Guillermo Diaz](https://github.com/gm0d) which included the following:

- Added Get-VSTeamWiki, Add-VSTeamWiki, Remove-VSTeamWiki, for interacting with Wikis

## 7.4.0

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/400) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:
Expand Down
8 changes: 7 additions & 1 deletion Source/Classes/Versions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public enum APIs
Build, Release, Core, Git, DistributedTask, DistributedTaskReleased,
VariableGroups, Tfvc, Packaging, MemberEntitlementManagement,
ExtensionsManagement, ServiceEndpoints, Graph, TaskGroups, Policy,
Processes, Version, HierarchyQuery, Pipelines, Billing, Wiki
Processes, Version, HierarchyQuery, Pipelines, Billing, Wiki, WorkItemTracking
}

public static class Versions
Expand Down Expand Up @@ -76,6 +76,9 @@ public static void SetApiVersion(APIs service, string version)
case APIs.Wiki:
Wiki = version;
break;
case APIs.WorkItemTracking:
WorkItemTracking = version;
break;
}
}

Expand Down Expand Up @@ -123,6 +126,8 @@ public static string GetApiVersion(APIs service)
return Processes;
case APIs.Wiki:
return Wiki;
case APIs.WorkItemTracking:
return WorkItemTracking;
default:
return Version;
}
Expand Down Expand Up @@ -161,5 +166,6 @@ public static string GetApiVersion(APIs service)
public static string Policy { get; set; } = "3.0";
public static string Processes { get; set; } = "";
public static string Wiki { get; set; } = "6.0";
public static string WorkItemTracking { get; set; } = "6.0";
}
}
6 changes: 4 additions & 2 deletions Source/Public/Get-VSTeamAPIVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Get-VSTeamAPIVersion {
'Packaging', 'MemberEntitlementManagement',
'ExtensionsManagement', 'ServiceEndpoints', 'Graph',
'TaskGroups', 'Policy', 'Processes', 'HierarchyQuery',
'Pipelines', 'Billing')]
'Pipelines', 'Billing', 'Wiki', 'WorkItemTracking')]
[string] $Service
)

Expand Down Expand Up @@ -39,7 +39,9 @@ function Get-VSTeamAPIVersion {
TaskGroups = $(_getApiVersion TaskGroups)
Tfvc = $(_getApiVersion Tfvc)
VariableGroups = $(_getApiVersion VariableGroups)
Version = $(_getApiVersion -Target)
Version = $(_getApiVersion Version)
Wiki = $(_getApiVersion Wiki)
WorkItemTracking = $(_getApiVersion WorkItemTracking)
}
}
}
2 changes: 1 addition & 1 deletion Source/Public/Get-VSTeamProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Get-VSTeamProcess {
$commonArgs = @{
# In later APIs you can get the process templates from the 'work'
# area. For older APIs the process templates are in the 'processes'
# area. Default to the newer way of accessing process templates.
# area. Defaults to the newer way of accessing process templates.
# Get-VSTeamOption -area 'work' -resource 'processes' returns nothing
# this is odd but the call works.
area = 'work'
Expand Down
36 changes: 36 additions & 0 deletions Source/Public/Get-VSTeamWorkItemTag.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function Get-VSTeamWorkItemTag {
[CmdletBinding(HelpUri='https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Get-VSTeamWorkItemTag')]
param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('TagName')]
[Alias('TagId')]
[string] $TagIdOrName,
smholvoet marked this conversation as resolved.
Show resolved Hide resolved

[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true )]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)
process {
$commonArgs = @{
area = 'wit'
resource = 'tags'
projectName = $ProjectName
version = $(_getApiVersion WorkItemTracking)
}

if ($TagIdOrName) { # TagIdOrName was specified, fetch a specific tag
$resp = _callAPI @commonArgs -id $TagIdOrName
Write-Output $resp
}
else { # TagIdOrName not specified, list all tags
$listurl = _buildRequestURI @commonArgs
$resp = _callAPI -url $listurl
$objs = @()
foreach ($item in $resp.value) {
$objs += $item
}
Write-Output $objs
}
}
}
32 changes: 32 additions & 0 deletions Source/Public/Remove-VSTeamWorkItemTag.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function Remove-VSTeamWorkItemTag {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High", DefaultParameterSetName = 'ByID',
HelpUri='https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Remove-VSTeamWorkItemTag')]
param(
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string] $TagIdOrName,

[switch] $Force,

[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)

Process {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete work item tag from all work items in this team project")) {
try {
_callAPI -Method DELETE `
-Area "wit" `
-Resource "tags" `
-id $TagIdOrName `
-Version $(_getApiVersion WorkItemTracking) | Out-Null

Write-Output "Deleted tag $TagIdOrName"
}
catch {
_handleException $_
}
}
}
}
34 changes: 34 additions & 0 deletions Source/Public/Update-VSTeamWorkItemTag.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function Update-VSTeamWorkItemTag {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium", DefaultParameterSetName = 'JSON',
HelpUri='https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Update-VSTeamWorkItemTag')]
Param(
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string] $TagIdOrName,

[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string] $NewTagName,

[switch] $Force,

[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)

process {
if ($Force -or $pscmdlet.ShouldProcess($Id, "Update work item tag in all work items in this team project")) {

$body = '{ "name": "' + $NewTagName + '" }'

$resp = _callAPI -Method PATCH -ProjectName $ProjectName `
-Area wit `
-Resource tags `
-Id $TagIdOrName `
-Body $body `
-Version $(_getApiVersion WorkItemTracking)

Write-Output $resp
}
}
}
Loading