Skip to content

Commit 9bfa417

Browse files
authored
Merge pull request #189 from snazy2000/develop
Release 1.8
2 parents 6dc704c + 2d7c315 commit 9bfa417

17 files changed

+369
-69
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/),
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
9+
# [v.1.8.x] - 2021-06-17
10+
11+
## Support for new Snipe it endpoints
12+
13+
## New features
14+
15+
Get-SnipeitAccessories -user_id
16+
returns accessories checked out to user id
17+
18+
Get-SnipeitAsset -user_id
19+
Return Assets checked out to user id
20+
21+
Get-SnipeitAsset -component_id
22+
Returns assets with specific component id
23+
24+
Get-SnipeitLicense -user_id
25+
Get licenses checked out to user ID
26+
27+
Get-SnipeitLicense -asset_id
28+
Get licenses checked out to asset ID
29+
30+
Get-SnipeitUser -accessory_id
31+
Get users that have specific accessory id checked out
32+
833
# [v.1.7.x] - 2021-06-14
934

1035
## Consumables

SnipeitPS/Public/Get-SnipeitAccessory.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ Get-SnipeitAccessory -search Keyboard
3232
.EXAMPLE
3333
Get-SnipeitAccessory -id 1
3434
35+
.EXAMPLE
36+
Get-SnipeitAccessory -user_id 1
37+
Get accessories checked out to user ID 1
38+
3539
#>
3640

