forked from aws/aws-sdk-go-v2
/
api.go
180 lines (151 loc) · 5.05 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package translate
import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)
const opText = "TranslateText"
// TextRequest is a API request type for the Text API operation.
type TextRequest struct {
*aws.Request
Input *TextInput
Copy func(*TextInput) TextRequest
}
// Send marshals and sends the Text API request.
func (r TextRequest) Send() (*TextOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*TextOutput), nil
}
// TextRequest returns a request value for making API operation for
// Amazon Translate.
//
// Translates input text from the source language to the target language. You
// can translate between English (en) and one of the following languages, or
// between one of the following languages and English.
//
// * Arabic (ar)
//
// * Chinese (Simplified) (zh)
//
// * French (fr)
//
// * German (de)
//
// * Portuguese (pt)
//
// * Spanish (es)
//
// To have Amazon Translate determine the source language of your text, you
// can specify auto in the SourceLanguageCode field. If you specify auto, Amazon
// Translate will call Amazon Comprehend to determine the source language.
//
// // Example sending a request using the TextRequest method.
// req := client.TextRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/translate-2017-07-01/Text
func (c *Translate) TextRequest(input *TextInput) TextRequest {
op := &aws.Operation{
Name: opText,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &TextInput{}
}
output := &TextOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return TextRequest{Request: req, Input: input, Copy: c.TextRequest}
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/translate-2017-07-01/TextRequest
type TextInput struct {
_ struct{} `type:"structure"`
// One of the supported language codes for the source text. If the TargetLanguageCode
// is not "en", the SourceLanguageCode must be "en".
//
// To have Amazon Translate determine the source language of your text, you
// can specify auto in the SourceLanguageCode field. If you specify auto, Amazon
// Translate will call Amazon Comprehend to determine the source language.
//
// SourceLanguageCode is a required field
SourceLanguageCode *string `min:"2" type:"string" required:"true"`
// One of the supported language codes for the target text. If the SourceLanguageCode
// is not "en", the TargetLanguageCode must be "en".
//
// TargetLanguageCode is a required field
TargetLanguageCode *string `min:"2" type:"string" required:"true"`
// The text to translate.
//
// Text is a required field
Text *string `min:"1" type:"string" required:"true"`
}
// String returns the string representation
func (s TextInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s TextInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *TextInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "TextInput"}
if s.SourceLanguageCode == nil {
invalidParams.Add(aws.NewErrParamRequired("SourceLanguageCode"))
}
if s.SourceLanguageCode != nil && len(*s.SourceLanguageCode) < 2 {
invalidParams.Add(aws.NewErrParamMinLen("SourceLanguageCode", 2))
}
if s.TargetLanguageCode == nil {
invalidParams.Add(aws.NewErrParamRequired("TargetLanguageCode"))
}
if s.TargetLanguageCode != nil && len(*s.TargetLanguageCode) < 2 {
invalidParams.Add(aws.NewErrParamMinLen("TargetLanguageCode", 2))
}
if s.Text == nil {
invalidParams.Add(aws.NewErrParamRequired("Text"))
}
if s.Text != nil && len(*s.Text) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("Text", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/translate-2017-07-01/TextResponse
type TextOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
// The language code for the language of the input text.
//
// SourceLanguageCode is a required field
SourceLanguageCode *string `min:"2" type:"string" required:"true"`
// The language code for the language of the translated text.
//
// TargetLanguageCode is a required field
TargetLanguageCode *string `min:"2" type:"string" required:"true"`
// The text translated into the target language.
//
// TranslatedText is a required field
TranslatedText *string `min:"1" type:"string" required:"true"`
}
// String returns the string representation
func (s TextOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s TextOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s TextOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}