UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

145 lines 4.68 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Schema = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A schema is a format that messages must follow, * creating a contract between publisher and subscriber that Pub/Sub will enforce. * * To get more information about Schema, see: * * * [API documentation](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas) * * How-to Guides * * [Creating and managing schemas](https://cloud.google.com/pubsub/docs/schemas) * * ## Example Usage * * ### Pubsub Schema Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Schema("example", { * name: "example-schema", * type: "AVRO", * definition: `{ * "type" : "record", * "name" : "Avro", * "fields" : [ * { * "name" : "StringField", * "type" : "string" * }, * { * "name" : "IntField", * "type" : "int" * } * ] * } * `, * }); * ``` * ### Pubsub Schema Protobuf * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Schema("example", { * name: "example", * type: "PROTOCOL_BUFFER", * definition: `syntax = "proto3"; * message Results { * string message_request = 1; * string message_response = 2; * string timestamp_request = 3; * string timestamp_response = 4; * }`, * }); * const exampleTopic = new gcp.pubsub.Topic("example", { * name: "example-topic", * schemaSettings: { * schema: "projects/my-project-name/schemas/example", * encoding: "JSON", * }, * }, { * dependsOn: [example], * }); * ``` * * ## Import * * Schema can be imported using any of these accepted formats: * * * `projects/{{project}}/schemas/{{name}}` * * * `{{project}}/{{name}}` * * * `{{name}}` * * When using the `pulumi import` command, Schema can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:pubsub/schema:Schema default projects/{{project}}/schemas/{{name}} * ``` * * ```sh * $ pulumi import gcp:pubsub/schema:Schema default {{project}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:pubsub/schema:Schema default {{name}} * ``` */ class Schema extends pulumi.CustomResource { /** * Get an existing Schema 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 Schema(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Schema. 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'] === Schema.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["definition"] = state ? state.definition : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["type"] = state ? state.type : undefined; } else { const args = argsOrState; resourceInputs["definition"] = args ? args.definition : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["type"] = args ? args.type : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Schema.__pulumiType, name, resourceInputs, opts); } } exports.Schema = Schema; /** @internal */ Schema.__pulumiType = 'gcp:pubsub/schema:Schema'; //# sourceMappingURL=schema.js.map