google-cloud-speech-v1 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +24 -0
- data/lib/google-cloud-speech-v1.rb +1 -0
- data/lib/google/cloud/common_resources_pb.rb +15 -0
- data/lib/google/cloud/speech/v1.rb +19 -0
- data/lib/google/cloud/speech/v1/cloud_speech_pb.rb +193 -0
- data/lib/google/cloud/speech/v1/cloud_speech_services_pb.rb +57 -0
- data/lib/google/cloud/speech/v1/speech.rb +21 -0
- data/lib/google/cloud/speech/v1/speech/client.rb +527 -0
- data/lib/google/cloud/speech/v1/speech/credentials.rb +51 -0
- data/lib/google/cloud/speech/v1/speech/operations.rb +558 -0
- data/lib/google/cloud/speech/v1/version.rb +28 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/resource.rb +247 -0
- data/proto_docs/google/cloud/speech/v1/cloud_speech.rb +753 -0
- data/proto_docs/google/longrunning/operations.rb +150 -0
- data/proto_docs/google/protobuf/any.rb +137 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/timestamp.rb +116 -0
- data/proto_docs/google/rpc/status.rb +46 -0
- metadata +183 -0
@@ -0,0 +1,150 @@
|
|
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 Longrunning
|
22
|
+
# This resource represents a long-running operation that is the result of a
|
23
|
+
# network API call.
|
24
|
+
# @!attribute [rw] name
|
25
|
+
# @return [String]
|
26
|
+
# The server-assigned name, which is only unique within the same service that
|
27
|
+
# originally returns it. If you use the default HTTP mapping, the
|
28
|
+
# `name` should have the format of `operations/some/unique/name`.
|
29
|
+
# @!attribute [rw] metadata
|
30
|
+
# @return [Google::Protobuf::Any]
|
31
|
+
# Service-specific metadata associated with the operation. It typically
|
32
|
+
# contains progress information and common metadata such as create time.
|
33
|
+
# Some services might not provide such metadata. Any method that returns a
|
34
|
+
# long-running operation should document the metadata type, if any.
|
35
|
+
# @!attribute [rw] done
|
36
|
+
# @return [Boolean]
|
37
|
+
# If the value is `false`, it means the operation is still in progress.
|
38
|
+
# If true, the operation is completed, and either `error` or `response` is
|
39
|
+
# available.
|
40
|
+
# @!attribute [rw] error
|
41
|
+
# @return [Google::Rpc::Status]
|
42
|
+
# The error result of the operation in case of failure or cancellation.
|
43
|
+
# @!attribute [rw] response
|
44
|
+
# @return [Google::Protobuf::Any]
|
45
|
+
# The normal response of the operation in case of success. If the original
|
46
|
+
# method returns no data on success, such as `Delete`, the response is
|
47
|
+
# `google.protobuf.Empty`. If the original method is standard
|
48
|
+
# `Get`/`Create`/`Update`, the response should be the resource. For other
|
49
|
+
# methods, the response should have the type `XxxResponse`, where `Xxx`
|
50
|
+
# is the original method name. For example, if the original method name
|
51
|
+
# is `TakeSnapshot()`, the inferred response type is
|
52
|
+
# `TakeSnapshotResponse`.
|
53
|
+
class Operation
|
54
|
+
include Google::Protobuf::MessageExts
|
55
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
56
|
+
end
|
57
|
+
|
58
|
+
# The request message for Operations.GetOperation.
|
59
|
+
# @!attribute [rw] name
|
60
|
+
# @return [String]
|
61
|
+
# The name of the operation resource.
|
62
|
+
class GetOperationRequest
|
63
|
+
include Google::Protobuf::MessageExts
|
64
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
65
|
+
end
|
66
|
+
|
67
|
+
# The request message for Operations.ListOperations.
|
68
|
+
# @!attribute [rw] name
|
69
|
+
# @return [String]
|
70
|
+
# The name of the operation collection.
|
71
|
+
# @!attribute [rw] filter
|
72
|
+
# @return [String]
|
73
|
+
# The standard list filter.
|
74
|
+
# @!attribute [rw] page_size
|
75
|
+
# @return [Integer]
|
76
|
+
# The standard list page size.
|
77
|
+
# @!attribute [rw] page_token
|
78
|
+
# @return [String]
|
79
|
+
# The standard list page token.
|
80
|
+
class ListOperationsRequest
|
81
|
+
include Google::Protobuf::MessageExts
|
82
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
83
|
+
end
|
84
|
+
|
85
|
+
# The response message for Operations.ListOperations.
|
86
|
+
# @!attribute [rw] operations
|
87
|
+
# @return [Array<Google::Longrunning::Operation>]
|
88
|
+
# A list of operations that matches the specified filter in the request.
|
89
|
+
# @!attribute [rw] next_page_token
|
90
|
+
# @return [String]
|
91
|
+
# The standard List next-page token.
|
92
|
+
class ListOperationsResponse
|
93
|
+
include Google::Protobuf::MessageExts
|
94
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
95
|
+
end
|
96
|
+
|
97
|
+
# The request message for Operations.CancelOperation.
|
98
|
+
# @!attribute [rw] name
|
99
|
+
# @return [String]
|
100
|
+
# The name of the operation resource to be cancelled.
|
101
|
+
class CancelOperationRequest
|
102
|
+
include Google::Protobuf::MessageExts
|
103
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
104
|
+
end
|
105
|
+
|
106
|
+
# The request message for Operations.DeleteOperation.
|
107
|
+
# @!attribute [rw] name
|
108
|
+
# @return [String]
|
109
|
+
# The name of the operation resource to be deleted.
|
110
|
+
class DeleteOperationRequest
|
111
|
+
include Google::Protobuf::MessageExts
|
112
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
113
|
+
end
|
114
|
+
|
115
|
+
# A message representing the message types used by a long-running operation.
|
116
|
+
#
|
117
|
+
# Example:
|
118
|
+
#
|
119
|
+
# rpc LongRunningRecognize(LongRunningRecognizeRequest)
|
120
|
+
# returns (google.longrunning.Operation) {
|
121
|
+
# option (google.longrunning.operation_info) = {
|
122
|
+
# response_type: "LongRunningRecognizeResponse"
|
123
|
+
# metadata_type: "LongRunningRecognizeMetadata"
|
124
|
+
# };
|
125
|
+
# }
|
126
|
+
# @!attribute [rw] response_type
|
127
|
+
# @return [String]
|
128
|
+
# Required. The message name of the primary return type for this
|
129
|
+
# long-running operation.
|
130
|
+
# This type will be used to deserialize the LRO's response.
|
131
|
+
#
|
132
|
+
# If the response is in a different package from the rpc, a fully-qualified
|
133
|
+
# message name must be used (e.g. `google.protobuf.Struct`).
|
134
|
+
#
|
135
|
+
# Note: Altering this value constitutes a breaking change.
|
136
|
+
# @!attribute [rw] metadata_type
|
137
|
+
# @return [String]
|
138
|
+
# Required. The message name of the metadata type for this long-running
|
139
|
+
# operation.
|
140
|
+
#
|
141
|
+
# If the response is in a different package from the rpc, a fully-qualified
|
142
|
+
# message name must be used (e.g. `google.protobuf.Struct`).
|
143
|
+
#
|
144
|
+
# Note: Altering this value constitutes a breaking change.
|
145
|
+
class OperationInfo
|
146
|
+
include Google::Protobuf::MessageExts
|
147
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,137 @@
|
|
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
|
+
# `Any` contains an arbitrary serialized protocol buffer message along with a
|
23
|
+
# URL that describes the type of the serialized message.
|
24
|
+
#
|
25
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
26
|
+
# of utility functions or additional generated methods of the Any type.
|
27
|
+
#
|
28
|
+
# Example 1: Pack and unpack a message in C++.
|
29
|
+
#
|
30
|
+
# Foo foo = ...;
|
31
|
+
# Any any;
|
32
|
+
# any.PackFrom(foo);
|
33
|
+
# ...
|
34
|
+
# if (any.UnpackTo(&foo)) {
|
35
|
+
# ...
|
36
|
+
# }
|
37
|
+
#
|
38
|
+
# Example 2: Pack and unpack a message in Java.
|
39
|
+
#
|
40
|
+
# Foo foo = ...;
|
41
|
+
# Any any = Any.pack(foo);
|
42
|
+
# ...
|
43
|
+
# if (any.is(Foo.class)) {
|
44
|
+
# foo = any.unpack(Foo.class);
|
45
|
+
# }
|
46
|
+
#
|
47
|
+
# Example 3: Pack and unpack a message in Python.
|
48
|
+
#
|
49
|
+
# foo = Foo(...)
|
50
|
+
# any = Any()
|
51
|
+
# any.Pack(foo)
|
52
|
+
# ...
|
53
|
+
# if any.Is(Foo.DESCRIPTOR):
|
54
|
+
# any.Unpack(foo)
|
55
|
+
# ...
|
56
|
+
#
|
57
|
+
# Example 4: Pack and unpack a message in Go
|
58
|
+
#
|
59
|
+
# foo := &pb.Foo{...}
|
60
|
+
# any, err := ptypes.MarshalAny(foo)
|
61
|
+
# ...
|
62
|
+
# foo := &pb.Foo{}
|
63
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
64
|
+
# ...
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# The pack methods provided by protobuf library will by default use
|
68
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
69
|
+
# methods only use the fully qualified type name after the last '/'
|
70
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
71
|
+
# name "y.z".
|
72
|
+
#
|
73
|
+
#
|
74
|
+
# JSON
|
75
|
+
# ====
|
76
|
+
# The JSON representation of an `Any` value uses the regular
|
77
|
+
# representation of the deserialized, embedded message, with an
|
78
|
+
# additional field `@type` which contains the type URL. Example:
|
79
|
+
#
|
80
|
+
# package google.profile;
|
81
|
+
# message Person {
|
82
|
+
# string first_name = 1;
|
83
|
+
# string last_name = 2;
|
84
|
+
# }
|
85
|
+
#
|
86
|
+
# {
|
87
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
88
|
+
# "firstName": <string>,
|
89
|
+
# "lastName": <string>
|
90
|
+
# }
|
91
|
+
#
|
92
|
+
# If the embedded message type is well-known and has a custom JSON
|
93
|
+
# representation, that representation will be embedded adding a field
|
94
|
+
# `value` which holds the custom JSON in addition to the `@type`
|
95
|
+
# field. Example (for message [google.protobuf.Duration][]):
|
96
|
+
#
|
97
|
+
# {
|
98
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
99
|
+
# "value": "1.212s"
|
100
|
+
# }
|
101
|
+
# @!attribute [rw] type_url
|
102
|
+
# @return [String]
|
103
|
+
# A URL/resource name that uniquely identifies the type of the serialized
|
104
|
+
# protocol buffer message. The last segment of the URL's path must represent
|
105
|
+
# the fully qualified name of the type (as in
|
106
|
+
# `path/google.protobuf.Duration`). The name should be in a canonical form
|
107
|
+
# (e.g., leading "." is not accepted).
|
108
|
+
#
|
109
|
+
# In practice, teams usually precompile into the binary all types that they
|
110
|
+
# expect it to use in the context of Any. However, for URLs which use the
|
111
|
+
# scheme `http`, `https`, or no scheme, one can optionally set up a type
|
112
|
+
# server that maps type URLs to message definitions as follows:
|
113
|
+
#
|
114
|
+
# * If no scheme is provided, `https` is assumed.
|
115
|
+
# * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
116
|
+
# value in binary format, or produce an error.
|
117
|
+
# * Applications are allowed to cache lookup results based on the
|
118
|
+
# URL, or have them precompiled into a binary to avoid any
|
119
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
120
|
+
# on changes to types. (Use versioned type names to manage
|
121
|
+
# breaking changes.)
|
122
|
+
#
|
123
|
+
# Note: this functionality is not currently available in the official
|
124
|
+
# protobuf release, and it is not used for type URLs beginning with
|
125
|
+
# type.googleapis.com.
|
126
|
+
#
|
127
|
+
# Schemes other than `http`, `https` (or the empty scheme) might be
|
128
|
+
# used with implementation specific semantics.
|
129
|
+
# @!attribute [rw] value
|
130
|
+
# @return [String]
|
131
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
132
|
+
class Any
|
133
|
+
include Google::Protobuf::MessageExts
|
134
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,98 @@
|
|
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 Duration represents a signed, fixed-length span of time represented
|
23
|
+
# as a count of seconds and fractions of seconds at nanosecond
|
24
|
+
# resolution. It is independent of any calendar and concepts like "day"
|
25
|
+
# or "month". It is related to Timestamp in that the difference between
|
26
|
+
# two Timestamp values is a Duration and it can be added or subtracted
|
27
|
+
# from a Timestamp. Range is approximately +-10,000 years.
|
28
|
+
#
|
29
|
+
# # Examples
|
30
|
+
#
|
31
|
+
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
32
|
+
#
|
33
|
+
# Timestamp start = ...;
|
34
|
+
# Timestamp end = ...;
|
35
|
+
# Duration duration = ...;
|
36
|
+
#
|
37
|
+
# duration.seconds = end.seconds - start.seconds;
|
38
|
+
# duration.nanos = end.nanos - start.nanos;
|
39
|
+
#
|
40
|
+
# if (duration.seconds < 0 && duration.nanos > 0) {
|
41
|
+
# duration.seconds += 1;
|
42
|
+
# duration.nanos -= 1000000000;
|
43
|
+
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
44
|
+
# duration.seconds -= 1;
|
45
|
+
# duration.nanos += 1000000000;
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
49
|
+
#
|
50
|
+
# Timestamp start = ...;
|
51
|
+
# Duration duration = ...;
|
52
|
+
# Timestamp end = ...;
|
53
|
+
#
|
54
|
+
# end.seconds = start.seconds + duration.seconds;
|
55
|
+
# end.nanos = start.nanos + duration.nanos;
|
56
|
+
#
|
57
|
+
# if (end.nanos < 0) {
|
58
|
+
# end.seconds -= 1;
|
59
|
+
# end.nanos += 1000000000;
|
60
|
+
# } else if (end.nanos >= 1000000000) {
|
61
|
+
# end.seconds += 1;
|
62
|
+
# end.nanos -= 1000000000;
|
63
|
+
# }
|
64
|
+
#
|
65
|
+
# Example 3: Compute Duration from datetime.timedelta in Python.
|
66
|
+
#
|
67
|
+
# td = datetime.timedelta(days=3, minutes=10)
|
68
|
+
# duration = Duration()
|
69
|
+
# duration.FromTimedelta(td)
|
70
|
+
#
|
71
|
+
# # JSON Mapping
|
72
|
+
#
|
73
|
+
# In JSON format, the Duration type is encoded as a string rather than an
|
74
|
+
# object, where the string ends in the suffix "s" (indicating seconds) and
|
75
|
+
# is preceded by the number of seconds, with nanoseconds expressed as
|
76
|
+
# fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
77
|
+
# encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
78
|
+
# be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
79
|
+
# microsecond should be expressed in JSON format as "3.000001s".
|
80
|
+
# @!attribute [rw] seconds
|
81
|
+
# @return [Integer]
|
82
|
+
# Signed seconds of the span of time. Must be from -315,576,000,000
|
83
|
+
# to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
84
|
+
# 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
85
|
+
# @!attribute [rw] nanos
|
86
|
+
# @return [Integer]
|
87
|
+
# Signed fractions of a second at nanosecond resolution of the span
|
88
|
+
# of time. Durations less than one second are represented with a 0
|
89
|
+
# `seconds` field and a positive or negative `nanos` field. For durations
|
90
|
+
# of one second or more, a non-zero value for the `nanos` field must be
|
91
|
+
# of the same sign as the `seconds` field. Must be from -999,999,999
|
92
|
+
# to +999,999,999 inclusive.
|
93
|
+
class Duration
|
94
|
+
include Google::Protobuf::MessageExts
|
95
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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 generic empty message that you can re-use to avoid defining duplicated
|
23
|
+
# empty messages in your APIs. A typical example is to use it as the request
|
24
|
+
# or the response type of an API method. For instance:
|
25
|
+
#
|
26
|
+
# service Foo {
|
27
|
+
# rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
28
|
+
# }
|
29
|
+
#
|
30
|
+
# The JSON representation for `Empty` is empty JSON object `{}`.
|
31
|
+
class Empty
|
32
|
+
include Google::Protobuf::MessageExts
|
33
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,116 @@
|
|
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
|
23
|
+
# or calendar, represented as seconds and fractions of seconds at
|
24
|
+
# nanosecond resolution in UTC Epoch time. It is encoded using the
|
25
|
+
# Proleptic Gregorian Calendar which extends the Gregorian calendar
|
26
|
+
# backwards to year one. It is encoded assuming all minutes are 60
|
27
|
+
# seconds long, i.e. leap seconds are "smeared" so that no leap second
|
28
|
+
# table is needed for interpretation. Range is from
|
29
|
+
# 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
|
30
|
+
# By restricting to that range, we ensure that we can convert to
|
31
|
+
# and from RFC 3339 date strings.
|
32
|
+
# See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
|
33
|
+
#
|
34
|
+
# # Examples
|
35
|
+
#
|
36
|
+
# Example 1: Compute Timestamp from POSIX `time()`.
|
37
|
+
#
|
38
|
+
# Timestamp timestamp;
|
39
|
+
# timestamp.set_seconds(time(NULL));
|
40
|
+
# timestamp.set_nanos(0);
|
41
|
+
#
|
42
|
+
# Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
43
|
+
#
|
44
|
+
# struct timeval tv;
|
45
|
+
# gettimeofday(&tv, NULL);
|
46
|
+
#
|
47
|
+
# Timestamp timestamp;
|
48
|
+
# timestamp.set_seconds(tv.tv_sec);
|
49
|
+
# timestamp.set_nanos(tv.tv_usec * 1000);
|
50
|
+
#
|
51
|
+
# Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
52
|
+
#
|
53
|
+
# FILETIME ft;
|
54
|
+
# GetSystemTimeAsFileTime(&ft);
|
55
|
+
# UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
56
|
+
#
|
57
|
+
# // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
58
|
+
# // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
59
|
+
# Timestamp timestamp;
|
60
|
+
# timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
61
|
+
# timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
62
|
+
#
|
63
|
+
# Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
64
|
+
#
|
65
|
+
# long millis = System.currentTimeMillis();
|
66
|
+
#
|
67
|
+
# Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
68
|
+
# .setNanos((int) ((millis % 1000) * 1000000)).build();
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# Example 5: Compute Timestamp from current time in Python.
|
72
|
+
#
|
73
|
+
# timestamp = Timestamp()
|
74
|
+
# timestamp.GetCurrentTime()
|
75
|
+
#
|
76
|
+
# # JSON Mapping
|
77
|
+
#
|
78
|
+
# In JSON format, the Timestamp type is encoded as a string in the
|
79
|
+
# [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
80
|
+
# format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z"
|
81
|
+
# where \\{year} is always expressed using four digits while \\{month}, \\{day},
|
82
|
+
# \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional
|
83
|
+
# seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
84
|
+
# are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
85
|
+
# is required. A proto3 JSON serializer should always use UTC (as indicated by
|
86
|
+
# "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
87
|
+
# able to accept both UTC and other timezones (as indicated by an offset).
|
88
|
+
#
|
89
|
+
# For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
90
|
+
# 01:30 UTC on January 15, 2017.
|
91
|
+
#
|
92
|
+
# In JavaScript, one can convert a Date object to this format using the
|
93
|
+
# standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
|
94
|
+
# method. In Python, a standard `datetime.datetime` object can be converted
|
95
|
+
# to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
|
96
|
+
# with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
|
97
|
+
# can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
98
|
+
# http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
|
99
|
+
# ) to obtain a formatter capable of generating timestamps in this format.
|
100
|
+
# @!attribute [rw] seconds
|
101
|
+
# @return [Integer]
|
102
|
+
# Represents seconds of UTC time since Unix epoch
|
103
|
+
# 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
104
|
+
# 9999-12-31T23:59:59Z inclusive.
|
105
|
+
# @!attribute [rw] nanos
|
106
|
+
# @return [Integer]
|
107
|
+
# Non-negative fractions of a second at nanosecond resolution. Negative
|
108
|
+
# second values with fractions must still have non-negative nanos values
|
109
|
+
# that count forward in time. Must be from 0 to 999,999,999
|
110
|
+
# inclusive.
|
111
|
+
class Timestamp
|
112
|
+
include Google::Protobuf::MessageExts
|
113
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|