You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1883 lines
67 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package language provides access to the Cloud Natural Language API.
  6. //
  7. // This package is DEPRECATED. Use package cloud.google.com/go/language/apiv1 instead.
  8. //
  9. // For product documentation, see: https://cloud.google.com/natural-language/
  10. //
  11. // Creating a client
  12. //
  13. // Usage example:
  14. //
  15. // import "google.golang.org/api/language/v1beta1"
  16. // ...
  17. // ctx := context.Background()
  18. // languageService, err := language.NewService(ctx)
  19. //
  20. // In this example, Google Application Default Credentials are used for authentication.
  21. //
  22. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  23. //
  24. // Other authentication options
  25. //
  26. // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
  27. //
  28. // languageService, err := language.NewService(ctx, option.WithScopes(language.CloudPlatformScope))
  29. //
  30. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  31. //
  32. // languageService, err := language.NewService(ctx, option.WithAPIKey("AIza..."))
  33. //
  34. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  35. //
  36. // config := &oauth2.Config{...}
  37. // // ...
  38. // token, err := config.Exchange(ctx, ...)
  39. // languageService, err := language.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  40. //
  41. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  42. package language // import "google.golang.org/api/language/v1beta1"
  43. import (
  44. "bytes"
  45. "context"
  46. "encoding/json"
  47. "errors"
  48. "fmt"
  49. "io"
  50. "net/http"
  51. "net/url"
  52. "strconv"
  53. "strings"
  54. gensupport "google.golang.org/api/gensupport"
  55. googleapi "google.golang.org/api/googleapi"
  56. option "google.golang.org/api/option"
  57. htransport "google.golang.org/api/transport/http"
  58. )
  59. // Always reference these packages, just in case the auto-generated code
  60. // below doesn't.
  61. var _ = bytes.NewBuffer
  62. var _ = strconv.Itoa
  63. var _ = fmt.Sprintf
  64. var _ = json.NewDecoder
  65. var _ = io.Copy
  66. var _ = url.Parse
  67. var _ = gensupport.MarshalJSON
  68. var _ = googleapi.Version
  69. var _ = errors.New
  70. var _ = strings.Replace
  71. var _ = context.Canceled
  72. const apiId = "language:v1beta1"
  73. const apiName = "language"
  74. const apiVersion = "v1beta1"
  75. const basePath = "https://language.googleapis.com/"
  76. // OAuth2 scopes used by this API.
  77. const (
  78. // Apply machine learning models to reveal the structure and meaning of
  79. // text
  80. CloudLanguageScope = "https://www.googleapis.com/auth/cloud-language"
  81. // View and manage your data across Google Cloud Platform services
  82. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  83. )
  84. // NewService creates a new Service.
  85. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  86. scopesOption := option.WithScopes(
  87. "https://www.googleapis.com/auth/cloud-language",
  88. "https://www.googleapis.com/auth/cloud-platform",
  89. )
  90. // NOTE: prepend, so we don't override user-specified scopes.
  91. opts = append([]option.ClientOption{scopesOption}, opts...)
  92. client, endpoint, err := htransport.NewClient(ctx, opts...)
  93. if err != nil {
  94. return nil, err
  95. }
  96. s, err := New(client)
  97. if err != nil {
  98. return nil, err
  99. }
  100. if endpoint != "" {
  101. s.BasePath = endpoint
  102. }
  103. return s, nil
  104. }
  105. // New creates a new Service. It uses the provided http.Client for requests.
  106. //
  107. // Deprecated: please use NewService instead.
  108. // To provide a custom HTTP client, use option.WithHTTPClient.
  109. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  110. func New(client *http.Client) (*Service, error) {
  111. if client == nil {
  112. return nil, errors.New("client is nil")
  113. }
  114. s := &Service{client: client, BasePath: basePath}
  115. s.Documents = NewDocumentsService(s)
  116. return s, nil
  117. }
  118. type Service struct {
  119. client *http.Client
  120. BasePath string // API endpoint base URL
  121. UserAgent string // optional additional User-Agent fragment
  122. Documents *DocumentsService
  123. }
  124. func (s *Service) userAgent() string {
  125. if s.UserAgent == "" {
  126. return googleapi.UserAgent
  127. }
  128. return googleapi.UserAgent + " " + s.UserAgent
  129. }
  130. func NewDocumentsService(s *Service) *DocumentsService {
  131. rs := &DocumentsService{s: s}
  132. return rs
  133. }
  134. type DocumentsService struct {
  135. s *Service
  136. }
  137. // AnalyzeEntitiesRequest: The entity analysis request message.
  138. type AnalyzeEntitiesRequest struct {
  139. // Document: Input document.
  140. Document *Document `json:"document,omitempty"`
  141. // EncodingType: The encoding type used by the API to calculate offsets.
  142. //
  143. // Possible values:
  144. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  145. // information (such as
  146. // `begin_offset`) will be set at `-1`.
  147. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  148. // calculated based
  149. // on the UTF-8 encoding of the input. C++ and Go are examples of
  150. // languages
  151. // that use this encoding natively.
  152. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  153. // is calculated based
  154. // on the UTF-16 encoding of the input. Java and Javascript are examples
  155. // of
  156. // languages that use this encoding natively.
  157. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  158. // is calculated based
  159. // on the UTF-32 encoding of the input. Python is an example of a
  160. // language
  161. // that uses this encoding natively.
  162. EncodingType string `json:"encodingType,omitempty"`
  163. // ForceSendFields is a list of field names (e.g. "Document") to
  164. // unconditionally include in API requests. By default, fields with
  165. // empty values are omitted from API requests. However, any non-pointer,
  166. // non-interface field appearing in ForceSendFields will be sent to the
  167. // server regardless of whether the field is empty or not. This may be
  168. // used to include empty fields in Patch requests.
  169. ForceSendFields []string `json:"-"`
  170. // NullFields is a list of field names (e.g. "Document") to include in
  171. // API requests with the JSON null value. By default, fields with empty
  172. // values are omitted from API requests. However, any field with an
  173. // empty value appearing in NullFields will be sent to the server as
  174. // null. It is an error if a field in this list has a non-empty value.
  175. // This may be used to include null fields in Patch requests.
  176. NullFields []string `json:"-"`
  177. }
  178. func (s *AnalyzeEntitiesRequest) MarshalJSON() ([]byte, error) {
  179. type NoMethod AnalyzeEntitiesRequest
  180. raw := NoMethod(*s)
  181. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  182. }
  183. // AnalyzeEntitiesResponse: The entity analysis response message.
  184. type AnalyzeEntitiesResponse struct {
  185. // Entities: The recognized entities in the input document.
  186. Entities []*Entity `json:"entities,omitempty"`
  187. // Language: The language of the text, which will be the same as the
  188. // language specified
  189. // in the request or, if not specified, the automatically-detected
  190. // language.
  191. // See Document.language field for more details.
  192. Language string `json:"language,omitempty"`
  193. // ServerResponse contains the HTTP response code and headers from the
  194. // server.
  195. googleapi.ServerResponse `json:"-"`
  196. // ForceSendFields is a list of field names (e.g. "Entities") to
  197. // unconditionally include in API requests. By default, fields with
  198. // empty values are omitted from API requests. However, any non-pointer,
  199. // non-interface field appearing in ForceSendFields will be sent to the
  200. // server regardless of whether the field is empty or not. This may be
  201. // used to include empty fields in Patch requests.
  202. ForceSendFields []string `json:"-"`
  203. // NullFields is a list of field names (e.g. "Entities") to include in
  204. // API requests with the JSON null value. By default, fields with empty
  205. // values are omitted from API requests. However, any field with an
  206. // empty value appearing in NullFields will be sent to the server as
  207. // null. It is an error if a field in this list has a non-empty value.
  208. // This may be used to include null fields in Patch requests.
  209. NullFields []string `json:"-"`
  210. }
  211. func (s *AnalyzeEntitiesResponse) MarshalJSON() ([]byte, error) {
  212. type NoMethod AnalyzeEntitiesResponse
  213. raw := NoMethod(*s)
  214. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  215. }
  216. // AnalyzeSentimentRequest: The sentiment analysis request message.
  217. type AnalyzeSentimentRequest struct {
  218. // Document: Input document.
  219. Document *Document `json:"document,omitempty"`
  220. // EncodingType: The encoding type used by the API to calculate sentence
  221. // offsets for the
  222. // sentence sentiment.
  223. //
  224. // Possible values:
  225. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  226. // information (such as
  227. // `begin_offset`) will be set at `-1`.
  228. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  229. // calculated based
  230. // on the UTF-8 encoding of the input. C++ and Go are examples of
  231. // languages
  232. // that use this encoding natively.
  233. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  234. // is calculated based
  235. // on the UTF-16 encoding of the input. Java and Javascript are examples
  236. // of
  237. // languages that use this encoding natively.
  238. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  239. // is calculated based
  240. // on the UTF-32 encoding of the input. Python is an example of a
  241. // language
  242. // that uses this encoding natively.
  243. EncodingType string `json:"encodingType,omitempty"`
  244. // ForceSendFields is a list of field names (e.g. "Document") to
  245. // unconditionally include in API requests. By default, fields with
  246. // empty values are omitted from API requests. However, any non-pointer,
  247. // non-interface field appearing in ForceSendFields will be sent to the
  248. // server regardless of whether the field is empty or not. This may be
  249. // used to include empty fields in Patch requests.
  250. ForceSendFields []string `json:"-"`
  251. // NullFields is a list of field names (e.g. "Document") to include in
  252. // API requests with the JSON null value. By default, fields with empty
  253. // values are omitted from API requests. However, any field with an
  254. // empty value appearing in NullFields will be sent to the server as
  255. // null. It is an error if a field in this list has a non-empty value.
  256. // This may be used to include null fields in Patch requests.
  257. NullFields []string `json:"-"`
  258. }
  259. func (s *AnalyzeSentimentRequest) MarshalJSON() ([]byte, error) {
  260. type NoMethod AnalyzeSentimentRequest
  261. raw := NoMethod(*s)
  262. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  263. }
  264. // AnalyzeSentimentResponse: The sentiment analysis response message.
  265. type AnalyzeSentimentResponse struct {
  266. // DocumentSentiment: The overall sentiment of the input document.
  267. DocumentSentiment *Sentiment `json:"documentSentiment,omitempty"`
  268. // Language: The language of the text, which will be the same as the
  269. // language specified
  270. // in the request or, if not specified, the automatically-detected
  271. // language.
  272. // See Document.language field for more details.
  273. Language string `json:"language,omitempty"`
  274. // Sentences: The sentiment for all the sentences in the document.
  275. Sentences []*Sentence `json:"sentences,omitempty"`
  276. // ServerResponse contains the HTTP response code and headers from the
  277. // server.
  278. googleapi.ServerResponse `json:"-"`
  279. // ForceSendFields is a list of field names (e.g. "DocumentSentiment")
  280. // to unconditionally include in API requests. By default, fields with
  281. // empty values are omitted from API requests. However, any non-pointer,
  282. // non-interface field appearing in ForceSendFields will be sent to the
  283. // server regardless of whether the field is empty or not. This may be
  284. // used to include empty fields in Patch requests.
  285. ForceSendFields []string `json:"-"`
  286. // NullFields is a list of field names (e.g. "DocumentSentiment") to
  287. // include in API requests with the JSON null value. By default, fields
  288. // with empty values are omitted from API requests. However, any field
  289. // with an empty value appearing in NullFields will be sent to the
  290. // server as null. It is an error if a field in this list has a
  291. // non-empty value. This may be used to include null fields in Patch
  292. // requests.
  293. NullFields []string `json:"-"`
  294. }
  295. func (s *AnalyzeSentimentResponse) MarshalJSON() ([]byte, error) {
  296. type NoMethod AnalyzeSentimentResponse
  297. raw := NoMethod(*s)
  298. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  299. }
  300. // AnalyzeSyntaxRequest: The syntax analysis request message.
  301. type AnalyzeSyntaxRequest struct {
  302. // Document: Input document.
  303. Document *Document `json:"document,omitempty"`
  304. // EncodingType: The encoding type used by the API to calculate offsets.
  305. //
  306. // Possible values:
  307. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  308. // information (such as
  309. // `begin_offset`) will be set at `-1`.
  310. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  311. // calculated based
  312. // on the UTF-8 encoding of the input. C++ and Go are examples of
  313. // languages
  314. // that use this encoding natively.
  315. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  316. // is calculated based
  317. // on the UTF-16 encoding of the input. Java and Javascript are examples
  318. // of
  319. // languages that use this encoding natively.
  320. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  321. // is calculated based
  322. // on the UTF-32 encoding of the input. Python is an example of a
  323. // language
  324. // that uses this encoding natively.
  325. EncodingType string `json:"encodingType,omitempty"`
  326. // ForceSendFields is a list of field names (e.g. "Document") to
  327. // unconditionally include in API requests. By default, fields with
  328. // empty values are omitted from API requests. However, any non-pointer,
  329. // non-interface field appearing in ForceSendFields will be sent to the
  330. // server regardless of whether the field is empty or not. This may be
  331. // used to include empty fields in Patch requests.
  332. ForceSendFields []string `json:"-"`
  333. // NullFields is a list of field names (e.g. "Document") to include in
  334. // API requests with the JSON null value. By default, fields with empty
  335. // values are omitted from API requests. However, any field with an
  336. // empty value appearing in NullFields will be sent to the server as
  337. // null. It is an error if a field in this list has a non-empty value.
  338. // This may be used to include null fields in Patch requests.
  339. NullFields []string `json:"-"`
  340. }
  341. func (s *AnalyzeSyntaxRequest) MarshalJSON() ([]byte, error) {
  342. type NoMethod AnalyzeSyntaxRequest
  343. raw := NoMethod(*s)
  344. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  345. }
  346. // AnalyzeSyntaxResponse: The syntax analysis response message.
  347. type AnalyzeSyntaxResponse struct {
  348. // Language: The language of the text, which will be the same as the
  349. // language specified
  350. // in the request or, if not specified, the automatically-detected
  351. // language.
  352. // See Document.language field for more details.
  353. Language string `json:"language,omitempty"`
  354. // Sentences: Sentences in the input document.
  355. Sentences []*Sentence `json:"sentences,omitempty"`
  356. // Tokens: Tokens, along with their syntactic information, in the input
  357. // document.
  358. Tokens []*Token `json:"tokens,omitempty"`
  359. // ServerResponse contains the HTTP response code and headers from the
  360. // server.
  361. googleapi.ServerResponse `json:"-"`
  362. // ForceSendFields is a list of field names (e.g. "Language") to
  363. // unconditionally include in API requests. By default, fields with
  364. // empty values are omitted from API requests. However, any non-pointer,
  365. // non-interface field appearing in ForceSendFields will be sent to the
  366. // server regardless of whether the field is empty or not. This may be
  367. // used to include empty fields in Patch requests.
  368. ForceSendFields []string `json:"-"`
  369. // NullFields is a list of field names (e.g. "Language") to include in
  370. // API requests with the JSON null value. By default, fields with empty
  371. // values are omitted from API requests. However, any field with an
  372. // empty value appearing in NullFields will be sent to the server as
  373. // null. It is an error if a field in this list has a non-empty value.
  374. // This may be used to include null fields in Patch requests.
  375. NullFields []string `json:"-"`
  376. }
  377. func (s *AnalyzeSyntaxResponse) MarshalJSON() ([]byte, error) {
  378. type NoMethod AnalyzeSyntaxResponse
  379. raw := NoMethod(*s)
  380. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  381. }
  382. // AnnotateTextRequest: The request message for the text annotation API,
  383. // which can perform multiple
  384. // analysis types (sentiment, entities, and syntax) in one call.
  385. type AnnotateTextRequest struct {
  386. // Document: Input document.
  387. Document *Document `json:"document,omitempty"`
  388. // EncodingType: The encoding type used by the API to calculate offsets.
  389. //
  390. // Possible values:
  391. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  392. // information (such as
  393. // `begin_offset`) will be set at `-1`.
  394. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  395. // calculated based
  396. // on the UTF-8 encoding of the input. C++ and Go are examples of
  397. // languages
  398. // that use this encoding natively.
  399. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  400. // is calculated based
  401. // on the UTF-16 encoding of the input. Java and Javascript are examples
  402. // of
  403. // languages that use this encoding natively.
  404. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  405. // is calculated based
  406. // on the UTF-32 encoding of the input. Python is an example of a
  407. // language
  408. // that uses this encoding natively.
  409. EncodingType string `json:"encodingType,omitempty"`
  410. // Features: The enabled features.
  411. Features *Features `json:"features,omitempty"`
  412. // ForceSendFields is a list of field names (e.g. "Document") to
  413. // unconditionally include in API requests. By default, fields with
  414. // empty values are omitted from API requests. However, any non-pointer,
  415. // non-interface field appearing in ForceSendFields will be sent to the
  416. // server regardless of whether the field is empty or not. This may be
  417. // used to include empty fields in Patch requests.
  418. ForceSendFields []string `json:"-"`
  419. // NullFields is a list of field names (e.g. "Document") to include in
  420. // API requests with the JSON null value. By default, fields with empty
  421. // values are omitted from API requests. However, any field with an
  422. // empty value appearing in NullFields will be sent to the server as
  423. // null. It is an error if a field in this list has a non-empty value.
  424. // This may be used to include null fields in Patch requests.
  425. NullFields []string `json:"-"`
  426. }
  427. func (s *AnnotateTextRequest) MarshalJSON() ([]byte, error) {
  428. type NoMethod AnnotateTextRequest
  429. raw := NoMethod(*s)
  430. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  431. }
  432. // AnnotateTextResponse: The text annotations response message.
  433. type AnnotateTextResponse struct {
  434. // DocumentSentiment: The overall sentiment for the document. Populated
  435. // if the user
  436. // enables
  437. // AnnotateTextRequest.Features.extract_document_sentiment.
  438. DocumentSentiment *Sentiment `json:"documentSentiment,omitempty"`
  439. // Entities: Entities, along with their semantic information, in the
  440. // input document.
  441. // Populated if the user
  442. // enables
  443. // AnnotateTextRequest.Features.extract_entities.
  444. Entities []*Entity `json:"entities,omitempty"`
  445. // Language: The language of the text, which will be the same as the
  446. // language specified
  447. // in the request or, if not specified, the automatically-detected
  448. // language.
  449. // See Document.language field for more details.
  450. Language string `json:"language,omitempty"`
  451. // Sentences: Sentences in the input document. Populated if the user
  452. // enables
  453. // AnnotateTextRequest.Features.extract_syntax.
  454. Sentences []*Sentence `json:"sentences,omitempty"`
  455. // Tokens: Tokens, along with their syntactic information, in the input
  456. // document.
  457. // Populated if the user
  458. // enables
  459. // AnnotateTextRequest.Features.extract_syntax.
  460. Tokens []*Token `json:"tokens,omitempty"`
  461. // ServerResponse contains the HTTP response code and headers from the
  462. // server.
  463. googleapi.ServerResponse `json:"-"`
  464. // ForceSendFields is a list of field names (e.g. "DocumentSentiment")
  465. // to unconditionally include in API requests. By default, fields with
  466. // empty values are omitted from API requests. However, any non-pointer,
  467. // non-interface field appearing in ForceSendFields will be sent to the
  468. // server regardless of whether the field is empty or not. This may be
  469. // used to include empty fields in Patch requests.
  470. ForceSendFields []string `json:"-"`
  471. // NullFields is a list of field names (e.g. "DocumentSentiment") to
  472. // include in API requests with the JSON null value. By default, fields
  473. // with empty values are omitted from API requests. However, any field
  474. // with an empty value appearing in NullFields will be sent to the
  475. // server as null. It is an error if a field in this list has a
  476. // non-empty value. This may be used to include null fields in Patch
  477. // requests.
  478. NullFields []string `json:"-"`
  479. }
  480. func (s *AnnotateTextResponse) MarshalJSON() ([]byte, error) {
  481. type NoMethod AnnotateTextResponse
  482. raw := NoMethod(*s)
  483. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  484. }
  485. // DependencyEdge: Represents dependency parse tree information for a
  486. // token.
  487. type DependencyEdge struct {
  488. // HeadTokenIndex: Represents the head of this token in the dependency
  489. // tree.
  490. // This is the index of the token which has an arc going to this
  491. // token.
  492. // The index is the position of the token in the array of tokens
  493. // returned
  494. // by the API method. If this token is a root token, then
  495. // the
  496. // `head_token_index` is its own index.
  497. HeadTokenIndex int64 `json:"headTokenIndex,omitempty"`
  498. // Label: The parse label for the token.
  499. //
  500. // Possible values:
  501. // "UNKNOWN" - Unknown
  502. // "ABBREV" - Abbreviation modifier
  503. // "ACOMP" - Adjectival complement
  504. // "ADVCL" - Adverbial clause modifier
  505. // "ADVMOD" - Adverbial modifier
  506. // "AMOD" - Adjectival modifier of an NP
  507. // "APPOS" - Appositional modifier of an NP
  508. // "ATTR" - Attribute dependent of a copular verb
  509. // "AUX" - Auxiliary (non-main) verb
  510. // "AUXPASS" - Passive auxiliary
  511. // "CC" - Coordinating conjunction
  512. // "CCOMP" - Clausal complement of a verb or adjective
  513. // "CONJ" - Conjunct
  514. // "CSUBJ" - Clausal subject
  515. // "CSUBJPASS" - Clausal passive subject
  516. // "DEP" - Dependency (unable to determine)
  517. // "DET" - Determiner
  518. // "DISCOURSE" - Discourse
  519. // "DOBJ" - Direct object
  520. // "EXPL" - Expletive
  521. // "GOESWITH" - Goes with (part of a word in a text not well edited)
  522. // "IOBJ" - Indirect object
  523. // "MARK" - Marker (word introducing a subordinate clause)
  524. // "MWE" - Multi-word expression
  525. // "MWV" - Multi-word verbal expression
  526. // "NEG" - Negation modifier
  527. // "NN" - Noun compound modifier
  528. // "NPADVMOD" - Noun phrase used as an adverbial modifier
  529. // "NSUBJ" - Nominal subject
  530. // "NSUBJPASS" - Passive nominal subject
  531. // "NUM" - Numeric modifier of a noun
  532. // "NUMBER" - Element of compound number
  533. // "P" - Punctuation mark
  534. // "PARATAXIS" - Parataxis relation
  535. // "PARTMOD" - Participial modifier
  536. // "PCOMP" - The complement of a preposition is a clause
  537. // "POBJ" - Object of a preposition
  538. // "POSS" - Possession modifier
  539. // "POSTNEG" - Postverbal negative particle
  540. // "PRECOMP" - Predicate complement
  541. // "PRECONJ" - Preconjunt
  542. // "PREDET" - Predeterminer
  543. // "PREF" - Prefix
  544. // "PREP" - Prepositional modifier
  545. // "PRONL" - The relationship between a verb and verbal morpheme
  546. // "PRT" - Particle
  547. // "PS" - Associative or possessive marker
  548. // "QUANTMOD" - Quantifier phrase modifier
  549. // "RCMOD" - Relative clause modifier
  550. // "RCMODREL" - Complementizer in relative clause
  551. // "RDROP" - Ellipsis without a preceding predicate
  552. // "REF" - Referent
  553. // "REMNANT" - Remnant
  554. // "REPARANDUM" - Reparandum
  555. // "ROOT" - Root
  556. // "SNUM" - Suffix specifying a unit of number
  557. // "SUFF" - Suffix
  558. // "TMOD" - Temporal modifier
  559. // "TOPIC" - Topic marker
  560. // "VMOD" - Clause headed by an infinite form of the verb that
  561. // modifies a noun
  562. // "VOCATIVE" - Vocative
  563. // "XCOMP" - Open clausal complement
  564. // "SUFFIX" - Name suffix
  565. // "TITLE" - Name title
  566. // "ADVPHMOD" - Adverbial phrase modifier
  567. // "AUXCAUS" - Causative auxiliary
  568. // "AUXVV" - Helper auxiliary
  569. // "DTMOD" - Rentaishi (Prenominal modifier)
  570. // "FOREIGN" - Foreign words
  571. // "KW" - Keyword
  572. // "LIST" - List for chains of comparable items
  573. // "NOMC" - Nominalized clause
  574. // "NOMCSUBJ" - Nominalized clausal subject
  575. // "NOMCSUBJPASS" - Nominalized clausal passive
  576. // "NUMC" - Compound of numeric modifier
  577. // "COP" - Copula
  578. // "DISLOCATED" - Dislocated relation (for fronted/topicalized
  579. // elements)
  580. // "ASP" - Aspect marker
  581. // "GMOD" - Genitive modifier
  582. // "GOBJ" - Genitive object
  583. // "INFMOD" - Infinitival modifier
  584. // "MES" - Measure
  585. // "NCOMP" - Nominal complement of a noun
  586. Label string `json:"label,omitempty"`
  587. // ForceSendFields is a list of field names (e.g. "HeadTokenIndex") to
  588. // unconditionally include in API requests. By default, fields with
  589. // empty values are omitted from API requests. However, any non-pointer,
  590. // non-interface field appearing in ForceSendFields will be sent to the
  591. // server regardless of whether the field is empty or not. This may be
  592. // used to include empty fields in Patch requests.
  593. ForceSendFields []string `json:"-"`
  594. // NullFields is a list of field names (e.g. "HeadTokenIndex") to
  595. // include in API requests with the JSON null value. By default, fields
  596. // with empty values are omitted from API requests. However, any field
  597. // with an empty value appearing in NullFields will be sent to the
  598. // server as null. It is an error if a field in this list has a
  599. // non-empty value. This may be used to include null fields in Patch
  600. // requests.
  601. NullFields []string `json:"-"`
  602. }
  603. func (s *DependencyEdge) MarshalJSON() ([]byte, error) {
  604. type NoMethod DependencyEdge
  605. raw := NoMethod(*s)
  606. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  607. }
  608. // Document:
  609. // ################################################################
  610. // #
  611. //
  612. // Represents the input to API methods.
  613. type Document struct {
  614. // Content: The content of the input in string format.
  615. // Cloud audit logging exempt since it is based on user data.
  616. Content string `json:"content,omitempty"`
  617. // GcsContentUri: The Google Cloud Storage URI where the file content is
  618. // located.
  619. // This URI must be of the form: gs://bucket_name/object_name. For
  620. // more
  621. // details, see
  622. // https://cloud.google.com/storage/docs/reference-uris.
  623. // NOTE: Cloud Storage object versioning is not supported.
  624. GcsContentUri string `json:"gcsContentUri,omitempty"`
  625. // Language: The language of the document (if not specified, the
  626. // language is
  627. // automatically detected). Both ISO and BCP-47 language codes
  628. // are
  629. // accepted.<br>
  630. // [Language Support](/natural-language/docs/languages)
  631. // lists currently supported languages for each API method.
  632. // If the language (either specified by the caller or automatically
  633. // detected)
  634. // is not supported by the called API method, an `INVALID_ARGUMENT`
  635. // error
  636. // is returned.
  637. Language string `json:"language,omitempty"`
  638. // Type: Required. If the type is not set or is
  639. // `TYPE_UNSPECIFIED`,
  640. // returns an `INVALID_ARGUMENT` error.
  641. //
  642. // Possible values:
  643. // "TYPE_UNSPECIFIED" - The content type is not specified.
  644. // "PLAIN_TEXT" - Plain text
  645. // "HTML" - HTML
  646. Type string `json:"type,omitempty"`
  647. // ForceSendFields is a list of field names (e.g. "Content") to
  648. // unconditionally include in API requests. By default, fields with
  649. // empty values are omitted from API requests. However, any non-pointer,
  650. // non-interface field appearing in ForceSendFields will be sent to the
  651. // server regardless of whether the field is empty or not. This may be
  652. // used to include empty fields in Patch requests.
  653. ForceSendFields []string `json:"-"`
  654. // NullFields is a list of field names (e.g. "Content") to include in
  655. // API requests with the JSON null value. By default, fields with empty
  656. // values are omitted from API requests. However, any field with an
  657. // empty value appearing in NullFields will be sent to the server as
  658. // null. It is an error if a field in this list has a non-empty value.
  659. // This may be used to include null fields in Patch requests.
  660. NullFields []string `json:"-"`
  661. }
  662. func (s *Document) MarshalJSON() ([]byte, error) {
  663. type NoMethod Document
  664. raw := NoMethod(*s)
  665. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  666. }
  667. // Entity: Represents a phrase in the text that is a known entity, such
  668. // as
  669. // a person, an organization, or location. The API associates
  670. // information, such
  671. // as salience and mentions, with entities.
  672. type Entity struct {
  673. // Mentions: The mentions of this entity in the input document. The API
  674. // currently
  675. // supports proper noun mentions.
  676. Mentions []*EntityMention `json:"mentions,omitempty"`
  677. // Metadata: Metadata associated with the entity.
  678. //
  679. // Currently, Wikipedia URLs and Knowledge Graph MIDs are provided,
  680. // if
  681. // available. The associated keys are "wikipedia_url" and "mid",
  682. // respectively.
  683. Metadata map[string]string `json:"metadata,omitempty"`
  684. // Name: The representative name for the entity.
  685. Name string `json:"name,omitempty"`
  686. // Salience: The salience score associated with the entity in the [0,
  687. // 1.0] range.
  688. //
  689. // The salience score for an entity provides information about
  690. // the
  691. // importance or centrality of that entity to the entire document
  692. // text.
  693. // Scores closer to 0 are less salient, while scores closer to 1.0 are
  694. // highly
  695. // salient.
  696. Salience float64 `json:"salience,omitempty"`
  697. // Type: The entity type.
  698. //
  699. // Possible values:
  700. // "UNKNOWN" - Unknown
  701. // "PERSON" - Person
  702. // "LOCATION" - Location
  703. // "ORGANIZATION" - Organization
  704. // "EVENT" - Event
  705. // "WORK_OF_ART" - Work of art
  706. // "CONSUMER_GOOD" - Consumer goods
  707. // "OTHER" - Other types
  708. Type string `json:"type,omitempty"`
  709. // ForceSendFields is a list of field names (e.g. "Mentions") to
  710. // unconditionally include in API requests. By default, fields with
  711. // empty values are omitted from API requests. However, any non-pointer,
  712. // non-interface field appearing in ForceSendFields will be sent to the
  713. // server regardless of whether the field is empty or not. This may be
  714. // used to include empty fields in Patch requests.
  715. ForceSendFields []string `json:"-"`
  716. // NullFields is a list of field names (e.g. "Mentions") to include in
  717. // API requests with the JSON null value. By default, fields with empty
  718. // values are omitted from API requests. However, any field with an
  719. // empty value appearing in NullFields will be sent to the server as
  720. // null. It is an error if a field in this list has a non-empty value.
  721. // This may be used to include null fields in Patch requests.
  722. NullFields []string `json:"-"`
  723. }
  724. func (s *Entity) MarshalJSON() ([]byte, error) {
  725. type NoMethod Entity
  726. raw := NoMethod(*s)
  727. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  728. }
  729. func (s *Entity) UnmarshalJSON(data []byte) error {
  730. type NoMethod Entity
  731. var s1 struct {
  732. Salience gensupport.JSONFloat64 `json:"salience"`
  733. *NoMethod
  734. }
  735. s1.NoMethod = (*NoMethod)(s)
  736. if err := json.Unmarshal(data, &s1); err != nil {
  737. return err
  738. }
  739. s.Salience = float64(s1.Salience)
  740. return nil
  741. }
  742. // EntityMention: Represents a mention for an entity in the text.
  743. // Currently, proper noun
  744. // mentions are supported.
  745. type EntityMention struct {
  746. // Text: The mention text.
  747. Text *TextSpan `json:"text,omitempty"`
  748. // Type: The type of the entity mention.
  749. //
  750. // Possible values:
  751. // "TYPE_UNKNOWN" - Unknown
  752. // "PROPER" - Proper name
  753. // "COMMON" - Common noun (or noun compound)
  754. Type string `json:"type,omitempty"`
  755. // ForceSendFields is a list of field names (e.g. "Text") to
  756. // unconditionally include in API requests. By default, fields with
  757. // empty values are omitted from API requests. However, any non-pointer,
  758. // non-interface field appearing in ForceSendFields will be sent to the
  759. // server regardless of whether the field is empty or not. This may be
  760. // used to include empty fields in Patch requests.
  761. ForceSendFields []string `json:"-"`
  762. // NullFields is a list of field names (e.g. "Text") to include in API
  763. // requests with the JSON null value. By default, fields with empty
  764. // values are omitted from API requests. However, any field with an
  765. // empty value appearing in NullFields will be sent to the server as
  766. // null. It is an error if a field in this list has a non-empty value.
  767. // This may be used to include null fields in Patch requests.
  768. NullFields []string `json:"-"`
  769. }
  770. func (s *EntityMention) MarshalJSON() ([]byte, error) {
  771. type NoMethod EntityMention
  772. raw := NoMethod(*s)
  773. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  774. }
  775. // Features: All available features for sentiment, syntax, and semantic
  776. // analysis.
  777. // Setting each one to true will enable that specific analysis for the
  778. // input.
  779. type Features struct {
  780. // ExtractDocumentSentiment: Extract document-level sentiment.
  781. ExtractDocumentSentiment bool `json:"extractDocumentSentiment,omitempty"`
  782. // ExtractEntities: Extract entities.
  783. ExtractEntities bool `json:"extractEntities,omitempty"`
  784. // ExtractSyntax: Extract syntax information.
  785. ExtractSyntax bool `json:"extractSyntax,omitempty"`
  786. // ForceSendFields is a list of field names (e.g.
  787. // "ExtractDocumentSentiment") to unconditionally include in API
  788. // requests. By default, fields with empty values are omitted from API
  789. // requests. However, any non-pointer, non-interface field appearing in
  790. // ForceSendFields will be sent to the server regardless of whether the
  791. // field is empty or not. This may be used to include empty fields in
  792. // Patch requests.
  793. ForceSendFields []string `json:"-"`
  794. // NullFields is a list of field names (e.g. "ExtractDocumentSentiment")
  795. // to include in API requests with the JSON null value. By default,
  796. // fields with empty values are omitted from API requests. However, any
  797. // field with an empty value appearing in NullFields will be sent to the
  798. // server as null. It is an error if a field in this list has a
  799. // non-empty value. This may be used to include null fields in Patch
  800. // requests.
  801. NullFields []string `json:"-"`
  802. }
  803. func (s *Features) MarshalJSON() ([]byte, error) {
  804. type NoMethod Features
  805. raw := NoMethod(*s)
  806. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  807. }
  808. // PartOfSpeech: Represents part of speech information for a token.
  809. type PartOfSpeech struct {
  810. // Aspect: The grammatical aspect.
  811. //
  812. // Possible values:
  813. // "ASPECT_UNKNOWN" - Aspect is not applicable in the analyzed
  814. // language or is not predicted.
  815. // "PERFECTIVE" - Perfective
  816. // "IMPERFECTIVE" - Imperfective
  817. // "PROGRESSIVE" - Progressive
  818. Aspect string `json:"aspect,omitempty"`
  819. // Case: The grammatical case.
  820. //
  821. // Possible values:
  822. // "CASE_UNKNOWN" - Case is not applicable in the analyzed language or
  823. // is not predicted.
  824. // "ACCUSATIVE" - Accusative
  825. // "ADVERBIAL" - Adverbial
  826. // "COMPLEMENTIVE" - Complementive
  827. // "DATIVE" - Dative
  828. // "GENITIVE" - Genitive
  829. // "INSTRUMENTAL" - Instrumental
  830. // "LOCATIVE" - Locative
  831. // "NOMINATIVE" - Nominative
  832. // "OBLIQUE" - Oblique
  833. // "PARTITIVE" - Partitive
  834. // "PREPOSITIONAL" - Prepositional
  835. // "REFLEXIVE_CASE" - Reflexive
  836. // "RELATIVE_CASE" - Relative
  837. // "VOCATIVE" - Vocative
  838. Case string `json:"case,omitempty"`
  839. // Form: The grammatical form.
  840. //
  841. // Possible values:
  842. // "FORM_UNKNOWN" - Form is not applicable in the analyzed language or
  843. // is not predicted.
  844. // "ADNOMIAL" - Adnomial
  845. // "AUXILIARY" - Auxiliary
  846. // "COMPLEMENTIZER" - Complementizer
  847. // "FINAL_ENDING" - Final ending
  848. // "GERUND" - Gerund
  849. // "REALIS" - Realis
  850. // "IRREALIS" - Irrealis
  851. // "SHORT" - Short form
  852. // "LONG" - Long form
  853. // "ORDER" - Order form
  854. // "SPECIFIC" - Specific form
  855. Form string `json:"form,omitempty"`
  856. // Gender: The grammatical gender.
  857. //
  858. // Possible values:
  859. // "GENDER_UNKNOWN" - Gender is not applicable in the analyzed
  860. // language or is not predicted.
  861. // "FEMININE" - Feminine
  862. // "MASCULINE" - Masculine
  863. // "NEUTER" - Neuter
  864. Gender string `json:"gender,omitempty"`
  865. // Mood: The grammatical mood.
  866. //
  867. // Possible values:
  868. // "MOOD_UNKNOWN" - Mood is not applicable in the analyzed language or
  869. // is not predicted.
  870. // "CONDITIONAL_MOOD" - Conditional
  871. // "IMPERATIVE" - Imperative
  872. // "INDICATIVE" - Indicative
  873. // "INTERROGATIVE" - Interrogative
  874. // "JUSSIVE" - Jussive
  875. // "SUBJUNCTIVE" - Subjunctive
  876. Mood string `json:"mood,omitempty"`
  877. // Number: The grammatical number.
  878. //
  879. // Possible values:
  880. // "NUMBER_UNKNOWN" - Number is not applicable in the analyzed
  881. // language or is not predicted.
  882. // "SINGULAR" - Singular
  883. // "PLURAL" - Plural
  884. // "DUAL" - Dual
  885. Number string `json:"number,omitempty"`
  886. // Person: The grammatical person.
  887. //
  888. // Possible values:
  889. // "PERSON_UNKNOWN" - Person is not applicable in the analyzed
  890. // language or is not predicted.
  891. // "FIRST" - First
  892. // "SECOND" - Second
  893. // "THIRD" - Third
  894. // "REFLEXIVE_PERSON" - Reflexive
  895. Person string `json:"person,omitempty"`
  896. // Proper: The grammatical properness.
  897. //
  898. // Possible values:
  899. // "PROPER_UNKNOWN" - Proper is not applicable in the analyzed
  900. // language or is not predicted.
  901. // "PROPER" - Proper
  902. // "NOT_PROPER" - Not proper
  903. Proper string `json:"proper,omitempty"`
  904. // Reciprocity: The grammatical reciprocity.
  905. //
  906. // Possible values:
  907. // "RECIPROCITY_UNKNOWN" - Reciprocity is not applicable in the
  908. // analyzed language or is not
  909. // predicted.
  910. // "RECIPROCAL" - Reciprocal
  911. // "NON_RECIPROCAL" - Non-reciprocal
  912. Reciprocity string `json:"reciprocity,omitempty"`
  913. // Tag: The part of speech tag.
  914. //
  915. // Possible values:
  916. // "UNKNOWN" - Unknown
  917. // "ADJ" - Adjective
  918. // "ADP" - Adposition (preposition and postposition)
  919. // "ADV" - Adverb
  920. // "CONJ" - Conjunction
  921. // "DET" - Determiner
  922. // "NOUN" - Noun (common and proper)
  923. // "NUM" - Cardinal number
  924. // "PRON" - Pronoun
  925. // "PRT" - Particle or other function word
  926. // "PUNCT" - Punctuation
  927. // "VERB" - Verb (all tenses and modes)
  928. // "X" - Other: foreign words, typos, abbreviations
  929. // "AFFIX" - Affix
  930. Tag string `json:"tag,omitempty"`
  931. // Tense: The grammatical tense.
  932. //
  933. // Possible values:
  934. // "TENSE_UNKNOWN" - Tense is not applicable in the analyzed language
  935. // or is not predicted.
  936. // "CONDITIONAL_TENSE" - Conditional
  937. // "FUTURE" - Future
  938. // "PAST" - Past
  939. // "PRESENT" - Present
  940. // "IMPERFECT" - Imperfect
  941. // "PLUPERFECT" - Pluperfect
  942. Tense string `json:"tense,omitempty"`
  943. // Voice: The grammatical voice.
  944. //
  945. // Possible values:
  946. // "VOICE_UNKNOWN" - Voice is not applicable in the analyzed language
  947. // or is not predicted.
  948. // "ACTIVE" - Active
  949. // "CAUSATIVE" - Causative
  950. // "PASSIVE" - Passive
  951. Voice string `json:"voice,omitempty"`
  952. // ForceSendFields is a list of field names (e.g. "Aspect") to
  953. // unconditionally include in API requests. By default, fields with
  954. // empty values are omitted from API requests. However, any non-pointer,
  955. // non-interface field appearing in ForceSendFields will be sent to the
  956. // server regardless of whether the field is empty or not. This may be
  957. // used to include empty fields in Patch requests.
  958. ForceSendFields []string `json:"-"`
  959. // NullFields is a list of field names (e.g. "Aspect") to include in API
  960. // requests with the JSON null value. By default, fields with empty
  961. // values are omitted from API requests. However, any field with an
  962. // empty value appearing in NullFields will be sent to the server as
  963. // null. It is an error if a field in this list has a non-empty value.
  964. // This may be used to include null fields in Patch requests.
  965. NullFields []string `json:"-"`
  966. }
  967. func (s *PartOfSpeech) MarshalJSON() ([]byte, error) {
  968. type NoMethod PartOfSpeech
  969. raw := NoMethod(*s)
  970. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  971. }
  972. // Sentence: Represents a sentence in the input document.
  973. type Sentence struct {
  974. // Sentiment: For calls to AnalyzeSentiment or
  975. // if
  976. // AnnotateTextRequest.Features.extract_document_sentiment is set
  977. // to
  978. // true, this field will contain the sentiment for the sentence.
  979. Sentiment *Sentiment `json:"sentiment,omitempty"`
  980. // Text: The sentence text.
  981. Text *TextSpan `json:"text,omitempty"`
  982. // ForceSendFields is a list of field names (e.g. "Sentiment") to
  983. // unconditionally include in API requests. By default, fields with
  984. // empty values are omitted from API requests. However, any non-pointer,
  985. // non-interface field appearing in ForceSendFields will be sent to the
  986. // server regardless of whether the field is empty or not. This may be
  987. // used to include empty fields in Patch requests.
  988. ForceSendFields []string `json:"-"`
  989. // NullFields is a list of field names (e.g. "Sentiment") to include in
  990. // API requests with the JSON null value. By default, fields with empty
  991. // values are omitted from API requests. However, any field with an
  992. // empty value appearing in NullFields will be sent to the server as
  993. // null. It is an error if a field in this list has a non-empty value.
  994. // This may be used to include null fields in Patch requests.
  995. NullFields []string `json:"-"`
  996. }
  997. func (s *Sentence) MarshalJSON() ([]byte, error) {
  998. type NoMethod Sentence
  999. raw := NoMethod(*s)
  1000. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1001. }
  1002. // Sentiment: Represents the feeling associated with the entire text or
  1003. // entities in
  1004. // the text.
  1005. type Sentiment struct {
  1006. // Magnitude: A non-negative number in the [0, +inf) range, which
  1007. // represents
  1008. // the absolute magnitude of sentiment regardless of score (positive
  1009. // or
  1010. // negative).
  1011. Magnitude float64 `json:"magnitude,omitempty"`
  1012. // Polarity: DEPRECATED FIELD - This field is being deprecated in
  1013. // favor of score. Please refer to our documentation
  1014. // at
  1015. // https://cloud.google.com/natural-language/docs for more information.
  1016. Polarity float64 `json:"polarity,omitempty"`
  1017. // Score: Sentiment score between -1.0 (negative sentiment) and
  1018. // 1.0
  1019. // (positive sentiment).
  1020. Score float64 `json:"score,omitempty"`
  1021. // ForceSendFields is a list of field names (e.g. "Magnitude") to
  1022. // unconditionally include in API requests. By default, fields with
  1023. // empty values are omitted from API requests. However, any non-pointer,
  1024. // non-interface field appearing in ForceSendFields will be sent to the
  1025. // server regardless of whether the field is empty or not. This may be
  1026. // used to include empty fields in Patch requests.
  1027. ForceSendFields []string `json:"-"`
  1028. // NullFields is a list of field names (e.g. "Magnitude") to include in
  1029. // API requests with the JSON null value. By default, fields with empty
  1030. // values are omitted from API requests. However, any field with an
  1031. // empty value appearing in NullFields will be sent to the server as
  1032. // null. It is an error if a field in this list has a non-empty value.
  1033. // This may be used to include null fields in Patch requests.
  1034. NullFields []string `json:"-"`
  1035. }
  1036. func (s *Sentiment) MarshalJSON() ([]byte, error) {
  1037. type NoMethod Sentiment
  1038. raw := NoMethod(*s)
  1039. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1040. }
  1041. func (s *Sentiment) UnmarshalJSON(data []byte) error {
  1042. type NoMethod Sentiment
  1043. var s1 struct {
  1044. Magnitude gensupport.JSONFloat64 `json:"magnitude"`
  1045. Polarity gensupport.JSONFloat64 `json:"polarity"`
  1046. Score gensupport.JSONFloat64 `json:"score"`
  1047. *NoMethod
  1048. }
  1049. s1.NoMethod = (*NoMethod)(s)
  1050. if err := json.Unmarshal(data, &s1); err != nil {
  1051. return err
  1052. }
  1053. s.Magnitude = float64(s1.Magnitude)
  1054. s.Polarity = float64(s1.Polarity)
  1055. s.Score = float64(s1.Score)
  1056. return nil
  1057. }
  1058. // Status: The `Status` type defines a logical error model that is
  1059. // suitable for
  1060. // different programming environments, including REST APIs and RPC APIs.
  1061. // It is
  1062. // used by [gRPC](https://github.com/grpc). The error model is designed
  1063. // to be:
  1064. //
  1065. // - Simple to use and understand for most users
  1066. // - Flexible enough to meet unexpected needs
  1067. //
  1068. // # Overview
  1069. //
  1070. // The `Status` message contains three pieces of data: error code,
  1071. // error
  1072. // message, and error details. The error code should be an enum value
  1073. // of
  1074. // google.rpc.Code, but it may accept additional error codes if needed.
  1075. // The
  1076. // error message should be a developer-facing English message that
  1077. // helps
  1078. // developers *understand* and *resolve* the error. If a localized
  1079. // user-facing
  1080. // error message is needed, put the localized message in the error
  1081. // details or
  1082. // localize it in the client. The optional error details may contain
  1083. // arbitrary
  1084. // information about the error. There is a predefined set of error
  1085. // detail types
  1086. // in the package `google.rpc` that can be used for common error
  1087. // conditions.
  1088. //
  1089. // # Language mapping
  1090. //
  1091. // The `Status` message is the logical representation of the error
  1092. // model, but it
  1093. // is not necessarily the actual wire format. When the `Status` message
  1094. // is
  1095. // exposed in different client libraries and different wire protocols,
  1096. // it can be
  1097. // mapped differently. For example, it will likely be mapped to some
  1098. // exceptions
  1099. // in Java, but more likely mapped to some error codes in C.
  1100. //
  1101. // # Other uses
  1102. //
  1103. // The error model and the `Status` message can be used in a variety
  1104. // of
  1105. // environments, either with or without APIs, to provide a
  1106. // consistent developer experience across different
  1107. // environments.
  1108. //
  1109. // Example uses of this error model include:
  1110. //
  1111. // - Partial errors. If a service needs to return partial errors to the
  1112. // client,
  1113. // it may embed the `Status` in the normal response to indicate the
  1114. // partial
  1115. // errors.
  1116. //
  1117. // - Workflow errors. A typical workflow has multiple steps. Each step
  1118. // may
  1119. // have a `Status` message for error reporting.
  1120. //
  1121. // - Batch operations. If a client uses batch request and batch
  1122. // response, the
  1123. // `Status` message should be used directly inside batch response,
  1124. // one for
  1125. // each error sub-response.
  1126. //
  1127. // - Asynchronous operations. If an API call embeds asynchronous
  1128. // operation
  1129. // results in its response, the status of those operations should
  1130. // be
  1131. // represented directly using the `Status` message.
  1132. //
  1133. // - Logging. If some API errors are stored in logs, the message
  1134. // `Status` could
  1135. // be used directly after any stripping needed for security/privacy
  1136. // reasons.
  1137. type Status struct {
  1138. // Code: The status code, which should be an enum value of
  1139. // google.rpc.Code.
  1140. Code int64 `json:"code,omitempty"`
  1141. // Details: A list of messages that carry the error details. There is a
  1142. // common set of
  1143. // message types for APIs to use.
  1144. Details []googleapi.RawMessage `json:"details,omitempty"`
  1145. // Message: A developer-facing error message, which should be in
  1146. // English. Any
  1147. // user-facing error message should be localized and sent in
  1148. // the
  1149. // google.rpc.Status.details field, or localized by the client.
  1150. Message string `json:"message,omitempty"`
  1151. // ForceSendFields is a list of field names (e.g. "Code") to
  1152. // unconditionally include in API requests. By default, fields with
  1153. // empty values are omitted from API requests. However, any non-pointer,
  1154. // non-interface field appearing in ForceSendFields will be sent to the
  1155. // server regardless of whether the field is empty or not. This may be
  1156. // used to include empty fields in Patch requests.
  1157. ForceSendFields []string `json:"-"`
  1158. // NullFields is a list of field names (e.g. "Code") to include in API
  1159. // requests with the JSON null value. By default, fields with empty
  1160. // values are omitted from API requests. However, any field with an
  1161. // empty value appearing in NullFields will be sent to the server as
  1162. // null. It is an error if a field in this list has a non-empty value.
  1163. // This may be used to include null fields in Patch requests.
  1164. NullFields []string `json:"-"`
  1165. }
  1166. func (s *Status) MarshalJSON() ([]byte, error) {
  1167. type NoMethod Status
  1168. raw := NoMethod(*s)
  1169. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1170. }
  1171. // TextSpan: Represents an output piece of text.
  1172. type TextSpan struct {
  1173. // BeginOffset: The API calculates the beginning offset of the content
  1174. // in the original
  1175. // document according to the EncodingType specified in the API request.
  1176. BeginOffset int64 `json:"beginOffset,omitempty"`
  1177. // Content: The content of the output text.
  1178. Content string `json:"content,omitempty"`
  1179. // ForceSendFields is a list of field names (e.g. "BeginOffset") to
  1180. // unconditionally include in API requests. By default, fields with
  1181. // empty values are omitted from API requests. However, any non-pointer,
  1182. // non-interface field appearing in ForceSendFields will be sent to the
  1183. // server regardless of whether the field is empty or not. This may be
  1184. // used to include empty fields in Patch requests.
  1185. ForceSendFields []string `json:"-"`
  1186. // NullFields is a list of field names (e.g. "BeginOffset") to include
  1187. // in API requests with the JSON null value. By default, fields with
  1188. // empty values are omitted from API requests. However, any field with
  1189. // an empty value appearing in NullFields will be sent to the server as
  1190. // null. It is an error if a field in this list has a non-empty value.
  1191. // This may be used to include null fields in Patch requests.
  1192. NullFields []string `json:"-"`
  1193. }
  1194. func (s *TextSpan) MarshalJSON() ([]byte, error) {
  1195. type NoMethod TextSpan
  1196. raw := NoMethod(*s)
  1197. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1198. }
  1199. // Token: Represents the smallest syntactic building block of the text.
  1200. type Token struct {
  1201. // DependencyEdge: Dependency tree parse for this token.
  1202. DependencyEdge *DependencyEdge `json:"dependencyEdge,omitempty"`
  1203. // Lemma: [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29)
  1204. // of the token.
  1205. Lemma string `json:"lemma,omitempty"`
  1206. // PartOfSpeech: Parts of speech tag for this token.
  1207. PartOfSpeech *PartOfSpeech `json:"partOfSpeech,omitempty"`
  1208. // Text: The token text.
  1209. Text *TextSpan `json:"text,omitempty"`
  1210. // ForceSendFields is a list of field names (e.g. "DependencyEdge") to
  1211. // unconditionally include in API requests. By default, fields with
  1212. // empty values are omitted from API requests. However, any non-pointer,
  1213. // non-interface field appearing in ForceSendFields will be sent to the
  1214. // server regardless of whether the field is empty or not. This may be
  1215. // used to include empty fields in Patch requests.
  1216. ForceSendFields []string `json:"-"`
  1217. // NullFields is a list of field names (e.g. "DependencyEdge") to
  1218. // include in API requests with the JSON null value. By default, fields
  1219. // with empty values are omitted from API requests. However, any field
  1220. // with an empty value appearing in NullFields will be sent to the
  1221. // server as null. It is an error if a field in this list has a
  1222. // non-empty value. This may be used to include null fields in Patch
  1223. // requests.
  1224. NullFields []string `json:"-"`
  1225. }
  1226. func (s *Token) MarshalJSON() ([]byte, error) {
  1227. type NoMethod Token
  1228. raw := NoMethod(*s)
  1229. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1230. }
  1231. // method id "language.documents.analyzeEntities":
  1232. type DocumentsAnalyzeEntitiesCall struct {
  1233. s *Service
  1234. analyzeentitiesrequest *AnalyzeEntitiesRequest
  1235. urlParams_ gensupport.URLParams
  1236. ctx_ context.Context
  1237. header_ http.Header
  1238. }
  1239. // AnalyzeEntities: Finds named entities (currently proper names and
  1240. // common nouns) in the text
  1241. // along with entity types, salience, mentions for each entity,
  1242. // and
  1243. // other properties.
  1244. func (r *DocumentsService) AnalyzeEntities(analyzeentitiesrequest *AnalyzeEntitiesRequest) *DocumentsAnalyzeEntitiesCall {
  1245. c := &DocumentsAnalyzeEntitiesCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1246. c.analyzeentitiesrequest = analyzeentitiesrequest
  1247. return c
  1248. }
  1249. // Fields allows partial responses to be retrieved. See
  1250. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1251. // for more information.
  1252. func (c *DocumentsAnalyzeEntitiesCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeEntitiesCall {
  1253. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1254. return c
  1255. }
  1256. // Context sets the context to be used in this call's Do method. Any
  1257. // pending HTTP request will be aborted if the provided context is
  1258. // canceled.
  1259. func (c *DocumentsAnalyzeEntitiesCall) Context(ctx context.Context) *DocumentsAnalyzeEntitiesCall {
  1260. c.ctx_ = ctx
  1261. return c
  1262. }
  1263. // Header returns an http.Header that can be modified by the caller to
  1264. // add HTTP headers to the request.
  1265. func (c *DocumentsAnalyzeEntitiesCall) Header() http.Header {
  1266. if c.header_ == nil {
  1267. c.header_ = make(http.Header)
  1268. }
  1269. return c.header_
  1270. }
  1271. func (c *DocumentsAnalyzeEntitiesCall) doRequest(alt string) (*http.Response, error) {
  1272. reqHeaders := make(http.Header)
  1273. for k, v := range c.header_ {
  1274. reqHeaders[k] = v
  1275. }
  1276. reqHeaders.Set("User-Agent", c.s.userAgent())
  1277. var body io.Reader = nil
  1278. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzeentitiesrequest)
  1279. if err != nil {
  1280. return nil, err
  1281. }
  1282. reqHeaders.Set("Content-Type", "application/json")
  1283. c.urlParams_.Set("alt", alt)
  1284. c.urlParams_.Set("prettyPrint", "false")
  1285. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/documents:analyzeEntities")
  1286. urls += "?" + c.urlParams_.Encode()
  1287. req, err := http.NewRequest("POST", urls, body)
  1288. if err != nil {
  1289. return nil, err
  1290. }
  1291. req.Header = reqHeaders
  1292. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1293. }
  1294. // Do executes the "language.documents.analyzeEntities" call.
  1295. // Exactly one of *AnalyzeEntitiesResponse or error will be non-nil. Any
  1296. // non-2xx status code is an error. Response headers are in either
  1297. // *AnalyzeEntitiesResponse.ServerResponse.Header or (if a response was
  1298. // returned at all) in error.(*googleapi.Error).Header. Use
  1299. // googleapi.IsNotModified to check whether the returned error was
  1300. // because http.StatusNotModified was returned.
  1301. func (c *DocumentsAnalyzeEntitiesCall) Do(opts ...googleapi.CallOption) (*AnalyzeEntitiesResponse, error) {
  1302. gensupport.SetOptions(c.urlParams_, opts...)
  1303. res, err := c.doRequest("json")
  1304. if res != nil && res.StatusCode == http.StatusNotModified {
  1305. if res.Body != nil {
  1306. res.Body.Close()
  1307. }
  1308. return nil, &googleapi.Error{
  1309. Code: res.StatusCode,
  1310. Header: res.Header,
  1311. }
  1312. }
  1313. if err != nil {
  1314. return nil, err
  1315. }
  1316. defer googleapi.CloseBody(res)
  1317. if err := googleapi.CheckResponse(res); err != nil {
  1318. return nil, err
  1319. }
  1320. ret := &AnalyzeEntitiesResponse{
  1321. ServerResponse: googleapi.ServerResponse{
  1322. Header: res.Header,
  1323. HTTPStatusCode: res.StatusCode,
  1324. },
  1325. }
  1326. target := &ret
  1327. if err := gensupport.DecodeResponse(target, res); err != nil {
  1328. return nil, err
  1329. }
  1330. return ret, nil
  1331. // {
  1332. // "description": "Finds named entities (currently proper names and common nouns) in the text\nalong with entity types, salience, mentions for each entity, and\nother properties.",
  1333. // "flatPath": "v1beta1/documents:analyzeEntities",
  1334. // "httpMethod": "POST",
  1335. // "id": "language.documents.analyzeEntities",
  1336. // "parameterOrder": [],
  1337. // "parameters": {},
  1338. // "path": "v1beta1/documents:analyzeEntities",
  1339. // "request": {
  1340. // "$ref": "AnalyzeEntitiesRequest"
  1341. // },
  1342. // "response": {
  1343. // "$ref": "AnalyzeEntitiesResponse"
  1344. // },
  1345. // "scopes": [
  1346. // "https://www.googleapis.com/auth/cloud-language",
  1347. // "https://www.googleapis.com/auth/cloud-platform"
  1348. // ]
  1349. // }
  1350. }
  1351. // method id "language.documents.analyzeSentiment":
  1352. type DocumentsAnalyzeSentimentCall struct {
  1353. s *Service
  1354. analyzesentimentrequest *AnalyzeSentimentRequest
  1355. urlParams_ gensupport.URLParams
  1356. ctx_ context.Context
  1357. header_ http.Header
  1358. }
  1359. // AnalyzeSentiment: Analyzes the sentiment of the provided text.
  1360. func (r *DocumentsService) AnalyzeSentiment(analyzesentimentrequest *AnalyzeSentimentRequest) *DocumentsAnalyzeSentimentCall {
  1361. c := &DocumentsAnalyzeSentimentCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1362. c.analyzesentimentrequest = analyzesentimentrequest
  1363. return c
  1364. }
  1365. // Fields allows partial responses to be retrieved. See
  1366. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1367. // for more information.
  1368. func (c *DocumentsAnalyzeSentimentCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeSentimentCall {
  1369. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1370. return c
  1371. }
  1372. // Context sets the context to be used in this call's Do method. Any
  1373. // pending HTTP request will be aborted if the provided context is
  1374. // canceled.
  1375. func (c *DocumentsAnalyzeSentimentCall) Context(ctx context.Context) *DocumentsAnalyzeSentimentCall {
  1376. c.ctx_ = ctx
  1377. return c
  1378. }
  1379. // Header returns an http.Header that can be modified by the caller to
  1380. // add HTTP headers to the request.
  1381. func (c *DocumentsAnalyzeSentimentCall) Header() http.Header {
  1382. if c.header_ == nil {
  1383. c.header_ = make(http.Header)
  1384. }
  1385. return c.header_
  1386. }
  1387. func (c *DocumentsAnalyzeSentimentCall) doRequest(alt string) (*http.Response, error) {
  1388. reqHeaders := make(http.Header)
  1389. for k, v := range c.header_ {
  1390. reqHeaders[k] = v
  1391. }
  1392. reqHeaders.Set("User-Agent", c.s.userAgent())
  1393. var body io.Reader = nil
  1394. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzesentimentrequest)
  1395. if err != nil {
  1396. return nil, err
  1397. }
  1398. reqHeaders.Set("Content-Type", "application/json")
  1399. c.urlParams_.Set("alt", alt)
  1400. c.urlParams_.Set("prettyPrint", "false")
  1401. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/documents:analyzeSentiment")
  1402. urls += "?" + c.urlParams_.Encode()
  1403. req, err := http.NewRequest("POST", urls, body)
  1404. if err != nil {
  1405. return nil, err
  1406. }
  1407. req.Header = reqHeaders
  1408. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1409. }
  1410. // Do executes the "language.documents.analyzeSentiment" call.
  1411. // Exactly one of *AnalyzeSentimentResponse or error will be non-nil.
  1412. // Any non-2xx status code is an error. Response headers are in either
  1413. // *AnalyzeSentimentResponse.ServerResponse.Header or (if a response was
  1414. // returned at all) in error.(*googleapi.Error).Header. Use
  1415. // googleapi.IsNotModified to check whether the returned error was
  1416. // because http.StatusNotModified was returned.
  1417. func (c *DocumentsAnalyzeSentimentCall) Do(opts ...googleapi.CallOption) (*AnalyzeSentimentResponse, error) {
  1418. gensupport.SetOptions(c.urlParams_, opts...)
  1419. res, err := c.doRequest("json")
  1420. if res != nil && res.StatusCode == http.StatusNotModified {
  1421. if res.Body != nil {
  1422. res.Body.Close()
  1423. }
  1424. return nil, &googleapi.Error{
  1425. Code: res.StatusCode,
  1426. Header: res.Header,
  1427. }
  1428. }
  1429. if err != nil {
  1430. return nil, err
  1431. }
  1432. defer googleapi.CloseBody(res)
  1433. if err := googleapi.CheckResponse(res); err != nil {
  1434. return nil, err
  1435. }
  1436. ret := &AnalyzeSentimentResponse{
  1437. ServerResponse: googleapi.ServerResponse{
  1438. Header: res.Header,
  1439. HTTPStatusCode: res.StatusCode,
  1440. },
  1441. }
  1442. target := &ret
  1443. if err := gensupport.DecodeResponse(target, res); err != nil {
  1444. return nil, err
  1445. }
  1446. return ret, nil
  1447. // {
  1448. // "description": "Analyzes the sentiment of the provided text.",
  1449. // "flatPath": "v1beta1/documents:analyzeSentiment",
  1450. // "httpMethod": "POST",
  1451. // "id": "language.documents.analyzeSentiment",
  1452. // "parameterOrder": [],
  1453. // "parameters": {},
  1454. // "path": "v1beta1/documents:analyzeSentiment",
  1455. // "request": {
  1456. // "$ref": "AnalyzeSentimentRequest"
  1457. // },
  1458. // "response": {
  1459. // "$ref": "AnalyzeSentimentResponse"
  1460. // },
  1461. // "scopes": [
  1462. // "https://www.googleapis.com/auth/cloud-language",
  1463. // "https://www.googleapis.com/auth/cloud-platform"
  1464. // ]
  1465. // }
  1466. }
  1467. // method id "language.documents.analyzeSyntax":
  1468. type DocumentsAnalyzeSyntaxCall struct {
  1469. s *Service
  1470. analyzesyntaxrequest *AnalyzeSyntaxRequest
  1471. urlParams_ gensupport.URLParams
  1472. ctx_ context.Context
  1473. header_ http.Header
  1474. }
  1475. // AnalyzeSyntax: Analyzes the syntax of the text and provides sentence
  1476. // boundaries and
  1477. // tokenization along with part of speech tags, dependency trees, and
  1478. // other
  1479. // properties.
  1480. func (r *DocumentsService) AnalyzeSyntax(analyzesyntaxrequest *AnalyzeSyntaxRequest) *DocumentsAnalyzeSyntaxCall {
  1481. c := &DocumentsAnalyzeSyntaxCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1482. c.analyzesyntaxrequest = analyzesyntaxrequest
  1483. return c
  1484. }
  1485. // Fields allows partial responses to be retrieved. See
  1486. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1487. // for more information.
  1488. func (c *DocumentsAnalyzeSyntaxCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeSyntaxCall {
  1489. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1490. return c
  1491. }
  1492. // Context sets the context to be used in this call's Do method. Any
  1493. // pending HTTP request will be aborted if the provided context is
  1494. // canceled.
  1495. func (c *DocumentsAnalyzeSyntaxCall) Context(ctx context.Context) *DocumentsAnalyzeSyntaxCall {
  1496. c.ctx_ = ctx
  1497. return c
  1498. }
  1499. // Header returns an http.Header that can be modified by the caller to
  1500. // add HTTP headers to the request.
  1501. func (c *DocumentsAnalyzeSyntaxCall) Header() http.Header {
  1502. if c.header_ == nil {
  1503. c.header_ = make(http.Header)
  1504. }
  1505. return c.header_
  1506. }
  1507. func (c *DocumentsAnalyzeSyntaxCall) doRequest(alt string) (*http.Response, error) {
  1508. reqHeaders := make(http.Header)
  1509. for k, v := range c.header_ {
  1510. reqHeaders[k] = v
  1511. }
  1512. reqHeaders.Set("User-Agent", c.s.userAgent())
  1513. var body io.Reader = nil
  1514. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzesyntaxrequest)
  1515. if err != nil {
  1516. return nil, err
  1517. }
  1518. reqHeaders.Set("Content-Type", "application/json")
  1519. c.urlParams_.Set("alt", alt)
  1520. c.urlParams_.Set("prettyPrint", "false")
  1521. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/documents:analyzeSyntax")
  1522. urls += "?" + c.urlParams_.Encode()
  1523. req, err := http.NewRequest("POST", urls, body)
  1524. if err != nil {
  1525. return nil, err
  1526. }
  1527. req.Header = reqHeaders
  1528. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1529. }
  1530. // Do executes the "language.documents.analyzeSyntax" call.
  1531. // Exactly one of *AnalyzeSyntaxResponse or error will be non-nil. Any
  1532. // non-2xx status code is an error. Response headers are in either
  1533. // *AnalyzeSyntaxResponse.ServerResponse.Header or (if a response was
  1534. // returned at all) in error.(*googleapi.Error).Header. Use
  1535. // googleapi.IsNotModified to check whether the returned error was
  1536. // because http.StatusNotModified was returned.
  1537. func (c *DocumentsAnalyzeSyntaxCall) Do(opts ...googleapi.CallOption) (*AnalyzeSyntaxResponse, error) {
  1538. gensupport.SetOptions(c.urlParams_, opts...)
  1539. res, err := c.doRequest("json")
  1540. if res != nil && res.StatusCode == http.StatusNotModified {
  1541. if res.Body != nil {
  1542. res.Body.Close()
  1543. }
  1544. return nil, &googleapi.Error{
  1545. Code: res.StatusCode,
  1546. Header: res.Header,
  1547. }
  1548. }
  1549. if err != nil {
  1550. return nil, err
  1551. }
  1552. defer googleapi.CloseBody(res)
  1553. if err := googleapi.CheckResponse(res); err != nil {
  1554. return nil, err
  1555. }
  1556. ret := &AnalyzeSyntaxResponse{
  1557. ServerResponse: googleapi.ServerResponse{
  1558. Header: res.Header,
  1559. HTTPStatusCode: res.StatusCode,
  1560. },
  1561. }
  1562. target := &ret
  1563. if err := gensupport.DecodeResponse(target, res); err != nil {
  1564. return nil, err
  1565. }
  1566. return ret, nil
  1567. // {
  1568. // "description": "Analyzes the syntax of the text and provides sentence boundaries and\ntokenization along with part of speech tags, dependency trees, and other\nproperties.",
  1569. // "flatPath": "v1beta1/documents:analyzeSyntax",
  1570. // "httpMethod": "POST",
  1571. // "id": "language.documents.analyzeSyntax",
  1572. // "parameterOrder": [],
  1573. // "parameters": {},
  1574. // "path": "v1beta1/documents:analyzeSyntax",
  1575. // "request": {
  1576. // "$ref": "AnalyzeSyntaxRequest"
  1577. // },
  1578. // "response": {
  1579. // "$ref": "AnalyzeSyntaxResponse"
  1580. // },
  1581. // "scopes": [
  1582. // "https://www.googleapis.com/auth/cloud-language",
  1583. // "https://www.googleapis.com/auth/cloud-platform"
  1584. // ]
  1585. // }
  1586. }
  1587. // method id "language.documents.annotateText":
  1588. type DocumentsAnnotateTextCall struct {
  1589. s *Service
  1590. annotatetextrequest *AnnotateTextRequest
  1591. urlParams_ gensupport.URLParams
  1592. ctx_ context.Context
  1593. header_ http.Header
  1594. }
  1595. // AnnotateText: A convenience method that provides all the features
  1596. // that analyzeSentiment,
  1597. // analyzeEntities, and analyzeSyntax provide in one call.
  1598. func (r *DocumentsService) AnnotateText(annotatetextrequest *AnnotateTextRequest) *DocumentsAnnotateTextCall {
  1599. c := &DocumentsAnnotateTextCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1600. c.annotatetextrequest = annotatetextrequest
  1601. return c
  1602. }
  1603. // Fields allows partial responses to be retrieved. See
  1604. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1605. // for more information.
  1606. func (c *DocumentsAnnotateTextCall) Fields(s ...googleapi.Field) *DocumentsAnnotateTextCall {
  1607. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1608. return c
  1609. }
  1610. // Context sets the context to be used in this call's Do method. Any
  1611. // pending HTTP request will be aborted if the provided context is
  1612. // canceled.
  1613. func (c *DocumentsAnnotateTextCall) Context(ctx context.Context) *DocumentsAnnotateTextCall {
  1614. c.ctx_ = ctx
  1615. return c
  1616. }
  1617. // Header returns an http.Header that can be modified by the caller to
  1618. // add HTTP headers to the request.
  1619. func (c *DocumentsAnnotateTextCall) Header() http.Header {
  1620. if c.header_ == nil {
  1621. c.header_ = make(http.Header)
  1622. }
  1623. return c.header_
  1624. }
  1625. func (c *DocumentsAnnotateTextCall) doRequest(alt string) (*http.Response, error) {
  1626. reqHeaders := make(http.Header)
  1627. for k, v := range c.header_ {
  1628. reqHeaders[k] = v
  1629. }
  1630. reqHeaders.Set("User-Agent", c.s.userAgent())
  1631. var body io.Reader = nil
  1632. body, err := googleapi.WithoutDataWrapper.JSONReader(c.annotatetextrequest)
  1633. if err != nil {
  1634. return nil, err
  1635. }
  1636. reqHeaders.Set("Content-Type", "application/json")
  1637. c.urlParams_.Set("alt", alt)
  1638. c.urlParams_.Set("prettyPrint", "false")
  1639. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/documents:annotateText")
  1640. urls += "?" + c.urlParams_.Encode()
  1641. req, err := http.NewRequest("POST", urls, body)
  1642. if err != nil {
  1643. return nil, err
  1644. }
  1645. req.Header = reqHeaders
  1646. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1647. }
  1648. // Do executes the "language.documents.annotateText" call.
  1649. // Exactly one of *AnnotateTextResponse or error will be non-nil. Any
  1650. // non-2xx status code is an error. Response headers are in either
  1651. // *AnnotateTextResponse.ServerResponse.Header or (if a response was
  1652. // returned at all) in error.(*googleapi.Error).Header. Use
  1653. // googleapi.IsNotModified to check whether the returned error was
  1654. // because http.StatusNotModified was returned.
  1655. func (c *DocumentsAnnotateTextCall) Do(opts ...googleapi.CallOption) (*AnnotateTextResponse, error) {
  1656. gensupport.SetOptions(c.urlParams_, opts...)
  1657. res, err := c.doRequest("json")
  1658. if res != nil && res.StatusCode == http.StatusNotModified {
  1659. if res.Body != nil {
  1660. res.Body.Close()
  1661. }
  1662. return nil, &googleapi.Error{
  1663. Code: res.StatusCode,
  1664. Header: res.Header,
  1665. }
  1666. }
  1667. if err != nil {
  1668. return nil, err
  1669. }
  1670. defer googleapi.CloseBody(res)
  1671. if err := googleapi.CheckResponse(res); err != nil {
  1672. return nil, err
  1673. }
  1674. ret := &AnnotateTextResponse{
  1675. ServerResponse: googleapi.ServerResponse{
  1676. Header: res.Header,
  1677. HTTPStatusCode: res.StatusCode,
  1678. },
  1679. }
  1680. target := &ret
  1681. if err := gensupport.DecodeResponse(target, res); err != nil {
  1682. return nil, err
  1683. }
  1684. return ret, nil
  1685. // {
  1686. // "description": "A convenience method that provides all the features that analyzeSentiment,\nanalyzeEntities, and analyzeSyntax provide in one call.",
  1687. // "flatPath": "v1beta1/documents:annotateText",
  1688. // "httpMethod": "POST",
  1689. // "id": "language.documents.annotateText",
  1690. // "parameterOrder": [],
  1691. // "parameters": {},
  1692. // "path": "v1beta1/documents:annotateText",
  1693. // "request": {
  1694. // "$ref": "AnnotateTextRequest"
  1695. // },
  1696. // "response": {
  1697. // "$ref": "AnnotateTextResponse"
  1698. // },
  1699. // "scopes": [
  1700. // "https://www.googleapis.com/auth/cloud-language",
  1701. // "https://www.googleapis.com/auth/cloud-platform"
  1702. // ]
  1703. // }
  1704. }