From 4fc6c9ebcd7c2007a17ca9108a89e732bd1605c2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 6 Jun 2019 13:36:04 -0400 Subject: [PATCH] Create Get-ZAEvent Files --- Tests/Public/Get-ZAEvent.Tests.ps1 | 19 ++++ ZertoApiWrapper/Public/Get-ZAEvent.ps1 | 39 +++++++ docs/Get-ZAEvent.md | 140 +++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 Tests/Public/Get-ZAEvent.Tests.ps1 create mode 100644 ZertoApiWrapper/Public/Get-ZAEvent.ps1 create mode 100644 docs/Get-ZAEvent.md diff --git a/Tests/Public/Get-ZAEvent.Tests.ps1 b/Tests/Public/Get-ZAEvent.Tests.ps1 new file mode 100644 index 0000000..f5816b6 --- /dev/null +++ b/Tests/Public/Get-ZAEvent.Tests.ps1 @@ -0,0 +1,19 @@ +#Requires -Modules Pester +$moduleFileName = "ZertoApiWrapper.psd1" +$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") +$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") +$file = Get-ChildItem "$here\$sut" +$modulePath = $here -replace "Public", "" +$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" +Get-Module -Name ZertoApiWrapper | Remove-Module -Force +Import-Module $moduleFile -Force + +Describe $file.BaseName -Tag 'Unit' { + + It "is valid Powershell (Has no script errors)" { + $contents = Get-Content -Path $file -ErrorAction Stop + $errors = $null + $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) + $errors | Should -HaveCount 0 + } +} diff --git a/ZertoApiWrapper/Public/Get-ZAEvent.ps1 b/ZertoApiWrapper/Public/Get-ZAEvent.ps1 new file mode 100644 index 0000000..beb9ca9 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAEvent.ps1 @@ -0,0 +1,39 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAEvent { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the user's events. If the ZORG identifier is omitted, events is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The event category (events/alertsHistory). Default displays the list of all." + )] + [ValidateSet("events", "alertsHistory")] + [string]$category, + [Parameter( + HelpMessage = "The maximum number of events to return." + )] + [ValidateRange(1, 1000000)] + [int]$limitTo, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). Default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). Default is the present time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "monitoring/events" + + if ( $PSBoundParameters.Keys.Count -gt 0 ) { + $filterString = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "{0}{1}" -f $uri, $filterString + } + + Invoke-ZARestRequest -uri $uri +} diff --git a/docs/Get-ZAEvent.md b/docs/Get-ZAEvent.md new file mode 100644 index 0000000..dbfa390 --- /dev/null +++ b/docs/Get-ZAEvent.md @@ -0,0 +1,140 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAEvent.md +schema: 2.0.0 +--- + +# Get-ZAEvent + +## SYNOPSIS + +Retrieve details of all existing events. + +## SYNTAX + +``` +Get-ZAEvent [[-zOrgIdentifier] ] [[-category] ] [[-limitTo] ] [[-startDate] ] + [[-endDate] ] [] +``` + +## DESCRIPTION + +Retrieve details of all existing events. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAEvent +``` + +Retrieve details of all existing events. + +### Example 2 +```powershell +PS C:\> Get-ZAEvent -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve details of all existing events for zOrg with Identifier "1234-5678-9012" + +### Example 3 +```powershell +PS C:\> Get-ZAEvent -category events -startDate "2019-03-01" -endDate "2019-04-01" -limitTo 400 +``` + +Retrieve details of all events between March 1st and April 1st and limit results to 400. + +## PARAMETERS + +### -category +The event category (events/alertsHistory). +Default displays the list of all. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +Default is the present time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -limitTo +The maximum number of events to return. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +Default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the user's events. +If the ZORG identifier is omitted, events is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +[Zerto Analytics REST API Endpoint for Events](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_events)