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

io.cloudshiftdev.awscdk.services.appsync.HttpDataSourceOptions.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 io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.String
import kotlin.Unit
import kotlin.jvm.JvmName

/**
 * Optional configuration for Http data sources.
 *
 * Example:
 *
 * ```
 * GraphqlApi api = GraphqlApi.Builder.create(this, "api")
 * .name("api")
 * .definition(Definition.fromFile(join(__dirname, "schema.graphql")))
 * .build();
 * HttpDataSource httpDs = api.addHttpDataSource("ds", "https://states.amazonaws.com",
 * HttpDataSourceOptions.builder()
 * .name("httpDsWithStepF")
 * .description("from appsync to StepFunctions Workflow")
 * .authorizationConfig(AwsIamConfig.builder()
 * .signingRegion("us-east-1")
 * .signingServiceName("states")
 * .build())
 * .build());
 * httpDs.createResolver("MutationCallStepFunctionResolver", BaseResolverProps.builder()
 * .typeName("Mutation")
 * .fieldName("callStepFunction")
 * .requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
 * .responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
 * .build());
 * ```
 */
public interface HttpDataSourceOptions : DataSourceOptions {
  /**
   * The authorization config in case the HTTP endpoint requires authorization.
   *
   * Default: - none
   */
  public fun authorizationConfig(): AwsIamConfig? =
      unwrap(this).getAuthorizationConfig()?.let(AwsIamConfig::wrap)

  /**
   * A builder for [HttpDataSourceOptions]
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * @param authorizationConfig The authorization config in case the HTTP endpoint requires
     * authorization.
     */
    public fun authorizationConfig(authorizationConfig: AwsIamConfig)

    /**
     * @param authorizationConfig The authorization config in case the HTTP endpoint requires
     * authorization.
     */
    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("17d553a9e8bba7dd7cadc025198b46f845a52abeaa352034b0f1f270306bbaf1")
    public fun authorizationConfig(authorizationConfig: AwsIamConfig.Builder.() -> Unit)

    /**
     * @param description The description of the data source.
     */
    public fun description(description: String)

    /**
     * @param name The name of the data source, overrides the id given by cdk.
     */
    public fun name(name: String)
  }

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

    /**
     * @param authorizationConfig The authorization config in case the HTTP endpoint requires
     * authorization.
     */
    override fun authorizationConfig(authorizationConfig: AwsIamConfig) {
      cdkBuilder.authorizationConfig(authorizationConfig.let(AwsIamConfig.Companion::unwrap))
    }

    /**
     * @param authorizationConfig The authorization config in case the HTTP endpoint requires
     * authorization.
     */
    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("17d553a9e8bba7dd7cadc025198b46f845a52abeaa352034b0f1f270306bbaf1")
    override fun authorizationConfig(authorizationConfig: AwsIamConfig.Builder.() -> Unit): Unit =
        authorizationConfig(AwsIamConfig(authorizationConfig))

    /**
     * @param description The description of the data source.
     */
    override fun description(description: String) {
      cdkBuilder.description(description)
    }

    /**
     * @param name The name of the data source, overrides the id given by cdk.
     */
    override fun name(name: String) {
      cdkBuilder.name(name)
    }

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

  private class Wrapper(
    cdkObject: software.amazon.awscdk.services.appsync.HttpDataSourceOptions,
  ) : CdkObject(cdkObject),
      HttpDataSourceOptions {
    /**
     * The authorization config in case the HTTP endpoint requires authorization.
     *
     * Default: - none
     */
    override fun authorizationConfig(): AwsIamConfig? =
        unwrap(this).getAuthorizationConfig()?.let(AwsIamConfig::wrap)

    /**
     * The description of the data source.
     *
     * Default: - No description
     */
    override fun description(): String? = unwrap(this).getDescription()

    /**
     * The name of the data source, overrides the id given by cdk.
     *
     * Default: - generated by cdk given the id
     */
    override fun name(): String? = unwrap(this).getName()
  }

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy