"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Topic = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A named resource to which messages are sent by publishers.
 *
 * To get more information about Topic, see:
 *
 * * [API documentation](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics)
 * * How-to Guides
 *     * [Managing Topics](https://cloud.google.com/pubsub/docs/admin#managing_topics)
 *
 * > **Note:** You can retrieve the email of the Google Managed Pub/Sub Service Account used for forwarding
 * by using the `gcp.projects.ServiceIdentity` resource.
 *
 * ## Example Usage
 *
 * ### Pubsub Topic Basic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     labels: {
 *         foo: "bar",
 *     },
 *     messageRetentionDuration: "86600s",
 * });
 * ```
 * ### Pubsub Topic Cmek
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const keyRing = new gcp.kms.KeyRing("key_ring", {
 *     name: "example-keyring",
 *     location: "global",
 * });
 * const cryptoKey = new gcp.kms.CryptoKey("crypto_key", {
 *     name: "example-key",
 *     keyRing: keyRing.id,
 * });
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     kmsKeyName: cryptoKey.id,
 * });
 * ```
 * ### Pubsub Topic Geo Restricted
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     messageStoragePolicy: {
 *         allowedPersistenceRegions: ["europe-west3"],
 *         enforceInTransit: true,
 *     },
 * });
 * ```
 * ### Pubsub Topic Schema Settings
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Schema("example", {
 *     name: "example",
 *     type: "AVRO",
 *     definition: `{
 *   "type" : "record",
 *   "name" : "Avro",
 *   "fields" : [
 *     {
 *       "name" : "StringField",
 *       "type" : "string"
 *     },
 *     {
 *       "name" : "IntField",
 *       "type" : "int"
 *     }
 *   ]
 * }
 * `,
 * });
 * const exampleTopic = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     schemaSettings: {
 *         schema: "projects/my-project-name/schemas/example",
 *         encoding: "JSON",
 *     },
 * }, {
 *     dependsOn: [example],
 * });
 * ```
 * ### Pubsub Topic Ingestion Kinesis
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     ingestionDataSourceSettings: {
 *         awsKinesis: {
 *             streamArn: "arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name",
 *             consumerArn: "arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name/consumer/consumer-1:1111111111",
 *             awsRoleArn: "arn:aws:iam::111111111111:role/fake-role-name",
 *             gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com",
 *         },
 *     },
 * });
 * ```
 * ### Pubsub Topic Ingestion Cloud Storage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     ingestionDataSourceSettings: {
 *         cloudStorage: {
 *             bucket: "test-bucket",
 *             textFormat: {
 *                 delimiter: " ",
 *             },
 *             minimumObjectCreateTime: "2024-01-01T00:00:00Z",
 *             matchGlob: "foo/**",
 *         },
 *         platformLogsSettings: {
 *             severity: "WARNING",
 *         },
 *     },
 * });
 * ```
 * ### Pubsub Topic Ingestion Azure Event Hubs
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     ingestionDataSourceSettings: {
 *         azureEventHubs: {
 *             resourceGroup: "azure-ingestion-resource-group",
 *             namespace: "azure-ingestion-namespace",
 *             eventHub: "azure-ingestion-event-hub",
 *             clientId: "aZZZZZZZ-YYYY-HHHH-GGGG-abcdef569123",
 *             tenantId: "0XXXXXXX-YYYY-HHHH-GGGG-123456789123",
 *             subscriptionId: "bXXXXXXX-YYYY-HHHH-GGGG-123456789123",
 *             gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com",
 *         },
 *     },
 * });
 * ```
 * ### Pubsub Topic Ingestion Aws Msk
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     ingestionDataSourceSettings: {
 *         awsMsk: {
 *             clusterArn: "arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name",
 *             topic: "test-topic",
 *             awsRoleArn: "arn:aws:iam::111111111111:role/fake-role-name",
 *             gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com",
 *         },
 *     },
 * });
 * ```
 * ### Pubsub Topic Ingestion Confluent Cloud
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     ingestionDataSourceSettings: {
 *         confluentCloud: {
 *             bootstrapServer: "test.us-west2.gcp.confluent.cloud:1111",
 *             clusterId: "1234",
 *             topic: "test-topic",
 *             identityPoolId: "test-identity-pool-id",
 *             gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com",
 *         },
 *     },
 * });
 * ```
 * ### Pubsub Topic Single Smt
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     messageTransforms: [{
 *         javascriptUdf: {
 *             functionName: "isYearEven",
 *             code: `function isYearEven(message, metadata) {
 *   const data = JSON.parse(message.data);
 *   return message.year %2 === 0;
 * }
 * `,
 *         },
 *     }],
 * });
 * ```
 * ### Pubsub Topic Multiple Smts
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     messageTransforms: [
 *         {
 *             javascriptUdf: {
 *                 functionName: "redactSSN",
 *                 code: `function redactSSN(message, metadata) {
 *   const data = JSON.parse(message.data);
 *   delete data['ssn'];
 *   message.data = JSON.stringify(data);
 *   return message;
 * }
 * `,
 *             },
 *         },
 *         {
 *             javascriptUdf: {
 *                 functionName: "otherFunc",
 *                 code: `function otherFunc(message, metadata) {
 *   return null;
 * }
 * `,
 *             },
 *         },
 *         {
 *             disabled: true,
 *             javascriptUdf: {
 *                 functionName: "someSMTWeDisabled",
 *                 code: "...",
 *             },
 *         },
 *     ],
 * });
 * ```
 * ### Pubsub Topic Tags
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const project = gcp.organizations.getProject({});
 * const tagKey = new gcp.tags.TagKey("tag_key", {
 *     parent: project.then(project => project.id),
 *     shortName: "tag_key",
 * });
 * const tagValue = new gcp.tags.TagValue("tag_value", {
 *     parent: tagKey.id,
 *     shortName: "tag_value",
 * });
 * const example = new gcp.pubsub.Topic("example", {
 *     name: "example-topic",
 *     tags: pulumi.all([tagKey.namespacedName, tagValue.shortName]).apply(([namespacedName, shortName]) => {
 *         [namespacedName]: shortName,
 *     }),
 * });
 * ```
 *
 * ## Import
 *
 * Topic can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/topics/{{name}}`
 *
 * * `{{project}}/{{name}}`
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, Topic can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:pubsub/topic:Topic default projects/{{project}}/topics/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:pubsub/topic:Topic default {{project}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:pubsub/topic:Topic default {{name}}
 * ```
 */
class Topic extends pulumi.CustomResource {
    /**
     * Get an existing Topic 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 Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new Topic(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Topic.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === Topic.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["effectiveLabels"] = state?.effectiveLabels;
            resourceInputs["ingestionDataSourceSettings"] = state?.ingestionDataSourceSettings;
            resourceInputs["kmsKeyName"] = state?.kmsKeyName;
            resourceInputs["labels"] = state?.labels;
            resourceInputs["messageRetentionDuration"] = state?.messageRetentionDuration;
            resourceInputs["messageStoragePolicy"] = state?.messageStoragePolicy;
            resourceInputs["messageTransforms"] = state?.messageTransforms;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["pulumiLabels"] = state?.pulumiLabels;
            resourceInputs["schemaSettings"] = state?.schemaSettings;
            resourceInputs["tags"] = state?.tags;
        }
        else {
            const args = argsOrState;
            resourceInputs["ingestionDataSourceSettings"] = args?.ingestionDataSourceSettings;
            resourceInputs["kmsKeyName"] = args?.kmsKeyName;
            resourceInputs["labels"] = args?.labels;
            resourceInputs["messageRetentionDuration"] = args?.messageRetentionDuration;
            resourceInputs["messageStoragePolicy"] = args?.messageStoragePolicy;
            resourceInputs["messageTransforms"] = args?.messageTransforms;
            resourceInputs["name"] = args?.name;
            resourceInputs["project"] = args?.project;
            resourceInputs["schemaSettings"] = args?.schemaSettings;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["effectiveLabels"] = undefined /*out*/;
            resourceInputs["pulumiLabels"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(Topic.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Topic = Topic;
/** @internal */
Topic.__pulumiType = 'gcp:pubsub/topic:Topic';
//# sourceMappingURL=topic.js.map