Skip to content

Commit 6522b67

Browse files
feat: support DetectToxicContent (#7)
1 parent 2137beb commit 6522b67

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

src/resty/aws/init.lua

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,66 @@ local aws_config = {
7878
api = {},
7979
}
8080

81+
local detect_toxic_content_spec = {
82+
name = "DetectToxicContent",
83+
http = {
84+
method = "POST",
85+
requestUri = "/"
86+
},
87+
input = {
88+
type = "structure",
89+
members = {
90+
LanguageCode = {
91+
shape = "LanguageCode"
92+
},
93+
TextSegments = {
94+
member = {
95+
Text = {
96+
shape = "CustomerInputString"
97+
}
98+
},
99+
type = "list"
100+
}
101+
},
102+
required = {
103+
"TextSegments",
104+
"LanguageCode"
105+
},
106+
},
107+
output = {
108+
type = "structure",
109+
members = {
110+
ResultList = {
111+
member = {
112+
Labels = {
113+
shape = "ListOfLabels"
114+
},
115+
Toxicity = {
116+
shape = "Float"
117+
}
118+
},
119+
type = "list"
120+
}
121+
},
122+
sensitive = true,
123+
},
124+
errors = {
125+
{
126+
shape = "InvalidRequestException"
127+
},
128+
{
129+
shape = "TextSizeLimitExceededException"
130+
},
131+
{
132+
shape = "UnsupportedLanguageException"
133+
},
134+
{
135+
shape = "InternalServerException"
136+
}
137+
},
138+
}
139+
140+
81141
local load_api
82142
do
83143
-- The API table is a map, where the index is the service-name. The value is a table.
@@ -119,6 +179,9 @@ do
119179
end
120180

121181
api = require(module_name)
182+
if module_name == "resty.aws.raw-api.comprehend-2017-11-27" or module_name == "resty.aws.raw-api.comprehend-latest" then
183+
api.operations["DetectToxicContent"] = detect_toxic_content_spec
184+
end
122185
dereference_service(api)
123186

124187
cache[module_name] = api

src/resty/aws/request/build.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ local function build_request(operation, config, params)
106106
local body_tbl = {}
107107

108108
if config.signingName or config.targetPrefix then
109-
request.headers["X-Amz-Target"] = (config.signingName or config.targetPrefix) .. "." .. operation.name
109+
if operation.name == "DetectToxicContent" then
110+
request.headers["X-Amz-Target"] = (config.targetPrefix or config.signingName) .. "." .. operation.name
111+
else
112+
request.headers["X-Amz-Target"] = (config.signingName or config.targetPrefix) .. "." .. operation.name
113+
end
110114
end
111115
if config.protocol == "query" then
112116
request.query["Action"] = operation.name

0 commit comments

Comments
 (0)