google-cloud-language-v1beta2 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/lib/google/cloud/language/v1beta2/language_service/client.rb +5 -2
- data/lib/google/cloud/language/v1beta2/language_service_pb.rb +30 -1
- data/lib/google/cloud/language/v1beta2/language_service_services_pb.rb +2 -3
- data/lib/google/cloud/language/v1beta2/version.rb +1 -1
- data/proto_docs/google/cloud/language/v1beta2/language_service.rb +74 -1
- metadata +4 -5
- data/proto_docs/google/protobuf/timestamp.rb +0 -129
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54edb9b0db12a1443da0bdbaefc899d151ea1f4d62ee48739ddccb2028472c01
|
4
|
+
data.tar.gz: c64d9f82f2936a70d140cecf3baba4d855763566fa731a1e240b47d0f47192ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a0015537cc76fedbf5568a4df22197b5c78b3b5ad19322ddbe84a0e6f058649eef41274a1351e160573bbc4c6d4dbec11bebf9dbec0fc798a30c546eda26d2
|
7
|
+
data.tar.gz: 83c1ea529ab771c558beed222cd7a5336a75a142df43e455166ecc2f869399e1b9356485d5411a23730ec5a0c9bf6d296c9f39a315bfacf811c235435bbaa568
|
data/AUTHENTICATION.md
CHANGED
@@ -114,7 +114,7 @@ credentials are discovered.
|
|
114
114
|
To configure your system for this, simply:
|
115
115
|
|
116
116
|
1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
|
117
|
-
2. Authenticate using OAuth 2.0 `$ gcloud auth login`
|
117
|
+
2. Authenticate using OAuth 2.0 `$ gcloud auth application-default login`
|
118
118
|
3. Write code as if already authenticated.
|
119
119
|
|
120
120
|
**NOTE:** This is _not_ recommended for running in production. The Cloud SDK
|
@@ -416,7 +416,7 @@ module Google
|
|
416
416
|
|
417
417
|
##
|
418
418
|
# Analyzes the syntax of the text and provides sentence boundaries and
|
419
|
-
# tokenization along with part
|
419
|
+
# tokenization along with part of speech tags, dependency trees, and other
|
420
420
|
# properties.
|
421
421
|
#
|
422
422
|
# @overload analyze_syntax(request, options = nil)
|
@@ -508,13 +508,16 @@ module Google
|
|
508
508
|
# @param options [::Gapic::CallOptions, ::Hash]
|
509
509
|
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
510
510
|
#
|
511
|
-
# @overload classify_text(document: nil)
|
511
|
+
# @overload classify_text(document: nil, classification_model_options: nil)
|
512
512
|
# Pass arguments to `classify_text` via keyword arguments. Note that at
|
513
513
|
# least one keyword argument is required. To specify no parameters, or to keep all
|
514
514
|
# the default parameter values, pass an empty Hash as a request object (see above).
|
515
515
|
#
|
516
516
|
# @param document [::Google::Cloud::Language::V1beta2::Document, ::Hash]
|
517
517
|
# Required. Input document.
|
518
|
+
# @param classification_model_options [::Google::Cloud::Language::V1beta2::ClassificationModelOptions, ::Hash]
|
519
|
+
# Model options to use for classification. Defaults to v1 options if not
|
520
|
+
# specified.
|
518
521
|
#
|
519
522
|
# @yield [response, operation] Access the result along with the RPC operation
|
520
523
|
# @yieldparam response [::Google::Cloud::Language::V1beta2::ClassifyTextResponse]
|
@@ -6,13 +6,14 @@ require 'google/protobuf'
|
|
6
6
|
require 'google/api/annotations_pb'
|
7
7
|
require 'google/api/client_pb'
|
8
8
|
require 'google/api/field_behavior_pb'
|
9
|
-
require 'google/protobuf/timestamp_pb'
|
10
9
|
|
11
10
|
Google::Protobuf::DescriptorPool.generated_pool.build do
|
12
11
|
add_file("google/cloud/language/v1beta2/language_service.proto", :syntax => :proto3) do
|
13
12
|
add_message "google.cloud.language.v1beta2.Document" do
|
14
13
|
optional :type, :enum, 1, "google.cloud.language.v1beta2.Document.Type"
|
15
14
|
optional :language, :string, 4
|
15
|
+
optional :reference_web_uri, :string, 5
|
16
|
+
optional :boilerplate_handling, :enum, 6, "google.cloud.language.v1beta2.Document.BoilerplateHandling"
|
16
17
|
oneof :source do
|
17
18
|
optional :content, :string, 2
|
18
19
|
optional :gcs_content_uri, :string, 3
|
@@ -23,6 +24,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
23
24
|
value :PLAIN_TEXT, 1
|
24
25
|
value :HTML, 2
|
25
26
|
end
|
27
|
+
add_enum "google.cloud.language.v1beta2.Document.BoilerplateHandling" do
|
28
|
+
value :BOILERPLATE_HANDLING_UNSPECIFIED, 0
|
29
|
+
value :SKIP_BOILERPLATE, 1
|
30
|
+
value :KEEP_BOILERPLATE, 2
|
31
|
+
end
|
26
32
|
add_message "google.cloud.language.v1beta2.Sentence" do
|
27
33
|
optional :text, :message, 1, "google.cloud.language.v1beta2.TextSpan"
|
28
34
|
optional :sentiment, :message, 2, "google.cloud.language.v1beta2.Sentiment"
|
@@ -287,6 +293,22 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
287
293
|
optional :name, :string, 1
|
288
294
|
optional :confidence, :float, 2
|
289
295
|
end
|
296
|
+
add_message "google.cloud.language.v1beta2.ClassificationModelOptions" do
|
297
|
+
oneof :model_type do
|
298
|
+
optional :v1_model, :message, 1, "google.cloud.language.v1beta2.ClassificationModelOptions.V1Model"
|
299
|
+
optional :v2_model, :message, 2, "google.cloud.language.v1beta2.ClassificationModelOptions.V2Model"
|
300
|
+
end
|
301
|
+
end
|
302
|
+
add_message "google.cloud.language.v1beta2.ClassificationModelOptions.V1Model" do
|
303
|
+
end
|
304
|
+
add_message "google.cloud.language.v1beta2.ClassificationModelOptions.V2Model" do
|
305
|
+
optional :content_categories_version, :enum, 1, "google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion"
|
306
|
+
end
|
307
|
+
add_enum "google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion" do
|
308
|
+
value :CONTENT_CATEGORIES_VERSION_UNSPECIFIED, 0
|
309
|
+
value :V1, 1
|
310
|
+
value :V2, 2
|
311
|
+
end
|
290
312
|
add_message "google.cloud.language.v1beta2.AnalyzeSentimentRequest" do
|
291
313
|
optional :document, :message, 1, "google.cloud.language.v1beta2.Document"
|
292
314
|
optional :encoding_type, :enum, 2, "google.cloud.language.v1beta2.EncodingType"
|
@@ -323,6 +345,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
323
345
|
end
|
324
346
|
add_message "google.cloud.language.v1beta2.ClassifyTextRequest" do
|
325
347
|
optional :document, :message, 1, "google.cloud.language.v1beta2.Document"
|
348
|
+
optional :classification_model_options, :message, 3, "google.cloud.language.v1beta2.ClassificationModelOptions"
|
326
349
|
end
|
327
350
|
add_message "google.cloud.language.v1beta2.ClassifyTextResponse" do
|
328
351
|
repeated :categories, :message, 1, "google.cloud.language.v1beta2.ClassificationCategory"
|
@@ -338,6 +361,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
338
361
|
optional :extract_document_sentiment, :bool, 3
|
339
362
|
optional :extract_entity_sentiment, :bool, 4
|
340
363
|
optional :classify_text, :bool, 6
|
364
|
+
optional :classification_model_options, :message, 10, "google.cloud.language.v1beta2.ClassificationModelOptions"
|
341
365
|
end
|
342
366
|
add_message "google.cloud.language.v1beta2.AnnotateTextResponse" do
|
343
367
|
repeated :sentences, :message, 1, "google.cloud.language.v1beta2.Sentence"
|
@@ -362,6 +386,7 @@ module Google
|
|
362
386
|
module V1beta2
|
363
387
|
Document = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Document").msgclass
|
364
388
|
Document::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Document.Type").enummodule
|
389
|
+
Document::BoilerplateHandling = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Document.BoilerplateHandling").enummodule
|
365
390
|
Sentence = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Sentence").msgclass
|
366
391
|
Entity = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Entity").msgclass
|
367
392
|
Entity::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Entity.Type").enummodule
|
@@ -386,6 +411,10 @@ module Google
|
|
386
411
|
EntityMention::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.EntityMention.Type").enummodule
|
387
412
|
TextSpan = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.TextSpan").msgclass
|
388
413
|
ClassificationCategory = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationCategory").msgclass
|
414
|
+
ClassificationModelOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationModelOptions").msgclass
|
415
|
+
ClassificationModelOptions::V1Model = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationModelOptions.V1Model").msgclass
|
416
|
+
ClassificationModelOptions::V2Model = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationModelOptions.V2Model").msgclass
|
417
|
+
ClassificationModelOptions::V2Model::ContentCategoriesVersion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion").enummodule
|
389
418
|
AnalyzeSentimentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSentimentRequest").msgclass
|
390
419
|
AnalyzeSentimentResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSentimentResponse").msgclass
|
391
420
|
AnalyzeEntitySentimentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest").msgclass
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# Source: google/cloud/language/v1beta2/language_service.proto for package 'google.cloud.language.v1beta2'
|
3
3
|
# Original file comments:
|
4
|
-
# Copyright
|
4
|
+
# Copyright 2022 Google LLC
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -15,7 +15,6 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
#
|
19
18
|
|
20
19
|
require 'grpc'
|
21
20
|
require 'google/cloud/language/v1beta2/language_service_pb'
|
@@ -45,7 +44,7 @@ module Google
|
|
45
44
|
# sentiment associated with each entity and its mentions.
|
46
45
|
rpc :AnalyzeEntitySentiment, ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest, ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse
|
47
46
|
# Analyzes the syntax of the text and provides sentence boundaries and
|
48
|
-
# tokenization along with part
|
47
|
+
# tokenization along with part of speech tags, dependency trees, and other
|
49
48
|
# properties.
|
50
49
|
rpc :AnalyzeSyntax, ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest, ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse
|
51
50
|
# Classifies a document into categories.
|
@@ -46,6 +46,15 @@ module Google
|
|
46
46
|
# currently supported languages for each API method. If the language (either
|
47
47
|
# specified by the caller or automatically detected) is not supported by the
|
48
48
|
# called API method, an `INVALID_ARGUMENT` error is returned.
|
49
|
+
# @!attribute [rw] reference_web_uri
|
50
|
+
# @return [::String]
|
51
|
+
# The web URI where the document comes from. This URI is not used for
|
52
|
+
# fetching the content, but as a hint for analyzing the document.
|
53
|
+
# @!attribute [rw] boilerplate_handling
|
54
|
+
# @return [::Google::Cloud::Language::V1beta2::Document::BoilerplateHandling]
|
55
|
+
# Indicates how detected boilerplate(e.g. advertisements, copyright
|
56
|
+
# declarations, banners) should be handled for this document. If not
|
57
|
+
# specified, boilerplate will be treated the same as content.
|
49
58
|
class Document
|
50
59
|
include ::Google::Protobuf::MessageExts
|
51
60
|
extend ::Google::Protobuf::MessageExts::ClassMethods
|
@@ -61,6 +70,19 @@ module Google
|
|
61
70
|
# HTML
|
62
71
|
HTML = 2
|
63
72
|
end
|
73
|
+
|
74
|
+
# Ways of handling boilerplate detected in the document
|
75
|
+
module BoilerplateHandling
|
76
|
+
# The boilerplate handling is not specified.
|
77
|
+
BOILERPLATE_HANDLING_UNSPECIFIED = 0
|
78
|
+
|
79
|
+
# Do not analyze detected boilerplate. Reference web URI is required for
|
80
|
+
# detecting boilerplate.
|
81
|
+
SKIP_BOILERPLATE = 1
|
82
|
+
|
83
|
+
# Treat boilerplate the same as content.
|
84
|
+
KEEP_BOILERPLATE = 2
|
85
|
+
end
|
64
86
|
end
|
65
87
|
|
66
88
|
# Represents a sentence in the input document.
|
@@ -896,6 +918,49 @@ module Google
|
|
896
918
|
extend ::Google::Protobuf::MessageExts::ClassMethods
|
897
919
|
end
|
898
920
|
|
921
|
+
# Model options available for classification requests.
|
922
|
+
# @!attribute [rw] v1_model
|
923
|
+
# @return [::Google::Cloud::Language::V1beta2::ClassificationModelOptions::V1Model]
|
924
|
+
# Setting this field will use the V1 model and V1 content categories
|
925
|
+
# version. The V1 model is a legacy model; support for this will be
|
926
|
+
# discontinued in the future.
|
927
|
+
# @!attribute [rw] v2_model
|
928
|
+
# @return [::Google::Cloud::Language::V1beta2::ClassificationModelOptions::V2Model]
|
929
|
+
# Setting this field will use the V2 model with the appropriate content
|
930
|
+
# categories version. The V2 model is a better performing model.
|
931
|
+
class ClassificationModelOptions
|
932
|
+
include ::Google::Protobuf::MessageExts
|
933
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
934
|
+
|
935
|
+
# Options for the V1 model.
|
936
|
+
class V1Model
|
937
|
+
include ::Google::Protobuf::MessageExts
|
938
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
939
|
+
end
|
940
|
+
|
941
|
+
# Options for the V2 model.
|
942
|
+
# @!attribute [rw] content_categories_version
|
943
|
+
# @return [::Google::Cloud::Language::V1beta2::ClassificationModelOptions::V2Model::ContentCategoriesVersion]
|
944
|
+
# The content categories used for classification.
|
945
|
+
class V2Model
|
946
|
+
include ::Google::Protobuf::MessageExts
|
947
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
948
|
+
|
949
|
+
# The content categories used for classification.
|
950
|
+
module ContentCategoriesVersion
|
951
|
+
# If `ContentCategoriesVersion` is not specified, this option will
|
952
|
+
# default to `V1`.
|
953
|
+
CONTENT_CATEGORIES_VERSION_UNSPECIFIED = 0
|
954
|
+
|
955
|
+
# Legacy content categories of our initial launch in 2017.
|
956
|
+
V1 = 1
|
957
|
+
|
958
|
+
# Updated content categories in 2022.
|
959
|
+
V2 = 2
|
960
|
+
end
|
961
|
+
end
|
962
|
+
end
|
963
|
+
|
899
964
|
# The sentiment analysis request message.
|
900
965
|
# @!attribute [rw] document
|
901
966
|
# @return [::Google::Cloud::Language::V1beta2::Document]
|
@@ -1011,6 +1076,10 @@ module Google
|
|
1011
1076
|
# @!attribute [rw] document
|
1012
1077
|
# @return [::Google::Cloud::Language::V1beta2::Document]
|
1013
1078
|
# Required. Input document.
|
1079
|
+
# @!attribute [rw] classification_model_options
|
1080
|
+
# @return [::Google::Cloud::Language::V1beta2::ClassificationModelOptions]
|
1081
|
+
# Model options to use for classification. Defaults to v1 options if not
|
1082
|
+
# specified.
|
1014
1083
|
class ClassifyTextRequest
|
1015
1084
|
include ::Google::Protobuf::MessageExts
|
1016
1085
|
extend ::Google::Protobuf::MessageExts::ClassMethods
|
@@ -1042,7 +1111,7 @@ module Google
|
|
1042
1111
|
|
1043
1112
|
# All available features for sentiment, syntax, and semantic analysis.
|
1044
1113
|
# Setting each one to true will enable that specific analysis for the input.
|
1045
|
-
# Next ID:
|
1114
|
+
# Next ID: 11
|
1046
1115
|
# @!attribute [rw] extract_syntax
|
1047
1116
|
# @return [::Boolean]
|
1048
1117
|
# Extract syntax information.
|
@@ -1061,6 +1130,10 @@ module Google
|
|
1061
1130
|
# the API will use the default model which classifies into a
|
1062
1131
|
# [predefined
|
1063
1132
|
# taxonomy](https://cloud.google.com/natural-language/docs/categories).
|
1133
|
+
# @!attribute [rw] classification_model_options
|
1134
|
+
# @return [::Google::Cloud::Language::V1beta2::ClassificationModelOptions]
|
1135
|
+
# The model options to use for classification. Defaults to v1 options
|
1136
|
+
# if not specified. Only used if `classify_text` is set to true.
|
1064
1137
|
class Features
|
1065
1138
|
include ::Google::Protobuf::MessageExts
|
1066
1139
|
extend ::Google::Protobuf::MessageExts::ClassMethods
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-language-v1beta2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gapic-common
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.12'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 2.a
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.12'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.a
|
@@ -182,7 +182,6 @@ files:
|
|
182
182
|
- proto_docs/google/api/field_behavior.rb
|
183
183
|
- proto_docs/google/api/resource.rb
|
184
184
|
- proto_docs/google/cloud/language/v1beta2/language_service.rb
|
185
|
-
- proto_docs/google/protobuf/timestamp.rb
|
186
185
|
homepage: https://github.com/googleapis/google-cloud-ruby
|
187
186
|
licenses:
|
188
187
|
- Apache-2.0
|
@@ -1,129 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2020 Google LLC
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
-
|
19
|
-
|
20
|
-
module Google
|
21
|
-
module Protobuf
|
22
|
-
# A Timestamp represents a point in time independent of any time zone or local
|
23
|
-
# calendar, encoded as a count of seconds and fractions of seconds at
|
24
|
-
# nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
25
|
-
# January 1, 1970, in the proleptic Gregorian calendar which extends the
|
26
|
-
# Gregorian calendar backwards to year one.
|
27
|
-
#
|
28
|
-
# All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
29
|
-
# second table is needed for interpretation, using a [24-hour linear
|
30
|
-
# smear](https://developers.google.com/time/smear).
|
31
|
-
#
|
32
|
-
# The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
33
|
-
# restricting to that range, we ensure that we can convert to and from [RFC
|
34
|
-
# 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
35
|
-
#
|
36
|
-
# # Examples
|
37
|
-
#
|
38
|
-
# Example 1: Compute Timestamp from POSIX `time()`.
|
39
|
-
#
|
40
|
-
# Timestamp timestamp;
|
41
|
-
# timestamp.set_seconds(time(NULL));
|
42
|
-
# timestamp.set_nanos(0);
|
43
|
-
#
|
44
|
-
# Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
45
|
-
#
|
46
|
-
# struct timeval tv;
|
47
|
-
# gettimeofday(&tv, NULL);
|
48
|
-
#
|
49
|
-
# Timestamp timestamp;
|
50
|
-
# timestamp.set_seconds(tv.tv_sec);
|
51
|
-
# timestamp.set_nanos(tv.tv_usec * 1000);
|
52
|
-
#
|
53
|
-
# Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
54
|
-
#
|
55
|
-
# FILETIME ft;
|
56
|
-
# GetSystemTimeAsFileTime(&ft);
|
57
|
-
# UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
58
|
-
#
|
59
|
-
# // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
60
|
-
# // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
61
|
-
# Timestamp timestamp;
|
62
|
-
# timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
63
|
-
# timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
64
|
-
#
|
65
|
-
# Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
66
|
-
#
|
67
|
-
# long millis = System.currentTimeMillis();
|
68
|
-
#
|
69
|
-
# Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
70
|
-
# .setNanos((int) ((millis % 1000) * 1000000)).build();
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# Example 5: Compute Timestamp from Java `Instant.now()`.
|
74
|
-
#
|
75
|
-
# Instant now = Instant.now();
|
76
|
-
#
|
77
|
-
# Timestamp timestamp =
|
78
|
-
# Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
79
|
-
# .setNanos(now.getNano()).build();
|
80
|
-
#
|
81
|
-
#
|
82
|
-
# Example 6: Compute Timestamp from current time in Python.
|
83
|
-
#
|
84
|
-
# timestamp = Timestamp()
|
85
|
-
# timestamp.GetCurrentTime()
|
86
|
-
#
|
87
|
-
# # JSON Mapping
|
88
|
-
#
|
89
|
-
# In JSON format, the Timestamp type is encoded as a string in the
|
90
|
-
# [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
91
|
-
# format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z"
|
92
|
-
# where \\{year} is always expressed using four digits while \\{month}, \\{day},
|
93
|
-
# \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional
|
94
|
-
# seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
95
|
-
# are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
96
|
-
# is required. A proto3 JSON serializer should always use UTC (as indicated by
|
97
|
-
# "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
98
|
-
# able to accept both UTC and other timezones (as indicated by an offset).
|
99
|
-
#
|
100
|
-
# For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
101
|
-
# 01:30 UTC on January 15, 2017.
|
102
|
-
#
|
103
|
-
# In JavaScript, one can convert a Date object to this format using the
|
104
|
-
# standard
|
105
|
-
# [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
106
|
-
# method. In Python, a standard `datetime.datetime` object can be converted
|
107
|
-
# to this format using
|
108
|
-
# [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
109
|
-
# the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
110
|
-
# the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
111
|
-
# http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
112
|
-
# ) to obtain a formatter capable of generating timestamps in this format.
|
113
|
-
# @!attribute [rw] seconds
|
114
|
-
# @return [::Integer]
|
115
|
-
# Represents seconds of UTC time since Unix epoch
|
116
|
-
# 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
117
|
-
# 9999-12-31T23:59:59Z inclusive.
|
118
|
-
# @!attribute [rw] nanos
|
119
|
-
# @return [::Integer]
|
120
|
-
# Non-negative fractions of a second at nanosecond resolution. Negative
|
121
|
-
# second values with fractions must still have non-negative nanos values
|
122
|
-
# that count forward in time. Must be from 0 to 999,999,999
|
123
|
-
# inclusive.
|
124
|
-
class Timestamp
|
125
|
-
include ::Google::Protobuf::MessageExts
|
126
|
-
extend ::Google::Protobuf::MessageExts::ClassMethods
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|