3741
function Get-SnipeitAccessory() {
@@ -43,6 +47,9 @@ function Get-SnipeitAccessory() {
4347
[parameter(ParameterSetName='Get by ID')]
4448
[int]$id,
4549

50+
[parameter(ParameterSetName='Accessories checked out to user id')]
51+
[int]$user_id,
52+
4653
[parameter(ParameterSetName='Search')]
4754
[int]$company_id,
4855

@@ -69,6 +76,7 @@ function Get-SnipeitAccessory() {
6976
[int]$offset,
7077

7178
[parameter(ParameterSetName='Search')]
79+
[parameter(ParameterSetName='Accessories checked out to user id')]
7280
[switch]$all = $false,
7381

7482
[parameter(mandatory = $true)]
@@ -79,23 +87,21 @@ function Get-SnipeitAccessory() {
7987
)
8088
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
8189

82-
if ($id -and $search){
83-
throw "Please specify only one of -id or -search parameter"
90+
switch($PsCmdlet.ParameterSetName) {
91+
'Search' {$apiurl = "$url/api/v1/accessories"}
92+
'Get by ID' {$apiurl= "$url/api/v1/accessories/$id"}
93+
'Accessories checked out to user id' {$apiurl = "$url/api/v1/users/$user_id/accessories"}
8494
}
8595

8696
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
8797

8898
$Parameters = @{
89-
Uri = "$url/api/v1/accessories"
99+
Uri = $apiurl
90100
Method = 'Get'
91101
GetParameters = $SearchParameter
92102
Token = $apiKey
93103
}
94104

95-
if($id){
96-
$Parameters.Uri ="$url/api/v1/accessories/$id"
97-
}
98-
99105
if ($all) {
100106
$offstart = $(if($offset){$offset} Else {0})
101107
$callargs = $SearchParameter

SnipeitPS/Public/Get-SnipeitAsset.ps1

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,42 @@ URL of Snipeit system, can be set using Set-SnipeitInfo command
6666
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
6767
6868
.EXAMPLE
69-
Get-SnipeitAsset -url "https://assets.example.com"-token "token..."
69+
Get-SnipeitAsset -all -url "https://assets.example.com"-token "token..."
70+
Returens all assets
7071
7172
.EXAMPLE
72-
Get-SnipeitAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
73+
Get-SnipeitAsset -search "myMachine"
74+
Search for specific asset
7375
7476
.EXAMPLE
75-
Get-SnipeitAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
77+
Get-SnipeitAsset -id 3
78+
Get asset with id number 3
7679
7780
.EXAMPLE
78-
Get-SnipeitAsset -asset_tag "myAssetTag"-url "https://assets.example.com"-token "token..."
81+
Get-SnipeitAsset -asset_tag snipe0003
82+
Get asset with asset tag snipe00033
83+
84+
.EXAMPLE
85+
Get-SnipeitAsset -serial 1234
86+
Get asset with searial number 1234
87+
88+
.EXAMPLE
89+
Get-SnipeitAsser -audit_due
90+
Get Assets due auditing soon
91+
92+
.EXAMPLE
93+
Get-SnipeitAsser -audit_overdue
94+
Get Assets overdue for auditing
95+
96+
.EXAMPLE
97+
Get-AnipeitAsset -user_id 4
98+
Get Assets checked out to user id 4
99+
100+
.EXAMPLE
101+
Get-SnipeitAsset -component_id 5
102+
Get Assets with component id 5
103+
104+
79105
#>
80106

81107
function Get-SnipeitAsset() {
@@ -100,6 +126,12 @@ function Get-SnipeitAsset() {
100126
[parameter(ParameterSetName='Assets overdue for auditing')]
101127
[switch]$audit_overdue,
102128

129+
[parameter(ParameterSetName='Assets checked out to user id')]
130+
[int]$user_id,
131+
132+
[parameter(ParameterSetName='Assets with component id')]
133+
[int]$component_id,
134+
103135
[parameter(ParameterSetName='Search')]
104136
[string]$order_number,
105137

@@ -133,28 +165,38 @@ function Get-SnipeitAsset() {
133165
[parameter(ParameterSetName='Search')]
134166
[parameter(ParameterSetName='Assets due auditing soon')]
135167
[parameter(ParameterSetName='Assets overdue for auditing')]
168+
[parameter(ParameterSetName='Assets checked out to user id')]
169+
[parameter(ParameterSetName='Assets with component id')]
136170
[ValidateSet('id','created_at','asset_tag','serial','order_number','model_id','category_id','manufacturer_id','company_id','location_id','status','status_id')]
137171
[string]$sort,
138172

139173
[parameter(ParameterSetName='Search')]
140174
[parameter(ParameterSetName='Assets due auditing soon')]
141175
[parameter(ParameterSetName='Assets overdue for auditing')]
176+
[parameter(ParameterSetName='Assets checked out to user id')]
177+
[parameter(ParameterSetName='Assets with component id')]
142178
[ValidateSet("asc", "desc")]
143179
[string]$order,
144180

145181
[parameter(ParameterSetName='Search')]
146182
[parameter(ParameterSetName='Assets due auditing soon')]
147183
[parameter(ParameterSetName='Assets overdue for auditing')]
184+
[parameter(ParameterSetName='Assets checked out to user id')]
185+
[parameter(ParameterSetName='Assets with component id')]
148186
[int]$limit = 50,
149187

150188
[parameter(ParameterSetName='Search')]
151189
[parameter(ParameterSetName='Assets due auditing soon')]
152190
[parameter(ParameterSetName='Assets overdue for auditing')]
191+
[parameter(ParameterSetName='Assets checked out to user id')]
192+
[parameter(ParameterSetName='Assets with component id')]
153193
[int]$offset,
154194

155195
[parameter(ParameterSetName='Search')]
156196
[parameter(ParameterSetName='Assets due auditing soon')]
157197
[parameter(ParameterSetName='Assets overdue for auditing')]
198+
[parameter(ParameterSetName='Assets checked out to user id')]
199+
[parameter(ParameterSetName='Assets with component id')]
158200
[switch]$all = $false,
159201

160202
[parameter(mandatory = $true)]
@@ -175,6 +217,8 @@ function Get-SnipeitAsset() {
175217
'Get with serial' { $apiurl= "$url/api/v1/hardware/byserial/$serial"}
176218
'Assets due auditing soon' {$apiurl = "$url/api/v1/hardware/audit/due"}
177219
'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"}
220+
'Assets checked out to user id'{$apiurl = "$url/api/v1/users/$user_id/assets"}
221+
'Assets with component id' {$apiurl = "$url/api/v1/components/$component_id/assets"}
178222
}
179223

180224

SnipeitPS/Public/Get-SnipeitLicense.ps1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ function Get-SnipeitLicense() {
4141
[parameter(ParameterSetName='Get with ID')]
4242
[int]$id,
4343

44+
[parameter(ParameterSetName='Get licenses checked out to user ID')]
45+
[int]$user_id,
46+
47+
[parameter(ParameterSetName='Get licenses checked out to asset ID')]
48+
[int]$asset_id,
49+
4450
[parameter(ParameterSetName='Search')]
4551
[string]$name,
4652

@@ -87,7 +93,8 @@ function Get-SnipeitLicense() {
8793

8894
[parameter(ParameterSetName='Search')]
8995
[int]$offset,
90-
96+
[parameter(ParameterSetName='Get licenses checked out to user ID')]
97+
[parameter(ParameterSetName='Get licenses checked out to asset ID')]
9198
[parameter(ParameterSetName='Search')]
9299
[switch]$all = $false,
93100

@@ -102,14 +109,11 @@ function Get-SnipeitLicense() {
102109

103110
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
104111

105-
$apiurl = "$url/api/v1/licenses"
106-
107-
if ($search -and $id ) {
108-
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
109-
}
110-
111-
if ($id) {
112-
$apiurl= "$url/api/v1/licenses/$id"
112+
switch($PsCmdlet.ParameterSetName) {
113+
'Search' {$apiurl = "$url/api/v1/licenses"}
114+
'Get with ID' {$apiurl= "$url/api/v1/licenses/$id"}
115+
'Get licenses checked out to user ID' {$apiurl= "$url/api/v1/users/$user_id/licenses"}
116+
'Get licenses checked out to asset ID' {$apiurl= "$url/api/v1/hardware/$asset_id/licenses"}
113117
}
114118

115119
$Parameters = @{

SnipeitPS/Public/Get-SnipeitUser.ps1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Get-SnipeitUser -username someuser
4040
4141
.EXAMPLE
4242
Get-SnipeitUser -email [email protected]
43+
44+
.EXAMPLE
45+
Get-SnipeitUser -accessory_id 3
46+
Get users with accessory id 3 has been checked out to
4347
#>
4448

4549
function Get-SnipeitUser() {
@@ -51,6 +55,9 @@ function Get-SnipeitUser() {
5155
[parameter(ParameterSetName='Get with ID')]
5256
[string]$id,
5357

58+
[parameter(ParameterSetName='Get users a specific accessory id has been checked out to')]
59+
[string]$accessory_id,
60+
5461
[parameter(ParameterSetName='Search')]
5562
[int]$company_id,
5663

@@ -80,6 +87,7 @@ function Get-SnipeitUser() {
8087
[int]$offset,
8188

8289
[parameter(ParameterSetName='Search')]
90+
[parameter(ParameterSetName='Get users a specific accessory id has been checked out to')]
8391
[switch]$all = $false,
8492

8593
[parameter(mandatory = $true)]
@@ -92,16 +100,12 @@ function Get-SnipeitUser() {
92100
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
93101

94102
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
95-
96-
$apiurl = "$url/api/v1/users"
97-
98-
if ($search -and $id ) {
99-
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
103+
switch ($PsCmdlet.ParameterSetName) {
104+
'Search' { $apiurl = "$url/api/v1/users"}
105+
'Get with id' {$apiurl= "$url/api/v1/users/$id"}
106+
'Get users a specific accessory id has been checked out to' {$apiurl= "$url/api/v1/accessories/$accessory_id/checkedout"}
100107
}
101108

102-
if ($id) {
103-
$apiurl= "$url/api/v1/users/$id"
104-
}
105109
$Parameters = @{
106110
Uri = $apiurl
107111
Method = 'Get'

SnipeitPS/Public/New-SnipeitAccessory.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ ID Number of the company the accessory is assigned to
2323
.PARAMETER manufacturer_id
2424
ID number of the manufacturer for this accessory.
2525
26+
.PARAMETER model_number
27+
Model number for this accessory
28+
2629
.PARAMETER order_number
2730
Order number for this accessory.
2831
@@ -47,7 +50,7 @@ ID number of the supplier for this accessory
4750
.PARAMETER location_id
4851
ID number of the location the accessory is assigned to
4952
50-
.PARAMETER min_qty
53+
.PARAMETER min_amt
5154
Min quantity of the accessory before alert is triggered
5255
5356
.PARAMETER url
@@ -86,11 +89,13 @@ function New-SnipeitAccessory() {
8689

8790
[string]$order_number,
8891

92+
[string]$model_number,
93+
8994
[float]$purchase_cost,
9095

9196
[datetime]$purchase_date,
9297

93-
[int]$min_qty,
98+
[int]$min_amt,
9499

95100
[ValidateRange(1, [int]::MaxValue)]
96101
[int]$supplier_id,

SnipeitPS/Public/Set-SnipeitAccessory.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ ID Number of the company the accessory is assigned to
2626
.PARAMETER manufacturer_id
2727
ID number of the manufacturer for this accessory.
2828
29+
.PARAMETER model_number
30+
Model number for this accessory
31+
2932
.PARAMETER order_number
3033
Order number for this accessory.
3134
@@ -85,6 +88,7 @@ function Set-SnipeitAccessory() {
8588

8689
[Nullable[System.Int32]]$manufacturer_id,
8790

91+
[string]$model_number,
8892

8993
[string]$order_number,
9094

@@ -120,7 +124,7 @@ function Set-SnipeitAccessory() {
120124
foreach($accessory_id in $id){
121125
$Parameters = @{
122126
Uri = "$url/api/v1/accessories/$accessory_id"
123-
Method = 'Patch'
127+
Method = 'Put'
124128
Body = $Body
125129
Token = $apiKey
126130
}

SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@
2323
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
2424
2525
.EXAMPLE
26-
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3 -Verbose
26+
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3
2727
Checkout licence to user id 3
2828
2929
.EXAMPLE
30-
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -asset_id 3 -Verbose
30+
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -asset_id 3
3131
Checkout licence to asset id 3
3232
33+
.EXAMPLE
34+
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -asset_id $null -assigned_id $null
35+
Checkin licence seat id 1 of licence id 1
36+
3337
#>
3438
function Set-SnipeitLicenseSeat()
3539
{

SnipeitPS/SnipeitPS.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'SnipeitPS'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.7'
15+
ModuleVersion = '1.8'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ environment:
1717
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
1818
PShell: '5'
1919

20-
version: 1.7.{build}
20+
version: 1.8.{build}
2121

2222
# Don't rebuild when I tag a release on GitHub
2323
skip_tags: true

0 commit comments

Comments
 (0)