Skip to content

Commit 313f44c

Browse files
committed
Implemented retrieving object storages closes #6
1 parent 5209f05 commit 313f44c

1 file changed

Lines changed: 168 additions & 1 deletion

File tree

src/OnCommand-Insight.psm1

Lines changed: 168 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21276,7 +21276,7 @@ function Global:Get-OciStorageCount {
2127621276
.SYNOPSIS
2127721277
Retrieve one storage
2127821278
.DESCRIPTION
21279-
21279+
Retrieve one storage
2128021280
.PARAMETER id
2128121281
Id of storage to retrieve
2128221282
.PARAMETER fromTime
@@ -21439,6 +21439,173 @@ function Global:Get-OciStorage {
2143921439
}
2144021440
}
2144121441

21442+
<#
21443+
.SYNOPSIS
21444+
Retrieve one object storage
21445+
.DESCRIPTION
21446+
Retrieve one object storage
21447+
.PARAMETER id
21448+
Id of storage to retrieve
21449+
.PARAMETER fromTime
21450+
Filter for time range, either in milliseconds or as DateTime
21451+
.PARAMETER toTime
21452+
Filter for time range, either in milliseconds or as DateTime
21453+
.PARAMETER expand
21454+
Expand parameter for underlying JSON object (e.g. expand=read,items)
21455+
.PARAMETER storageNodes
21456+
Return list of related Storage nodes
21457+
.PARAMETER storageResources
21458+
Return list of related Storage resources
21459+
.PARAMETER storagePools
21460+
Return list of related Storage pools
21461+
.PARAMETER internalVolumes
21462+
Return list of related Internal volumes
21463+
.PARAMETER volumes
21464+
Return list of related Volumes
21465+
.PARAMETER qtrees
21466+
Return list of related Qtrees
21467+
.PARAMETER shares
21468+
Return list of related Shares
21469+
.PARAMETER ports
21470+
Return list of related Ports
21471+
.PARAMETER datasources
21472+
Return list of related Datasources
21473+
.PARAMETER annotations
21474+
Return list of related Annotations
21475+
.PARAMETER disks
21476+
Return list of related Disks
21477+
.PARAMETER performance
21478+
Return related Performance
21479+
.PARAMETER protocols
21480+
Return list of related Protocols
21481+
.PARAMETER applications
21482+
Return list of related Applications
21483+
.PARAMETER performancehistory
21484+
Return related Performance History
21485+
#>
21486+
function Global:Get-OciObjectStorage {
21487+
[CmdletBinding()]
21488+
21489+
PARAM (
21490+
[parameter(Mandatory=$True,
21491+
Position=0,
21492+
HelpMessage="Id of storage to retrieve",
21493+
ValueFromPipeline=$True,
21494+
ValueFromPipelineByPropertyName=$True)][Long[]]$id,
21495+
[parameter(Mandatory=$False,
21496+
Position=1,
21497+
HelpMessage="Filter for time range, either in milliseconds or as DateTime")][PSObject]$fromTime,
21498+
[parameter(Mandatory=$False,
21499+
Position=2,
21500+
HelpMessage="Filter for time range, either in milliseconds or as DateTime")][PSObject]$toTime,
21501+
[parameter(Mandatory=$False,
21502+
Position=3,
21503+
HelpMessage="Expand parameter for underlying JSON object (e.g. expand=read,items)")][String]$expand,
21504+
[parameter(Mandatory=$False,
21505+
Position=4,
21506+
HelpMessage="Return list of related Storage nodes")][Switch]$storageNodes,
21507+
[parameter(Mandatory=$False,
21508+
Position=5,
21509+
HelpMessage="Return list of related Storage resources")][Switch]$storageResources,
21510+
[parameter(Mandatory=$False,
21511+
Position=6,
21512+
HelpMessage="Return list of related Storage pools")][Switch]$storagePools,
21513+
[parameter(Mandatory=$False,
21514+
Position=7,
21515+
HelpMessage="Return list of related Internal volumes")][Switch]$internalVolumes,
21516+
[parameter(Mandatory=$False,
21517+
Position=8,
21518+
HelpMessage="Return list of related Volumes")][Switch]$volumes,
21519+
[parameter(Mandatory=$False,
21520+
Position=9,
21521+
HelpMessage="Return list of related Qtrees")][Switch]$qtrees,
21522+
[parameter(Mandatory=$False,
21523+
Position=10,
21524+
HelpMessage="Return list of related Shares")][Switch]$shares,
21525+
[parameter(Mandatory=$False,
21526+
Position=11,
21527+
HelpMessage="Return list of related Ports")][Switch]$ports,
21528+
[parameter(Mandatory=$False,
21529+
Position=12,
21530+
HelpMessage="Return list of related Datasources")][Switch]$datasources,
21531+
[parameter(Mandatory=$False,
21532+
Position=13,
21533+
HelpMessage="Return list of related Annotations")][Switch]$annotations,
21534+
[parameter(Mandatory=$False,
21535+
Position=14,
21536+
HelpMessage="Return list of related Disks")][Switch]$disks,
21537+
[parameter(Mandatory=$False,
21538+
Position=15,
21539+
HelpMessage="Return related Performance")][Switch]$performance,
21540+
[parameter(Mandatory=$False,
21541+
Position=16,
21542+
HelpMessage="Return list of related Protocols")][Switch]$protocols,
21543+
[parameter(Mandatory=$False,
21544+
Position=17,
21545+
HelpMessage="Return list of related Applications")][Switch]$applications,
21546+
[parameter(Mandatory=$False,
21547+
Position=18,
21548+
HelpMessage="Return related Performance History")][Switch]$performancehistory,
21549+
[parameter(Mandatory=$False,
21550+
Position=19,
21551+
HelpMessage="OnCommand Insight Server.")]$Server=$CurrentOciServer
21552+
)
21553+
21554+
Begin {
21555+
$Result = $null
21556+
if (!$Server) {
21557+
throw "Server parameter not specified and no global OCI Server available. Run Connect-OciServer first!"
21558+
}
21559+
21560+
$switchparameters=@("storageNodes","storageResources","storagePools","internalVolumes","volumes","qtrees","shares","ports","datasources","annotations","disks","performance","protocols","applications","performancehistory")
21561+
foreach ($parameter in $switchparameters) {
21562+
if ((Get-Variable $parameter).Value) {
21563+
if ($expand) {
21564+
$expand += ",$($parameter -replace 'performancehistory','performance.history' -replace 'hostswitch','host')"
21565+
}
21566+
else {
21567+
$expand = $($parameter -replace 'performancehistory','performance.history' -replace 'hostswitch','host')
21568+
}
21569+
}
21570+
}
21571+
}
21572+
21573+
Process {
21574+
$Uri = $Server.BaseUri + "/rest/v1/assets/objectstorages/$id"
21575+
21576+
if ($fromTime -or $toTime -or $expand) {
21577+
$Uri += '?'
21578+
$Separator = ''
21579+
if ($fromTime) {
21580+
$Uri += "fromTime=$($fromTime | ConvertTo-UnixTimestamp)"
21581+
$Separator = '&'
21582+
}
21583+
if ($toTime) {
21584+
$Uri += "$($Separator)toTime=$($toTime | ConvertTo-UnixTimestamp)"
21585+
$Separator = '&'
21586+
}
21587+
if ($expand) {
21588+
$Uri += "$($Separator)expand=$expand"
21589+
}
21590+
}
21591+
21592+
try {
21593+
$Result = Invoke-RestMethod -WebSession $Server.Session -TimeoutSec $Server.Timeout -Method GET -Uri $Uri -Headers $Server.Headers
21594+
}
21595+
catch {
21596+
$ResponseBody = ParseExceptionBody -Response $_.Exception.Response
21597+
Write-Error "GET to $Uri failed with Exception $($_.Exception.Message) `n $responseBody"
21598+
}
21599+
21600+
if (([String]$Result).Trim().startsWith('{') -or ([String]$Result).toString().Trim().startsWith('[')) {
21601+
$Result = ParseJsonString -json $Result.Trim()
21602+
}
21603+
21604+
$Storage = ParseStorages -Storages $Result -Timezone $Server.Timezone
21605+
Write-Output $Storage
21606+
}
21607+
}
21608+
2144221609
<#
2144321610
.SYNOPSIS
2144421611
Delete annotations from object

0 commit comments

Comments
 (0)