-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from snazy2000/develop
Version to 1.4
- Loading branch information
Showing
13 changed files
with
379 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets and search Snipe-it Activity history | ||
.DESCRIPTION | ||
Gets a list of Snipe-it activity history | ||
.PARAMETER search | ||
A text string to search the Activity history | ||
.PARAMETER target_type | ||
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' | ||
.PARAMETER target_id | ||
Needed if target_type is specified | ||
.PARAMETER item_type | ||
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' | ||
.PARAMETER item_id | ||
Needed if target_type is specified | ||
.PARAMETER action_type | ||
Type of action. One from following list "add seats", "checkin from", 'checkout' or 'update' | ||
.PARAMETER offset | ||
Result offset to use | ||
.PARAMETER all | ||
A return all results, works with -offset and other parameters | ||
.PARAMETER url | ||
URL of Snipeit system, can be set using Set-SnipeItInfo command | ||
.PARAMETER apiKey | ||
Users API Key for Snipeit, can be set using Set-SnipeItInfo command | ||
.EXAMPLE | ||
Get-SnipeItAccessory -search Keyboard | ||
.EXAMPLE | ||
Get-SnipeItAccessory -id 1 | ||
#> | ||
|
||
function Get-SnipeItActivity() { | ||
Param( | ||
|
||
[string]$search, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[ValidateSet('Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User')] | ||
[string]$target_type, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[int]$target_id, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[ValidateSet('Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User')] | ||
[string]$item_type, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[int]$item_id, | ||
|
||
[ValidateSet("add seats", "checkin from", 'checkout','update')] | ||
[string]$action_type , | ||
|
||
[int]$limit = 50, | ||
|
||
[int]$offset, | ||
|
||
[switch]$all = $false, | ||
|
||
[parameter(mandatory = $true)] | ||
[string]$url, | ||
|
||
[parameter(mandatory = $true)] | ||
[string]$apiKey | ||
) | ||
|
||
if(($target_type -and -not $target_id) -or | ||
($target_id -and -not $target_type)) { | ||
throw "Please specify both target_type and target_id" | ||
} | ||
|
||
if(($item_type -and -not $item_id) -or | ||
($item_id -and -not $item_type)) { | ||
throw "Please specify both item_type and item_id" | ||
} | ||
|
||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters | ||
|
||
|
||
$Parameters = @{ | ||
Uri = "$url/api/v1/reports/activity" | ||
Method = 'Get' | ||
GetParameters = $SearchParameter | ||
Token = $apiKey | ||
} | ||
|
||
if ($all) { | ||
$offstart = $(if($offset){$offset} Else {0}) | ||
$callargs = $SearchParameter | ||
$callargs.Remove('all') | ||
|
||
while ($true) { | ||
$callargs['offset'] = $offstart | ||
$callargs['limit'] = $limit | ||
$res=Get-SnipeItActivity @callargs | ||
$res | ||
if ($res.count -lt $limit) { | ||
break | ||
} | ||
$offstart = $offstart + $limit | ||
} | ||
} else { | ||
$result = Invoke-SnipeitMethod @Parameters | ||
$result | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
--- | ||
external help file: SnipeItPS-help.xml | ||
Module Name: SnipeitPS | ||
online version: | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Get-SnipeItActivity | ||
|
||
## SYNOPSIS | ||
Gets and search Snipe-it Activity history | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Get-SnipeItActivity [[-search] <String>] [[-target_type] <String>] [[-target_id] <Int32>] | ||
[[-item_type] <String>] [[-item_id] <Int32>] [[-action_type] <String>] [[-limit] <Int32>] [[-offset] <Int32>] | ||
[-all] [-url] <String> [-apiKey] <String> [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Gets a list of Snipe-it activity history | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
Get-SnipeItAccessory -search Keyboard | ||
``` | ||
|
||
### EXAMPLE 2 | ||
``` | ||
Get-SnipeItAccessory -id 1 | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
### -action_type | ||
Type of action. | ||
One from following list "add seats", "checkin from", 'checkout' or 'update' | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 6 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -all | ||
A return all results, works with -offset and other parameters | ||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: False | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -apiKey | ||
Users API Key for Snipeit, can be set using Set-SnipeItInfo command | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 10 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -item_id | ||
Needed if target_type is specified | ||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 5 | ||
Default value: 0 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -item_type | ||
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' | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 4 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -limit | ||
{{ Fill limit Description }} | ||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 7 | ||
Default value: 50 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -offset | ||
Result offset to use | ||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 8 | ||
Default value: 0 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -search | ||
A text string to search the Activity history | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -target_id | ||
Needed if target_type is specified | ||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 3 | ||
Default value: 0 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -target_type | ||
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' | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 2 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -url | ||
URL of Snipeit system, can be set using Set-SnipeItInfo command | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 9 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
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). | ||
## INPUTS | ||
## OUTPUTS | ||
## NOTES | ||
## RELATED LINKS |
Oops, something went wrong.