@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
582 lines • 21.5 kB
TypeScript
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-3.0-flash-001",
* 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-3.0-flash-001",
* 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}}
* $ pulumi import gcp:ces/guardrail:Guardrail default {{project}}/{{location}}/{{app}}/{{name}}
* $ 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<pulumi.ID>, 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<outputs.ces.GuardrailAction | undefined>;
/**
* 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<string>;
/**
* Guardrail that blocks the conversation based on the code callbacks
* provided.
* Structure is documented below.
*/
readonly codeCallback: pulumi.Output<outputs.ces.GuardrailCodeCallback | undefined>;
/**
* Guardrail that bans certain content from being used in the conversation.
* Structure is documented below.
*/
readonly contentFilter: pulumi.Output<outputs.ces.GuardrailContentFilter | undefined>;
/**
* Timestamp when the guardrail was created.
*/
readonly createTime: pulumi.Output<string>;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
readonly deletionPolicy: pulumi.Output<string>;
/**
* Description of the guardrail.
*/
readonly description: pulumi.Output<string | undefined>;
/**
* Display name of the guardrail.
*/
readonly displayName: pulumi.Output<string>;
/**
* Whether the guardrail is enabled.
*/
readonly enabled: pulumi.Output<boolean | undefined>;
/**
* 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<string>;
/**
* 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<string>;
/**
* 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<outputs.ces.GuardrailLlmPolicy | undefined>;
/**
* Guardrail that blocks the conversation if the input is considered unsafe
* based on the LLM classification.
* Structure is documented below.
*/
readonly llmPromptSecurity: pulumi.Output<outputs.ces.GuardrailLlmPromptSecurity | undefined>;
/**
* 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<string>;
/**
* 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<outputs.ces.GuardrailModelSafety | undefined>;
/**
* Identifier. The unique identifier of the guardrail.
* Format:
* `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}`
*/
readonly name: pulumi.Output<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
readonly project: pulumi.Output<string>;
/**
* Timestamp when the guardrail was last updated.
*/
readonly updateTime: pulumi.Output<string>;
/**
* 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<inputs.ces.GuardrailAction | undefined>;
/**
* 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<string | undefined>;
/**
* Guardrail that blocks the conversation based on the code callbacks
* provided.
* Structure is documented below.
*/
codeCallback?: pulumi.Input<inputs.ces.GuardrailCodeCallback | undefined>;
/**
* Guardrail that bans certain content from being used in the conversation.
* Structure is documented below.
*/
contentFilter?: pulumi.Input<inputs.ces.GuardrailContentFilter | undefined>;
/**
* Timestamp when the guardrail was created.
*/
createTime?: pulumi.Input<string | undefined>;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* Description of the guardrail.
*/
description?: pulumi.Input<string | undefined>;
/**
* Display name of the guardrail.
*/
displayName?: pulumi.Input<string | undefined>;
/**
* Whether the guardrail is enabled.
*/
enabled?: pulumi.Input<boolean | undefined>;
/**
* 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<string | undefined>;
/**
* 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<string | undefined>;
/**
* 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<inputs.ces.GuardrailLlmPolicy | undefined>;
/**
* Guardrail that blocks the conversation if the input is considered unsafe
* based on the LLM classification.
* Structure is documented below.
*/
llmPromptSecurity?: pulumi.Input<inputs.ces.GuardrailLlmPromptSecurity | undefined>;
/**
* 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<string | undefined>;
/**
* 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<inputs.ces.GuardrailModelSafety | undefined>;
/**
* Identifier. The unique identifier of the guardrail.
* Format:
* `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}`
*/
name?: pulumi.Input<string | undefined>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* Timestamp when the guardrail was last updated.
*/
updateTime?: pulumi.Input<string | undefined>;
}
/**
* 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<inputs.ces.GuardrailAction | undefined>;
/**
* 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<string>;
/**
* Guardrail that blocks the conversation based on the code callbacks
* provided.
* Structure is documented below.
*/
codeCallback?: pulumi.Input<inputs.ces.GuardrailCodeCallback | undefined>;
/**
* Guardrail that bans certain content from being used in the conversation.
* Structure is documented below.
*/
contentFilter?: pulumi.Input<inputs.ces.GuardrailContentFilter | undefined>;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* Description of the guardrail.
*/
description?: pulumi.Input<string | undefined>;
/**
* Display name of the guardrail.
*/
displayName: pulumi.Input<string>;
/**
* Whether the guardrail is enabled.
*/
enabled?: pulumi.Input<boolean | undefined>;
/**
* 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<string>;
/**
* 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<inputs.ces.GuardrailLlmPolicy | undefined>;
/**
* Guardrail that blocks the conversation if the input is considered unsafe
* based on the LLM classification.
* Structure is documented below.
*/
llmPromptSecurity?: pulumi.Input<inputs.ces.GuardrailLlmPromptSecurity | undefined>;
/**
* 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<string>;
/**
* 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<inputs.ces.GuardrailModelSafety | undefined>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
}
//# sourceMappingURL=guardrail.d.ts.map