Add search to all Get commands

This commit is contained in:
Stephen Maunder 2018-03-29 13:50:10 +01:00
parent 57512d50f7
commit cc72820bde
12 changed files with 66 additions and 7 deletions

View file

@ -19,6 +19,8 @@ Get-Asset -url "https://assets.example.com" -token "token..." | Where-Object {$_
function Get-Asset() function Get-Asset()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,7 +32,8 @@ function Get-Asset()
Uri = "$url/api/v1/hardware" Uri = "$url/api/v1/hardware"
Method = 'Get' Method = 'Get'
GetParameters = @{ GetParameters = @{
limit = 9999 search = $search
limit = 999
} }
Token = $apiKey Token = $apiKey
} }

View file

@ -30,6 +30,10 @@ function Get-Category()
Uri = "$url/api/v1/categories" Uri = "$url/api/v1/categories"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Company -url "https://assets.example.com" -token "token..." | Where-Object {
function Get-Company() function Get-Company()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Company()
Uri = "$url/api/v1/companies" Uri = "$url/api/v1/companies"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Component -url "https://assets.example.com" -token "token..." | Where-Object
function Get-Component() function Get-Component()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Component()
Uri = "$url/api/v1/components" Uri = "$url/api/v1/components"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Department -url "https://assets.example.com" -token "token..." | Where-Objec
function Get-Department() function Get-Department()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Department()
Uri = "$url/api/v1/departments" Uri = "$url/api/v1/departments"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Location -url "https://assets.example.com" -token "token..." | Where-Object
function Get-Location() function Get-Location()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Location()
Uri = "$url/api/v1/locations" Uri = "$url/api/v1/locations"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Manufacturer -url "https://assets.example.com" -token "token..." | Where-Obj
function Get-Manufacturer() function Get-Manufacturer()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Manufacturer()
Uri = "$url/api/v1/manufacturers" Uri = "$url/api/v1/manufacturers"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Models -url "https://assets.example.com" -token "token..." | Where-Object {$
function Get-Model() function Get-Model()
{ {
Param( Param(
[string]$search,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Model()
Uri = "$url/api/v1/models" Uri = "$url/api/v1/models"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Status -url "https://assets.example.com" -token "token..." | Where-Object {$
function Get-Status() function Get-Status()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Status()
Uri = "$url/api/v1/statuslabels" Uri = "$url/api/v1/statuslabels"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,6 +19,8 @@ Get-Supplier -url "https://assets.example.com" -token "token..." | Where-Object
function Get-Supplier() function Get-Supplier()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -30,6 +32,10 @@ function Get-Supplier()
Uri = "$url/api/v1/suppliers" Uri = "$url/api/v1/suppliers"
Method = 'Get' Method = 'Get'
Token = $apiKey Token = $apiKey
GetParameters = @{
search = $search
limit = 999
}
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -18,6 +18,8 @@ Get-User -url "https://assets.example.com" -token "token..." | Where-Object {$_.
function Get-User() function Get-User()
{ {
Param( Param(
[string]$search,
[parameter(mandatory=$true)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
@ -29,6 +31,7 @@ function Get-User()
Uri = "$url/api/v1/users" Uri = "$url/api/v1/users"
Method = 'Get' Method = 'Get'
GetParameters = @{ GetParameters = @{
search = $search
limit = 999 limit = 999
} }
Token = $apiKey Token = $apiKey

View file

@ -17,7 +17,7 @@
.PARAMETER userName .PARAMETER userName
Parameter description Parameter description
.PARAMETER jobTitle .PARAMETER jobtitle
Parameter description Parameter description
.PARAMETER email .PARAMETER email
@ -76,7 +76,7 @@ function Set-User() {
[string]$userName, [string]$userName,
[string]$jobTitle, [string]$jobtitle,
[string]$email, [string]$email,
@ -105,17 +105,18 @@ function Set-User() {
$Values = @{} $Values = @{}
$exclude = @('id', 'url', 'apiKey') #$exclude = @('id', 'url', 'apiKey')
$excludeRegex = [string]::Join('|', $exclude) # create the regex #$excludeRegex = [string]::Join('|', $exclude) # create the regex
foreach ($psbp in $PSBoundParameters.GetEnumerator()) { foreach ($psbp in $PSBoundParameters.GetEnumerator()) {
if ($psbp.Key -notmatch $excludeRegex) { #if ($psbp.Key -notmatch $excludeRegex) {
$Values.Add($psbp.Key, $psbp.Value) $Values.Add($psbp.Key, $psbp.Value)
} #}
} }
$Body = $Values | ConvertTo-Json; $Body = $Values | ConvertTo-Json;
$Body
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users/$id" Uri = "$url/api/v1/users/$id"
Method = 'PATCH' Method = 'PATCH'