UNPKG

@pulumi/gcp

Version:

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

272 lines • 9.68 kB
"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.CxTool = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A tool provides a list of actions which are available to the Playbook to attain its goal. * A Tool consists of a description of the tool's usage and a specification of the tool which contains the schema and authentication information. * * To get more information about Tool, see: * * * [API documentation](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.tools) * * How-to Guides * * [Official Documentation](https://cloud.google.com/dialogflow/cx/docs) * * ## Example Usage * * ### Dialogflowcx Tool Open Api * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as std from "@pulumi/std"; * * const agent = new gcp.diagflow.CxAgent("agent", { * displayName: "dialogflowcx-agent-open-api", * location: "global", * defaultLanguageCode: "en", * timeZone: "America/New_York", * description: "Example description.", * }); * const openApiTool = new gcp.diagflow.CxTool("open_api_tool", { * parent: agent.id, * displayName: "Example Open API Tool", * description: "Example Description", * openApiSpec: { * authentication: { * oauthConfig: { * oauthGrantType: "CLIENT_CREDENTIAL", * clientId: "example client ID", * clientSecret: "example client secret", * scopes: ["example scope"], * secretVersionForClientSecret: "projects/-/secrets/-/versions/-", * tokenEndpoint: "https://example.com/oauth/token", * }, * }, * tlsConfig: { * caCerts: [{ * displayName: "example ca cert name", * cert: std.base64encode({ * input: "example cert", * }).then(invoke => invoke.result), * }], * }, * serviceDirectoryConfig: { * service: "projects/-/locations/-/namespaces/-/services/-", * }, * textSchema: ` { * "openapi": "3.0.0", * "info": { * "title": "Time API", * "version": "1.0.0", * "description": "A simple API to get the current time." * }, * "servers": [ * { * "url": "https://example-api-endpoint.com" * } * ], * "paths": { * "/time": { * "get": { * "operationId": "getCurrentTime", * "summary": "Gets the current server time.", * "responses": { * "200": { * "description": "Successful response with the current time.", * "content": { * "application/json": { * "schema": { * "type": "object", * "properties": { * "currentTime": { * "type": "string", * "format": "date-time", * "description": "The current time in ISO 8601 format." * } * } * } * } * } * } * } * } * } * } * } * `, * }, * }); * ``` * ### Dialogflowcx Tool Data Store * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myDatastore = new gcp.discoveryengine.DataStore("my_datastore", { * location: "global", * dataStoreId: "datastore-tool", * displayName: "datastore for Tool test", * industryVertical: "GENERIC", * contentConfig: "NO_CONTENT", * solutionTypes: ["SOLUTION_TYPE_CHAT"], * }); * const agent = new gcp.diagflow.CxAgent("agent", { * displayName: "dialogflowcx-agent-data-store", * location: "global", * defaultLanguageCode: "en", * timeZone: "America/New_York", * description: "Example description.", * deleteChatEngineOnDestroy: true, * }, { * dependsOn: [myDatastore], * }); * const project = gcp.organizations.getProject({}); * const dataStoreTool = new gcp.diagflow.CxTool("data_store_tool", { * parent: agent.id, * displayName: "Example Data Store Tool", * description: "Example Description", * dataStoreSpec: { * dataStoreConnections: [{ * dataStoreType: "UNSTRUCTURED", * dataStore: pulumi.all([project, myDatastore.dataStoreId]).apply(([project, dataStoreId]) => `projects/${project.number}/locations/global/collections/default_collection/dataStores/${dataStoreId}`), * documentProcessingMode: "DOCUMENTS", * }], * fallbackPrompt: {}, * }, * }, { * dependsOn: [ * myDatastore, * agent, * ], * }); * ``` * ### Dialogflowcx Tool Function * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const agent = new gcp.diagflow.CxAgent("agent", { * displayName: "dialogflowcx-agent-fucntion", * location: "global", * defaultLanguageCode: "en", * timeZone: "America/New_York", * description: "Example description.", * }); * const functionTool = new gcp.diagflow.CxTool("function_tool", { * parent: agent.id, * displayName: "Example Function Tool", * description: "Example Description", * functionSpec: { * inputSchema: ` { * "type": "object", * "properties": { * "message_to_echo": { * "type": "string", * "description": "The message that should be echoed back." * } * }, * "required": [ * "message_to_echo" * ] * } * `, * outputSchema: ` { * "type": "object", * "properties": { * "echoed_message": { * "type": "string", * "description": "The message that is echoed back." * } * } * } * `, * }, * }); * ``` * * ## Import * * Tool can be imported using any of these accepted formats: * * * `{{parent}}/tools/{{name}}` * * * `{{parent}}/{{name}}` * * When using the `pulumi import` command, Tool can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:diagflow/cxTool:CxTool default {{parent}}/tools/{{name}} * ``` * * ```sh * $ pulumi import gcp:diagflow/cxTool:CxTool default {{parent}}/{{name}} * ``` */ class CxTool extends pulumi.CustomResource { /** * Get an existing CxTool 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 CxTool(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of CxTool. 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'] === CxTool.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["dataStoreSpec"] = state?.dataStoreSpec; resourceInputs["description"] = state?.description; resourceInputs["displayName"] = state?.displayName; resourceInputs["functionSpec"] = state?.functionSpec; resourceInputs["name"] = state?.name; resourceInputs["openApiSpec"] = state?.openApiSpec; resourceInputs["parent"] = state?.parent; resourceInputs["toolType"] = state?.toolType; } else { const args = argsOrState; if (args?.description === undefined && !opts.urn) { throw new Error("Missing required property 'description'"); } if (args?.displayName === undefined && !opts.urn) { throw new Error("Missing required property 'displayName'"); } resourceInputs["dataStoreSpec"] = args?.dataStoreSpec; resourceInputs["description"] = args?.description; resourceInputs["displayName"] = args?.displayName; resourceInputs["functionSpec"] = args?.functionSpec; resourceInputs["openApiSpec"] = args?.openApiSpec; resourceInputs["parent"] = args?.parent; resourceInputs["name"] = undefined /*out*/; resourceInputs["toolType"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(CxTool.__pulumiType, name, resourceInputs, opts); } } exports.CxTool = CxTool; /** @internal */ CxTool.__pulumiType = 'gcp:diagflow/cxTool:CxTool'; //# sourceMappingURL=cxTool.js.map