Skip to content

Commit 522704e

Browse files
committed
Update all Get commands with all avaliable search options, Added CheckIn Asset
1 parent 55bd578 commit 522704e

16 files changed

+453
-75
lines changed

.vscode/tasks.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@
3535
"showOutput": "always",
3636
// Associate with test task runner
3737
"tasks": [{
38-
"taskName": "Build Help",
39-
"suppressTaskName": true,
38+
"label": "Build Help",
4039
"args": [
41-
"Write-Host 'Invoking platyPS'; New-ExternalHelp -Path .\\docs\\en-US -OutputPath .\\ConfluencePS\\en-US -Force;",
40+
"Write-Host 'Invoking platyPS'; New-ExternalHelp -Path .\\docs\\en-US -OutputPath .\\SnipeitPS\\en-US -Force;",
4241
"Invoke-Command { Write-Host 'Completed Build task in task runner.' }"
4342
]
4443
},
4544
{
46-
"taskName": "Test",
45+
"label": "Test",
4746
"suppressTaskName": true,
4847
"isTestCommand": true,
4948
"args": [
@@ -53,4 +52,4 @@
5352
"problemMatcher": "$pester"
5453
}
5554
]
56-
}
55+
}

SnipeitPS/Public/Get-Asset.ps1

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,64 @@ Get-Asset -url "https://assets.example.com" -token "token..." | Where-Object {$_
1616
1717
#>
1818

19-
function Get-Asset()
20-
{
19+
function Get-Asset() {
2120
Param(
2221
[string]$search,
2322

24-
[parameter(mandatory=$true)]
23+
[int]$order_number,
24+
25+
[int]$model_id,
26+
27+
[int]$category_id,
28+
29+
[int]$manufacturer_id,
30+
31+
[int]$company_id,
32+
33+
[int]$location_id,
34+
35+
[string]$status,
36+
37+
[int]$status_id,
38+
39+
[string]$sort = "created_at",
40+
41+
[ValidateSet("asc", "desc")]
42+
[string]$order = "desc",
43+
44+
[int]$limit = 50,
45+
46+
[int]$offset,
47+
48+
[parameter(mandatory = $true)]
2549
[string]$url,
2650

27-
[parameter(mandatory=$true)]
51+
[parameter(mandatory = $true)]
2852
[string]$apiKey
2953
)
3054

55+
$SearchParameter = @{
56+
sort = $sort
57+
order = $order
58+
limit = $limit
59+
offset = $offset
60+
}
61+
62+
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
63+
if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) }
64+
if ($PSBoundParameters.ContainsKey('model_id')) { $SearchParameter.Add("model_id", $model_id) }
65+
if ($PSBoundParameters.ContainsKey('category_id')) { $SearchParameter.Add("category_id", $category_id) }
66+
if ($PSBoundParameters.ContainsKey('manufacturer_id')) { $SearchParameter.Add("manufacturer_id", $manufacturer_id) }
67+
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
68+
if ($PSBoundParameters.ContainsKey('location_id')) { $SearchParameter.Add("location_id", $location_id) }
69+
if ($PSBoundParameters.ContainsKey('status_id')) { $SearchParameter.Add("status_id", $order_number) }
70+
if ($PSBoundParameters.ContainsKey('status')) { $SearchParameter.Add("status", $order_number) }
71+
if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) }
72+
3173
$Parameters = @{
3274
Uri = "$url/api/v1/hardware"
3375
Method = 'Get'
34-
GetParameters = @{
35-
search = $search
36-
limit = 999
37-
}
76+
GetParameters = $SearchParameter
3877
Token = $apiKey
3978
}
4079

SnipeitPS/Public/Get-Category.ps1

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,34 @@ function Get-Category()
2121
Param(
2222
[string]$search,
2323

24-
[parameter(mandatory=$true)]
24+
[ValidateSet("asc", "desc")]
25+
[string]$order = "desc",
26+
27+
[int]$limit = 50,
28+
29+
[int]$offset,
30+
31+
[parameter(mandatory = $true)]
2532
[string]$url,
2633

27-
[parameter(mandatory=$true)]
34+
[parameter(mandatory = $true)]
2835
[string]$apiKey
2936
)
3037

38+
$SearchParameter = @{
39+
sort = $sort
40+
order = $order
41+
limit = $limit
42+
offset = $offset
43+
}
44+
45+
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
46+
3147
$Parameters = @{
3248
Uri = "$url/api/v1/categories"
3349
Method = 'Get'
3450
Token = $apiKey
35-
GetParameters = @{
36-
search = $search
37-
limit = 999
38-
}
51+
GetParameters = $SearchParameter
3952
}
4053

4154
$result = Invoke-SnipeitMethod @Parameters

SnipeitPS/Public/Get-Company.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,34 @@ function Get-Company()
2121
Param(
2222
[string]$search,
2323

24+
[ValidateSet("asc", "desc")]
25+
[string]$order = "desc",
26+
27+
[int]$limit = 50,
28+
29+
[int]$offset,
30+
2431
[parameter(mandatory=$true)]
2532
[string]$url,
2633

2734
[parameter(mandatory=$true)]
2835
[string]$apiKey
2936
)
3037

38+
$SearchParameter = @{
39+
sort = $sort
40+
order = $order
41+
limit = $limit
42+
offset = $offset
43+
}
44+
45+
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
46+
3147
$Parameters = @{
3248
Uri = "$url/api/v1/companies"
3349
Method = 'Get'
3450
Token = $apiKey
35-
GetParameters = @{
36-
search = $search
37-
limit = 999
38-
}
51+
GetParameters = $SearchParameter
3952
}
4053

