Spectrum Protect REST API

At version 7.1.3, Spectrum Protect began supporting a REST API for both the Operations Center and Client Management Services.  I did a short video on using the API and also wrote a sample PowerShell script to access the OC and lock a node.  Have a look at the video and code below. 

Spectrum Protect REST API Video

Presentation

<#  Short PowerShell Script to lock a node in Spectrum Protect using Restful API
    Syntax : locknode <Node> 
    OC Rest API:  7.1.4                                         
    Note:  Operates on a single server environment #>

<# get the node name #>
param( 
    [Parameter(Mandatory=$true)]
[string]$NodeName

)

<# Set Up headers for Rest API call to Operations Center #>
$admin = "admin"
$secPw = ConvertTo-SecureString "Object00" -AsPlainText -Force
$cred = New-Object PSCredential -ArgumentList $admin,$secPw
$headers = @{}
$headers.Add( "OC-API-Version", "1.0" )
$headers.Add( "accept" , "application/json" )

<# Call the Rest API to get the list of current clients
   Note that if you have an unsigned certificate, you must add code to ignore it #>
$nodelist = Invoke-RestMethod -uri "https://localhost:11090/oc/api/clients" -Credential $cred -Headers $headers 

<# Make sure the node exists #>
$locknode = $nodelist.clients | Where-Object { $_.Name -like $NodeName }  
If (($locknode | Measure-Object).Count -ne 1) {
    Write-Output "$NodeName not found in list of nodes or multiple matches.  Exiting..."
    Exit 1
}

<# Build the command to lock the node and pass it to the rest API#>
$restcommand = "https://localhost:11090/oc/api/servers/" + ($locknode.SERVER) + "/clients/" + $locknode.Name + "/lock"
(Invoke-RestMethod -uri $restcommand -Credential $cred -Headers $headers -Method Put).Message.Messagefordev