New-PodeLogApiMethod
SYNOPSIS
Creates a new API Log Method.
SYNTAX
New-PodeLogApiMethod [[-Id] <String>] [[-Type] <String>] [-Url] <String> [[-ContentType] <String>]
[[-Method] <String>] [[-Headers] <Hashtable>] [[-HeadersScriptBlock] <ScriptBlock>]
[[-HeadersArguments] <Hashtable>] [-BodyScriptBlock] <ScriptBlock> [[-BodyArguments] <Hashtable>]
[[-BatchInfo] <Hashtable>] [-SkipCertificateCheck] [-Compress] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION
Creates a new API Log Method for outputting log items to custom API endpoints.
EXAMPLES
EXAMPLE 1
' }
$methodId = New-PodeLogApiMethod -Url 'https://api.example.com/logs' -Headers $headers -Compress -BodyScriptBlock {
param($logItems)
return $logItems.Data | ConvertTo-Json -Compress
}
PARAMETERS
-BatchInfo
An optional hashtable containing batch configuration for writing log items in bulk. Should be created using New-PodeLogBatchInfo.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-BodyArguments
An optional hashtable of arguments to pass to the BodyScriptBlock.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-BodyScriptBlock
A ScriptBlock that returns the body of the API request as a valid string, based on a collection of log items. Protect-PodeLogItem will be automatically applied to the returned string.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: True
Position: 9
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Compress
If supplied, the API request will include a Content-Encoding: gzip header and compress the request body.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-ContentType
An optional Content-Type header to include in the API request. (Default: application/json)
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: Application/json
Accept pipeline input: False
Accept wildcard characters: False
-Headers
An optional hashtable of headers to include in the API request, typically used for the Authorization header.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False
-HeadersArguments
An optional hashtable of arguments to pass to the HeadersScriptBlock.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-HeadersScriptBlock
An optional ScriptBlock that returns a hashtable of headers to include in the API request. Useful for dynamically generating headers based on the request body or other elements.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Id
An optional ID to assign to the Log Method. If not supplied, a random ID will be generated.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Method
An optional HTTP Method to use for the API request. (Default: POST)
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: Post
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-SkipCertificateCheck
If supplied, the API request will skip certificate validation checks.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Type
An optional Type to assign to the Log Method. (Default: API)
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Url
The URL of the API endpoint to send log items to.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
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.