google-cloud-logging-v2 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 +75 -0
- data/lib/google-cloud-logging-v2.rb +21 -0
- data/lib/google/cloud/logging/v2.rb +37 -0
- data/lib/google/cloud/logging/v2/config_service.rb +49 -0
- data/lib/google/cloud/logging/v2/config_service/client.rb +1723 -0
- data/lib/google/cloud/logging/v2/config_service/credentials.rb +54 -0
- data/lib/google/cloud/logging/v2/config_service/paths.rb +413 -0
- data/lib/google/cloud/logging/v2/logging_service.rb +49 -0
- data/lib/google/cloud/logging/v2/logging_service/client.rb +826 -0
- data/lib/google/cloud/logging/v2/logging_service/credentials.rb +55 -0
- data/lib/google/cloud/logging/v2/logging_service/paths.rb +154 -0
- data/lib/google/cloud/logging/v2/metrics_service.rb +49 -0
- data/lib/google/cloud/logging/v2/metrics_service/client.rb +726 -0
- data/lib/google/cloud/logging/v2/metrics_service/credentials.rb +55 -0
- data/lib/google/cloud/logging/v2/metrics_service/paths.rb +64 -0
- data/lib/google/cloud/logging/v2/version.rb +28 -0
- data/lib/google/logging/type/http_request_pb.rb +38 -0
- data/lib/google/logging/type/log_severity_pb.rb +31 -0
- data/lib/google/logging/v2/log_entry_pb.rb +62 -0
- data/lib/google/logging/v2/logging_config_pb.rb +176 -0
- data/lib/google/logging/v2/logging_config_services_pb.rb +113 -0
- data/lib/google/logging/v2/logging_metrics_pb.rb +75 -0
- data/lib/google/logging/v2/logging_metrics_services_pb.rb +53 -0
- data/lib/google/logging/v2/logging_pb.rb +83 -0
- data/lib/google/logging/v2/logging_services_pb.rb +65 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/distribution.rb +225 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/label.rb +49 -0
- data/proto_docs/google/api/metric.rb +203 -0
- data/proto_docs/google/api/monitored_resource.rb +137 -0
- data/proto_docs/google/api/resource.rb +247 -0
- data/proto_docs/google/logging/type/http_request.rb +95 -0
- data/proto_docs/google/logging/type/log_severity.rb +71 -0
- data/proto_docs/google/logging/v2/log_entry.rb +203 -0
- data/proto_docs/google/logging/v2/logging.rb +303 -0
- data/proto_docs/google/logging/v2/logging_config.rb +735 -0
- data/proto_docs/google/logging/v2/logging_metrics.rb +256 -0
- data/proto_docs/google/protobuf/any.rb +138 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/field_mask.rb +229 -0
- data/proto_docs/google/protobuf/struct.rb +96 -0
- data/proto_docs/google/protobuf/timestamp.rb +120 -0
- data/proto_docs/google/rpc/status.rb +46 -0
- metadata +231 -0
@@ -0,0 +1,256 @@
|
|
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 Cloud
|
22
|
+
module Logging
|
23
|
+
module V2
|
24
|
+
# Describes a logs-based metric. The value of the metric is the number of log
|
25
|
+
# entries that match a logs filter in a given time interval.
|
26
|
+
#
|
27
|
+
# Logs-based metric can also be used to extract values from logs and create a
|
28
|
+
# a distribution of the values. The distribution records the statistics of the
|
29
|
+
# extracted values along with an optional histogram of the values as specified
|
30
|
+
# by the bucket options.
|
31
|
+
# @!attribute [rw] name
|
32
|
+
# @return [::String]
|
33
|
+
# Required. The client-assigned metric identifier.
|
34
|
+
# Examples: `"error_count"`, `"nginx/requests"`.
|
35
|
+
#
|
36
|
+
# Metric identifiers are limited to 100 characters and can include only the
|
37
|
+
# following characters: `A-Z`, `a-z`, `0-9`, and the special characters
|
38
|
+
# `_-.,+!*',()%/`. The forward-slash character (`/`) denotes a hierarchy of
|
39
|
+
# name pieces, and it cannot be the first character of the name.
|
40
|
+
#
|
41
|
+
# The metric identifier in this field must not be
|
42
|
+
# [URL-encoded](https://en.wikipedia.org/wiki/Percent-encoding).
|
43
|
+
# However, when the metric identifier appears as the `[METRIC_ID]` part of a
|
44
|
+
# `metric_name` API parameter, then the metric identifier must be
|
45
|
+
# URL-encoded. Example: `"projects/my-project/metrics/nginx%2Frequests"`.
|
46
|
+
# @!attribute [rw] description
|
47
|
+
# @return [::String]
|
48
|
+
# Optional. A description of this metric, which is used in documentation.
|
49
|
+
# The maximum length of the description is 8000 characters.
|
50
|
+
# @!attribute [rw] filter
|
51
|
+
# @return [::String]
|
52
|
+
# Required. An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters) which is
|
53
|
+
# used to match log entries.
|
54
|
+
# Example:
|
55
|
+
#
|
56
|
+
# "resource.type=gae_app AND severity>=ERROR"
|
57
|
+
#
|
58
|
+
# The maximum length of the filter is 20000 characters.
|
59
|
+
# @!attribute [rw] metric_descriptor
|
60
|
+
# @return [::Google::Api::MetricDescriptor]
|
61
|
+
# Optional. The metric descriptor associated with the logs-based metric.
|
62
|
+
# If unspecified, it uses a default metric descriptor with a DELTA metric
|
63
|
+
# kind, INT64 value type, with no labels and a unit of "1". Such a metric
|
64
|
+
# counts the number of log entries matching the `filter` expression.
|
65
|
+
#
|
66
|
+
# The `name`, `type`, and `description` fields in the `metric_descriptor`
|
67
|
+
# are output only, and is constructed using the `name` and `description`
|
68
|
+
# field in the LogMetric.
|
69
|
+
#
|
70
|
+
# To create a logs-based metric that records a distribution of log values, a
|
71
|
+
# DELTA metric kind with a DISTRIBUTION value type must be used along with
|
72
|
+
# a `value_extractor` expression in the LogMetric.
|
73
|
+
#
|
74
|
+
# Each label in the metric descriptor must have a matching label
|
75
|
+
# name as the key and an extractor expression as the value in the
|
76
|
+
# `label_extractors` map.
|
77
|
+
#
|
78
|
+
# The `metric_kind` and `value_type` fields in the `metric_descriptor` cannot
|
79
|
+
# be updated once initially configured. New labels can be added in the
|
80
|
+
# `metric_descriptor`, but existing labels cannot be modified except for
|
81
|
+
# their description.
|
82
|
+
# @!attribute [rw] value_extractor
|
83
|
+
# @return [::String]
|
84
|
+
# Optional. A `value_extractor` is required when using a distribution
|
85
|
+
# logs-based metric to extract the values to record from a log entry.
|
86
|
+
# Two functions are supported for value extraction: `EXTRACT(field)` or
|
87
|
+
# `REGEXP_EXTRACT(field, regex)`. The argument are:
|
88
|
+
# 1. field: The name of the log entry field from which the value is to be
|
89
|
+
# extracted.
|
90
|
+
# 2. regex: A regular expression using the Google RE2 syntax
|
91
|
+
# (https://github.com/google/re2/wiki/Syntax) with a single capture
|
92
|
+
# group to extract data from the specified log entry field. The value
|
93
|
+
# of the field is converted to a string before applying the regex.
|
94
|
+
# It is an error to specify a regex that does not include exactly one
|
95
|
+
# capture group.
|
96
|
+
#
|
97
|
+
# The result of the extraction must be convertible to a double type, as the
|
98
|
+
# distribution always records double values. If either the extraction or
|
99
|
+
# the conversion to double fails, then those values are not recorded in the
|
100
|
+
# distribution.
|
101
|
+
#
|
102
|
+
# Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")`
|
103
|
+
# @!attribute [rw] label_extractors
|
104
|
+
# @return [::Google::Protobuf::Map{::String => ::String}]
|
105
|
+
# Optional. A map from a label key string to an extractor expression which is
|
106
|
+
# used to extract data from a log entry field and assign as the label value.
|
107
|
+
# Each label key specified in the LabelDescriptor must have an associated
|
108
|
+
# extractor expression in this map. The syntax of the extractor expression
|
109
|
+
# is the same as for the `value_extractor` field.
|
110
|
+
#
|
111
|
+
# The extracted value is converted to the type defined in the label
|
112
|
+
# descriptor. If the either the extraction or the type conversion fails,
|
113
|
+
# the label will have a default value. The default value for a string
|
114
|
+
# label is an empty string, for an integer label its 0, and for a boolean
|
115
|
+
# label its `false`.
|
116
|
+
#
|
117
|
+
# Note that there are upper bounds on the maximum number of labels and the
|
118
|
+
# number of active time series that are allowed in a project.
|
119
|
+
# @!attribute [rw] bucket_options
|
120
|
+
# @return [::Google::Api::Distribution::BucketOptions]
|
121
|
+
# Optional. The `bucket_options` are required when the logs-based metric is
|
122
|
+
# using a DISTRIBUTION value type and it describes the bucket boundaries
|
123
|
+
# used to create a histogram of the extracted values.
|
124
|
+
# @!attribute [r] create_time
|
125
|
+
# @return [::Google::Protobuf::Timestamp]
|
126
|
+
# Output only. The creation timestamp of the metric.
|
127
|
+
#
|
128
|
+
# This field may not be present for older metrics.
|
129
|
+
# @!attribute [r] update_time
|
130
|
+
# @return [::Google::Protobuf::Timestamp]
|
131
|
+
# Output only. The last update timestamp of the metric.
|
132
|
+
#
|
133
|
+
# This field may not be present for older metrics.
|
134
|
+
# @!attribute [rw] version
|
135
|
+
# @return [::Google::Cloud::Logging::V2::LogMetric::ApiVersion]
|
136
|
+
# Deprecated. The API version that created or updated this metric.
|
137
|
+
# The v2 format is used by default and cannot be changed.
|
138
|
+
class LogMetric
|
139
|
+
include ::Google::Protobuf::MessageExts
|
140
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
141
|
+
|
142
|
+
# @!attribute [rw] key
|
143
|
+
# @return [::String]
|
144
|
+
# @!attribute [rw] value
|
145
|
+
# @return [::String]
|
146
|
+
class LabelExtractorsEntry
|
147
|
+
include ::Google::Protobuf::MessageExts
|
148
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
149
|
+
end
|
150
|
+
|
151
|
+
# Logging API version.
|
152
|
+
module ApiVersion
|
153
|
+
# Logging API v2.
|
154
|
+
V2 = 0
|
155
|
+
|
156
|
+
# Logging API v1.
|
157
|
+
V1 = 1
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# The parameters to ListLogMetrics.
|
162
|
+
# @!attribute [rw] parent
|
163
|
+
# @return [::String]
|
164
|
+
# Required. The name of the project containing the metrics:
|
165
|
+
#
|
166
|
+
# "projects/[PROJECT_ID]"
|
167
|
+
# @!attribute [rw] page_token
|
168
|
+
# @return [::String]
|
169
|
+
# Optional. If present, then retrieve the next batch of results from the
|
170
|
+
# preceding call to this method. `pageToken` must be the value of
|
171
|
+
# `nextPageToken` from the previous response. The values of other method
|
172
|
+
# parameters should be identical to those in the previous call.
|
173
|
+
# @!attribute [rw] page_size
|
174
|
+
# @return [::Integer]
|
175
|
+
# Optional. The maximum number of results to return from this request.
|
176
|
+
# Non-positive values are ignored. The presence of `nextPageToken` in the
|
177
|
+
# response indicates that more results might be available.
|
178
|
+
class ListLogMetricsRequest
|
179
|
+
include ::Google::Protobuf::MessageExts
|
180
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
181
|
+
end
|
182
|
+
|
183
|
+
# Result returned from ListLogMetrics.
|
184
|
+
# @!attribute [rw] metrics
|
185
|
+
# @return [::Array<::Google::Cloud::Logging::V2::LogMetric>]
|
186
|
+
# A list of logs-based metrics.
|
187
|
+
# @!attribute [rw] next_page_token
|
188
|
+
# @return [::String]
|
189
|
+
# If there might be more results than appear in this response, then
|
190
|
+
# `nextPageToken` is included. To get the next set of results, call this
|
191
|
+
# method again using the value of `nextPageToken` as `pageToken`.
|
192
|
+
class ListLogMetricsResponse
|
193
|
+
include ::Google::Protobuf::MessageExts
|
194
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
195
|
+
end
|
196
|
+
|
197
|
+
# The parameters to GetLogMetric.
|
198
|
+
# @!attribute [rw] metric_name
|
199
|
+
# @return [::String]
|
200
|
+
# Required. The resource name of the desired metric:
|
201
|
+
#
|
202
|
+
# "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
|
203
|
+
class GetLogMetricRequest
|
204
|
+
include ::Google::Protobuf::MessageExts
|
205
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
206
|
+
end
|
207
|
+
|
208
|
+
# The parameters to CreateLogMetric.
|
209
|
+
# @!attribute [rw] parent
|
210
|
+
# @return [::String]
|
211
|
+
# Required. The resource name of the project in which to create the metric:
|
212
|
+
#
|
213
|
+
# "projects/[PROJECT_ID]"
|
214
|
+
#
|
215
|
+
# The new metric must be provided in the request.
|
216
|
+
# @!attribute [rw] metric
|
217
|
+
# @return [::Google::Cloud::Logging::V2::LogMetric]
|
218
|
+
# Required. The new logs-based metric, which must not have an identifier that
|
219
|
+
# already exists.
|
220
|
+
class CreateLogMetricRequest
|
221
|
+
include ::Google::Protobuf::MessageExts
|
222
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
223
|
+
end
|
224
|
+
|
225
|
+
# The parameters to UpdateLogMetric.
|
226
|
+
# @!attribute [rw] metric_name
|
227
|
+
# @return [::String]
|
228
|
+
# Required. The resource name of the metric to update:
|
229
|
+
#
|
230
|
+
# "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
|
231
|
+
#
|
232
|
+
# The updated metric must be provided in the request and it's
|
233
|
+
# `name` field must be the same as `[METRIC_ID]` If the metric
|
234
|
+
# does not exist in `[PROJECT_ID]`, then a new metric is created.
|
235
|
+
# @!attribute [rw] metric
|
236
|
+
# @return [::Google::Cloud::Logging::V2::LogMetric]
|
237
|
+
# Required. The updated metric.
|
238
|
+
class UpdateLogMetricRequest
|
239
|
+
include ::Google::Protobuf::MessageExts
|
240
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
241
|
+
end
|
242
|
+
|
243
|
+
# The parameters to DeleteLogMetric.
|
244
|
+
# @!attribute [rw] metric_name
|
245
|
+
# @return [::String]
|
246
|
+
# Required. The resource name of the metric to delete:
|
247
|
+
#
|
248
|
+
# "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
|
249
|
+
class DeleteLogMetricRequest
|
250
|
+
include ::Google::Protobuf::MessageExts
|
251
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,138 @@
|
|
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. This string must contain at least
|
105
|
+
# one "/" character. The last segment of the URL's path must represent
|
106
|
+
# the fully qualified name of the type (as in
|
107
|
+
# `path/google.protobuf.Duration`). The name should be in a canonical form
|
108
|
+
# (e.g., leading "." is not accepted).
|
109
|
+
#
|
110
|
+
# In practice, teams usually precompile into the binary all types that they
|
111
|
+
# expect it to use in the context of Any. However, for URLs which use the
|
112
|
+
# scheme `http`, `https`, or no scheme, one can optionally set up a type
|
113
|
+
# server that maps type URLs to message definitions as follows:
|
114
|
+
#
|
115
|
+
# * If no scheme is provided, `https` is assumed.
|
116
|
+
# * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
117
|
+
# value in binary format, or produce an error.
|
118
|
+
# * Applications are allowed to cache lookup results based on the
|
119
|
+
# URL, or have them precompiled into a binary to avoid any
|
120
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
121
|
+
# on changes to types. (Use versioned type names to manage
|
122
|
+
# breaking changes.)
|
123
|
+
#
|
124
|
+
# Note: this functionality is not currently available in the official
|
125
|
+
# protobuf release, and it is not used for type URLs beginning with
|
126
|
+
# type.googleapis.com.
|
127
|
+
#
|
128
|
+
# Schemes other than `http`, `https` (or the empty scheme) might be
|
129
|
+
# used with implementation specific semantics.
|
130
|
+
# @!attribute [rw] value
|
131
|
+
# @return [::String]
|
132
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
133
|
+
class Any
|
134
|
+
include ::Google::Protobuf::MessageExts
|
135
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
136
|
+
end
|
137
|
+
end
|
138
|
+
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 (duration.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
|