Skip to content

Commit

Permalink
feat: support DetectToxicContent
Browse files Browse the repository at this point in the history
  • Loading branch information
shreemaan-abhishek committed Aug 29, 2024
1 parent 2137beb commit bb3cc50
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
63 changes: 63 additions & 0 deletions src/resty/aws/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,66 @@ local aws_config = {
api = {},
}

local detect_toxic_content_spec = {
name = "DetectToxicContent",
http = {
method = "POST",
requestUri = "/"
},
input = {
type = "structure",
members = {
LanguageCode = {
shape = "LanguageCode"
},
TextSegments = {
member = {
Text = {
shape = "CustomerInputString"
}
},
type = "list"
}
},
required = {
"TextSegments",
"LanguageCode"
},
},
output = {
type = "structure",
members = {
ResultList = {
member = {
Labels = {
shape = "ListOfLabels"
},
Toxicity = {
shape = "Float"
}
},
type = "list"
}
},
sensitive = true,
},
errors = {
{
shape = "InvalidRequestException"
},
{
shape = "TextSizeLimitExceededException"
},
{
shape = "UnsupportedLanguageException"
},
{
shape = "InternalServerException"
}
},
}


local load_api
do
-- The API table is a map, where the index is the service-name. The value is a table.
Expand Down Expand Up @@ -119,6 +179,9 @@ do
end

api = require(module_name)
if module_name == "resty.aws.raw-api.comprehend-2017-11-27" or module_name == "resty.aws.raw-api.comprehend-latest" then
api.operations["DetectToxicContent"] = detect_toxic_content_spec
end
dereference_service(api)

cache[module_name] = api
Expand Down
2 changes: 1 addition & 1 deletion src/resty/aws/request/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ local function build_request(operation, config, params)
local body_tbl = {}

if config.signingName or config.targetPrefix then
request.headers["X-Amz-Target"] = (config.signingName or config.targetPrefix) .. "." .. operation.name
request.headers["X-Amz-Target"] = (config.targetPrefix or config.signingName) .. "." .. operation.name
end
if config.protocol == "query" then
request.query["Action"] = operation.name
Expand Down

0 comments on commit bb3cc50

Please sign in to comment.