4154
$result = Invoke-SnipeitMethod @Parameters

SnipeitPS/Public/Get-Component.ps1

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,44 @@ Get-Component -url "https://assets.example.com" -token "token..." | Where-Object
1616
1717
#>
1818

19-
function Get-Component()
20-
{
19+
function Get-Component() {
2120
Param(
2221
[string]$search,
2322

24-
[parameter(mandatory=$true)]
23+
[int]$category_id,
24+
25+
[int]$company_id,
26+
27+
[ValidateSet("asc", "desc")]
28+
[string]$order = "desc",
29+
30+
[int]$limit = 50,
31+
32+
[int]$offset,
33+
34+
[parameter(mandatory = $true)]
2535
[string]$url,
2636

27-
[parameter(mandatory=$true)]
37+
[parameter(mandatory = $true)]
2838
[string]$apiKey
2939
)
3040

41+
$SearchParameter = @{
42+
sort = $sort
43+
order = $order
44+
limit = $limit
45+
offset = $offset
46+
}
47+
48+
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
49+
if ($PSBoundParameters.ContainsKey('category_id')) { $SearchParameter.Add("category_id", $category_id) }
50+
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
51+
3152
$Parameters = @{
3253
Uri = "$url/api/v1/components"
3354
Method = 'Get'
3455
Token = $apiKey
35-
GetParameters = @{
36-
search = $search
37-
limit = 999
38-
}
56+
GetParameters = $SearchParameter
3957
}
4058

4159
$result = Invoke-SnipeitMethod @Parameters

SnipeitPS/Public/Get-Department.ps1

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,34 @@ function Get-Department()
2121
Param(
2222
[string]$search,
2323

24-
[parameter(mandatory=$true)]
24+
[ValidateSet("asc", "desc")]
25+
[string]$order = "desc",
26+
27+
[int]$limit = 50,
28+
29+
[int]$offset,
30+
31+
[parameter(mandatory = $true)]
2532
[string]$url,
2633

27-
[parameter(mandatory=$true)]
34+
[parameter(mandatory = $true)]
2835
[string]$apiKey
2936
)
3037

38+
$SearchParameter = @{
39+
sort = $sort
40+
order = $order
41+
limit = $limit
42+
offset = $offset
43+
}
44+
45+
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
46+
3147
$Parameters = @{
3248
Uri = "$url/api/v1/departments"
3349
Method = 'Get'
3450
Token = $apiKey
35-
GetParameters = @{
36-
search = $search
37-
limit = 999
38-
}
51+
GetParameters = $SearchParameter
3952
}
4053

4154
$result = Invoke-SnipeitMethod @Parameters

SnipeitPS/Public/Get-License.ps1

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<#
2+
.SYNOPSIS
3+
# Gets a list of Snipe-it Licenses
4+
5+
.PARAMETER url
6+
URL of Snipeit system, can be set using Set-Info command
7+
8+
.PARAMETER apiKey
9+
Users API Key for Snipeit, can be set using Set-Info command
10+
11+
.EXAMPLE
12+
Get-License -url "https://assets.example.com" -token "token..."
13+
14+
.EXAMPLE
15+
Get-License -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "License" }
16+
17+
#>
18+
19+
function Get-License() {
20+
Param(
21+
[string]$search,
22+
23+
[string]$name,
24+
25+
[int] $company_id,
26+
27+
[string]$product_key,
28+
29+
[int]$order_number,
30+
31+
[string]$purchase_order,
32+
33+
[string]$license_name,
34+
35+
[string]$license_email,
36+
37+
[int]$manufacturer_id,
38+
39+
[int]$supplier_id,
40+
41+
[int]$depreciation_id,
42+
43+
[ValidateSet("asc", "desc")]
44+
[string]$order = "desc",
45+
46+
[int]$limit = 50,
47+
48+
[int]$offset,
49+
50+
[parameter(mandatory = $true)]
51+
[string]$url,
52+
53+
[parameter(mandatory = $true)]
54+
[string]$apiKey
55+
)
56+
57+
$SearchParameter = @{
58+
sort = $sort
59+
order = $order
60+
limit = $limit
61+
offset = $offset
62+
}
63+
64+
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
65+
if ($PSBoundParameters.ContainsKey('name')) { $SearchParameter.Add("name", $name) }
66+
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
67+
if ($PSBoundParameters.ContainsKey('product_key')) { $SearchParameter.Add("product_key", $product_key) }
68+
if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) }
69+
if ($PSBoundParameters.ContainsKey('purchase_order')) { $SearchParameter.Add("purchase_order", $purchase_order) }
70+
if ($PSBoundParameters.ContainsKey('license_name')) { $SearchParameter.Add("license_name", $license_name) }
71+
if ($PSBoundParameters.ContainsKey('license_email')) { $SearchParameter.Add("license_email", $license_email) }
72+
if ($PSBoundParameters.ContainsKey('manufacturer_id')) { $SearchParameter.Add("manufacturer_id", $manufacturer_id) }
73+
if ($PSBoundParameters.ContainsKey('supplier_id')) { $SearchParameter.Add("supplier_id", $supplier_id) }
74+
if ($PSBoundParameters.ContainsKey('depreciation_id')) { $SearchParameter.Add("depreciation_id", $depreciation_id) }
75+
76+
$Parameters = @{
77+
Uri = "$url/api/v1/licenses"
78+
Method = 'Get'
79+
Token = $apiKey
80+
GetParameters = $SearchParameter
81+
}
82+
83+
$result = Invoke-SnipeitMethod @Parameters
84+
85+
$result
86+
}
87+

0 commit comments

Comments
 (0)