Skip to content

Commit

Permalink
Added possibility to create, get and delete azure artifacts for proje…
Browse files Browse the repository at this point in the history
…cts (#485)

* feat: added project parameter to feed
* feat: added verbose output for the api url called
* build: fixed side effect affecting current tests by setting default project in previous tests
* docs: added documentation for new project name parameter
  • Loading branch information
SebastianSchuetze authored Sep 8, 2022
1 parent 2646b2b commit a192d68
Show file tree
Hide file tree
Showing 19 changed files with 350 additions and 61 deletions.
10 changes: 10 additions & 0 deletions .docs/Add-VSTeamFeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Add-VSTeamFeed -Name test -Description 'Test Description'

This command adds a new package feed to the account.

### Example 2

```powershell
Add-VSTeamFeed -Name test -Description 'Test Description' -ProjectName 'MyProject'
```

This command adds a new package feed to the project.

## PARAMETERS

### Name
Expand Down Expand Up @@ -57,6 +65,8 @@ The feed will show deleted version in the feed
Type: SwitchParameter
```
<!-- #include "./params/projectName.md" -->
## INPUTS
## OUTPUTS
Expand Down
10 changes: 10 additions & 0 deletions .docs/Get-VSTeamFeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Get-VSTeamFeed

This command returns all the package feeds for the account.

### Example 2

```powershell
Get-VSTeamFeed -ProjectName 'MyProject'
```

This command returns all the package feeds for the project.

## PARAMETERS

### FeedId
Expand All @@ -34,6 +42,8 @@ Aliases: ID
Accept pipeline input: true (ByPropertyName)
```
<!-- #include "./params/projectName.md" -->
## INPUTS
## OUTPUTS
Expand Down
8 changes: 8 additions & 0 deletions .docs/Get-VSTeamPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ Get-VSTeamPackage -feedName vsteam -Top 1 -Skip 1

This command returns the second package from the feed named vsteam

### Example 4: Return only packages and versions from project

```powershell
Get-VSTeamPackage -feedId 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d -projectName MyProject
```

This command returns all the packages and versions for the feedId in the project.

## PARAMETERS

### FeedId
Expand Down
9 changes: 9 additions & 0 deletions .docs/Get-VSTeamPackageVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ Get-VSTeamPackageVersion -feedId $($p.FeedId) -packageId $($p.Id)

This command returns all the versions for the packageId.

### Example 3: Get version from package in project feed

```powershell
Get-VSTeamPackageVersion -feedId 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d -packageId 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d -projectName MyProject
```

This command returns all the versions for the packageId in the project feed.


## PARAMETERS

### FeedId
Expand Down
10 changes: 10 additions & 0 deletions .docs/Remove-VSTeamFeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Remove-VSTeamFeed -id '00000000-0000-0000-0000-000000000000'

This command remove the package feed from the account.

### Example 2

```powershell
Remove-VSTeamFeed -id '00000000-0000-0000-0000-000000000000' -ProjectName 'MyProject'
```

This command remove the package feed from the project.

## PARAMETERS

### FeedId
Expand All @@ -34,6 +42,8 @@ Aliases: ID
Accept pipeline input: true (ByPropertyName)
```
<!-- #include "./params/projectName.md" -->
## INPUTS
## OUTPUTS
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,8 @@ vsteam_Linux_ps7_tests_result.xml
vsteam_wcore1903_ps5_tests_result.xml
vsteam_wcore1903_ps7_tests_result.xml
integrationTest-results.xml
.vs/*
.vs/*

# Default storage of Azurite
azurite-testdrive
__azurite_db_*__.json
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 7.10.0


Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/485) from [Sebastian Schütze](https://github.com/SebastianSchuetze) the following:
- Added possibility to create, get and delete azure artifacts for projects [#379](https://github.com/MethodsAndPractices/vsteam/issues/379)


## 7.9.0

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/481) from [Sebastian Schütze](https://github.com/SebastianSchuetze) the following:
Expand Down
1 change: 1 addition & 0 deletions Source/Private/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function _callAPI {
}

$params = $PSBoundParameters
Write-Verbose "Calling: $Url"
$params.Add('Uri', $Url)
$params.Add('UserAgent', (_getUserAgent))
$params.Add('TimeoutSec', (_getDefaultTimeout))
Expand Down
31 changes: 25 additions & 6 deletions Source/Public/Add-VSTeamFeed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ function Add-VSTeamFeed {

[switch] $EnableUpstreamSources,

[switch] $showDeletedPackageVersions
[switch] $showDeletedPackageVersions,

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

process {
Expand Down Expand Up @@ -54,12 +59,26 @@ function Add-VSTeamFeed {

$bodyAsJson = $body | ConvertTo-Json -Compress -Depth 100



$commonArgs = @{
Method = 'POST'
subDomain = 'feeds'
Area = 'packaging'
Resource = 'feeds'
body = $bodyAsJson
Id = $item
Version = $(_getApiVersion Packaging)
}

if ($ProjectName) {
$commonArgs.ProjectName = $ProjectName
}else{
$commonArgs.NoProject = $true
}

# Call the REST API
$resp = _callAPI -Method POST -subDomain "feeds" `
-Area "packaging" `
-Resource "feeds" `
-body $bodyAsJson `
-Version $(_getApiVersion Packaging)
$resp = _callAPI @commonArgs

Write-Output [vsteam_lib.Feed]::new($resp)
}
Expand Down
14 changes: 12 additions & 2 deletions Source/Public/Get-VSTeamFeed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ function Get-VSTeamFeed {
param (
[Parameter(ParameterSetName = 'ByID', Position = 0)]
[Alias('FeedId')]
[string[]] $Id
[string[]] $Id,

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

process {
$commonArgs = @{
subDomain = 'feeds'
area = 'packaging'
resource = 'feeds'
NoProject = $true
version = $(_getApiVersion Packaging)
}

if ($ProjectName) {
$commonArgs.ProjectName = $ProjectName
}else{
$commonArgs.NoProject = $true
}

if ($id) {
foreach ($item in $id) {
$resp = _callAPI @commonArgs -Id $item
Expand Down
33 changes: 24 additions & 9 deletions Source/Public/Get-VSTeamPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ function Get-VSTeamPackage {
[CmdletBinding(DefaultParameterSetName = 'List',
HelpUri = 'https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Get-VSTeamPackage')]
param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Alias("feedName")]
[string] $feedId,

[Parameter(Position = 1, Mandatory, ParameterSetName = 'ById')]
[Parameter(Position = 1, Mandatory= $true, ParameterSetName = 'ById')]
[Alias("id")]
[guid] $packageId,

Expand All @@ -28,7 +28,12 @@ function Get-VSTeamPackage {
[int] $Top,

[Parameter(ParameterSetName = 'List')]
[int] $Skip
[int] $Skip,

[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)
process {
# Build query string
Expand All @@ -50,13 +55,23 @@ function Get-VSTeamPackage {
$qs.includeUrls = 'false'
}

$commonArgs = @{
subDomain = 'feeds'
area = 'packaging'
resource = 'feeds'
Id = "$feedId/Packages/$packageId"
QueryString = $qs
version = $(_getApiVersion Packaging)
}

if ($ProjectName) {
$commonArgs.ProjectName = $ProjectName
}else{
$commonArgs.NoProject = $true
}

# Call the REST API
$resp = _callAPI -Subdomain 'feeds' -NoProject `
-Area 'Packaging' `
-Resource 'Feeds' `
-Id "$feedId/Packages/$packageId" `
-QueryString $qs `
-Version $(_getApiVersion packaging)
$resp = _callAPI @commonArgs

if ($null -ne $packageId) {
return [vsteam_lib.Package]::new($resp, $feedId)
Expand Down
30 changes: 22 additions & 8 deletions Source/Public/Get-VSTeamPackageVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ function Get-VSTeamPackageVersion {
[Alias("id")]
[guid] $packageId,

[switch] $hideUrls
[switch] $hideUrls,

[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)
process {
# Build query string
Expand All @@ -23,16 +28,25 @@ function Get-VSTeamPackageVersion {
$qs.includeUrls = 'false'
}

$commonArgs = @{
SubDomain = 'feeds'
Area = 'packaging'
Resource = 'feeds'
Id = "$feedId/Packages/$packageId/versions"
QueryString = $qs
Version = $(_getApiVersion Packaging)
}

if ($ProjectName) {
$commonArgs.ProjectName = $ProjectName
}else{
$commonArgs.NoProject = $true
}

# Call the REST API
$resp = _callAPI -Subdomain 'feeds' -NoProject `
-Area 'Packaging' `
-Resource 'Feeds' `
-Id "$feedId/Packages/$packageId/versions" `
-QueryString $qs `
-Version $(_getApiVersion packaging)
$resp = _callAPI @commonArgs

$objs = @()

foreach ($item in $resp.value) {
$objs += [vsteam_lib.PackageVersion]::new($item)
}
Expand Down
29 changes: 23 additions & 6 deletions Source/Public/Remove-VSTeamFeed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@ function Remove-VSTeamFeed {
[Alias('FeedId')]
[string[]] $Id,

[switch] $Force
[switch] $Force,

[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
[string] $ProjectName
)
process {
foreach ($item in $id) {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete Package Feed")) {

$commonArgs = @{
Method = 'DELETE'
subDomain = 'feeds'
Area = 'packaging'
Resource = 'feeds'
Id = $item
Version = $(_getApiVersion Packaging)
}

if ($ProjectName) {
$commonArgs.ProjectName = $ProjectName
}else{
$commonArgs.NoProject = $true
}

# Call the REST API
_callAPI -Method DELETE -subDomain feeds `
-Area packaging `
-Resource feeds `
-Id $item `
-Version $(_getApiVersion Packaging) | Out-Null
_callAPI @commonArgs | Out-Null

Write-Output "Deleted Feed $item"
}
Expand Down
2 changes: 1 addition & 1 deletion Source/VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'VSTeam.psm1'

# Version number of this module.
ModuleVersion = '7.9.0'
ModuleVersion = '7.10.0'

# Supported PSEditions
CompatiblePSEditions = @('Core', 'Desktop')
Expand Down
Loading

0 comments on commit a192d68

Please sign in to comment.