From 0e148bdb1b2314d1bd64ce6b4f6a503d94f97411 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 6 Jun 2019 13:59:13 -0400 Subject: [PATCH] Create Get-ZATask files and content --- Tests/Public/Get-ZATask.Tests.ps1 | 19 +++++ ZertoApiWrapper/Public/Get-ZATask.ps1 | 39 +++++++++ docs/Get-ZATask.md | 112 ++++++++++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 Tests/Public/Get-ZATask.Tests.ps1 create mode 100644 ZertoApiWrapper/Public/Get-ZATask.ps1 create mode 100644 docs/Get-ZATask.md diff --git a/Tests/Public/Get-ZATask.Tests.ps1 b/Tests/Public/Get-ZATask.Tests.ps1 new file mode 100644 index 0000000..f5816b6 --- /dev/null +++ b/Tests/Public/Get-ZATask.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-ZATask.ps1 b/ZertoApiWrapper/Public/Get-ZATask.ps1 new file mode 100644 index 0000000..2f1bce5 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZATask.ps1 @@ -0,0 +1,39 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZATask { + [cmdletbinding( DefaultParameterSetName = "zOrg")] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the task list. If the ZORG identifier is omitted, a list of all the tasks is retrieved.", + ParameterSetName = "zOrg" + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The maximum number of tasks to return.", + ParameterSetName = "zOrg" + )] + [ValidateRange(1, 1000000)] + [int]$limitTo, + [Parameter( + HelpMessage = "The task Idnetifier", + ParameterSetName = "taskId", + Mandatory = $true + )] + [ValidateNotNullOrEmpty()] + [string]$taskIdentifier + ) + $uri = "monitoring/tasks" + switch ($PSCmdlet.ParameterSetName) { + zOrg { + if ( $PSBoundParameters.Keys.Count -gt 0 ) { + $filterString = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "{0}{1}" -f $uri, $filterString + } + } + + taskId { + $uri = "{0}/{1}" -f $uri, $taskIdentifier + } + } + Invoke-ZARestRequest -uri $uri +} diff --git a/docs/Get-ZATask.md b/docs/Get-ZATask.md new file mode 100644 index 0000000..bb5f3bf --- /dev/null +++ b/docs/Get-ZATask.md @@ -0,0 +1,112 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZATask.md +schema: 2.0.0 +--- + +# Get-ZATask + +## SYNOPSIS + +Retrieve details of all existing tasks. + +## SYNTAX + +### zOrg (Default) +``` +Get-ZATask [-zOrgIdentifier ] [-limitTo ] [] +``` + +### taskId +``` +Get-ZATask -taskIdentifier [] +``` + +## DESCRIPTION + +Retrieve details of all existing tasks. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZATask +``` + +Retrieve details of all existing tasks. + +### Example 2 +```powershell +PS C:\> Get-ZATask -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve details of all existing tasks for zOrg with Identifier "1234-5678-9012". + +### Example 1 +```powershell +PS C:\> Get-ZATask -taskIdentifier "9012-3456-7890" +``` + +Retrieve details of a specific task with identifier "9012-3456-7890". + +## PARAMETERS + +### -limitTo +The maximum number of tasks to return. + +```yaml +Type: Int32 +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -taskIdentifier +The task Idnetifier + +```yaml +Type: String +Parameter Sets: taskId +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the task list. +If the ZORG identifier is omitted, a list of all the tasks is retrieved. + +```yaml +Type: String +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +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 Tasks](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_tasks)