|
| 1 | +// smithy-typescript generated code |
| 2 | +import { getEndpointPlugin } from "@smithy/middleware-endpoint"; |
| 3 | +import { getSerdePlugin } from "@smithy/middleware-serde"; |
| 4 | +import { Command as $Command } from "@smithy/smithy-client"; |
| 5 | +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; |
| 6 | + |
| 7 | +import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient"; |
| 8 | +import { commonParams } from "../endpoint/EndpointParameters"; |
| 9 | +import { ApplyGuardrailRequest, ApplyGuardrailResponse } from "../models/models_0"; |
| 10 | +import { de_ApplyGuardrailCommand, se_ApplyGuardrailCommand } from "../protocols/Aws_restJson1"; |
| 11 | + |
| 12 | +/** |
| 13 | + * @public |
| 14 | + */ |
| 15 | +export type { __MetadataBearer }; |
| 16 | +export { $Command }; |
| 17 | +/** |
| 18 | + * @public |
| 19 | + * |
| 20 | + * The input for {@link ApplyGuardrailCommand}. |
| 21 | + */ |
| 22 | +export interface ApplyGuardrailCommandInput extends ApplyGuardrailRequest {} |
| 23 | +/** |
| 24 | + * @public |
| 25 | + * |
| 26 | + * The output of {@link ApplyGuardrailCommand}. |
| 27 | + */ |
| 28 | +export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __MetadataBearer {} |
| 29 | + |
| 30 | +/** |
| 31 | + * <p>The action to apply a guardrail.</p> |
| 32 | + * @example |
| 33 | + * Use a bare-bones client and the command you need to make an API call. |
| 34 | + * ```javascript |
| 35 | + * import { BedrockRuntimeClient, ApplyGuardrailCommand } from "@aws-sdk/client-bedrock-runtime"; // ES Modules import |
| 36 | + * // const { BedrockRuntimeClient, ApplyGuardrailCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import |
| 37 | + * const client = new BedrockRuntimeClient(config); |
| 38 | + * const input = { // ApplyGuardrailRequest |
| 39 | + * guardrailIdentifier: "STRING_VALUE", // required |
| 40 | + * guardrailVersion: "STRING_VALUE", // required |
| 41 | + * source: "INPUT" || "OUTPUT", // required |
| 42 | + * content: [ // GuardrailContentBlockList // required |
| 43 | + * { // GuardrailContentBlock Union: only one key present |
| 44 | + * text: { // GuardrailTextBlock |
| 45 | + * text: "STRING_VALUE", // required |
| 46 | + * qualifiers: [ // GuardrailContentQualifierList |
| 47 | + * "grounding_source" || "query" || "guard_content", |
| 48 | + * ], |
| 49 | + * }, |
| 50 | + * }, |
| 51 | + * ], |
| 52 | + * }; |
| 53 | + * const command = new ApplyGuardrailCommand(input); |
| 54 | + * const response = await client.send(command); |
| 55 | + * // { // ApplyGuardrailResponse |
| 56 | + * // usage: { // GuardrailUsage |
| 57 | + * // topicPolicyUnits: Number("int"), // required |
| 58 | + * // contentPolicyUnits: Number("int"), // required |
| 59 | + * // wordPolicyUnits: Number("int"), // required |
| 60 | + * // sensitiveInformationPolicyUnits: Number("int"), // required |
| 61 | + * // sensitiveInformationPolicyFreeUnits: Number("int"), // required |
| 62 | + * // contextualGroundingPolicyUnits: Number("int"), // required |
| 63 | + * // }, |
| 64 | + * // action: "NONE" || "GUARDRAIL_INTERVENED", // required |
| 65 | + * // outputs: [ // GuardrailOutputContentList // required |
| 66 | + * // { // GuardrailOutputContent |
| 67 | + * // text: "STRING_VALUE", |
| 68 | + * // }, |
| 69 | + * // ], |
| 70 | + * // assessments: [ // GuardrailAssessmentList // required |
| 71 | + * // { // GuardrailAssessment |
| 72 | + * // topicPolicy: { // GuardrailTopicPolicyAssessment |
| 73 | + * // topics: [ // GuardrailTopicList // required |
| 74 | + * // { // GuardrailTopic |
| 75 | + * // name: "STRING_VALUE", // required |
| 76 | + * // type: "DENY", // required |
| 77 | + * // action: "BLOCKED", // required |
| 78 | + * // }, |
| 79 | + * // ], |
| 80 | + * // }, |
| 81 | + * // contentPolicy: { // GuardrailContentPolicyAssessment |
| 82 | + * // filters: [ // GuardrailContentFilterList // required |
| 83 | + * // { // GuardrailContentFilter |
| 84 | + * // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required |
| 85 | + * // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required |
| 86 | + * // action: "BLOCKED", // required |
| 87 | + * // }, |
| 88 | + * // ], |
| 89 | + * // }, |
| 90 | + * // wordPolicy: { // GuardrailWordPolicyAssessment |
| 91 | + * // customWords: [ // GuardrailCustomWordList // required |
| 92 | + * // { // GuardrailCustomWord |
| 93 | + * // match: "STRING_VALUE", // required |
| 94 | + * // action: "BLOCKED", // required |
| 95 | + * // }, |
| 96 | + * // ], |
| 97 | + * // managedWordLists: [ // GuardrailManagedWordList // required |
| 98 | + * // { // GuardrailManagedWord |
| 99 | + * // match: "STRING_VALUE", // required |
| 100 | + * // type: "PROFANITY", // required |
| 101 | + * // action: "BLOCKED", // required |
| 102 | + * // }, |
| 103 | + * // ], |
| 104 | + * // }, |
| 105 | + * // sensitiveInformationPolicy: { // GuardrailSensitiveInformationPolicyAssessment |
| 106 | + * // piiEntities: [ // GuardrailPiiEntityFilterList // required |
| 107 | + * // { // GuardrailPiiEntityFilter |
| 108 | + * // match: "STRING_VALUE", // required |
| 109 | + * // type: "ADDRESS" || "AGE" || "AWS_ACCESS_KEY" || "AWS_SECRET_KEY" || "CA_HEALTH_NUMBER" || "CA_SOCIAL_INSURANCE_NUMBER" || "CREDIT_DEBIT_CARD_CVV" || "CREDIT_DEBIT_CARD_EXPIRY" || "CREDIT_DEBIT_CARD_NUMBER" || "DRIVER_ID" || "EMAIL" || "INTERNATIONAL_BANK_ACCOUNT_NUMBER" || "IP_ADDRESS" || "LICENSE_PLATE" || "MAC_ADDRESS" || "NAME" || "PASSWORD" || "PHONE" || "PIN" || "SWIFT_CODE" || "UK_NATIONAL_HEALTH_SERVICE_NUMBER" || "UK_NATIONAL_INSURANCE_NUMBER" || "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER" || "URL" || "USERNAME" || "US_BANK_ACCOUNT_NUMBER" || "US_BANK_ROUTING_NUMBER" || "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER" || "US_PASSPORT_NUMBER" || "US_SOCIAL_SECURITY_NUMBER" || "VEHICLE_IDENTIFICATION_NUMBER", // required |
| 110 | + * // action: "ANONYMIZED" || "BLOCKED", // required |
| 111 | + * // }, |
| 112 | + * // ], |
| 113 | + * // regexes: [ // GuardrailRegexFilterList // required |
| 114 | + * // { // GuardrailRegexFilter |
| 115 | + * // name: "STRING_VALUE", |
| 116 | + * // match: "STRING_VALUE", |
| 117 | + * // regex: "STRING_VALUE", |
| 118 | + * // action: "ANONYMIZED" || "BLOCKED", // required |
| 119 | + * // }, |
| 120 | + * // ], |
| 121 | + * // }, |
| 122 | + * // contextualGroundingPolicy: { // GuardrailContextualGroundingPolicyAssessment |
| 123 | + * // filters: [ // GuardrailContextualGroundingFilters |
| 124 | + * // { // GuardrailContextualGroundingFilter |
| 125 | + * // type: "GROUNDING" || "RELEVANCE", // required |
| 126 | + * // threshold: Number("double"), // required |
| 127 | + * // score: Number("double"), // required |
| 128 | + * // action: "BLOCKED" || "NONE", // required |
| 129 | + * // }, |
| 130 | + * // ], |
| 131 | + * // }, |
| 132 | + * // }, |
| 133 | + * // ], |
| 134 | + * // }; |
| 135 | + * |
| 136 | + * ``` |
| 137 | + * |
| 138 | + * @param ApplyGuardrailCommandInput - {@link ApplyGuardrailCommandInput} |
| 139 | + * @returns {@link ApplyGuardrailCommandOutput} |
| 140 | + * @see {@link ApplyGuardrailCommandInput} for command's `input` shape. |
| 141 | + * @see {@link ApplyGuardrailCommandOutput} for command's `response` shape. |
| 142 | + * @see {@link BedrockRuntimeClientResolvedConfig | config} for BedrockRuntimeClient's `config` shape. |
| 143 | + * |
| 144 | + * @throws {@link AccessDeniedException} (client fault) |
| 145 | + * <p>The request is denied because of missing access permissions.</p> |
| 146 | + * |
| 147 | + * @throws {@link InternalServerException} (server fault) |
| 148 | + * <p>An internal server error occurred. Retry your request.</p> |
| 149 | + * |
| 150 | + * @throws {@link ResourceNotFoundException} (client fault) |
| 151 | + * <p>The specified resource ARN was not found. Check the ARN and try your request again.</p> |
| 152 | + * |
| 153 | + * @throws {@link ServiceQuotaExceededException} (client fault) |
| 154 | + * <p>The number of requests exceeds the service quota. Resubmit your request later.</p> |
| 155 | + * |
| 156 | + * @throws {@link ThrottlingException} (client fault) |
| 157 | + * <p>The number of requests exceeds the limit. Resubmit your request later.</p> |
| 158 | + * |
| 159 | + * @throws {@link ValidationException} (client fault) |
| 160 | + * <p>Input validation failed. Check your request parameters and retry the request.</p> |
| 161 | + * |
| 162 | + * @throws {@link BedrockRuntimeServiceException} |
| 163 | + * <p>Base exception class for all service exceptions from BedrockRuntime service.</p> |
| 164 | + * |
| 165 | + * @public |
| 166 | + */ |
| 167 | +export class ApplyGuardrailCommand extends $Command |
| 168 | + .classBuilder< |
| 169 | + ApplyGuardrailCommandInput, |
| 170 | + ApplyGuardrailCommandOutput, |
| 171 | + BedrockRuntimeClientResolvedConfig, |
| 172 | + ServiceInputTypes, |
| 173 | + ServiceOutputTypes |
| 174 | + >() |
| 175 | + .ep({ |
| 176 | + ...commonParams, |
| 177 | + }) |
| 178 | + .m(function (this: any, Command: any, cs: any, config: BedrockRuntimeClientResolvedConfig, o: any) { |
| 179 | + return [ |
| 180 | + getSerdePlugin(config, this.serialize, this.deserialize), |
| 181 | + getEndpointPlugin(config, Command.getEndpointParameterInstructions()), |
| 182 | + ]; |
| 183 | + }) |
| 184 | + .s("AmazonBedrockFrontendService", "ApplyGuardrail", {}) |
| 185 | + .n("BedrockRuntimeClient", "ApplyGuardrailCommand") |
| 186 | + .f(void 0, void 0) |
| 187 | + .ser(se_ApplyGuardrailCommand) |
| 188 | + .de(de_ApplyGuardrailCommand) |
| 189 | + .build() {} |
0 commit comments