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

io.cloudshiftdev.awscdk.services.ecs.LogDriverConfig.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")

package io.cloudshiftdev.awscdk.services.ecs

import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map

/**
 * The configuration to use when creating a log driver.
 *
 * Example:
 *
 * ```
 * // The code below shows an example of how to instantiate this type.
 * // The values are placeholders you should change.
 * import io.cloudshiftdev.awscdk.services.ecs.*;
 * LogDriverConfig logDriverConfig = LogDriverConfig.builder()
 * .logDriver("logDriver")
 * // the properties below are optional
 * .options(Map.of(
 * "optionsKey", "options"))
 * .secretOptions(List.of(SecretProperty.builder()
 * .name("name")
 * .valueFrom("valueFrom")
 * .build()))
 * .build();
 * ```
 */
public interface LogDriverConfig {
  /**
   * The log driver to use for the container.
   *
   * The valid values listed for this parameter are log drivers
   * that the Amazon ECS container agent can communicate with by default.
   *
   * For tasks using the Fargate launch type, the supported log drivers are awslogs, splunk, and
   * awsfirelens.
   * For tasks using the EC2 launch type, the supported log drivers are awslogs, fluentd, gelf,
   * json-file, journald,
   * logentries,syslog, splunk, and awsfirelens.
   *
   * For more information about using the awslogs log driver, see
   * [Using the awslogs Log
   * Driver](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html)
   * in the Amazon Elastic Container Service Developer Guide.
   *
   * For more information about using the awsfirelens log driver, see
   * [Custom Log
   * Routing](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html)
   * in the Amazon Elastic Container Service Developer Guide.
   */
  public fun logDriver(): String

  /**
   * The configuration options to send to the log driver.
   */
  public fun options(): Map = unwrap(this).getOptions() ?: emptyMap()

  /**
   * The secrets to pass to the log configuration.
   *
   * Default: - No secret options provided.
   */
  public fun secretOptions(): List =
      unwrap(this).getSecretOptions()?.map(CfnTaskDefinition.SecretProperty::wrap) ?: emptyList()

  /**
   * A builder for [LogDriverConfig]
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * @param logDriver The log driver to use for the container. 
     * The valid values listed for this parameter are log drivers
     * that the Amazon ECS container agent can communicate with by default.
     *
     * For tasks using the Fargate launch type, the supported log drivers are awslogs, splunk, and
     * awsfirelens.
     * For tasks using the EC2 launch type, the supported log drivers are awslogs, fluentd, gelf,
     * json-file, journald,
     * logentries,syslog, splunk, and awsfirelens.
     *
     * For more information about using the awslogs log driver, see
     * [Using the awslogs Log
     * Driver](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html)
     * in the Amazon Elastic Container Service Developer Guide.
     *
     * For more information about using the awsfirelens log driver, see
     * [Custom Log
     * Routing](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html)
     * in the Amazon Elastic Container Service Developer Guide.
     */
    public fun logDriver(logDriver: String)

    /**
     * @param options The configuration options to send to the log driver.
     */
    public fun options(options: Map)

    /**
     * @param secretOptions The secrets to pass to the log configuration.
     */
    public fun secretOptions(secretOptions: List)

    /**
     * @param secretOptions The secrets to pass to the log configuration.
     */
    public fun secretOptions(vararg secretOptions: CfnTaskDefinition.SecretProperty)
  }

  private class BuilderImpl : Builder {
    private val cdkBuilder: software.amazon.awscdk.services.ecs.LogDriverConfig.Builder =
        software.amazon.awscdk.services.ecs.LogDriverConfig.builder()

    /**
     * @param logDriver The log driver to use for the container. 
     * The valid values listed for this parameter are log drivers
     * that the Amazon ECS container agent can communicate with by default.
     *
     * For tasks using the Fargate launch type, the supported log drivers are awslogs, splunk, and
     * awsfirelens.
     * For tasks using the EC2 launch type, the supported log drivers are awslogs, fluentd, gelf,
     * json-file, journald,
     * logentries,syslog, splunk, and awsfirelens.
     *
     * For more information about using the awslogs log driver, see
     * [Using the awslogs Log
     * Driver](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html)
     * in the Amazon Elastic Container Service Developer Guide.
     *
     * For more information about using the awsfirelens log driver, see
     * [Custom Log
     * Routing](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html)
     * in the Amazon Elastic Container Service Developer Guide.
     */
    override fun logDriver(logDriver: String) {
      cdkBuilder.logDriver(logDriver)
    }

    /**
     * @param options The configuration options to send to the log driver.
     */
    override fun options(options: Map) {
      cdkBuilder.options(options)
    }

    /**
     * @param secretOptions The secrets to pass to the log configuration.
     */
    override fun secretOptions(secretOptions: List) {
      cdkBuilder.secretOptions(secretOptions.map(CfnTaskDefinition.SecretProperty.Companion::unwrap))
    }

    /**
     * @param secretOptions The secrets to pass to the log configuration.
     */
    override fun secretOptions(vararg secretOptions: CfnTaskDefinition.SecretProperty): Unit =
        secretOptions(secretOptions.toList())

    public fun build(): software.amazon.awscdk.services.ecs.LogDriverConfig = cdkBuilder.build()
  }

  private class Wrapper(
    cdkObject: software.amazon.awscdk.services.ecs.LogDriverConfig,
  ) : CdkObject(cdkObject),
      LogDriverConfig {
    /**
     * The log driver to use for the container.
     *
     * The valid values listed for this parameter are log drivers
     * that the Amazon ECS container agent can communicate with by default.
     *
     * For tasks using the Fargate launch type, the supported log drivers are awslogs, splunk, and
     * awsfirelens.
     * For tasks using the EC2 launch type, the supported log drivers are awslogs, fluentd, gelf,
     * json-file, journald,
     * logentries,syslog, splunk, and awsfirelens.
     *
     * For more information about using the awslogs log driver, see
     * [Using the awslogs Log
     * Driver](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html)
     * in the Amazon Elastic Container Service Developer Guide.
     *
     * For more information about using the awsfirelens log driver, see
     * [Custom Log
     * Routing](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html)
     * in the Amazon Elastic Container Service Developer Guide.
     */
    override fun logDriver(): String = unwrap(this).getLogDriver()

    /**
     * The configuration options to send to the log driver.
     */
    override fun options(): Map = unwrap(this).getOptions() ?: emptyMap()

    /**
     * The secrets to pass to the log configuration.
     *
     * Default: - No secret options provided.
     */
    override fun secretOptions(): List =
        unwrap(this).getSecretOptions()?.map(CfnTaskDefinition.SecretProperty::wrap) ?: emptyList()
  }

  public companion object {
    public operator fun invoke(block: Builder.() -> Unit = {}): LogDriverConfig {
      val builderImpl = BuilderImpl()
      return Wrapper(builderImpl.apply(block).build())
    }

    internal fun wrap(cdkObject: software.amazon.awscdk.services.ecs.LogDriverConfig):
        LogDriverConfig = CdkObjectWrappers.wrap(cdkObject) as? LogDriverConfig ?:
        Wrapper(cdkObject)

    internal fun unwrap(wrapped: LogDriverConfig):
        software.amazon.awscdk.services.ecs.LogDriverConfig = (wrapped as CdkObject).cdkObject as
        software.amazon.awscdk.services.ecs.LogDriverConfig
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy