All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.digitalocean.kotlin.MonitorAlert.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.digitalocean.kotlin

import com.pulumi.core.Output
import com.pulumi.digitalocean.kotlin.outputs.MonitorAlertAlerts
import com.pulumi.digitalocean.kotlin.outputs.MonitorAlertAlerts.Companion.toKotlin
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Double
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

/**
 * Builder for [MonitorAlert].
 */
@PulumiTagMarker
public class MonitorAlertResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: MonitorAlertArgs = MonitorAlertArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend MonitorAlertArgsBuilder.() -> Unit) {
        val builder = MonitorAlertArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): MonitorAlert {
        val builtJavaResource = com.pulumi.digitalocean.MonitorAlert(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return MonitorAlert(builtJavaResource)
    }
}

/**
 * Provides a [DigitalOcean Monitoring](https://docs.digitalocean.com/reference/api/api-reference/#tag/Monitoring)
 * resource. Monitor alerts can be configured to alert about, e.g., disk or memory
 * usage exceeding a certain threshold or traffic at a certain limit. Notifications
 * can be sent to either an email address or a Slack channel.
 * > **Note** Currently, the [DigitalOcean API](https://docs.digitalocean.com/reference/api/api-reference/#operation/create_alert_policy) only supports creating alerts for Droplets.
 * ## Import
 * Monitor alerts can be imported using the monitor alert `uuid`, e.g.
 * ```sh
 * $ pulumi import digitalocean:index/monitorAlert:MonitorAlert cpu_alert b8ecd2ab-2267-4a5e-8692-cbf1d32583e3
 * ```
 */
public class MonitorAlert internal constructor(
    override val javaResource: com.pulumi.digitalocean.MonitorAlert,
) : KotlinCustomResource(javaResource, MonitorAlertMapper) {
    /**
     * How to send notifications about the alerts. This is a list with one element, .
     * Note that for Slack, the DigitalOcean app needs to have permissions for your workspace. You can
     * read more in [Slack's documentation](https://slack.com/intl/en-dk/help/articles/222386767-Manage-app-installation-settings-for-your-workspace)
     */
    public val alerts: Output
        get() = javaResource.alerts().applyValue({ args0 -> args0.let({ args0 -> toKotlin(args0) }) })

    /**
     * The comparison for `value`.
     * This may be either `GreaterThan` or `LessThan`.
     */
    public val compare: Output
        get() = javaResource.compare().applyValue({ args0 -> args0 })

    /**
     * The description of the alert.
     */
    public val description: Output
        get() = javaResource.description().applyValue({ args0 -> args0 })

    /**
     * The status of the alert.
     */
    public val enabled: Output?
        get() = javaResource.enabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A list of IDs for the resources to which the alert policy applies.
     */
    public val entities: Output>?
        get() = javaResource.entities().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * A list of tags. When an included tag is added to a resource, the alert policy will apply to it.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * The type of the alert.
     * This may be one of `v1/insights/droplet/load_1`, `v1/insights/droplet/load_5`, `v1/insights/droplet/load_15`,
     * `v1/insights/droplet/memory_utilization_percent`, `v1/insights/droplet/disk_utilization_percent`,
     * `v1/insights/droplet/cpu`, `v1/insights/droplet/disk_read`, `v1/insights/droplet/disk_write`,
     * `v1/insights/droplet/public_outbound_bandwidth`, `v1/insights/droplet/public_inbound_bandwidth`,
     * `v1/insights/droplet/private_outbound_bandwidth`, `v1/insights/droplet/private_inbound_bandwidth`,
     * `v1/insights/lbaas/avg_cpu_utilization_percent`, `v1/insights/lbaas/connection_utilization_percent`,
     * `v1/insights/lbaas/droplet_health`, `v1/insights/lbaas/tls_connections_per_second_utilization_percent`,
     * `v1/insights/lbaas/increase_in_http_error_rate_percentage_5xx`, `v1/insights/lbaas/increase_in_http_error_rate_percentage_4xx`,
     * `v1/insights/lbaas/increase_in_http_error_rate_count_5xx`, `v1/insights/lbaas/increase_in_http_error_rate_count_4xx`,
     * `v1/insights/lbaas/high_http_request_response_time`, `v1/insights/lbaas/high_http_request_response_time_50p`,
     * `v1/insights/lbaas/high_http_request_response_time_95p`, `v1/insights/lbaas/high_http_request_response_time_99p`,
     * `v1/dbaas/alerts/load_15_alerts`, `v1/dbaas/alerts/cpu_alerts`, `v1/dbaas/alerts/memory_utilization_alerts`, or
     * `v1/dbaas/alerts/disk_utilization_alerts`.
     */
    public val type: Output
        get() = javaResource.type().applyValue({ args0 -> args0 })

    /**
     * The uuid of the alert.
     */
    public val uuid: Output
        get() = javaResource.uuid().applyValue({ args0 -> args0 })

    /**
     * The value to start alerting at, e.g., 90% or 85Mbps. This is a floating-point number.
     * DigitalOcean will show the correct unit in the web panel.
     */
    public val `value`: Output
        get() = javaResource.`value`().applyValue({ args0 -> args0 })

    /**
     * The time frame of the alert. Either `5m`, `10m`, `30m`, or `1h`.
     */
    public val window: Output
        get() = javaResource.window().applyValue({ args0 -> args0 })
}

public object MonitorAlertMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.digitalocean.MonitorAlert::class == javaResource::class

    override fun map(javaResource: Resource): MonitorAlert = MonitorAlert(
        javaResource as
            com.pulumi.digitalocean.MonitorAlert,
    )
}

/**
 * @see [MonitorAlert].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [MonitorAlert].
 */
public suspend fun monitorAlert(
    name: String,
    block: suspend MonitorAlertResourceBuilder.() -> Unit,
): MonitorAlert {
    val builder = MonitorAlertResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [MonitorAlert].
 * @param name The _unique_ name of the resulting resource.
 */
public fun monitorAlert(name: String): MonitorAlert {
    val builder = MonitorAlertResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy