-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46c1e96
commit ab67f3a
Showing
3 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
APIs/PowerShellUniversal.API.PSResourceGet/.universal/endpoints.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
New-PSUEndpoint -Url "/psresourceget/module" -Description "Returns modules installed by PSResourceGet. " -Method @('GET') -Endpoint { | ||
param($Name, $Version, $Path, $Scope) | ||
|
||
$Parameters = @{} | ||
|
||
if ($Name) { | ||
$Parameters["Name"] = $Name | ||
} | ||
|
||
if ($Version) { | ||
$Parameters["Version"] = $Version | ||
} | ||
|
||
if ($Path) { | ||
$Parameters["Path"] = $Path | ||
} | ||
|
||
if ($Scope) { | ||
$Parameters["Scope"] = $Scope | ||
} | ||
|
||
Get-PSResource @Parameters | Select-Object Name, Version, Prerelease, Repository, Description | ||
} -Authentication -Role @('Administrator') | ||
New-PSUEndpoint -Url "/psresourceget/module" -Description "Installs a new resource." -Method @('POST') -Endpoint { | ||
param( | ||
$Name, | ||
$Version, | ||
$Repository, | ||
[ValidateSet("CurrentUser", "AllUsers")] | ||
$Scope) | ||
|
||
$Parameters = @{} | ||
|
||
if ($Name) { | ||
$Parameters["Name"] = $Name | ||
} | ||
|
||
if ($Version) { | ||
$Parameters["Version"] = $Version | ||
} | ||
|
||
if ($Repository) { | ||
$Parameters["Repository"] = $Repository | ||
} | ||
|
||
if ($Scope) { | ||
$Parameters["Scope"] = $Scope | ||
} | ||
|
||
Install-PSResource @Parameters -PassThru | Select-Object Name, Version | ||
} -Authentication -Role @('Administrator') | ||
New-PSUEndpoint -Url "/psresourceget/module/:name" -Description "Find a resource from the registered repositories." -Method @('GET') -Endpoint { | ||
param( | ||
[Parameter(Mandatory)] | ||
$Name, | ||
[Parameter()] | ||
$Repository, | ||
[Parameter()] | ||
[ValidateSet("Module", "Script", "Nupkg")] | ||
$Type | ||
) | ||
|
||
$OptionalParameters = @{} | ||
|
||
if ($Repository) { | ||
$OptionalParameters["Repository"] = $Repository | ||
} | ||
|
||
if ($Type) { | ||
$OptionalParameters["Type"] = $Type | ||
} | ||
|
||
Find-PSResource -Name $Name @OptionalParameters | ||
} -Authentication -Role @('Administrator') | ||
New-PSUEndpoint -Url "/psresourceget/module/:name" -Description "Uninstalls a PSResource." -Method @('DELETE') -Endpoint { | ||
param( | ||
[Parameter(Mandatory)] | ||
$Name | ||
) | ||
|
||
Uninstall-PSResource -Name $Name | ||
} -Authentication -Role @('Administrator') | ||
New-PSUEndpoint -Url "/psresourceget/repository" -Description "Returns registered resource repositories." -Method @('GET') -Endpoint { | ||
param($Name) | ||
|
||
$Parameters = @{} | ||
|
||
if ($Name) { | ||
$Parameters["Name"] = $Name | ||
} | ||
|
||
Get-PSResourceRepository @Parameters | ||
} -Authentication -Role @('Administrator') | ||
New-PSUEndpoint -Url "/psresourceget/repository" -Description "Registers a new resource repository." -Method @('POST') -Endpoint { | ||
param( | ||
[Parameter(Mandatory)] | ||
$Name, | ||
[Parameter(Mandatory)] | ||
$Uri, | ||
[Parameter()] | ||
[bool]$Trusted | ||
) | ||
|
||
$Parameters = @{ | ||
Name = $Name | ||
Uri = $Uri | ||
} | ||
|
||
if ($Trusted) { | ||
$Parameters["Trusted"] = $true | ||
} | ||
|
||
Register-PSResourceRepository @Pawrameters | ||
} -Authentication -Role @('Administrator') |
17 changes: 17 additions & 0 deletions
17
APIs/PowerShellUniversal.API.PSResourceGet/PowerShellUniversal.API.PSResourceGet.psd1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@{ | ||
ModuleVersion = '1.0.0' | ||
GUID = '384b8c8d-0aff-4b3c-b479-2e3dc1654f25' | ||
Author = 'Ironman Software' | ||
CompanyName = 'Ironman Software' | ||
Copyright = '(c) Ironman Software. All rights reserved.' | ||
Description = 'Provides API endpoints for managing PowerShell resources.' | ||
PrivateData = @{ | ||
PSData = @{ | ||
Tags = @('PowerShell', 'PSResourceGet', "PowerShellUniversal") | ||
LicenseUri = 'https://github.com/ironmansoftware/scripts/tree/main/LICENSE' | ||
ProjectUri = 'https://github.com/ironmansoftware/scripts/tree/main/APIs/PowerShellUniversal.API.PSResourceGet' | ||
IconUri = 'https://raw.githubusercontent.com/ironmansoftware/scripts/main/images/script.png' | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# PSResourceGet API | ||
|
||
This module provides a PowerShell Universal API for managed PowerShell resources. It uses `Microsoft.PowerShell.PSResourceGet` to find, install and remove PowerShell modules. | ||
|
||
## Endpoints | ||
|
||
- `GET /psresourceget/module` - Get a list of modules | ||
- `GET /psresourceget/module/{name}` - Find a module by name. | ||
- `POST /psresourceget/module` - Install a module. | ||
- `DELETE /psresourceget/module/{name}` - Uninstall a module. | ||
- `GET /psresourceget/repository` - Get a list of repositories. | ||
- `POST /psresourceget/repository` - Register a new repository. |