1// Copyright 2016 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Package translate provides access to the Translate API.
16//
17// See https://developers.google.com/translate/v2/using_rest
18//
19// Usage example:
20//
21//   import "cloud.google.com/go/translate/internal/translate/v2"
22//   ...
23//   translateService, err := translate.New(oauthHttpClient)
24package translate // import "cloud.google.com/go/translate/internal/translate/v2"
25
26import (
27	"bytes"
28	"context"
29	"encoding/json"
30	"errors"
31	"fmt"
32	"io"
33	"net/http"
34	"net/url"
35	"strconv"
36	"strings"
37
38	gensupport "google.golang.org/api/gensupport"
39	googleapi "google.golang.org/api/googleapi"
40)
41
42// Always reference these packages, just in case the auto-generated code
43// below doesn't.
44var _ = bytes.NewBuffer
45var _ = strconv.Itoa
46var _ = fmt.Sprintf
47var _ = json.NewDecoder
48var _ = io.Copy
49var _ = url.Parse
50var _ = gensupport.MarshalJSON
51var _ = googleapi.Version
52var _ = errors.New
53var _ = strings.Replace
54var _ = context.Canceled
55
56const apiId = "translate:v2"
57const apiName = "translate"
58const apiVersion = "v2"
59const basePath = "https://translation.googleapis.com/language/translate/"
60
61// OAuth2 scopes used by this API.
62const (
63	// View and manage your data across Google Cloud Platform services
64	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
65)
66
67func New(client *http.Client) (*Service, error) {
68	if client == nil {
69		return nil, errors.New("client is nil")
70	}
71	s := &Service{client: client, BasePath: basePath}
72	s.Detections = NewDetectionsService(s)
73	s.Languages = NewLanguagesService(s)
74	s.Translations = NewTranslationsService(s)
75	return s, nil
76}
77
78type Service struct {
79	client    *http.Client
80	BasePath  string // API endpoint base URL
81	UserAgent string // optional additional User-Agent fragment
82
83	Detections *DetectionsService
84
85	Languages *LanguagesService
86
87	Translations *TranslationsService
88}
89
90func (s *Service) userAgent() string {
91	if s.UserAgent == "" {
92		return googleapi.UserAgent
93	}
94	return googleapi.UserAgent + " " + s.UserAgent
95}
96
97func NewDetectionsService(s *Service) *DetectionsService {
98	rs := &DetectionsService{s: s}
99	return rs
100}
101
102type DetectionsService struct {
103	s *Service
104}
105
106func NewLanguagesService(s *Service) *LanguagesService {
107	rs := &LanguagesService{s: s}
108	return rs
109}
110
111type LanguagesService struct {
112	s *Service
113}
114
115func NewTranslationsService(s *Service) *TranslationsService {
116	rs := &TranslationsService{s: s}
117	return rs
118}
119
120type TranslationsService struct {
121	s *Service
122}
123
124type DetectionsListResponse struct {
125	// Detections: A detections contains detection results of several text
126	Detections [][]*DetectionsResourceItem `json:"detections,omitempty"`
127
128	// ServerResponse contains the HTTP response code and headers from the
129	// server.
130	googleapi.ServerResponse `json:"-"`
131
132	// ForceSendFields is a list of field names (e.g. "Detections") to
133	// unconditionally include in API requests. By default, fields with
134	// empty values are omitted from API requests. However, any non-pointer,
135	// non-interface field appearing in ForceSendFields will be sent to the
136	// server regardless of whether the field is empty or not. This may be
137	// used to include empty fields in Patch requests.
138	ForceSendFields []string `json:"-"`
139
140	// NullFields is a list of field names (e.g. "Detections") to include in
141	// API requests with the JSON null value. By default, fields with empty
142	// values are omitted from API requests. However, any field with an
143	// empty value appearing in NullFields will be sent to the server as
144	// null. It is an error if a field in this list has a non-empty value.
145	// This may be used to include null fields in Patch requests.
146	NullFields []string `json:"-"`
147}
148
149func (s *DetectionsListResponse) MarshalJSON() ([]byte, error) {
150	type noMethod DetectionsListResponse
151	raw := noMethod(*s)
152	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
153}
154
155type DetectionsResourceItem struct {
156	// Confidence: The confidence of the detection resul of this language.
157	Confidence float64 `json:"confidence,omitempty"`
158
159	// IsReliable: A boolean to indicate is the language detection result
160	// reliable.
161	IsReliable bool `json:"isReliable,omitempty"`
162
163	// Language: The language we detect
164	Language string `json:"language,omitempty"`
165
166	// ForceSendFields is a list of field names (e.g. "Confidence") to
167	// unconditionally include in API requests. By default, fields with
168	// empty values are omitted from API requests. However, any non-pointer,
169	// non-interface field appearing in ForceSendFields will be sent to the
170	// server regardless of whether the field is empty or not. This may be
171	// used to include empty fields in Patch requests.
172	ForceSendFields []string `json:"-"`
173
174	// NullFields is a list of field names (e.g. "Confidence") to include in
175	// API requests with the JSON null value. By default, fields with empty
176	// values are omitted from API requests. However, any field with an
177	// empty value appearing in NullFields will be sent to the server as
178	// null. It is an error if a field in this list has a non-empty value.
179	// This may be used to include null fields in Patch requests.
180	NullFields []string `json:"-"`
181}
182
183func (s *DetectionsResourceItem) MarshalJSON() ([]byte, error) {
184	type noMethod DetectionsResourceItem
185	raw := noMethod(*s)
186	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
187}
188
189type LanguagesListResponse struct {
190	// Languages: List of source/target languages supported by the
191	// translation API. If target parameter is unspecified, the list is
192	// sorted by the ASCII code point order of the language code. If target
193	// parameter is specified, the list is sorted by the collation order of
194	// the language name in the target language.
195	Languages []*LanguagesResource `json:"languages,omitempty"`
196
197	// ServerResponse contains the HTTP response code and headers from the
198	// server.
199	googleapi.ServerResponse `json:"-"`
200
201	// ForceSendFields is a list of field names (e.g. "Languages") to
202	// unconditionally include in API requests. By default, fields with
203	// empty values are omitted from API requests. However, any non-pointer,
204	// non-interface field appearing in ForceSendFields will be sent to the
205	// server regardless of whether the field is empty or not. This may be
206	// used to include empty fields in Patch requests.
207	ForceSendFields []string `json:"-"`
208
209	// NullFields is a list of field names (e.g. "Languages") to include in
210	// API requests with the JSON null value. By default, fields with empty
211	// values are omitted from API requests. However, any field with an
212	// empty value appearing in NullFields will be sent to the server as
213	// null. It is an error if a field in this list has a non-empty value.
214	// This may be used to include null fields in Patch requests.
215	NullFields []string `json:"-"`
216}
217
218func (s *LanguagesListResponse) MarshalJSON() ([]byte, error) {
219	type noMethod LanguagesListResponse
220	raw := noMethod(*s)
221	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
222}
223
224type LanguagesResource struct {
225	// Language: The language code.
226	Language string `json:"language,omitempty"`
227
228	// Name: The localized name of the language if target parameter is
229	// given.
230	Name string `json:"name,omitempty"`
231
232	// ForceSendFields is a list of field names (e.g. "Language") to
233	// unconditionally include in API requests. By default, fields with
234	// empty values are omitted from API requests. However, any non-pointer,
235	// non-interface field appearing in ForceSendFields will be sent to the
236	// server regardless of whether the field is empty or not. This may be
237	// used to include empty fields in Patch requests.
238	ForceSendFields []string `json:"-"`
239
240	// NullFields is a list of field names (e.g. "Language") to include in
241	// API requests with the JSON null value. By default, fields with empty
242	// values are omitted from API requests. However, any field with an
243	// empty value appearing in NullFields will be sent to the server as
244	// null. It is an error if a field in this list has a non-empty value.
245	// This may be used to include null fields in Patch requests.
246	NullFields []string `json:"-"`
247}
248
249func (s *LanguagesResource) MarshalJSON() ([]byte, error) {
250	type noMethod LanguagesResource
251	raw := noMethod(*s)
252	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
253}
254
255type TranslationsListResponse struct {
256	// Translations: Translations contains list of translation results of
257	// given text
258	Translations []*TranslationsResource `json:"translations,omitempty"`
259
260	// ServerResponse contains the HTTP response code and headers from the
261	// server.
262	googleapi.ServerResponse `json:"-"`
263
264	// ForceSendFields is a list of field names (e.g. "Translations") to
265	// unconditionally include in API requests. By default, fields with
266	// empty values are omitted from API requests. However, any non-pointer,
267	// non-interface field appearing in ForceSendFields will be sent to the
268	// server regardless of whether the field is empty or not. This may be
269	// used to include empty fields in Patch requests.
270	ForceSendFields []string `json:"-"`
271
272	// NullFields is a list of field names (e.g. "Translations") to include
273	// in API requests with the JSON null value. By default, fields with
274	// empty values are omitted from API requests. However, any field with
275	// an empty value appearing in NullFields will be sent to the server as
276	// null. It is an error if a field in this list has a non-empty value.
277	// This may be used to include null fields in Patch requests.
278	NullFields []string `json:"-"`
279}
280
281func (s *TranslationsListResponse) MarshalJSON() ([]byte, error) {
282	type noMethod TranslationsListResponse
283	raw := noMethod(*s)
284	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
285}
286
287type TranslationsResource struct {
288	// DetectedSourceLanguage: Detected source language if source parameter
289	// is unspecified.
290	DetectedSourceLanguage string `json:"detectedSourceLanguage,omitempty"`
291
292	// Model: Model used for translation.
293	Model string `json:"model,omitempty"`
294
295	// TranslatedText: The translation.
296	TranslatedText string `json:"translatedText,omitempty"`
297
298	// ForceSendFields is a list of field names (e.g.
299	// "DetectedSourceLanguage") to unconditionally include in API requests.
300	// By default, fields with empty values are omitted from API requests.
301	// However, any non-pointer, non-interface field appearing in
302	// ForceSendFields will be sent to the server regardless of whether the
303	// field is empty or not. This may be used to include empty fields in
304	// Patch requests.
305	ForceSendFields []string `json:"-"`
306
307	// NullFields is a list of field names (e.g. "DetectedSourceLanguage")
308	// to include in API requests with the JSON null value. By default,
309	// fields with empty values are omitted from API requests. However, any
310	// field with an empty value appearing in NullFields will be sent to the
311	// server as null. It is an error if a field in this list has a
312	// non-empty value. This may be used to include null fields in Patch
313	// requests.
314	NullFields []string `json:"-"`
315}
316
317func (s *TranslationsResource) MarshalJSON() ([]byte, error) {
318	type noMethod TranslationsResource
319	raw := noMethod(*s)
320	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
321}
322
323// method id "language.detections.list":
324
325type DetectionsListCall struct {
326	s            *Service
327	urlParams_   gensupport.URLParams
328	ifNoneMatch_ string
329	ctx_         context.Context
330	header_      http.Header
331}
332
333// List: Detect the language of text.
334func (r *DetectionsService) List(q []string) *DetectionsListCall {
335	c := &DetectionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
336	c.urlParams_.SetMulti("q", append([]string{}, q...))
337	return c
338}
339
340// Fields allows partial responses to be retrieved. See
341// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
342// for more information.
343func (c *DetectionsListCall) Fields(s ...googleapi.Field) *DetectionsListCall {
344	c.urlParams_.Set("fields", googleapi.CombineFields(s))
345	return c
346}
347
348// IfNoneMatch sets the optional parameter which makes the operation
349// fail if the object's ETag matches the given value. This is useful for
350// getting updates only after the object has changed since the last
351// request. Use googleapi.IsNotModified to check whether the response
352// error from Do is the result of In-None-Match.
353func (c *DetectionsListCall) IfNoneMatch(entityTag string) *DetectionsListCall {
354	c.ifNoneMatch_ = entityTag
355	return c
356}
357
358// Context sets the context to be used in this call's Do method. Any
359// pending HTTP request will be aborted if the provided context is
360// canceled.
361func (c *DetectionsListCall) Context(ctx context.Context) *DetectionsListCall {
362	c.ctx_ = ctx
363	return c
364}
365
366// Header returns an http.Header that can be modified by the caller to
367// add HTTP headers to the request.
368func (c *DetectionsListCall) Header() http.Header {
369	if c.header_ == nil {
370		c.header_ = make(http.Header)
371	}
372	return c.header_
373}
374
375func (c *DetectionsListCall) doRequest(alt string) (*http.Response, error) {
376	reqHeaders := make(http.Header)
377	for k, v := range c.header_ {
378		reqHeaders[k] = v
379	}
380	reqHeaders.Set("User-Agent", c.s.userAgent())
381	if c.ifNoneMatch_ != "" {
382		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
383	}
384	var body io.Reader = nil
385	c.urlParams_.Set("alt", alt)
386	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/detect")
387	urls += "?" + c.urlParams_.Encode()
388	req, _ := http.NewRequest("GET", urls, body)
389	req.Header = reqHeaders
390	return gensupport.SendRequest(c.ctx_, c.s.client, req)
391}
392
393// Do executes the "language.detections.list" call.
394// Exactly one of *DetectionsListResponse or error will be non-nil. Any
395// non-2xx status code is an error. Response headers are in either
396// *DetectionsListResponse.ServerResponse.Header or (if a response was
397// returned at all) in error.(*googleapi.Error).Header. Use
398// googleapi.IsNotModified to check whether the returned error was
399// because http.StatusNotModified was returned.
400func (c *DetectionsListCall) Do(opts ...googleapi.CallOption) (*DetectionsListResponse, error) {
401	gensupport.SetOptions(c.urlParams_, opts...)
402	res, err := c.doRequest("json")
403	if res != nil && res.StatusCode == http.StatusNotModified {
404		if res.Body != nil {
405			res.Body.Close()
406		}
407		return nil, &googleapi.Error{
408			Code:   res.StatusCode,
409			Header: res.Header,
410		}
411	}
412	if err != nil {
413		return nil, err
414	}
415	defer googleapi.CloseBody(res)
416	if err := googleapi.CheckResponse(res); err != nil {
417		return nil, err
418	}
419	ret := &DetectionsListResponse{
420		ServerResponse: googleapi.ServerResponse{
421			Header:         res.Header,
422			HTTPStatusCode: res.StatusCode,
423		},
424	}
425	target := &struct {
426		Data *DetectionsListResponse `json:"data"`
427	}{ret}
428	if err := json.NewDecoder(res.Body).Decode(target); err != nil {
429		return nil, err
430	}
431	return ret, nil
432	// {
433	//   "description": "Detect the language of text.",
434	//   "httpMethod": "GET",
435	//   "id": "language.detections.list",
436	//   "parameterOrder": [
437	//     "q"
438	//   ],
439	//   "parameters": {
440	//     "q": {
441	//       "description": "The text to detect",
442	//       "location": "query",
443	//       "repeated": true,
444	//       "required": true,
445	//       "type": "string"
446	//     }
447	//   },
448	//   "path": "v2/detect",
449	//   "response": {
450	//     "$ref": "DetectionsListResponse"
451	//   }
452	// }
453
454}
455
456// method id "language.languages.list":
457
458type LanguagesListCall struct {
459	s            *Service
460	urlParams_   gensupport.URLParams
461	ifNoneMatch_ string
462	ctx_         context.Context
463	header_      http.Header
464}
465
466// List: List the source/target languages supported by the API
467func (r *LanguagesService) List() *LanguagesListCall {
468	c := &LanguagesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
469	return c
470}
471
472// Target sets the optional parameter "target": the language and
473// collation in which the localized results should be returned
474func (c *LanguagesListCall) Target(target string) *LanguagesListCall {
475	c.urlParams_.Set("target", target)
476	return c
477}
478
479// Fields allows partial responses to be retrieved. See
480// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
481// for more information.
482func (c *LanguagesListCall) Fields(s ...googleapi.Field) *LanguagesListCall {
483	c.urlParams_.Set("fields", googleapi.CombineFields(s))
484	return c
485}
486
487// IfNoneMatch sets the optional parameter which makes the operation
488// fail if the object's ETag matches the given value. This is useful for
489// getting updates only after the object has changed since the last
490// request. Use googleapi.IsNotModified to check whether the response
491// error from Do is the result of In-None-Match.
492func (c *LanguagesListCall) IfNoneMatch(entityTag string) *LanguagesListCall {
493	c.ifNoneMatch_ = entityTag
494	return c
495}
496
497// Context sets the context to be used in this call's Do method. Any
498// pending HTTP request will be aborted if the provided context is
499// canceled.
500func (c *LanguagesListCall) Context(ctx context.Context) *LanguagesListCall {
501	c.ctx_ = ctx
502	return c
503}
504
505// Header returns an http.Header that can be modified by the caller to
506// add HTTP headers to the request.
507func (c *LanguagesListCall) Header() http.Header {
508	if c.header_ == nil {
509		c.header_ = make(http.Header)
510	}
511	return c.header_
512}
513
514func (c *LanguagesListCall) doRequest(alt string) (*http.Response, error) {
515	reqHeaders := make(http.Header)
516	for k, v := range c.header_ {
517		reqHeaders[k] = v
518	}
519	reqHeaders.Set("User-Agent", c.s.userAgent())
520	if c.ifNoneMatch_ != "" {
521		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
522	}
523	var body io.Reader = nil
524	c.urlParams_.Set("alt", alt)
525	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/languages")
526	urls += "?" + c.urlParams_.Encode()
527	req, _ := http.NewRequest("GET", urls, body)
528	req.Header = reqHeaders
529	return gensupport.SendRequest(c.ctx_, c.s.client, req)
530}
531
532// Do executes the "language.languages.list" call.
533// Exactly one of *LanguagesListResponse or error will be non-nil. Any
534// non-2xx status code is an error. Response headers are in either
535// *LanguagesListResponse.ServerResponse.Header or (if a response was
536// returned at all) in error.(*googleapi.Error).Header. Use
537// googleapi.IsNotModified to check whether the returned error was
538// because http.StatusNotModified was returned.
539func (c *LanguagesListCall) Do(opts ...googleapi.CallOption) (*LanguagesListResponse, error) {
540	gensupport.SetOptions(c.urlParams_, opts...)
541	res, err := c.doRequest("json")
542	if res != nil && res.StatusCode == http.StatusNotModified {
543		if res.Body != nil {
544			res.Body.Close()
545		}
546		return nil, &googleapi.Error{
547			Code:   res.StatusCode,
548			Header: res.Header,
549		}
550	}
551	if err != nil {
552		return nil, err
553	}
554	defer googleapi.CloseBody(res)
555	if err := googleapi.CheckResponse(res); err != nil {
556		return nil, err
557	}
558	ret := &LanguagesListResponse{
559		ServerResponse: googleapi.ServerResponse{
560			Header:         res.Header,
561			HTTPStatusCode: res.StatusCode,
562		},
563	}
564	target := &struct {
565		Data *LanguagesListResponse `json:"data"`
566	}{ret}
567	if err := json.NewDecoder(res.Body).Decode(target); err != nil {
568		return nil, err
569	}
570	return ret, nil
571	// {
572	//   "description": "List the source/target languages supported by the API",
573	//   "httpMethod": "GET",
574	//   "id": "language.languages.list",
575	//   "parameters": {
576	//     "target": {
577	//       "description": "the language and collation in which the localized results should be returned",
578	//       "location": "query",
579	//       "type": "string"
580	//     }
581	//   },
582	//   "path": "v2/languages",
583	//   "response": {
584	//     "$ref": "LanguagesListResponse"
585	//   }
586	// }
587
588}
589
590// method id "language.translations.list":
591
592type TranslationsListCall struct {
593	s            *Service
594	urlParams_   gensupport.URLParams
595	ifNoneMatch_ string
596	ctx_         context.Context
597	header_      http.Header
598}
599
600// List: Returns text translations from one language to another.
601func (r *TranslationsService) List(q []string, target string) *TranslationsListCall {
602	c := &TranslationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
603	c.urlParams_.SetMulti("q", append([]string{}, q...))
604	c.urlParams_.Set("target", target)
605	return c
606}
607
608// Cid sets the optional parameter "cid": The customization id for
609// translate
610func (c *TranslationsListCall) Cid(cid ...string) *TranslationsListCall {
611	c.urlParams_.SetMulti("cid", append([]string{}, cid...))
612	return c
613}
614
615// Format sets the optional parameter "format": The format of the text
616//
617// Possible values:
618//   "html" - Specifies the input is in HTML
619//   "text" - Specifies the input is in plain textual format
620func (c *TranslationsListCall) Format(format string) *TranslationsListCall {
621	c.urlParams_.Set("format", format)
622	return c
623}
624
625// Model sets the optional parameter "model": the model to use for
626// translation
627func (c *TranslationsListCall) Model(model string) *TranslationsListCall {
628	c.urlParams_.Set("model", model)
629	return c
630}
631
632// Source sets the optional parameter "source": The source language of
633// the text
634func (c *TranslationsListCall) Source(source string) *TranslationsListCall {
635	c.urlParams_.Set("source", source)
636	return c
637}
638
639// Fields allows partial responses to be retrieved. See
640// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
641// for more information.
642func (c *TranslationsListCall) Fields(s ...googleapi.Field) *TranslationsListCall {
643	c.urlParams_.Set("fields", googleapi.CombineFields(s))
644	return c
645}
646
647// IfNoneMatch sets the optional parameter which makes the operation
648// fail if the object's ETag matches the given value. This is useful for
649// getting updates only after the object has changed since the last
650// request. Use googleapi.IsNotModified to check whether the response
651// error from Do is the result of In-None-Match.
652func (c *TranslationsListCall) IfNoneMatch(entityTag string) *TranslationsListCall {
653	c.ifNoneMatch_ = entityTag
654	return c
655}
656
657// Context sets the context to be used in this call's Do method. Any
658// pending HTTP request will be aborted if the provided context is
659// canceled.
660func (c *TranslationsListCall) Context(ctx context.Context) *TranslationsListCall {
661	c.ctx_ = ctx
662	return c
663}
664
665// Header returns an http.Header that can be modified by the caller to
666// add HTTP headers to the request.
667func (c *TranslationsListCall) Header() http.Header {
668	if c.header_ == nil {
669		c.header_ = make(http.Header)
670	}
671	return c.header_
672}
673
674func (c *TranslationsListCall) doRequest(alt string) (*http.Response, error) {
675	reqHeaders := make(http.Header)
676	for k, v := range c.header_ {
677		reqHeaders[k] = v
678	}
679	reqHeaders.Set("User-Agent", c.s.userAgent())
680	if c.ifNoneMatch_ != "" {
681		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
682	}
683	var body io.Reader = nil
684	c.urlParams_.Set("alt", alt)
685	urls := googleapi.ResolveRelative(c.s.BasePath, "v2")
686	urls += "?" + c.urlParams_.Encode()
687	req, _ := http.NewRequest("GET", urls, body)
688	req.Header = reqHeaders
689	return gensupport.SendRequest(c.ctx_, c.s.client, req)
690}
691
692// Do executes the "language.translations.list" call.
693// Exactly one of *TranslationsListResponse or error will be non-nil.
694// Any non-2xx status code is an error. Response headers are in either
695// *TranslationsListResponse.ServerResponse.Header or (if a response was
696// returned at all) in error.(*googleapi.Error).Header. Use
697// googleapi.IsNotModified to check whether the returned error was
698// because http.StatusNotModified was returned.
699func (c *TranslationsListCall) Do(opts ...googleapi.CallOption) (*TranslationsListResponse, error) {
700	gensupport.SetOptions(c.urlParams_, opts...)
701	res, err := c.doRequest("json")
702	if res != nil && res.StatusCode == http.StatusNotModified {
703		if res.Body != nil {
704			res.Body.Close()
705		}
706		return nil, &googleapi.Error{
707			Code:   res.StatusCode,
708			Header: res.Header,
709		}
710	}
711	if err != nil {
712		return nil, err
713	}
714	defer googleapi.CloseBody(res)
715	if err := googleapi.CheckResponse(res); err != nil {
716		return nil, err
717	}
718	ret := &TranslationsListResponse{
719		ServerResponse: googleapi.ServerResponse{
720			Header:         res.Header,
721			HTTPStatusCode: res.StatusCode,
722		},
723	}
724	target := &struct {
725		Data *TranslationsListResponse `json:"data"`
726	}{ret}
727	if err := json.NewDecoder(res.Body).Decode(target); err != nil {
728		return nil, err
729	}
730	return ret, nil
731	// {
732	//   "description": "Returns text translations from one language to another.",
733	//   "httpMethod": "GET",
734	//   "id": "language.translations.list",
735	//   "parameterOrder": [
736	//     "q",
737	//     "target"
738	//   ],
739	//   "parameters": {
740	//     "cid": {
741	//       "description": "The customization id for translate",
742	//       "location": "query",
743	//       "repeated": true,
744	//       "type": "string"
745	//     },
746	//     "format": {
747	//       "description": "The format of the text",
748	//       "enum": [
749	//         "html",
750	//         "text"
751	//       ],
752	//       "enumDescriptions": [
753	//         "Specifies the input is in HTML",
754	//         "Specifies the input is in plain textual format"
755	//       ],
756	//       "location": "query",
757	//       "type": "string"
758	//     },
759	//     "model": {
760	//       "description": "the model to use for translation",
761	//       "location": "query",
762	//       "type": "string"
763	//     },
764	//     "q": {
765	//       "description": "The text to translate",
766	//       "location": "query",
767	//       "repeated": true,
768	//       "required": true,
769	//       "type": "string"
770	//     },
771	//     "source": {
772	//       "description": "The source language of the text",
773	//       "location": "query",
774	//       "type": "string"
775	//     },
776	//     "target": {
777	//       "description": "The target language into which the text should be translated",
778	//       "location": "query",
779	//       "required": true,
780	//       "type": "string"
781	//     }
782	//   },
783	//   "path": "v2",
784	//   "response": {
785	//     "$ref": "TranslationsListResponse"
786	//   }
787	// }
788
789}
790