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

io.cloudshiftdev.awscdk.services.appsync.Resolver.kt Maven / Gradle / Ivy

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

package io.cloudshiftdev.awscdk.services.appsync

import io.cloudshiftdev.awscdk.common.CdkDslMarker
import kotlin.Number
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName
import io.cloudshiftdev.constructs.Construct as CloudshiftdevConstructsConstruct
import software.constructs.Construct as SoftwareConstructsConstruct

/**
 * An AppSync resolver.
 *
 * Example:
 *
 * ```
 * GraphqlApi api;
 * AppsyncFunction appsyncFunction;
 * Resolver pipelineResolver = Resolver.Builder.create(this, "pipeline")
 * .api(api)
 * .dataSource(api.addNoneDataSource("none"))
 * .typeName("typeName")
 * .fieldName("fieldName")
 * .requestMappingTemplate(MappingTemplate.fromFile("beforeRequest.vtl"))
 * .pipelineConfig(List.of(appsyncFunction))
 * .responseMappingTemplate(MappingTemplate.fromFile("afterResponse.vtl"))
 * .build();
 * ```
 */
public open class Resolver(
  cdkObject: software.amazon.awscdk.services.appsync.Resolver,
) : CloudshiftdevConstructsConstruct(cdkObject) {
  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: ResolverProps,
  ) :
      this(software.amazon.awscdk.services.appsync.Resolver(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
      id, props.let(ResolverProps.Companion::unwrap))
  )

  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: ResolverProps.Builder.() -> Unit,
  ) : this(scope, id, ResolverProps(props)
  )

  /**
   * the ARN of the resolver.
   */
  public open fun arn(): String = unwrap(this).getArn()

  /**
   * A fluent builder for [io.cloudshiftdev.awscdk.services.appsync.Resolver].
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * The API this resolver is attached to.
     *
     * @param api The API this resolver is attached to. 
     */
    public fun api(api: IGraphqlApi)

    /**
     * The caching configuration for this resolver.
     *
     * Default: - No caching configuration
     *
     * @param cachingConfig The caching configuration for this resolver. 
     */
    public fun cachingConfig(cachingConfig: CachingConfig)

    /**
     * The caching configuration for this resolver.
     *
     * Default: - No caching configuration
     *
     * @param cachingConfig The caching configuration for this resolver. 
     */
    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("51f4392e584a1d17065b5b3621ce2b3e99c2bea2ef09929722839c455de638c6")
    public fun cachingConfig(cachingConfig: CachingConfig.Builder.() -> Unit)

    /**
     * The function code.
     *
     * Default: - no code is used
     *
     * @param code The function code. 
     */
    public fun code(code: Code)

    /**
     * The data source this resolver is using.
     *
     * Default: - No datasource
     *
     * @param dataSource The data source this resolver is using. 
     */
    public fun dataSource(dataSource: BaseDataSource)

    /**
     * name of the GraphQL field in the given type this resolver is attached to.
     *
     * @param fieldName name of the GraphQL field in the given type this resolver is attached to. 
     */
    public fun fieldName(fieldName: String)

    /**
     * The maximum number of elements per batch, when using batch invoke.
     *
     * Default: - No max batch size
     *
     * @param maxBatchSize The maximum number of elements per batch, when using batch invoke. 
     */
    public fun maxBatchSize(maxBatchSize: Number)

    /**
     * configuration of the pipeline resolver.
     *
     * Default: - no pipeline resolver configuration
     * An empty array | undefined sets resolver to be of kind, unit
     *
     * @param pipelineConfig configuration of the pipeline resolver. 
     */
    public fun pipelineConfig(pipelineConfig: List)

    /**
     * configuration of the pipeline resolver.
     *
     * Default: - no pipeline resolver configuration
     * An empty array | undefined sets resolver to be of kind, unit
     *
     * @param pipelineConfig configuration of the pipeline resolver. 
     */
    public fun pipelineConfig(vararg pipelineConfig: IAppsyncFunction)

    /**
     * The request mapping template for this resolver.
     *
     * Default: - No mapping template
     *
     * @param requestMappingTemplate The request mapping template for this resolver. 
     */
    public fun requestMappingTemplate(requestMappingTemplate: MappingTemplate)

    /**
     * The response mapping template for this resolver.
     *
     * Default: - No mapping template
     *
     * @param responseMappingTemplate The response mapping template for this resolver. 
     */
    public fun responseMappingTemplate(responseMappingTemplate: MappingTemplate)

    /**
     * The functions runtime.
     *
     * Default: - no function runtime, VTL mapping templates used
     *
     * @param runtime The functions runtime. 
     */
    public fun runtime(runtime: FunctionRuntime)

    /**
     * name of the GraphQL type this resolver is attached to.
     *
     * @param typeName name of the GraphQL type this resolver is attached to. 
     */
    public fun typeName(typeName: String)
  }

  private class BuilderImpl(
    scope: SoftwareConstructsConstruct,
    id: String,
  ) : Builder {
    private val cdkBuilder: software.amazon.awscdk.services.appsync.Resolver.Builder =
        software.amazon.awscdk.services.appsync.Resolver.Builder.create(scope, id)

    /**
     * The API this resolver is attached to.
     *
     * @param api The API this resolver is attached to. 
     */
    override fun api(api: IGraphqlApi) {
      cdkBuilder.api(api.let(IGraphqlApi.Companion::unwrap))
    }

    /**
     * The caching configuration for this resolver.
     *
     * Default: - No caching configuration
     *
     * @param cachingConfig The caching configuration for this resolver. 
     */
    override fun cachingConfig(cachingConfig: CachingConfig) {
      cdkBuilder.cachingConfig(cachingConfig.let(CachingConfig.Companion::unwrap))
    }

    /**
     * The caching configuration for this resolver.
     *
     * Default: - No caching configuration
     *
     * @param cachingConfig The caching configuration for this resolver. 
     */
    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("51f4392e584a1d17065b5b3621ce2b3e99c2bea2ef09929722839c455de638c6")
    override fun cachingConfig(cachingConfig: CachingConfig.Builder.() -> Unit): Unit =
        cachingConfig(CachingConfig(cachingConfig))

    /**
     * The function code.
     *
     * Default: - no code is used
     *
     * @param code The function code. 
     */
    override fun code(code: Code) {
      cdkBuilder.code(code.let(Code.Companion::unwrap))
    }

    /**
     * The data source this resolver is using.
     *
     * Default: - No datasource
     *
     * @param dataSource The data source this resolver is using. 
     */
    override fun dataSource(dataSource: BaseDataSource) {
      cdkBuilder.dataSource(dataSource.let(BaseDataSource.Companion::unwrap))
    }

    /**
     * name of the GraphQL field in the given type this resolver is attached to.
     *
     * @param fieldName name of the GraphQL field in the given type this resolver is attached to. 
     */
    override fun fieldName(fieldName: String) {
      cdkBuilder.fieldName(fieldName)
    }

    /**
     * The maximum number of elements per batch, when using batch invoke.
     *
     * Default: - No max batch size
     *
     * @param maxBatchSize The maximum number of elements per batch, when using batch invoke. 
     */
    override fun maxBatchSize(maxBatchSize: Number) {
      cdkBuilder.maxBatchSize(maxBatchSize)
    }

    /**
     * configuration of the pipeline resolver.
     *
     * Default: - no pipeline resolver configuration
     * An empty array | undefined sets resolver to be of kind, unit
     *
     * @param pipelineConfig configuration of the pipeline resolver. 
     */
    override fun pipelineConfig(pipelineConfig: List) {
      cdkBuilder.pipelineConfig(pipelineConfig.map(IAppsyncFunction.Companion::unwrap))
    }

    /**
     * configuration of the pipeline resolver.
     *
     * Default: - no pipeline resolver configuration
     * An empty array | undefined sets resolver to be of kind, unit
     *
     * @param pipelineConfig configuration of the pipeline resolver. 
     */
    override fun pipelineConfig(vararg pipelineConfig: IAppsyncFunction): Unit =
        pipelineConfig(pipelineConfig.toList())

    /**
     * The request mapping template for this resolver.
     *
     * Default: - No mapping template
     *
     * @param requestMappingTemplate The request mapping template for this resolver. 
     */
    override fun requestMappingTemplate(requestMappingTemplate: MappingTemplate) {
      cdkBuilder.requestMappingTemplate(requestMappingTemplate.let(MappingTemplate.Companion::unwrap))
    }

    /**
     * The response mapping template for this resolver.
     *
     * Default: - No mapping template
     *
     * @param responseMappingTemplate The response mapping template for this resolver. 
     */
    override fun responseMappingTemplate(responseMappingTemplate: MappingTemplate) {
      cdkBuilder.responseMappingTemplate(responseMappingTemplate.let(MappingTemplate.Companion::unwrap))
    }

    /**
     * The functions runtime.
     *
     * Default: - no function runtime, VTL mapping templates used
     *
     * @param runtime The functions runtime. 
     */
    override fun runtime(runtime: FunctionRuntime) {
      cdkBuilder.runtime(runtime.let(FunctionRuntime.Companion::unwrap))
    }

    /**
     * name of the GraphQL type this resolver is attached to.
     *
     * @param typeName name of the GraphQL type this resolver is attached to. 
     */
    override fun typeName(typeName: String) {
      cdkBuilder.typeName(typeName)
    }

    public fun build(): software.amazon.awscdk.services.appsync.Resolver = cdkBuilder.build()
  }

  public companion object {
    public operator fun invoke(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      block: Builder.() -> Unit = {},
    ): Resolver {
      val builderImpl = BuilderImpl(CloudshiftdevConstructsConstruct.unwrap(scope), id)
      return Resolver(builderImpl.apply(block).build())
    }

    internal fun wrap(cdkObject: software.amazon.awscdk.services.appsync.Resolver): Resolver =
        Resolver(cdkObject)

    internal fun unwrap(wrapped: Resolver): software.amazon.awscdk.services.appsync.Resolver =
        wrapped.cdkObject as software.amazon.awscdk.services.appsync.Resolver
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy