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

com.pulumi.gcp.apigateway.kotlin.Gateway.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.apigateway.kotlin

import com.pulumi.core.Output
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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map

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

    public var args: GatewayArgs = GatewayArgs()

    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 GatewayArgsBuilder.() -> Unit) {
        val builder = GatewayArgsBuilder()
        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(): Gateway {
        val builtJavaResource = com.pulumi.gcp.apigateway.Gateway(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Gateway(builtJavaResource)
    }
}

/**
 * A consumable API that can be used by multiple Gateways.
 * To get more information about Gateway, see:
 * * [API documentation](https://cloud.google.com/api-gateway/docs/reference/rest/v1beta/projects.locations.apis)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/api-gateway/docs/quickstart)
 * ## Example Usage
 * ### Apigateway Gateway Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 * const apiGw = new gcp.apigateway.Api("api_gw", {apiId: "my-api"});
 * const apiGwApiConfig = new gcp.apigateway.ApiConfig("api_gw", {
 *     api: apiGw.apiId,
 *     apiConfigId: "my-config",
 *     openapiDocuments: [{
 *         document: {
 *             path: "spec.yaml",
 *             contents: std.filebase64({
 *                 input: "test-fixtures/openapi.yaml",
 *             }).then(invoke => invoke.result),
 *         },
 *     }],
 * });
 * const apiGwGateway = new gcp.apigateway.Gateway("api_gw", {
 *     apiConfig: apiGwApiConfig.id,
 *     gatewayId: "my-gateway",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * import pulumi_std as std
 * api_gw = gcp.apigateway.Api("api_gw", api_id="my-api")
 * api_gw_api_config = gcp.apigateway.ApiConfig("api_gw",
 *     api=api_gw.api_id,
 *     api_config_id="my-config",
 *     openapi_documents=[gcp.apigateway.ApiConfigOpenapiDocumentArgs(
 *         document=gcp.apigateway.ApiConfigOpenapiDocumentDocumentArgs(
 *             path="spec.yaml",
 *             contents=std.filebase64(input="test-fixtures/openapi.yaml").result,
 *         ),
 *     )])
 * api_gw_gateway = gcp.apigateway.Gateway("api_gw",
 *     api_config=api_gw_api_config.id,
 *     gateway_id="my-gateway")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * using Std = Pulumi.Std;
 * return await Deployment.RunAsync(() =>
 * {
 *     var apiGw = new Gcp.ApiGateway.Api("api_gw", new()
 *     {
 *         ApiId = "my-api",
 *     });
 *     var apiGwApiConfig = new Gcp.ApiGateway.ApiConfig("api_gw", new()
 *     {
 *         Api = apiGw.ApiId,
 *         ApiConfigId = "my-config",
 *         OpenapiDocuments = new[]
 *         {
 *             new Gcp.ApiGateway.Inputs.ApiConfigOpenapiDocumentArgs
 *             {
 *                 Document = new Gcp.ApiGateway.Inputs.ApiConfigOpenapiDocumentDocumentArgs
 *                 {
 *                     Path = "spec.yaml",
 *                     Contents = Std.Filebase64.Invoke(new()
 *                     {
 *                         Input = "test-fixtures/openapi.yaml",
 *                     }).Apply(invoke => invoke.Result),
 *                 },
 *             },
 *         },
 *     });
 *     var apiGwGateway = new Gcp.ApiGateway.Gateway("api_gw", new()
 *     {
 *         ApiConfig = apiGwApiConfig.Id,
 *         GatewayId = "my-gateway",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/apigateway"
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		apiGw, err := apigateway.NewApi(ctx, "api_gw", &apigateway.ApiArgs{
 * 			ApiId: pulumi.String("my-api"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		invokeFilebase64, err := std.Filebase64(ctx, &std.Filebase64Args{
 * 			Input: "test-fixtures/openapi.yaml",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		apiGwApiConfig, err := apigateway.NewApiConfig(ctx, "api_gw", &apigateway.ApiConfigArgs{
 * 			Api:         apiGw.ApiId,
 * 			ApiConfigId: pulumi.String("my-config"),
 * 			OpenapiDocuments: apigateway.ApiConfigOpenapiDocumentArray{
 * 				&apigateway.ApiConfigOpenapiDocumentArgs{
 * 					Document: &apigateway.ApiConfigOpenapiDocumentDocumentArgs{
 * 						Path:     pulumi.String("spec.yaml"),
 * 						Contents: invokeFilebase64.Result,
 * 					},
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = apigateway.NewGateway(ctx, "api_gw", &apigateway.GatewayArgs{
 * 			ApiConfig: apiGwApiConfig.ID(),
 * 			GatewayId: pulumi.String("my-gateway"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.apigateway.Api;
 * import com.pulumi.gcp.apigateway.ApiArgs;
 * import com.pulumi.gcp.apigateway.ApiConfig;
 * import com.pulumi.gcp.apigateway.ApiConfigArgs;
 * import com.pulumi.gcp.apigateway.inputs.ApiConfigOpenapiDocumentArgs;
 * import com.pulumi.gcp.apigateway.inputs.ApiConfigOpenapiDocumentDocumentArgs;
 * import com.pulumi.gcp.apigateway.Gateway;
 * import com.pulumi.gcp.apigateway.GatewayArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var apiGw = new Api("apiGw", ApiArgs.builder()
 *             .apiId("my-api")
 *             .build());
 *         var apiGwApiConfig = new ApiConfig("apiGwApiConfig", ApiConfigArgs.builder()
 *             .api(apiGw.apiId())
 *             .apiConfigId("my-config")
 *             .openapiDocuments(ApiConfigOpenapiDocumentArgs.builder()
 *                 .document(ApiConfigOpenapiDocumentDocumentArgs.builder()
 *                     .path("spec.yaml")
 *                     .contents(StdFunctions.filebase64(Filebase64Args.builder()
 *                         .input("test-fixtures/openapi.yaml")
 *                         .build()).result())
 *                     .build())
 *                 .build())
 *             .build());
 *         var apiGwGateway = new Gateway("apiGwGateway", GatewayArgs.builder()
 *             .apiConfig(apiGwApiConfig.id())
 *             .gatewayId("my-gateway")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   apiGw:
 *     type: gcp:apigateway:Api
 *     name: api_gw
 *     properties:
 *       apiId: my-api
 *   apiGwApiConfig:
 *     type: gcp:apigateway:ApiConfig
 *     name: api_gw
 *     properties:
 *       api: ${apiGw.apiId}
 *       apiConfigId: my-config
 *       openapiDocuments:
 *         - document:
 *             path: spec.yaml
 *             contents:
 *               fn::invoke:
 *                 Function: std:filebase64
 *                 Arguments:
 *                   input: test-fixtures/openapi.yaml
 *                 Return: result
 *   apiGwGateway:
 *     type: gcp:apigateway:Gateway
 *     name: api_gw
 *     properties:
 *       apiConfig: ${apiGwApiConfig.id}
 *       gatewayId: my-gateway
 * ```
 * 
 * ## Import
 * Gateway can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{region}}/gateways/{{gateway_id}}`
 * * `{{project}}/{{region}}/{{gateway_id}}`
 * * `{{region}}/{{gateway_id}}`
 * * `{{gateway_id}}`
 * When using the `pulumi import` command, Gateway can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:apigateway/gateway:Gateway default projects/{{project}}/locations/{{region}}/gateways/{{gateway_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:apigateway/gateway:Gateway default {{project}}/{{region}}/{{gateway_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:apigateway/gateway:Gateway default {{region}}/{{gateway_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:apigateway/gateway:Gateway default {{gateway_id}}
 * ```
 */
public class Gateway internal constructor(
    override val javaResource: com.pulumi.gcp.apigateway.Gateway,
) : KotlinCustomResource(javaResource, GatewayMapper) {
    /**
     * Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}.
     * When changing api configs please ensure the new config is a new resource and the
     * lifecycle rule `create_before_destroy` is set.
     */
    public val apiConfig: Output
        get() = javaResource.apiConfig().applyValue({ args0 -> args0 })

    /**
     * The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.
     */
    public val defaultHostname: Output
        get() = javaResource.defaultHostname().applyValue({ args0 -> args0 })

    /**
     * A user-visible name for the API.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
     * - - -
     */
    public val gatewayId: Output
        get() = javaResource.gatewayId().applyValue({ args0 -> args0 })

    /**
     * Resource labels to represent user-provided metadata.
     * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
     * Please refer to the field `effective_labels` for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The region of the gateway for the API.
     */
    public val region: Output
        get() = javaResource.region().applyValue({ args0 -> args0 })
}

public object GatewayMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.apigateway.Gateway::class == javaResource::class

    override fun map(javaResource: Resource): Gateway = Gateway(
        javaResource as
            com.pulumi.gcp.apigateway.Gateway,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy