import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Description * * ## Example Usage * * ### Ces Guardrail Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cesAppForGuardrail = new gcp.ces.App("ces_app_for_guardrail", { * appId: "app-id", * location: "us", * description: "App used as parent for CES Toolset example", * displayName: "my-app", * languageSettings: { * defaultLanguageCode: "en-US", * supportedLanguageCodes: [ * "es-ES", * "fr-FR", * ], * enableMultilingualSupport: true, * fallbackAction: "escalate", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesGuardrailBasic = new gcp.ces.Guardrail("ces_guardrail_basic", { * guardrailId: "guardrail-id", * location: cesAppForGuardrail.location, * app: cesAppForGuardrail.appId, * displayName: "my-guardrail", * description: "Guardrail description", * action: { * respondImmediately: { * responses: [{ * text: "Text", * disabled: false, * }], * }, * }, * enabled: true, * modelSafety: { * safetySettings: [{ * category: "HARM_CATEGORY_HATE_SPEECH", * threshold: "BLOCK_NONE", * }], * }, * }); * ``` * ### Ces Guardrail Transfer Agent Content Filter * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cesAppForGuardrail = new gcp.ces.App("ces_app_for_guardrail", { * appId: "app-id", * location: "us", * description: "App used as parent for CES Toolset example", * displayName: "my-app", * languageSettings: { * defaultLanguageCode: "en-US", * supportedLanguageCodes: [ * "es-ES", * "fr-FR", * ], * enableMultilingualSupport: true, * fallbackAction: "escalate", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesGuardrailTransferAgentContentFilter = new gcp.ces.Guardrail("ces_guardrail_transfer_agent_content_filter", { * guardrailId: "guardrail-id", * location: cesAppForGuardrail.location, * app: cesAppForGuardrail.appId, * displayName: "my-guardrail", * description: "Guardrail description", * action: { * transferAgent: { * agent: pulumi.interpolate`projects/${cesAppForGuardrail.project}/locations/us/apps/${cesAppForGuardrail.appId}/agents/fake-agent`, * }, * }, * enabled: true, * contentFilter: { * bannedContents: ["example"], * bannedContentsInUserInputs: ["example"], * bannedContentsInAgentResponses: ["example"], * matchType: "SIMPLE_STRING_MATCH", * disregardDiacritics: true, * }, * }); * ``` * ### Ces Guardrail Generative Answer Llm Prompt Security * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cesAppForGuardrail = new gcp.ces.App("ces_app_for_guardrail", { * appId: "app-id", * location: "us", * description: "App used as parent for CES Toolset example", * displayName: "my-app", * languageSettings: { * defaultLanguageCode: "en-US", * supportedLanguageCodes: [ * "es-ES", * "fr-FR", * ], * enableMultilingualSupport: true, * fallbackAction: "escalate", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesGuardrailGenerativeAnswerLlmPromptSecurity = new gcp.ces.Guardrail("ces_guardrail_generative_answer_llm_prompt_security", { * guardrailId: "guardrail-id", * location: cesAppForGuardrail.location, * app: cesAppForGuardrail.appId, * displayName: "my-guardrail", * description: "Guardrail description", * action: { * generativeAnswer: { * prompt: "example_prompt", * }, * }, * enabled: true, * llmPromptSecurity: { * customPolicy: { * maxConversationMessages: 10, * modelSettings: { * model: "gemini-2.5-flash", * temperature: 50, * }, * prompt: "example_prompt", * policyScope: "USER_QUERY", * failOpen: true, * allowShortUtterance: true, * }, * }, * }); * ``` * ### Ces Guardrail Code Callback * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cesAppForGuardrail = new gcp.ces.App("ces_app_for_guardrail", { * appId: "app-id", * location: "us", * description: "App used as parent for CES Toolset example", * displayName: "my-app", * languageSettings: { * defaultLanguageCode: "en-US", * supportedLanguageCodes: [ * "es-ES", * "fr-FR", * ], * enableMultilingualSupport: true, * fallbackAction: "escalate", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesGuardrailCodeCallback = new gcp.ces.Guardrail("ces_guardrail_code_callback", { * guardrailId: "guardrail-id", * location: cesAppForGuardrail.location, * app: cesAppForGuardrail.appId, * displayName: "my-guardrail", * description: "Guardrail description", * action: { * generativeAnswer: { * prompt: "example_prompt", * }, * }, * enabled: true, * codeCallback: { * beforeAgentCallback: { * description: "Example callback", * disabled: true, * pythonCode: `def callback(context): * return {'override': False}`, * }, * afterAgentCallback: { * description: "Example callback", * disabled: true, * pythonCode: `def callback(context): * return {'override': False}`, * }, * beforeModelCallback: { * description: "Example callback", * disabled: true, * pythonCode: `def callback(context): * return {'override': False}`, * }, * afterModelCallback: { * description: "Example callback", * disabled: true, * pythonCode: `def callback(context): * return {'override': False}`, * }, * }, * }); * ``` * ### Ces Guardrail Llm Policy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cesAppForGuardrail = new gcp.ces.App("ces_app_for_guardrail", { * appId: "app-id", * location: "us", * description: "App used as parent for CES Toolset example", * displayName: "my-app", * languageSettings: { * defaultLanguageCode: "en-US", * supportedLanguageCodes: [ * "es-ES", * "fr-FR", * ], * enableMultilingualSupport: true, * fallbackAction: "escalate", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesGuardrailLlmPolicy = new gcp.ces.Guardrail("ces_guardrail_llm_policy", { * guardrailId: "guardrail-id", * location: cesAppForGuardrail.location, * app: cesAppForGuardrail.appId, * displayName: "my-guardrail", * description: "Guardrail description", * action: { * generativeAnswer: { * prompt: "example_prompt", * }, * }, * enabled: true, * llmPolicy: { * maxConversationMessages: 10, * modelSettings: { * model: "gemini-2.5-flash", * temperature: 50, * }, * prompt: "example_prompt", * policyScope: "USER_QUERY", * failOpen: true, * allowShortUtterance: true, * }, * }); * ``` * * ## Import * * Guardrail can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/apps/{{app}}/guardrails/{{name}}` * * * `{{project}}/{{location}}/{{app}}/{{name}}` * * * `{{location}}/{{app}}/{{name}}` * * When using the `pulumi import` command, Guardrail can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:ces/guardrail:Guardrail default projects/{{project}}/locations/{{location}}/apps/{{app}}/guardrails/{{name}} * ``` * * ```sh * $ pulumi import gcp:ces/guardrail:Guardrail default {{project}}/{{location}}/{{app}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:ces/guardrail:Guardrail default {{location}}/{{app}}/{{name}} * ``` */ export declare class Guardrail extends pulumi.CustomResource { /** * Get an existing Guardrail 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, state?: GuardrailState, opts?: pulumi.CustomResourceOptions): Guardrail; /** * Returns true if the given object is an instance of Guardrail. 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 Guardrail; /** * Action that is taken when a certain precondition is met. * Structure is documented below. */ readonly action: pulumi.Output; /** * Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. */ readonly app: pulumi.Output; /** * Guardrail that blocks the conversation based on the code callbacks * provided. * Structure is documented below. */ readonly codeCallback: pulumi.Output; /** * Guardrail that bans certain content from being used in the conversation. * Structure is documented below. */ readonly contentFilter: pulumi.Output; /** * Timestamp when the guardrail was created. */ readonly createTime: pulumi.Output; /** * Description of the guardrail. */ readonly description: pulumi.Output; /** * Display name of the guardrail. */ readonly displayName: pulumi.Output; /** * Whether the guardrail is enabled. */ readonly enabled: pulumi.Output; /** * Etag used to ensure the object hasn't changed during a read-modify-write * operation. If the etag is empty, the update will overwrite any concurrent * changes. */ readonly etag: pulumi.Output; /** * The ID to use for the guardrail, which will become the final component of * the guardrail's resource name. If not provided, a unique ID will be * automatically assigned for the guardrail. */ readonly guardrailId: pulumi.Output; /** * Guardrail that blocks the conversation if the LLM response is considered * violating the policy based on the LLM classification. * Structure is documented below. */ readonly llmPolicy: pulumi.Output; /** * Guardrail that blocks the conversation if the input is considered unsafe * based on the LLM classification. * Structure is documented below. */ readonly llmPromptSecurity: pulumi.Output; /** * Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. */ readonly location: pulumi.Output; /** * Model safety settings overrides. When this is set, it will override the * default settings and trigger the guardrail if the response is considered * unsafe. * Structure is documented below. */ readonly modelSafety: pulumi.Output; /** * Identifier. The unique identifier of the guardrail. * Format: * `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}` */ readonly name: pulumi.Output; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ readonly project: pulumi.Output; /** * Timestamp when the guardrail was last updated. */ readonly updateTime: pulumi.Output; /** * Create a Guardrail 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: GuardrailArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Guardrail resources. */ export interface GuardrailState { /** * Action that is taken when a certain precondition is met. * Structure is documented below. */ action?: pulumi.Input; /** * Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. */ app?: pulumi.Input; /** * Guardrail that blocks the conversation based on the code callbacks * provided. * Structure is documented below. */ codeCallback?: pulumi.Input; /** * Guardrail that bans certain content from being used in the conversation. * Structure is documented below. */ contentFilter?: pulumi.Input; /** * Timestamp when the guardrail was created. */ createTime?: pulumi.Input; /** * Description of the guardrail. */ description?: pulumi.Input; /** * Display name of the guardrail. */ displayName?: pulumi.Input; /** * Whether the guardrail is enabled. */ enabled?: pulumi.Input; /** * Etag used to ensure the object hasn't changed during a read-modify-write * operation. If the etag is empty, the update will overwrite any concurrent * changes. */ etag?: pulumi.Input; /** * The ID to use for the guardrail, which will become the final component of * the guardrail's resource name. If not provided, a unique ID will be * automatically assigned for the guardrail. */ guardrailId?: pulumi.Input; /** * Guardrail that blocks the conversation if the LLM response is considered * violating the policy based on the LLM classification. * Structure is documented below. */ llmPolicy?: pulumi.Input; /** * Guardrail that blocks the conversation if the input is considered unsafe * based on the LLM classification. * Structure is documented below. */ llmPromptSecurity?: pulumi.Input; /** * Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. */ location?: pulumi.Input; /** * Model safety settings overrides. When this is set, it will override the * default settings and trigger the guardrail if the response is considered * unsafe. * Structure is documented below. */ modelSafety?: pulumi.Input; /** * Identifier. The unique identifier of the guardrail. * Format: * `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}` */ name?: pulumi.Input; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ project?: pulumi.Input; /** * Timestamp when the guardrail was last updated. */ updateTime?: pulumi.Input; } /** * The set of arguments for constructing a Guardrail resource. */ export interface GuardrailArgs { /** * Action that is taken when a certain precondition is met. * Structure is documented below. */ action?: pulumi.Input; /** * Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. */ app: pulumi.Input; /** * Guardrail that blocks the conversation based on the code callbacks * provided. * Structure is documented below. */ codeCallback?: pulumi.Input; /** * Guardrail that bans certain content from being used in the conversation. * Structure is documented below. */ contentFilter?: pulumi.Input; /** * Description of the guardrail. */ description?: pulumi.Input; /** * Display name of the guardrail. */ displayName: pulumi.Input; /** * Whether the guardrail is enabled. */ enabled?: pulumi.Input; /** * The ID to use for the guardrail, which will become the final component of * the guardrail's resource name. If not provided, a unique ID will be * automatically assigned for the guardrail. */ guardrailId: pulumi.Input; /** * Guardrail that blocks the conversation if the LLM response is considered * violating the policy based on the LLM classification. * Structure is documented below. */ llmPolicy?: pulumi.Input; /** * Guardrail that blocks the conversation if the input is considered unsafe * based on the LLM classification. * Structure is documented below. */ llmPromptSecurity?: pulumi.Input; /** * Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. */ location: pulumi.Input; /** * Model safety settings overrides. When this is set, it will override the * default settings and trigger the guardrail if the response is considered * unsafe. * Structure is documented below. */ modelSafety?: pulumi.Input; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ project?: pulumi.Input; }