Create Get-ZAVolume and required files

This commit is contained in:
Wes Carroll
2019-06-08 16:08:25 -04:00
parent a475eee47a
commit c83eb2d8a7
3 changed files with 199 additions and 0 deletions
+19
View File
@@ -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
}
}
+43
View File
@@ -0,0 +1,43 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAVolume {
[CmdletBinding(DefaultParameterSetName = "VpgIdentifier")]
param (
[Parameter(
HelpMessage = "The site identifier. The site identifier is mandatory if vpgIdentifier is not entered.",
Mandatory,
ParameterSetName = "SiteAndClusterIdentifier"
)]
[Parameter(
HelpMessage = "The site identifier. The site identifier is mandatory if vpgIdentifier is not entered.",
Mandatory,
ParameterSetName = "SiteAndDatastoreIdentifier"
)]
[ValidateNotNullOrEmpty()]
[string]$siteIdentifier,
[Parameter(
HelpMessage = "The cluster identifier. If a cluster identifier is not entered, you must enter a datastore identifier.",
Mandatory,
ParameterSetName = "SiteAndClusterIdentifier"
)]
[ValidateNotNullOrEmpty()]
[string]$clusterIdentifier,
[Parameter(
HelpMessage = "The datastore identifer. If a datastore identifier is not entered, you must enter a cluster identifier.",
Mandatory,
ParameterSetName = "SiteAndDatastoreIdentifier"
)]
[ValidateNotNullOrEmpty()]
[string]$datastoreIdentifier,
[Parameter(
HelpMessage = "The vpg identifer.",
Mandatory,
ParameterSetName = "VpgIdentifier"
)]
[string]$vpgIdentifier
)
$filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters
$uri = "monitoring/volumes{0}" -f $filter
Invoke-ZARestRequest -uri $uri
}
+137
View File
@@ -0,0 +1,137 @@
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAVolume.md
schema: 2.0.0
---
# Get-ZAVolume
## SYNOPSIS
Retrieves account volumes by datastore. Enter a site identifier and cluster identifier to get the list of volumes that exist in the datastore cluster. Or, enter a site identifier and datastore identifier to get the list of volumes that exist in the datastore. To retrieve all volumes for a specific VPG, enter a VPG identifier only.
## SYNTAX
### VpgIdentifier (Default)
```
Get-ZAVolume -vpgIdentifier <String> [<CommonParameters>]
```
### SiteAndDatastoreIdentifier
```
Get-ZAVolume -siteIdentifier <String> -datastoreIdentifier <String> [<CommonParameters>]
```
### SiteAndClusterIdentifier
```
Get-ZAVolume -siteIdentifier <String> -clusterIdentifier <String> [<CommonParameters>]
```
## DESCRIPTION
Retrieves account volumes by datastore. Enter a site identifier and cluster identifier to get the list of volumes that exist in the datastore cluster. Or, enter a site identifier and datastore identifier to get the list of volumes that exist in the datastore. To retrieve all volumes for a specific VPG, enter a VPG identifier only.
## EXAMPLES
### Example 1
```powershell
PS C:\> Get-ZAVolume -vpgIdentifier "2345-6789-0123"
```
Returns all volume information for all VMs in VPG with Identifier "2345-6789-0123"
### Example 2
```powershell
PS C:\> Get-ZAVolume -siteIdentifier "3456-7890-1234" -clusterIdentifier "0123-4567-8901"
```
Returns all volume information for all volumes in Site with Identifier "3456-7890-1234" on Datastore Cluster with Identifier "0123-4567-8901"
### Example 3
```powershell
PS C:\> Get-ZAVolume -siteIdentifier "3456-7890-1234" -datastoreIdentifier "5678-9012-3456"
```
Returns all volume information for all volumes in Site with Identifier "3456-7890-1234" on Datastore with Identifier "5678-9012-3456"
## PARAMETERS
### -clusterIdentifier
The cluster identifier.
If a cluster identifier is not entered, you must enter a datastore identifier.
```yaml
Type: String
Parameter Sets: SiteAndClusterIdentifier
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -datastoreIdentifier
The datastore identifer.
If a datastore identifier is not entered, you must enter a cluster identifier.
```yaml
Type: String
Parameter Sets: SiteAndDatastoreIdentifier
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -siteIdentifier
The site identifier.
The site identifier is mandatory if vpgIdentifier is not entered.
```yaml
Type: String
Parameter Sets: SiteAndDatastoreIdentifier, SiteAndClusterIdentifier
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -vpgIdentifier
The vpg identifer.
```yaml
Type: String
Parameter Sets: VpgIdentifier
Aliases:
Required: True
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
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS
[Zerto Analytics REST API Endpoint for Volumes](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_volumes)