@@ -29094,27 +29094,15 @@ function Global:Update-OciAnnotationsByVolume {
2909429094
2909529095<#
2909629096 .SYNOPSIS
29097- Bulk un-assign applications from asset
29097+ Bulk un-assign applications from volume
2909829098 .DESCRIPTION
29099- Request body should contain a list of valid application ids, example: <br/>
29100-
29101- <pre>
29102- [
29103- {
29104- "id":"12345"
29105- },
29106- {
29107- "id":"67890"
29108- }
29109- ]
29110- </pre>
29111-
29099+ Bulk un-assign applications from volume
2911229100 .PARAMETER id
29113- Id of object to update
29114- .PARAMETER computeResources
29115- Return list of related Compute resources
29116- .PARAMETER storageResources
29117- Return list of related Storage resources
29101+ Id of volume to remove applications from
29102+ .PARAMETER computeResources
29103+ Return list of related Compute resources
29104+ .PARAMETER storageResources
29105+ Return list of related Storage resources
2911829106#>
2911929107function Global:Remove-OciApplicationsFromVolume {
2912029108 [CmdletBinding()]
@@ -29125,11 +29113,9 @@ function Global:Remove-OciApplicationsFromVolume {
2912529113 HelpMessage="Id of object to update",
2912629114 ValueFromPipeline=$True,
2912729115 ValueFromPipelineByPropertyName=$True)][Long[]]$id,
29128- [parameter(Mandatory=$True ,
29116+ [parameter(Mandatory=$False ,
2912929117 Position=1,
29130- HelpMessage="List of application IDs",
29131- ValueFromPipeline=$True,
29132- ValueFromPipelineByPropertyName=$True)][String[]]$applicationId,
29118+ HelpMessage="List of application IDs")][String[]]$applicationId,
2913329119 [parameter(Mandatory=$False,
2913429120 Position=2,
2913529121 HelpMessage="Return list of related Compute resources")][Switch]$computeResources,
@@ -29161,42 +29147,27 @@ function Global:Remove-OciApplicationsFromVolume {
2916129147 }
2916229148
2916329149 Process {
29164- $id = @($id)
29165- foreach ($id in $id) {
29166- $Uri = $Server.BaseUri + "/rest/v1/assets/volumes/$id/applications"
29167-
29168- if ($fromTime -or $toTime -or $expand) {
29169- $Uri += '?'
29170- $Separator = ''
29171- if ($fromTime) {
29172- $Uri += "fromTime=$($fromTime | ConvertTo-UnixTimestamp)"
29173- $Separator = '&'
29174- }
29175- if ($toTime) {
29176- $Uri += "$($Separator)toTime=$($toTime | ConvertTo-UnixTimestamp)"
29177- $Separator = '&'
29178- }
29179- if ($expand) {
29180- $Uri += "$($Separator)expand=$expand"
29181- }
29182- }
29150+ $Uri = $Server.BaseUri + "/rest/v1/assets/volumes/$id/applications"
2918329151
29184- try {
29185- $Body = ConvertTo-Json @($applicationId | % { @{id=$_} }) -Compress
29186- Write-Verbose "Body: $Body"
29187- $Result = Invoke-RestMethod -WebSession $Server.Session -TimeoutSec $Server.Timeout -Method DELETE -Uri $Uri -Headers $Server.Headers -Body $Body -ContentType 'application/json'
29188- }
29189- catch {
29190- $ResponseBody = ParseExceptionBody $_.Exception.Response
29191- Write-Error "DELETE to $Uri failed with Exception $($_.Exception.Message) `n $responseBody"
29192- }
29193-
29194- if (([String]$Result).Trim().startsWith('{') -or ([String]$Result).toString().Trim().startsWith('[')) {
29195- $Result = ParseJsonString($Result.Trim())
29196- }
29152+ if (!$applicationId) {
29153+ $applicationId = Get-OciApplicationsByVolume -id $id | select -ExpandProperty id
29154+ }
2919729155
29198- Write-Output $Result
29156+ try {
29157+ $Body = ConvertTo-Json @($applicationId | % { @{id=$_} }) -Compress
29158+ Write-Verbose "Body: $Body"
29159+ $Result = Invoke-RestMethod -WebSession $Server.Session -TimeoutSec $Server.Timeout -Method DELETE -Uri $Uri -Headers $Server.Headers -Body $Body -ContentType 'application/json'
29160+ }
29161+ catch {
29162+ $ResponseBody = ParseExceptionBody $_.Exception.Response
29163+ Write-Error "DELETE to $Uri failed with Exception $($_.Exception.Message) `n $responseBody"
2919929164 }
29165+
29166+ if (([String]$Result).Trim().startsWith('{') -or ([String]$Result).toString().Trim().startsWith('[')) {
29167+ $Result = ParseJsonString($Result.Trim())
29168+ }
29169+
29170+ Write-Output $Result
2920029171 }
2920129172}
2920229173
0 commit comments