Invoke-LXC1RestMethod
This cmdlet directly invokes a XClarity One REST API .
Note
You cannot pipe objects to this cmdlet.
Syntax
Invoke-LXC1RestMethod -Method WebRequestMethod
-ResourceUrl String
[-RequestBody String]
[-OutFile String]
[CommonParameter]
[-Connection LXC1Connection
Parameters
- -Method WebRequestMethod
- Specifies the HTTP request method. This can be one of these values.
- Get
- Post
- Put
- Patch
- Delete
- -ResourceUrl String
- Specifies the resource URL
- -OutFile String
- Specifies the output directory and file name in which to return the response body.
If you do not specify a directory or file name, the response body is not saved in an output file.
If you do not specify a file name (in other words, if the destination ends in a back slash "\"), the default file name is xc1RestMethod_MMddyyyy-HHmmss.out.
If the directory does not exist, it is automatically created.
- -RequestBody String
- Specifies the request body
- -Connection LXC1Connection
- Specifies the connection to the XClarity One server. If no connection is specified, the result from the last Connect-LXC1 cmdlet is used.
- CommonParameters
- This cmdlet supports the following common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer, -PipelineVariable, -OutVariable. For detailed information about each common parameter, see the Microsoft PowerShell Common Parameters webpage.
Results
- Lenovo.XC1.PowerShell.Common.DataTypes.LXC1RestResponse
This cmdlet returns an LXC1RestResponse object that contains information about the executed REST API, including resource URI, HTTP status code, response headers, and response body. For your convenience, this response contains the Response property that contains the returned JSON that is deserialized as a PSObject.
Examples
- The following example retrieves all events by invoking the GET /apis/v1/monitoring/events request.
param (
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] $ClientID,
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] $UserSecret
)
$securePassword = ConvertTo-SecureString $UserSecret -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($ClientID, $securePassword))
$hostOnprem = "192.0.2.0"
$connection = Connect-LXC1 -PortalAddress $hostOnprem `
-Credential $cred `
-PortalType cloud `
-SkipCertificateCheck
$url = "/apis/v1/monitoring/events"
$events = Invoke-LXC1RestMethod -Method Get `
-ResourceUrl $url `
-OutFile $PSScriptRoot/../test/
$events | Format-List
Give documentation feedback