-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
language-gen.go
6892 lines (6498 loc) · 302 KB
/
language-gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2024 Google LLC.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated file. DO NOT EDIT.
// Package language provides access to the Cloud Natural Language API.
//
// This package is DEPRECATED. Use package cloud.google.com/go/language/apiv1 instead.
//
// For product documentation, see: https://cloud.google.com/natural-language/
//
// # Library status
//
// These client libraries are officially supported by Google. However, this
// library is considered complete and is in maintenance mode. This means
// that we will address critical bugs and security issues but will not add
// any new features.
//
// When possible, we recommend using our newer
// [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
// that are still actively being worked and iterated on.
//
// # Creating a client
//
// Usage example:
//
// import "google.golang.org/api/language/v1"
// ...
// ctx := context.Background()
// languageService, err := language.NewService(ctx)
//
// In this example, Google Application Default Credentials are used for
// authentication. For information on how to create and obtain Application
// Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
//
// # Other authentication options
//
// By default, all available scopes (see "Constants") are used to authenticate.
// To restrict scopes, use [google.golang.org/api/option.WithScopes]:
//
// languageService, err := language.NewService(ctx, option.WithScopes(language.CloudPlatformScope))
//
// To use an API key for authentication (note: some APIs do not support API
// keys), use [google.golang.org/api/option.WithAPIKey]:
//
// languageService, err := language.NewService(ctx, option.WithAPIKey("AIza..."))
//
// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
// flow, use [google.golang.org/api/option.WithTokenSource]:
//
// config := &oauth2.Config{...}
// // ...
// token, err := config.Exchange(ctx, ...)
// languageService, err := language.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
//
// See [google.golang.org/api/option.ClientOption] for details on options.
package language // import "google.golang.org/api/language/v1"
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"strings"
googleapi "google.golang.org/api/googleapi"
internal "google.golang.org/api/internal"
gensupport "google.golang.org/api/internal/gensupport"
option "google.golang.org/api/option"
internaloption "google.golang.org/api/option/internaloption"
htransport "google.golang.org/api/transport/http"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = internaloption.WithDefaultEndpoint
var _ = internal.Version
const apiId = "language:v1"
const apiName = "language"
const apiVersion = "v1"
const basePath = "https://language.googleapis.com/"
const basePathTemplate = "https://language.UNIVERSE_DOMAIN/"
const mtlsBasePath = "https://language.mtls.googleapis.com/"
// OAuth2 scopes used by this API.
const (
// Apply machine learning models to reveal the structure and meaning of text
CloudLanguageScope = "https://www.googleapis.com/auth/cloud-language"
// See, edit, configure, and delete your Google Cloud data and see the email
// address for your Google Account.
CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
)
// NewService creates a new Service.
func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
scopesOption := internaloption.WithDefaultScopes(
"https://www.googleapis.com/auth/cloud-language",
"https://www.googleapis.com/auth/cloud-platform",
)
// NOTE: prepend, so we don't override user-specified scopes.
opts = append([]option.ClientOption{scopesOption}, opts...)
opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
opts = append(opts, internaloption.EnableNewAuthLibrary())
client, endpoint, err := htransport.NewClient(ctx, opts...)
if err != nil {
return nil, err
}
s, err := New(client)
if err != nil {
return nil, err
}
if endpoint != "" {
s.BasePath = endpoint
}
return s, nil
}
// New creates a new Service. It uses the provided http.Client for requests.
//
// Deprecated: please use NewService instead.
// To provide a custom HTTP client, use option.WithHTTPClient.
// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Documents = NewDocumentsService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Documents *DocumentsService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewDocumentsService(s *Service) *DocumentsService {
rs := &DocumentsService{s: s}
return rs
}
type DocumentsService struct {
s *Service
}
// AnalyzeEntitiesRequest: The entity analysis request message.
type AnalyzeEntitiesRequest struct {
// Document: Required. Input document.
Document *Document `json:"document,omitempty"`
// EncodingType: The encoding type used by the API to calculate offsets.
//
// Possible values:
// "NONE" - If `EncodingType` is not specified, encoding-dependent
// information (such as `begin_offset`) will be set at `-1`.
// "UTF8" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-8 encoding of the input. C++ and Go are examples
// of languages that use this encoding natively.
// "UTF16" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-16 encoding of the input. Java and JavaScript
// are examples of languages that use this encoding natively.
// "UTF32" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-32 encoding of the input. Python is an example
// of a language that uses this encoding natively.
EncodingType string `json:"encodingType,omitempty"`
// ForceSendFields is a list of field names (e.g. "Document") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Document") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeEntitiesRequest) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeEntitiesRequest
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeEntitiesResponse: The entity analysis response message.
type AnalyzeEntitiesResponse struct {
// Entities: The recognized entities in the input document.
Entities []*Entity `json:"entities,omitempty"`
// Language: The language of the text, which will be the same as the language
// specified in the request or, if not specified, the automatically-detected
// language. See Document.language field for more details.
Language string `json:"language,omitempty"`
// ServerResponse contains the HTTP response code and headers from the server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "Entities") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Entities") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeEntitiesResponse) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeEntitiesResponse
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeEntitySentimentRequest: The entity-level sentiment analysis request
// message.
type AnalyzeEntitySentimentRequest struct {
// Document: Required. Input document.
Document *Document `json:"document,omitempty"`
// EncodingType: The encoding type used by the API to calculate offsets.
//
// Possible values:
// "NONE" - If `EncodingType` is not specified, encoding-dependent
// information (such as `begin_offset`) will be set at `-1`.
// "UTF8" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-8 encoding of the input. C++ and Go are examples
// of languages that use this encoding natively.
// "UTF16" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-16 encoding of the input. Java and JavaScript
// are examples of languages that use this encoding natively.
// "UTF32" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-32 encoding of the input. Python is an example
// of a language that uses this encoding natively.
EncodingType string `json:"encodingType,omitempty"`
// ForceSendFields is a list of field names (e.g. "Document") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Document") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeEntitySentimentRequest) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeEntitySentimentRequest
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeEntitySentimentResponse: The entity-level sentiment analysis response
// message.
type AnalyzeEntitySentimentResponse struct {
// Entities: The recognized entities in the input document with associated
// sentiments.
Entities []*Entity `json:"entities,omitempty"`
// Language: The language of the text, which will be the same as the language
// specified in the request or, if not specified, the automatically-detected
// language. See Document.language field for more details.
Language string `json:"language,omitempty"`
// ServerResponse contains the HTTP response code and headers from the server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "Entities") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Entities") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeEntitySentimentResponse) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeEntitySentimentResponse
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeSentimentRequest: The sentiment analysis request message.
type AnalyzeSentimentRequest struct {
// Document: Required. Input document.
Document *Document `json:"document,omitempty"`
// EncodingType: The encoding type used by the API to calculate sentence
// offsets.
//
// Possible values:
// "NONE" - If `EncodingType` is not specified, encoding-dependent
// information (such as `begin_offset`) will be set at `-1`.
// "UTF8" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-8 encoding of the input. C++ and Go are examples
// of languages that use this encoding natively.
// "UTF16" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-16 encoding of the input. Java and JavaScript
// are examples of languages that use this encoding natively.
// "UTF32" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-32 encoding of the input. Python is an example
// of a language that uses this encoding natively.
EncodingType string `json:"encodingType,omitempty"`
// ForceSendFields is a list of field names (e.g. "Document") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Document") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeSentimentRequest) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeSentimentRequest
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeSentimentResponse: The sentiment analysis response message.
type AnalyzeSentimentResponse struct {
// DocumentSentiment: The overall sentiment of the input document.
DocumentSentiment *Sentiment `json:"documentSentiment,omitempty"`
// Language: The language of the text, which will be the same as the language
// specified in the request or, if not specified, the automatically-detected
// language. See Document.language field for more details.
Language string `json:"language,omitempty"`
// Sentences: The sentiment for all the sentences in the document.
Sentences []*Sentence `json:"sentences,omitempty"`
// ServerResponse contains the HTTP response code and headers from the server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "DocumentSentiment") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "DocumentSentiment") to include in
// API requests with the JSON null value. By default, fields with empty values
// are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeSentimentResponse) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeSentimentResponse
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeSyntaxRequest: The syntax analysis request message.
type AnalyzeSyntaxRequest struct {
// Document: Required. Input document.
Document *Document `json:"document,omitempty"`
// EncodingType: The encoding type used by the API to calculate offsets.
//
// Possible values:
// "NONE" - If `EncodingType` is not specified, encoding-dependent
// information (such as `begin_offset`) will be set at `-1`.
// "UTF8" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-8 encoding of the input. C++ and Go are examples
// of languages that use this encoding natively.
// "UTF16" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-16 encoding of the input. Java and JavaScript
// are examples of languages that use this encoding natively.
// "UTF32" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-32 encoding of the input. Python is an example
// of a language that uses this encoding natively.
EncodingType string `json:"encodingType,omitempty"`
// ForceSendFields is a list of field names (e.g. "Document") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Document") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeSyntaxRequest) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeSyntaxRequest
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnalyzeSyntaxResponse: The syntax analysis response message.
type AnalyzeSyntaxResponse struct {
// Language: The language of the text, which will be the same as the language
// specified in the request or, if not specified, the automatically-detected
// language. See Document.language field for more details.
Language string `json:"language,omitempty"`
// Sentences: Sentences in the input document.
Sentences []*Sentence `json:"sentences,omitempty"`
// Tokens: Tokens, along with their syntactic information, in the input
// document.
Tokens []*Token `json:"tokens,omitempty"`
// ServerResponse contains the HTTP response code and headers from the server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "Language") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Language") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnalyzeSyntaxResponse) MarshalJSON() ([]byte, error) {
type NoMethod AnalyzeSyntaxResponse
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnnotateTextRequest: The request message for the text annotation API, which
// can perform multiple analysis types (sentiment, entities, and syntax) in one
// call.
type AnnotateTextRequest struct {
// Document: Required. Input document.
Document *Document `json:"document,omitempty"`
// EncodingType: The encoding type used by the API to calculate offsets.
//
// Possible values:
// "NONE" - If `EncodingType` is not specified, encoding-dependent
// information (such as `begin_offset`) will be set at `-1`.
// "UTF8" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-8 encoding of the input. C++ and Go are examples
// of languages that use this encoding natively.
// "UTF16" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-16 encoding of the input. Java and JavaScript
// are examples of languages that use this encoding natively.
// "UTF32" - Encoding-dependent information (such as `begin_offset`) is
// calculated based on the UTF-32 encoding of the input. Python is an example
// of a language that uses this encoding natively.
EncodingType string `json:"encodingType,omitempty"`
// Features: Required. The enabled features.
Features *AnnotateTextRequestFeatures `json:"features,omitempty"`
// ForceSendFields is a list of field names (e.g. "Document") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Document") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnnotateTextRequest) MarshalJSON() ([]byte, error) {
type NoMethod AnnotateTextRequest
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnnotateTextRequestFeatures: All available features for sentiment, syntax,
// and semantic analysis. Setting each one to true will enable that specific
// analysis for the input.
type AnnotateTextRequestFeatures struct {
// ClassificationModelOptions: Optional. The model options to use for
// classification. Defaults to v1 options if not specified. Only used if
// `classify_text` is set to true.
ClassificationModelOptions *ClassificationModelOptions `json:"classificationModelOptions,omitempty"`
// ClassifyText: Classify the full document into categories.
ClassifyText bool `json:"classifyText,omitempty"`
// ExtractDocumentSentiment: Extract document-level sentiment.
ExtractDocumentSentiment bool `json:"extractDocumentSentiment,omitempty"`
// ExtractEntities: Extract entities.
ExtractEntities bool `json:"extractEntities,omitempty"`
// ExtractEntitySentiment: Extract entities and their associated sentiment.
ExtractEntitySentiment bool `json:"extractEntitySentiment,omitempty"`
// ExtractSyntax: Extract syntax information.
ExtractSyntax bool `json:"extractSyntax,omitempty"`
// ModerateText: Moderate the document for harmful and sensitive categories.
ModerateText bool `json:"moderateText,omitempty"`
// ForceSendFields is a list of field names (e.g. "ClassificationModelOptions")
// to unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "ClassificationModelOptions") to
// include in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnnotateTextRequestFeatures) MarshalJSON() ([]byte, error) {
type NoMethod AnnotateTextRequestFeatures
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// AnnotateTextResponse: The text annotations response message.
type AnnotateTextResponse struct {
// Categories: Categories identified in the input document.
Categories []*ClassificationCategory `json:"categories,omitempty"`
// DocumentSentiment: The overall sentiment for the document. Populated if the
// user enables AnnotateTextRequest.Features.extract_document_sentiment.
DocumentSentiment *Sentiment `json:"documentSentiment,omitempty"`
// Entities: Entities, along with their semantic information, in the input
// document. Populated if the user enables
// AnnotateTextRequest.Features.extract_entities.
Entities []*Entity `json:"entities,omitempty"`
// Language: The language of the text, which will be the same as the language
// specified in the request or, if not specified, the automatically-detected
// language. See Document.language field for more details.
Language string `json:"language,omitempty"`
// ModerationCategories: Harmful and sensitive categories identified in the
// input document.
ModerationCategories []*ClassificationCategory `json:"moderationCategories,omitempty"`
// Sentences: Sentences in the input document. Populated if the user enables
// AnnotateTextRequest.Features.extract_syntax.
Sentences []*Sentence `json:"sentences,omitempty"`
// Tokens: Tokens, along with their syntactic information, in the input
// document. Populated if the user enables
// AnnotateTextRequest.Features.extract_syntax.
Tokens []*Token `json:"tokens,omitempty"`
// ServerResponse contains the HTTP response code and headers from the server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "Categories") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Categories") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *AnnotateTextResponse) MarshalJSON() ([]byte, error) {
type NoMethod AnnotateTextResponse
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// ClassificationCategory: Represents a category returned from the text
// classifier.
type ClassificationCategory struct {
// Confidence: The classifier's confidence of the category. Number represents
// how certain the classifier is that this category represents the given text.
Confidence float64 `json:"confidence,omitempty"`
// Name: The name of the category representing the document.
Name string `json:"name,omitempty"`
// ForceSendFields is a list of field names (e.g. "Confidence") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Confidence") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *ClassificationCategory) MarshalJSON() ([]byte, error) {
type NoMethod ClassificationCategory
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
func (s *ClassificationCategory) UnmarshalJSON(data []byte) error {
type NoMethod ClassificationCategory
var s1 struct {
Confidence gensupport.JSONFloat64 `json:"confidence"`
*NoMethod
}
s1.NoMethod = (*NoMethod)(s)
if err := json.Unmarshal(data, &s1); err != nil {
return err
}
s.Confidence = float64(s1.Confidence)
return nil
}
// ClassificationModelOptions: Model options available for classification
// requests.
type ClassificationModelOptions struct {
// V1Model: Setting this field will use the V1 model and V1 content categories
// version. The V1 model is a legacy model; support for this will be
// discontinued in the future.
V1Model *ClassificationModelOptionsV1Model `json:"v1Model,omitempty"`
// V2Model: Setting this field will use the V2 model with the appropriate
// content categories version. The V2 model is a better performing model.
V2Model *ClassificationModelOptionsV2Model `json:"v2Model,omitempty"`
// ForceSendFields is a list of field names (e.g. "V1Model") to unconditionally
// include in API requests. By default, fields with empty or default values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "V1Model") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *ClassificationModelOptions) MarshalJSON() ([]byte, error) {
type NoMethod ClassificationModelOptions
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// ClassificationModelOptionsV1Model: Options for the V1 model.
type ClassificationModelOptionsV1Model struct {
}
// ClassificationModelOptionsV2Model: Options for the V2 model.
type ClassificationModelOptionsV2Model struct {
// ContentCategoriesVersion: The content categories used for classification.
//
// Possible values:
// "CONTENT_CATEGORIES_VERSION_UNSPECIFIED" - If `ContentCategoriesVersion`
// is not specified, this option will default to `V1`.
// "V1" - Legacy content categories of our initial launch in 2017.
// "V2" - Updated content categories in 2022.
ContentCategoriesVersion string `json:"contentCategoriesVersion,omitempty"`
// ForceSendFields is a list of field names (e.g. "ContentCategoriesVersion")
// to unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "ContentCategoriesVersion") to
// include in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *ClassificationModelOptionsV2Model) MarshalJSON() ([]byte, error) {
type NoMethod ClassificationModelOptionsV2Model
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// ClassifyTextRequest: The document classification request message.
type ClassifyTextRequest struct {
// ClassificationModelOptions: Optional. Model options to use for
// classification. Defaults to v1 options if not specified.
ClassificationModelOptions *ClassificationModelOptions `json:"classificationModelOptions,omitempty"`
// Document: Required. Input document.
Document *Document `json:"document,omitempty"`
// ForceSendFields is a list of field names (e.g. "ClassificationModelOptions")
// to unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "ClassificationModelOptions") to
// include in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *ClassifyTextRequest) MarshalJSON() ([]byte, error) {
type NoMethod ClassifyTextRequest
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// ClassifyTextResponse: The document classification response message.
type ClassifyTextResponse struct {
// Categories: Categories representing the input document.
Categories []*ClassificationCategory `json:"categories,omitempty"`
// ServerResponse contains the HTTP response code and headers from the server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "Categories") to
// unconditionally include in API requests. By default, fields with empty or
// default values are omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Categories") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *ClassifyTextResponse) MarshalJSON() ([]byte, error) {
type NoMethod ClassifyTextResponse
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
// Color: Represents a color in the RGBA color space. This representation is
// designed for simplicity of conversion to and from color representations in
// various languages over compactness. For example, the fields of this
// representation can be trivially provided to the constructor of
// `java.awt.Color` in Java; it can also be trivially provided to UIColor's
// `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little
// work, it can be easily formatted into a CSS `rgba()` string in JavaScript.
// This reference page doesn't have information about the absolute color space
// that should be used to interpret the RGB value—for example, sRGB, Adobe
// RGB, DCI-P3, and BT.2020. By default, applications should assume the sRGB
// color space. When color equality needs to be decided, implementations,
// unless documented otherwise, treat two colors as equal if all their red,
// green, blue, and alpha values each differ by at most `1e-5`. Example (Java):
// import com.google.type.Color; // ... public static java.awt.Color
// fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ?
// protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color(
// protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); }
// public static Color toProto(java.awt.Color color) { float red = (float)
// color.getRed(); float green = (float) color.getGreen(); float blue = (float)
// color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder =
// Color .newBuilder() .setRed(red / denominator) .setGreen(green /
// denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if
// (alpha != 255) { result.setAlpha( FloatValue .newBuilder()
// .setValue(((float) alpha) / denominator) .build()); } return
// resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static
// UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float
// green = [protocolor green]; float blue = [protocolor blue]; FloatValue*
// alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper !=
// nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red
// green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color)
// { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green
// blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc]
// init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue];
// if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; }
// [result autorelease]; return result; } // ... Example (JavaScript): // ...
// var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red ||
// 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue
// || 0.0; var red = Math.floor(redFrac * 255); var green =
// Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if
// (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var
// alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green,
// blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(”);
// }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new
// Number((red << 16) | (green << 8) | blue); var hexString =
// rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var
// resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) {
// resultBuilder.push('0'); } resultBuilder.push(hexString); return
// resultBuilder.join(”); }; // ...
type Color struct {
// Alpha: The fraction of this color that should be applied to the pixel. That
// is, the final pixel color is defined by the equation: `pixel color = alpha *
// (this color) + (1.0 - alpha) * (background color)` This means that a value
// of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a
// completely transparent color. This uses a wrapper message rather than a
// simple float scalar so that it is possible to distinguish between a default
// value and the value being unset. If omitted, this color object is rendered
// as a solid color (as if the alpha value had been explicitly given a value of
// 1.0).
Alpha float64 `json:"alpha,omitempty"`
// Blue: The amount of blue in the color as a value in the interval [0, 1].
Blue float64 `json:"blue,omitempty"`
// Green: The amount of green in the color as a value in the interval [0, 1].
Green float64 `json:"green,omitempty"`
// Red: The amount of red in the color as a value in the interval [0, 1].
Red float64 `json:"red,omitempty"`
// ForceSendFields is a list of field names (e.g. "Alpha") to unconditionally
// include in API requests. By default, fields with empty or default values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
// details.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Alpha") to include in API
// requests with the JSON null value. By default, fields with empty values are
// omitted from API requests. See
// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
NullFields []string `json:"-"`
}
func (s *Color) MarshalJSON() ([]byte, error) {
type NoMethod Color
return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
}
func (s *Color) UnmarshalJSON(data []byte) error {
type NoMethod Color
var s1 struct {
Alpha gensupport.JSONFloat64 `json:"alpha"`
Blue gensupport.JSONFloat64 `json:"blue"`
Green gensupport.JSONFloat64 `json:"green"`
Red gensupport.JSONFloat64 `json:"red"`
*NoMethod
}
s1.NoMethod = (*NoMethod)(s)
if err := json.Unmarshal(data, &s1); err != nil {
return err
}
s.Alpha = float64(s1.Alpha)
s.Blue = float64(s1.Blue)
s.Green = float64(s1.Green)
s.Red = float64(s1.Red)
return nil
}
// CpuMetric: Metric for billing reports.
type CpuMetric struct {
// CoreNumber: Required. Number of CPU cores.
CoreNumber int64 `json:"coreNumber,omitempty,string"`
// CoreSec: Required. Total seconds of core usage, e.g. 4.
CoreSec int64 `json:"coreSec,omitempty,string"`
// CpuType: Required. Type of cpu, e.g. N2.
//
// Possible values:
// "UNKNOWN_CPU_TYPE"
// "A2" - GPU-based machine, skip quota reporting.
// "A3" - GPU-based machine, skip quota reporting.
// "C2" - COMPUTE_OPTIMIZED
// "C2D"
// "CUSTOM"
// "E2"
// "G2" - GPU-based machine, skip quota reporting.
// "C3"
// "M2" - MEMORY_OPTIMIZED_UPGRADE_PREMIUM
// "M1" - MEMORY_OPTIMIZED
// "N1"
// "N2_CUSTOM"
// "N2"
// "N2D"
CpuType string `json:"cpuType,omitempty"`
// MachineSpec: Required. Machine spec, e.g. N1_STANDARD_4.
//
// Possible values:
// "UNKNOWN_MACHINE_SPEC"
// "N1_STANDARD_2"
// "N1_STANDARD_4"
// "N1_STANDARD_8"
// "N1_STANDARD_16"
// "N1_STANDARD_32"
// "N1_STANDARD_64"
// "N1_STANDARD_96"
// "N1_HIGHMEM_2"
// "N1_HIGHMEM_4"
// "N1_HIGHMEM_8"
// "N1_HIGHMEM_16"
// "N1_HIGHMEM_32"
// "N1_HIGHMEM_64"
// "N1_HIGHMEM_96"
// "N1_HIGHCPU_2"
// "N1_HIGHCPU_4"
// "N1_HIGHCPU_8"
// "N1_HIGHCPU_16"
// "N1_HIGHCPU_32"
// "N1_HIGHCPU_64"
// "N1_HIGHCPU_96"
// "A2_HIGHGPU_1G"
// "A2_HIGHGPU_2G"
// "A2_HIGHGPU_4G"
// "A2_HIGHGPU_8G"
// "A2_MEGAGPU_16G"
// "A2_ULTRAGPU_1G"
// "A2_ULTRAGPU_2G"
// "A2_ULTRAGPU_4G"
// "A2_ULTRAGPU_8G"
// "A3_HIGHGPU_8G"
// "E2_STANDARD_2"
// "E2_STANDARD_4"
// "E2_STANDARD_8"
// "E2_STANDARD_16"
// "E2_STANDARD_32"
// "E2_HIGHMEM_2"
// "E2_HIGHMEM_4"
// "E2_HIGHMEM_8"
// "E2_HIGHMEM_16"
// "E2_HIGHCPU_2"
// "E2_HIGHCPU_4"
// "E2_HIGHCPU_8"
// "E2_HIGHCPU_16"
// "E2_HIGHCPU_32"
// "N2_STANDARD_2"
// "N2_STANDARD_4"
// "N2_STANDARD_8"
// "N2_STANDARD_16"
// "N2_STANDARD_32"
// "N2_STANDARD_48"
// "N2_STANDARD_64"
// "N2_STANDARD_80"
// "N2_STANDARD_96"
// "N2_STANDARD_128"
// "N2_HIGHMEM_2"
// "N2_HIGHMEM_4"
// "N2_HIGHMEM_8"
// "N2_HIGHMEM_16"
// "N2_HIGHMEM_32"
// "N2_HIGHMEM_48"
// "N2_HIGHMEM_64"
// "N2_HIGHMEM_80"
// "N2_HIGHMEM_96"
// "N2_HIGHMEM_128"
// "N2_HIGHCPU_2"
// "N2_HIGHCPU_4"
// "N2_HIGHCPU_8"
// "N2_HIGHCPU_16"
// "N2_HIGHCPU_32"
// "N2_HIGHCPU_48"
// "N2_HIGHCPU_64"
// "N2_HIGHCPU_80"
// "N2_HIGHCPU_96"
// "N2D_STANDARD_2"
// "N2D_STANDARD_4"
// "N2D_STANDARD_8"
// "N2D_STANDARD_16"
// "N2D_STANDARD_32"
// "N2D_STANDARD_48"
// "N2D_STANDARD_64"
// "N2D_STANDARD_80"
// "N2D_STANDARD_96"
// "N2D_STANDARD_128"
// "N2D_STANDARD_224"
// "N2D_HIGHMEM_2"
// "N2D_HIGHMEM_4"
// "N2D_HIGHMEM_8"
// "N2D_HIGHMEM_16"
// "N2D_HIGHMEM_32"
// "N2D_HIGHMEM_48"
// "N2D_HIGHMEM_64"
// "N2D_HIGHMEM_80"
// "N2D_HIGHMEM_96"
// "N2D_HIGHCPU_2"
// "N2D_HIGHCPU_4"
// "N2D_HIGHCPU_8"
// "N2D_HIGHCPU_16"
// "N2D_HIGHCPU_32"
// "N2D_HIGHCPU_48"
// "N2D_HIGHCPU_64"
// "N2D_HIGHCPU_80"
// "N2D_HIGHCPU_96"
// "N2D_HIGHCPU_128"
// "N2D_HIGHCPU_224"
// "C2_STANDARD_4"
// "C2_STANDARD_8"
// "C2_STANDARD_16"
// "C2_STANDARD_30"
// "C2_STANDARD_60"
// "C2D_STANDARD_2"
// "C2D_STANDARD_4"
// "C2D_STANDARD_8"
// "C2D_STANDARD_16"
// "C2D_STANDARD_32"
// "C2D_STANDARD_56"
// "C2D_STANDARD_112"
// "C2D_HIGHCPU_2"
// "C2D_HIGHCPU_4"
// "C2D_HIGHCPU_8"
// "C2D_HIGHCPU_16"
// "C2D_HIGHCPU_32"
// "C2D_HIGHCPU_56"
// "C2D_HIGHCPU_112"
// "C2D_HIGHMEM_2"
// "C2D_HIGHMEM_4"
// "C2D_HIGHMEM_8"
// "C2D_HIGHMEM_16"
// "C2D_HIGHMEM_32"
// "C2D_HIGHMEM_56"
// "C2D_HIGHMEM_112"
// "G2_STANDARD_4"
// "G2_STANDARD_8"
// "G2_STANDARD_12"
// "G2_STANDARD_16"
// "G2_STANDARD_24"
// "G2_STANDARD_32"
// "G2_STANDARD_48"
// "G2_STANDARD_96"
// "C3_STANDARD_4"
// "C3_STANDARD_8"
// "C3_STANDARD_22"
// "C3_STANDARD_44"
// "C3_STANDARD_88"