UNPKG

@pulumi/gcp

Version:

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

353 lines (352 loc) • 12.8 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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-test-_79169", * 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}} * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: CxToolState, opts?: pulumi.CustomResourceOptions): CxTool; /** * 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: any): obj is CxTool; /** * Data store search tool specification. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ readonly dataStoreSpec: pulumi.Output<outputs.diagflow.CxToolDataStoreSpec | undefined>; /** * High level description of the Tool and its usage. */ readonly description: pulumi.Output<string>; /** * The human-readable name of the tool, unique within the agent. */ readonly displayName: pulumi.Output<string>; /** * Client side executed function specification. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ readonly functionSpec: pulumi.Output<outputs.diagflow.CxToolFunctionSpec | undefined>; /** * The unique identifier of the Tool. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/tools/<Tool ID>. */ readonly name: pulumi.Output<string>; /** * OpenAPI specification of the Tool. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ readonly openApiSpec: pulumi.Output<outputs.diagflow.CxToolOpenApiSpec | undefined>; /** * The agent to create a Tool for. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>. */ readonly parent: pulumi.Output<string | undefined>; /** * The tool type. */ readonly toolType: pulumi.Output<string>; /** * Create a CxTool resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: CxToolArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering CxTool resources. */ export interface CxToolState { /** * Data store search tool specification. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ dataStoreSpec?: pulumi.Input<inputs.diagflow.CxToolDataStoreSpec>; /** * High level description of the Tool and its usage. */ description?: pulumi.Input<string>; /** * The human-readable name of the tool, unique within the agent. */ displayName?: pulumi.Input<string>; /** * Client side executed function specification. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ functionSpec?: pulumi.Input<inputs.diagflow.CxToolFunctionSpec>; /** * The unique identifier of the Tool. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/tools/<Tool ID>. */ name?: pulumi.Input<string>; /** * OpenAPI specification of the Tool. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ openApiSpec?: pulumi.Input<inputs.diagflow.CxToolOpenApiSpec>; /** * The agent to create a Tool for. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>. */ parent?: pulumi.Input<string>; /** * The tool type. */ toolType?: pulumi.Input<string>; } /** * The set of arguments for constructing a CxTool resource. */ export interface CxToolArgs { /** * Data store search tool specification. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ dataStoreSpec?: pulumi.Input<inputs.diagflow.CxToolDataStoreSpec>; /** * High level description of the Tool and its usage. */ description: pulumi.Input<string>; /** * The human-readable name of the tool, unique within the agent. */ displayName: pulumi.Input<string>; /** * Client side executed function specification. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ functionSpec?: pulumi.Input<inputs.diagflow.CxToolFunctionSpec>; /** * OpenAPI specification of the Tool. * This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, or `functionSpec` may be set. * Structure is documented below. */ openApiSpec?: pulumi.Input<inputs.diagflow.CxToolOpenApiSpec>; /** * The agent to create a Tool for. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>. */ parent?: pulumi.Input<string>; }