// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.gcp.bigquery;

import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import com.pulumi.gcp.Utilities;
import com.pulumi.gcp.bigquery.ConnectionArgs;
import com.pulumi.gcp.bigquery.inputs.ConnectionState;
import com.pulumi.gcp.bigquery.outputs.ConnectionAws;
import com.pulumi.gcp.bigquery.outputs.ConnectionAzure;
import com.pulumi.gcp.bigquery.outputs.ConnectionCloudResource;
import com.pulumi.gcp.bigquery.outputs.ConnectionCloudSpanner;
import com.pulumi.gcp.bigquery.outputs.ConnectionCloudSql;
import java.lang.Boolean;
import java.lang.String;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * A connection allows BigQuery connections to external data sources..
 * 
 * To get more information about Connection, see:
 * 
 * * [API documentation](https://cloud.google.com/bigquery/docs/reference/bigqueryconnection/rest/v1/projects.locations.connections/create)
 * * How-to Guides
 *     * [Cloud SQL federated queries](https://cloud.google.com/bigquery/docs/cloud-sql-federated-queries)
 * 
 * &gt; **Warning:** All arguments including the following potentially sensitive
 * values will be stored in the raw state as plain text: `cloud_sql.credential.password`.
 * Read more about sensitive data in state.
 * 
 * ## Example Usage
 * ### Bigquery Connection Cloud Resource
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.bigquery.Connection;
 * import com.pulumi.gcp.bigquery.ConnectionArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionCloudResourceArgs;
 * 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 connection = new Connection(&#34;connection&#34;, ConnectionArgs.builder()        
 *             .cloudResource()
 *             .connectionId(&#34;my-connection&#34;)
 *             .description(&#34;a riveting description&#34;)
 *             .friendlyName(&#34;👋&#34;)
 *             .location(&#34;US&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Bigquery Connection Basic
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.sql.DatabaseInstance;
 * import com.pulumi.gcp.sql.DatabaseInstanceArgs;
 * import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
 * import com.pulumi.gcp.sql.Database;
 * import com.pulumi.gcp.sql.DatabaseArgs;
 * import com.pulumi.random.RandomPassword;
 * import com.pulumi.random.RandomPasswordArgs;
 * import com.pulumi.gcp.sql.User;
 * import com.pulumi.gcp.sql.UserArgs;
 * import com.pulumi.gcp.bigquery.Connection;
 * import com.pulumi.gcp.bigquery.ConnectionArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionCloudSqlArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionCloudSqlCredentialArgs;
 * 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 instance = new DatabaseInstance(&#34;instance&#34;, DatabaseInstanceArgs.builder()        
 *             .databaseVersion(&#34;POSTGRES_11&#34;)
 *             .region(&#34;us-central1&#34;)
 *             .settings(DatabaseInstanceSettingsArgs.builder()
 *                 .tier(&#34;db-f1-micro&#34;)
 *                 .build())
 *             .deletionProtection(&#34;true&#34;)
 *             .build());
 * 
 *         var db = new Database(&#34;db&#34;, DatabaseArgs.builder()        
 *             .instance(instance.name())
 *             .build());
 * 
 *         var pwd = new RandomPassword(&#34;pwd&#34;, RandomPasswordArgs.builder()        
 *             .length(16)
 *             .special(false)
 *             .build());
 * 
 *         var user = new User(&#34;user&#34;, UserArgs.builder()        
 *             .instance(instance.name())
 *             .password(pwd.result())
 *             .build());
 * 
 *         var connection = new Connection(&#34;connection&#34;, ConnectionArgs.builder()        
 *             .friendlyName(&#34;👋&#34;)
 *             .description(&#34;a riveting description&#34;)
 *             .location(&#34;US&#34;)
 *             .cloudSql(ConnectionCloudSqlArgs.builder()
 *                 .instanceId(instance.connectionName())
 *                 .database(db.name())
 *                 .type(&#34;POSTGRES&#34;)
 *                 .credential(ConnectionCloudSqlCredentialArgs.builder()
 *                     .username(user.name())
 *                     .password(user.password())
 *                     .build())
 *                 .build())
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Bigquery Connection Full
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.sql.DatabaseInstance;
 * import com.pulumi.gcp.sql.DatabaseInstanceArgs;
 * import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
 * import com.pulumi.gcp.sql.Database;
 * import com.pulumi.gcp.sql.DatabaseArgs;
 * import com.pulumi.random.RandomPassword;
 * import com.pulumi.random.RandomPasswordArgs;
 * import com.pulumi.gcp.sql.User;
 * import com.pulumi.gcp.sql.UserArgs;
 * import com.pulumi.gcp.bigquery.Connection;
 * import com.pulumi.gcp.bigquery.ConnectionArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionCloudSqlArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionCloudSqlCredentialArgs;
 * 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 instance = new DatabaseInstance(&#34;instance&#34;, DatabaseInstanceArgs.builder()        
 *             .databaseVersion(&#34;POSTGRES_11&#34;)
 *             .region(&#34;us-central1&#34;)
 *             .settings(DatabaseInstanceSettingsArgs.builder()
 *                 .tier(&#34;db-f1-micro&#34;)
 *                 .build())
 *             .deletionProtection(&#34;true&#34;)
 *             .build());
 * 
 *         var db = new Database(&#34;db&#34;, DatabaseArgs.builder()        
 *             .instance(instance.name())
 *             .build());
 * 
 *         var pwd = new RandomPassword(&#34;pwd&#34;, RandomPasswordArgs.builder()        
 *             .length(16)
 *             .special(false)
 *             .build());
 * 
 *         var user = new User(&#34;user&#34;, UserArgs.builder()        
 *             .instance(instance.name())
 *             .password(pwd.result())
 *             .build());
 * 
 *         var connection = new Connection(&#34;connection&#34;, ConnectionArgs.builder()        
 *             .connectionId(&#34;my-connection&#34;)
 *             .location(&#34;US&#34;)
 *             .friendlyName(&#34;👋&#34;)
 *             .description(&#34;a riveting description&#34;)
 *             .cloudSql(ConnectionCloudSqlArgs.builder()
 *                 .instanceId(instance.connectionName())
 *                 .database(db.name())
 *                 .type(&#34;POSTGRES&#34;)
 *                 .credential(ConnectionCloudSqlCredentialArgs.builder()
 *                     .username(user.name())
 *                     .password(user.password())
 *                     .build())
 *                 .build())
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Bigquery Connection Aws
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.bigquery.Connection;
 * import com.pulumi.gcp.bigquery.ConnectionArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionAwsArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionAwsAccessRoleArgs;
 * 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 connection = new Connection(&#34;connection&#34;, ConnectionArgs.builder()        
 *             .aws(ConnectionAwsArgs.builder()
 *                 .accessRole(ConnectionAwsAccessRoleArgs.builder()
 *                     .iamRoleId(&#34;arn:aws:iam::999999999999:role/omnirole&#34;)
 *                     .build())
 *                 .build())
 *             .connectionId(&#34;my-connection&#34;)
 *             .description(&#34;a riveting description&#34;)
 *             .friendlyName(&#34;👋&#34;)
 *             .location(&#34;aws-us-east-1&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Bigquery Connection Azure
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.bigquery.Connection;
 * import com.pulumi.gcp.bigquery.ConnectionArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionAzureArgs;
 * 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 connection = new Connection(&#34;connection&#34;, ConnectionArgs.builder()        
 *             .azure(ConnectionAzureArgs.builder()
 *                 .customerTenantId(&#34;customer-tenant-id&#34;)
 *                 .federatedApplicationClientId(&#34;b43eeeee-eeee-eeee-eeee-a480155501ce&#34;)
 *                 .build())
 *             .connectionId(&#34;my-connection&#34;)
 *             .description(&#34;a riveting description&#34;)
 *             .friendlyName(&#34;👋&#34;)
 *             .location(&#34;azure-eastus2&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Bigquery Connection Cloudspanner
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.bigquery.Connection;
 * import com.pulumi.gcp.bigquery.ConnectionArgs;
 * import com.pulumi.gcp.bigquery.inputs.ConnectionCloudSpannerArgs;
 * 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 connection = new Connection(&#34;connection&#34;, ConnectionArgs.builder()        
 *             .cloudSpanner(ConnectionCloudSpannerArgs.builder()
 *                 .database(&#34;projects/project/instances/instance/databases/database&#34;)
 *                 .build())
 *             .connectionId(&#34;my-connection&#34;)
 *             .description(&#34;a riveting description&#34;)
 *             .friendlyName(&#34;👋&#34;)
 *             .location(&#34;US&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * Connection can be imported using any of these accepted formats
 * 
 * ```sh
 *  $ pulumi import gcp:bigquery/connection:Connection default projects/{{project}}/locations/{{location}}/connections/{{connection_id}}
 * ```
 * 
 * ```sh
 *  $ pulumi import gcp:bigquery/connection:Connection default {{project}}/{{location}}/{{connection_id}}
 * ```
 * 
 * ```sh
 *  $ pulumi import gcp:bigquery/connection:Connection default {{location}}/{{connection_id}}
 * ```
 * 
 */
@ResourceType(type="gcp:bigquery/connection:Connection")
public class Connection extends com.pulumi.resources.CustomResource {
    /**
     * Connection properties specific to Amazon Web Services.
     * Structure is documented below.
     * 
     */
    @Export(name="aws", type=ConnectionAws.class, parameters={})
    private Output</* @Nullable */ ConnectionAws> aws;

    /**
     * @return Connection properties specific to Amazon Web Services.
     * Structure is documented below.
     * 
     */
    public Output<Optional<ConnectionAws>> aws() {
        return Codegen.optional(this.aws);
    }
    /**
     * Container for connection properties specific to Azure.
     * Structure is documented below.
     * 
     */
    @Export(name="azure", type=ConnectionAzure.class, parameters={})
    private Output</* @Nullable */ ConnectionAzure> azure;

    /**
     * @return Container for connection properties specific to Azure.
     * Structure is documented below.
     * 
     */
    public Output<Optional<ConnectionAzure>> azure() {
        return Codegen.optional(this.azure);
    }
    /**
     * Container for connection properties for delegation of access to GCP resources.
     * Structure is documented below.
     * 
     */
    @Export(name="cloudResource", type=ConnectionCloudResource.class, parameters={})
    private Output</* @Nullable */ ConnectionCloudResource> cloudResource;

    /**
     * @return Container for connection properties for delegation of access to GCP resources.
     * Structure is documented below.
     * 
     */
    public Output<Optional<ConnectionCloudResource>> cloudResource() {
        return Codegen.optional(this.cloudResource);
    }
    /**
     * Connection properties specific to Cloud Spanner
     * Structure is documented below.
     * 
     */
    @Export(name="cloudSpanner", type=ConnectionCloudSpanner.class, parameters={})
    private Output</* @Nullable */ ConnectionCloudSpanner> cloudSpanner;

    /**
     * @return Connection properties specific to Cloud Spanner
     * Structure is documented below.
     * 
     */
    public Output<Optional<ConnectionCloudSpanner>> cloudSpanner() {
        return Codegen.optional(this.cloudSpanner);
    }
    /**
     * Connection properties specific to the Cloud SQL.
     * Structure is documented below.
     * 
     */
    @Export(name="cloudSql", type=ConnectionCloudSql.class, parameters={})
    private Output</* @Nullable */ ConnectionCloudSql> cloudSql;

    /**
     * @return Connection properties specific to the Cloud SQL.
     * Structure is documented below.
     * 
     */
    public Output<Optional<ConnectionCloudSql>> cloudSql() {
        return Codegen.optional(this.cloudSql);
    }
    /**
     * Optional connection id that should be assigned to the created connection.
     * 
     */
    @Export(name="connectionId", type=String.class, parameters={})
    private Output<String> connectionId;

    /**
     * @return Optional connection id that should be assigned to the created connection.
     * 
     */
    public Output<String> connectionId() {
        return this.connectionId;
    }
    /**
     * A descriptive description for the connection
     * 
     */
    @Export(name="description", type=String.class, parameters={})
    private Output</* @Nullable */ String> description;

    /**
     * @return A descriptive description for the connection
     * 
     */
    public Output<Optional<String>> description() {
        return Codegen.optional(this.description);
    }
    /**
     * A descriptive name for the connection
     * 
     */
    @Export(name="friendlyName", type=String.class, parameters={})
    private Output</* @Nullable */ String> friendlyName;

    /**
     * @return A descriptive name for the connection
     * 
     */
    public Output<Optional<String>> friendlyName() {
        return Codegen.optional(this.friendlyName);
    }
    /**
     * True if the connection has credential assigned.
     * 
     */
    @Export(name="hasCredential", type=Boolean.class, parameters={})
    private Output<Boolean> hasCredential;

    /**
     * @return True if the connection has credential assigned.
     * 
     */
    public Output<Boolean> hasCredential() {
        return this.hasCredential;
    }
    /**
     * The geographic location where the connection should reside.
     * Cloud SQL instance must be in the same location as the connection
     * with following exceptions: Cloud SQL us-central1 maps to BigQuery US, Cloud SQL europe-west1 maps to BigQuery EU.
     * Examples: US, EU, asia-northeast1, us-central1, europe-west1.
     * Spanner Connections same as spanner region
     * AWS allowed regions are aws-us-east-1
     * Azure allowed regions are azure-eastus2
     * 
     */
    @Export(name="location", type=String.class, parameters={})
    private Output</* @Nullable */ String> location;

    /**
     * @return The geographic location where the connection should reside.
     * Cloud SQL instance must be in the same location as the connection
     * with following exceptions: Cloud SQL us-central1 maps to BigQuery US, Cloud SQL europe-west1 maps to BigQuery EU.
     * Examples: US, EU, asia-northeast1, us-central1, europe-west1.
     * Spanner Connections same as spanner region
     * AWS allowed regions are aws-us-east-1
     * Azure allowed regions are azure-eastus2
     * 
     */
    public Output<Optional<String>> location() {
        return Codegen.optional(this.location);
    }
    /**
     * The resource name of the connection in the form of:
     * &#34;projects/{project_id}/locations/{location_id}/connections/{connectionId}&#34;
     * 
     */
    @Export(name="name", type=String.class, parameters={})
    private Output<String> name;

    /**
     * @return The resource name of the connection in the form of:
     * &#34;projects/{project_id}/locations/{location_id}/connections/{connectionId}&#34;
     * 
     */
    public Output<String> name() {
        return this.name;
    }
    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     * 
     */
    @Export(name="project", type=String.class, parameters={})
    private Output<String> project;

    /**
     * @return The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     * 
     */
    public Output<String> project() {
        return this.project;
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public Connection(String name) {
        this(name, ConnectionArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public Connection(String name, @Nullable ConnectionArgs args) {
        this(name, args, null);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     * @param options A bag of options that control this resource's behavior.
     */
    public Connection(String name, @Nullable ConnectionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("gcp:bigquery/connection:Connection", name, args == null ? ConnectionArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private Connection(String name, Output<String> id, @Nullable ConnectionState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("gcp:bigquery/connection:Connection", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
        var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
            .version(Utilities.getVersion())
            .build();
        return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
    }

    /**
     * Get an existing Host resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state
     * @param options Optional settings to control the behavior of the CustomResource.
     */
    public static Connection get(String name, Output<String> id, @Nullable ConnectionState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new Connection(name, id, state, options);
    }
}
