Merge pull request #110 from PetriAsi/feature/get-by-id

get by id
This commit is contained in:
Petri Asikainen 2021-05-22 09:03:44 +03:00 committed by GitHub
commit bf13cdab6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 4 deletions

View file

@ -1,6 +1,9 @@
<#
.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
URL of Snipeit system, can be set using Set-Info command
@ -16,6 +19,8 @@
function Get-CustomField()
{
Param(
[int]$id,
[parameter(mandatory = $true)]
[string]$url,
@ -23,8 +28,14 @@ function Get-CustomField()
[string]$apiKey
)
if ($id) {
$apiurl= "$url/api/v1/fields/$id"
} else {
$apiurl = "$url/api/v1/fields"
}
$Parameters = @{
Uri = "$url/api/v1/fields"
Uri = $apiurl
Method = 'Get'
Token = $apiKey
}

View file

@ -1,6 +1,9 @@
<#
.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
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() {
Param(
[int]$id,
[parameter(mandatory = $true)]
[string]$url,
@ -25,8 +30,14 @@ function Get-Fieldset() {
[string]$apiKey
)
if ($id) {
$apiurl = "$url/api/v1/fieldsets/$id"
} else {
$apiurl = "$url/api/v1/fieldsets"
}
$Parameters = @{
Uri = "$url/api/v1/fieldsets"
Uri = $apiurl
Method = 'Get'
Token = $apiKey
}