get by id

This commit is contained in:
Petri Asikainen 2021-05-22 09:00:40 +03:00
parent d4d50d8fd5
commit 5c17660cca
2 changed files with 26 additions and 4 deletions

View file

@ -1,6 +1,9 @@
<# <#
.SYNOPSIS .SYNOPSIS
Returns a list of all Snipe-IT custom fields Returns specific Snipe-IT custom field or a list of all custom field
.PARAMETER id
A id of specific field
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-Info command URL of Snipeit system, can be set using Set-Info command
@ -16,6 +19,8 @@
function Get-CustomField() function Get-CustomField()
{ {
Param( Param(
[int]$id,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
@ -23,8 +28,14 @@ function Get-CustomField()
[string]$apiKey [string]$apiKey
) )
if ($id) {
$apiurl= "$url/api/v1/fields/$id"
} else {
$apiurl = "$url/api/v1/fields"
}
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields" Uri = $apiurl
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
} }

View file

@ -1,6 +1,9 @@
<# <#
.SYNOPSIS .SYNOPSIS
Gets a list of Snipe-it Fieldsets Returns a fieldset or list of Snipe-it Fieldsets
.PARAMETER id
A id of specific fieldset
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-Info command URL of Snipeit system, can be set using Set-Info command
@ -18,6 +21,8 @@ Get-Fieldset -url "https://assets.example.com" -token "token..." | Where-Object
function Get-Fieldset() { function Get-Fieldset() {
Param( Param(
[int]$id,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
@ -25,8 +30,14 @@ function Get-Fieldset() {
[string]$apiKey [string]$apiKey
) )
if ($id) {
$apiurl = "$url/api/v1/fieldsets/$id"
} else {
$apiurl = "$url/api/v1/fieldsets"
}
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fieldsets" Uri = $apiurl
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
} }