Skip to content

Commit 0b1d7f9

Browse files
authored
Merge pull request #133 from snazy2000/develop
Version to 1.4
2 parents 1742db7 + b062072 commit 0b1d7f9

13 files changed

+379
-31
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ 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+
# [v1.4.x] - 2021-05-27
9+
10+
## More Activity
11+
12+
### New features
13+
SnipeIt activity history is now searchable. So finding out checked out the
14+
assest its easy. Api support many different target or item types that can
15+
be uses as filter. Searchable types are 'Accessory','Asset','AssetMaintenance'
16+
,'AssetModel','Category','Company','Component','Consumable','CustomField',
17+
,'Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel',
18+
'Supplier','User'
19+
20+
21+
### New Functions
22+
- Get-SnipeItActivity Get and search Snipe-It change history.
23+
24+
825
# [v1.3.x] - 2021-05-27
926

1027
## Checking out accessories
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<#
2+
.SYNOPSIS
3+
Gets and search Snipe-it Activity history
4+
5+
.DESCRIPTION
6+
Gets a list of Snipe-it activity history
7+
8+
.PARAMETER search
9+
A text string to search the Activity history
10+
11+
.PARAMETER target_type
12+
Type of target. One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
13+
14+
.PARAMETER target_id
15+
Needed if target_type is specified
16+
17+
.PARAMETER item_type
18+
Type of target. One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
19+
20+
.PARAMETER item_id
21+
Needed if target_type is specified
22+
23+
.PARAMETER action_type
24+
Type of action. One from following list "add seats", "checkin from", 'checkout' or 'update'
25+
26+
.PARAMETER offset
27+
Result offset to use
28+
29+
.PARAMETER all
30+
A return all results, works with -offset and other parameters
31+
32+
.PARAMETER url
33+
URL of Snipeit system, can be set using Set-SnipeItInfo command
34+
35+
.PARAMETER apiKey
36+
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
37+
38+
.EXAMPLE
39+
Get-SnipeItAccessory -search Keyboard
40+
41+
.EXAMPLE
42+
Get-SnipeItAccessory -id 1
43+
44+
#>
45+
46+
function Get-SnipeItActivity() {
47+
Param(
48+
49+
[string]$search,
50+
51+
[Parameter(Mandatory=$false)]
52+
[ValidateSet('Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User')]
53+
[string]$target_type,
54+
55+
[Parameter(Mandatory=$false)]
56+
[int]$target_id,
57+
58+
[Parameter(Mandatory=$false)]
59+
[ValidateSet('Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User')]
60+
[string]$item_type,
61+
62+
[Parameter(Mandatory=$false)]
63+
[int]$item_id,
64+
65+
[ValidateSet("add seats", "checkin from", 'checkout','update')]
66+
[string]$action_type ,
67+
68+
[int]$limit = 50,
69+
70+
[int]$offset,
71+
72+
[switch]$all = $false,
73+
74+
[parameter(mandatory = $true)]
75+
[string]$url,
76+
77+
[parameter(mandatory = $true)]
78+
[string]$apiKey
79+
)
80+
81+
if(($target_type -and -not $target_id) -or
82+
($target_id -and -not $target_type)) {
83+
throw "Please specify both target_type and target_id"
84+
}
85+
86+
if(($item_type -and -not $item_id) -or
87+
($item_id -and -not $item_type)) {
88+
throw "Please specify both item_type and item_id"
89+
}
90+
91+
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
92+
93+
94+
$Parameters = @{
95+
Uri = "$url/api/v1/reports/activity"
96+
Method = 'Get'
97+
GetParameters = $SearchParameter
98+
Token = $apiKey
99+
}
100+
101+
if ($all) {
102+
$offstart = $(if($offset){$offset} Else {0})
103+
$callargs = $SearchParameter
104+
$callargs.Remove('all')
105+
106+
while ($true) {
107+
$callargs['offset'] = $offstart
108+
$callargs['limit'] = $limit
109+
$res=Get-SnipeItActivity @callargs
110+
$res
111+
if ($res.count -lt $limit) {
112+
break
113+
}
114+
$offstart = $offstart + $limit
115+
}
116+
} else {
117+
$result = Invoke-SnipeitMethod @Parameters
118+
$result
119+
}
120+
}
121+
122+
123+
124+
125+
126+

SnipeitPS/SnipeItPS.psd1

Lines changed: 3 additions & 2 deletions
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.3'
15+
ModuleVersion = '1.4'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -114,7 +114,8 @@ FunctionsToExport = @(
114114
'Update-SnipeItAlias',
115115
'Set-SnipeItAccessoryOwner',
116116
'Get-SnipeItAccessoryOwner',
117-
'Reset-SnipeItAccessoryOwner'
117+
'Reset-SnipeItAccessoryOwner',
118+
'Get-SnipeItActivity'
118119

119120
)
120121

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ environment:
1414
PSGalleryAPIKey:
1515
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
1616

17-
version: 1.3.{build}
17+
version: 1.4.{build}
1818

1919
# Don't rebuild when I tag a release on GitHub
2020
skip_tags: true

