# API keys and credentials
$lwApiKey = "your_lacework_api_key"
$zdEmail = "your_zendesk_email"
$zdPassword = "your_zendesk_password"
$zdSubdomain = "your_zendesk_subdomain"
# Lacework API endpoint
$lwApiEndpoint = "https://api.lacework.net/api/v1/AlertTypes"
# Zendesk API endpoint
$zdApiEndpoint = "https://$zdSubdomain.zendesk.com/api/v2/objects/records"
# Create authentication header for Zendesk
$zdAuthHeader = @{
'Authorization' = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$zdEmail:$zdPassword"))
}
# Get Lacework alert types
$response = Invoke-RestMethod -Uri $lwApiEndpoint -Headers @{ "X-Api-Key" = $lwApiKey } -Method Get
$alertTypes = $response.data
# Create a custom object in Zendesk for each Lacework alert type
foreach ($alertType in $alertTypes) {
$customObject = @{
'data' = @{
'type' = 'custom_object'
'attributes' = @{
'name' = $alertType.AlertName
'alert_type' = $alertType.AlertType
'event_model' = $alertType.EventModel
'alert_subcategory' = $alertType.AlertSubcategory
'connection' = $alertType.Connection
}
}
}
$customObjectJson = $customObject | ConvertTo-Json -Depth 10
# Create the custom object in Zendesk
try {
Invoke-RestMethod -Uri $zdApiEndpoint -Headers $zdAuthHeader -Method Post -ContentType 'application/json' -Body $customObjectJson
} catch {
Write-Error "Error creating custom object in Zendesk: $_"
}
}
Comments
Post a Comment