docs/Get-SnipeItActivity.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
---
2+
external help file: SnipeItPS-help.xml
3+
Module Name: SnipeitPS
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Get-SnipeItActivity
9+
10+
## SYNOPSIS
11+
Gets and search Snipe-it Activity history
12+
13+
## SYNTAX
14+
15+
```
16+
Get-SnipeItActivity [[-search] <String>] [[-target_type] <String>] [[-target_id] <Int32>]
17+
[[-item_type] <String>] [[-item_id] <Int32>] [[-action_type] <String>] [[-limit] <Int32>] [[-offset] <Int32>]
18+
[-all] [-url] <String> [-apiKey] <String> [<CommonParameters>]
19+
```
20+
21+
## DESCRIPTION
22+
Gets a list of Snipe-it activity history
23+
24+
## EXAMPLES
25+
26+
### EXAMPLE 1
27+
```
28+
Get-SnipeItAccessory -search Keyboard
29+
```
30+
31+
### EXAMPLE 2
32+
```
33+
Get-SnipeItAccessory -id 1
34+
```
35+
36+
## PARAMETERS
37+
38+
### -action_type
39+
Type of action.
40+
One from following list "add seats", "checkin from", 'checkout' or 'update'
41+
42+
```yaml
43+
Type: String
44+
Parameter Sets: (All)
45+
Aliases:
46+
47+
Required: False
48+
Position: 6
49+
Default value: None
50+
Accept pipeline input: False
51+
Accept wildcard characters: False
52+
```
53+
54+
### -all
55+
A return all results, works with -offset and other parameters
56+
57+
```yaml
58+
Type: SwitchParameter
59+
Parameter Sets: (All)
60+
Aliases:
61+
62+
Required: False
63+
Position: Named
64+
Default value: False
65+
Accept pipeline input: False
66+
Accept wildcard characters: False
67+
```
68+
69+
### -apiKey
70+
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
71+
72+
```yaml
73+
Type: String
74+
Parameter Sets: (All)
75+
Aliases:
76+
77+
Required: True
78+
Position: 10
79+
Default value: None
80+
Accept pipeline input: False
81+
Accept wildcard characters: False
82+
```
83+
84+
### -item_id
85+
Needed if target_type is specified
86+
87+
```yaml
88+
Type: Int32
89+
Parameter Sets: (All)
90+
Aliases:
91+
92+
Required: False
93+
Position: 5
94+
Default value: 0
95+
Accept pipeline input: False
96+
Accept wildcard characters: False
97+
```
98+
99+
### -item_type
100+
Type of target.
101+
One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
102+
103+
```yaml
104+
Type: String
105+
Parameter Sets: (All)
106+
Aliases:
107+
108+
Required: False
109+
Position: 4
110+
Default value: None
111+
Accept pipeline input: False
112+
Accept wildcard characters: False
113+
```
114+
115+
### -limit
116+
{{ Fill limit Description }}
117+
118+
```yaml
119+
Type: Int32
120+
Parameter Sets: (All)
121+
Aliases:
122+
123+
Required: False
124+
Position: 7
125+
Default value: 50
126+
Accept pipeline input: False
127+
Accept wildcard characters: False
128+
```
129+
130+
### -offset
131+
Result offset to use
132+
133+
```yaml
134+
Type: Int32
135+
Parameter Sets: (All)
136+
Aliases:
137+
138+
Required: False
139+
Position: 8
140+
Default value: 0
141+
Accept pipeline input: False
142+
Accept wildcard characters: False
143+
```
144+
145+
### -search
146+
A text string to search the Activity history
147+
148+
```yaml
149+
Type: String
150+
Parameter Sets: (All)
151+
Aliases:
152+
153+
Required: False
154+
Position: 1
155+
Default value: None
156+
Accept pipeline input: False
157+
Accept wildcard characters: False
158+
```
159+
160+
### -target_id
161+
Needed if target_type is specified
162+
163+
```yaml
164+
Type: Int32
165+
Parameter Sets: (All)
166+
Aliases:
167+
168+
Required: False
169+
Position: 3
170+
Default value: 0
171+
Accept pipeline input: False
172+
Accept wildcard characters: False
173+
```
174+
175+
### -target_type
176+
Type of target.
177+
One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
178+
179+
```yaml
180+
Type: String
181+
Parameter Sets: (All)
182+
Aliases:
183+
184+
Required: False
185+
Position: 2
186+
Default value: None
187+
Accept pipeline input: False
188+
Accept wildcard characters: False
189+
```
190+
191+
### -url
192+
URL of Snipeit system, can be set using Set-SnipeItInfo command
193+
194+
```yaml
195+
Type: String
196+
Parameter Sets: (All)
197+
Aliases:
198+
199+
Required: True
200+
Position: 9
201+
Default value: None
202+
Accept pipeline input: False
203+
Accept wildcard characters: False
204+
```
205+
206+
### CommonParameters
207+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
208+
209+
## INPUTS
210+
211+
## OUTPUTS
212+
213+
## NOTES
214+
215+
## RELATED LINKS

0 commit comments

Comments
 (0)