google-cloud-security_center 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 +9 -0
- data/LICENSE +201 -0
- data/README.md +69 -0
- data/lib/google/cloud/security_center.rb +141 -0
- data/lib/google/cloud/security_center/v1.rb +139 -0
- data/lib/google/cloud/security_center/v1/asset_pb.rb +37 -0
- data/lib/google/cloud/security_center/v1/credentials.rb +41 -0
- data/lib/google/cloud/security_center/v1/doc/google/cloud/securitycenter/v1/asset.rb +96 -0
- data/lib/google/cloud/security_center/v1/doc/google/cloud/securitycenter/v1/finding.rb +94 -0
- data/lib/google/cloud/security_center/v1/doc/google/cloud/securitycenter/v1/organization_settings.rb +72 -0
- data/lib/google/cloud/security_center/v1/doc/google/cloud/securitycenter/v1/security_marks.rb +44 -0
- data/lib/google/cloud/security_center/v1/doc/google/cloud/securitycenter/v1/securitycenter_service.rb +759 -0
- data/lib/google/cloud/security_center/v1/doc/google/cloud/securitycenter/v1/source.rb +51 -0
- data/lib/google/cloud/security_center/v1/doc/google/iam/v1/iam_policy.rb +63 -0
- data/lib/google/cloud/security_center/v1/doc/google/iam/v1/policy.rb +104 -0
- data/lib/google/cloud/security_center/v1/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/security_center/v1/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/security_center/v1/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/security_center/v1/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/security_center/v1/doc/google/protobuf/struct.rb +74 -0
- data/lib/google/cloud/security_center/v1/doc/google/protobuf/timestamp.rb +111 -0
- data/lib/google/cloud/security_center/v1/doc/google/rpc/status.rb +87 -0
- data/lib/google/cloud/security_center/v1/finding_pb.rb +34 -0
- data/lib/google/cloud/security_center/v1/helpers.rb +87 -0
- data/lib/google/cloud/security_center/v1/organization_settings_pb.rb +29 -0
- data/lib/google/cloud/security_center/v1/security_center_client.rb +1772 -0
- data/lib/google/cloud/security_center/v1/security_center_client_config.json +116 -0
- data/lib/google/cloud/security_center/v1/security_marks_pb.rb +17 -0
- data/lib/google/cloud/security_center/v1/securitycenter_service_pb.rb +186 -0
- data/lib/google/cloud/security_center/v1/securitycenter_service_services_pb.rb +90 -0
- data/lib/google/cloud/security_center/v1/source_pb.rb +18 -0
- metadata +172 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Securitycenter
|
19
|
+
module V1
|
20
|
+
# Cloud Security Command Center's (Cloud SCC) finding source. A finding source
|
21
|
+
# is an entity or a mechanism that can produce a finding. A source is like a
|
22
|
+
# container of findings that come from the same scanner, logger, monitor, etc.
|
23
|
+
# @!attribute [rw] name
|
24
|
+
# @return [String]
|
25
|
+
# The relative resource name of this source. See:
|
26
|
+
# https://cloud.google.com/apis/design/resource_names#relative_resource_name
|
27
|
+
# Example:
|
28
|
+
# "organizations/123/sources/456"
|
29
|
+
# @!attribute [rw] display_name
|
30
|
+
# @return [String]
|
31
|
+
# The source’s display name.
|
32
|
+
# A source’s display name must be unique amongst its siblings, for example,
|
33
|
+
# two sources with the same parent can't share the same display name.
|
34
|
+
# The display name must start and end with a letter or digit, may contain
|
35
|
+
# letters, digits, spaces, hyphens, and underscores, and can be no longer
|
36
|
+
# than 32 characters. This is captured by the regular expression:
|
37
|
+
# [\p{L}\p{N}](https://cloud.google.com{\p{L}\p{N}_- ]{0,30}[\p{L}\p{N}])?.
|
38
|
+
# @!attribute [rw] description
|
39
|
+
# @return [String]
|
40
|
+
# The description of the source (max of 1024 characters).
|
41
|
+
# Example:
|
42
|
+
# "Cloud Security Scanner is a web security scanner for common
|
43
|
+
# vulnerabilities in App Engine applications. It can automatically
|
44
|
+
# scan and detect four common vulnerabilities, including cross-site-scripting
|
45
|
+
# (XSS), Flash injection, mixed content (HTTP in HTTPS), and
|
46
|
+
# outdated/insecure libraries."
|
47
|
+
class Source; end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Iam
|
18
|
+
module V1
|
19
|
+
# Request message for `SetIamPolicy` method.
|
20
|
+
# @!attribute [rw] resource
|
21
|
+
# @return [String]
|
22
|
+
# REQUIRED: The resource for which the policy is being specified.
|
23
|
+
# `resource` is usually specified as a path. For example, a Project
|
24
|
+
# resource is specified as `projects/{project}`.
|
25
|
+
# @!attribute [rw] policy
|
26
|
+
# @return [Google::Iam::V1::Policy]
|
27
|
+
# REQUIRED: The complete policy to be applied to the `resource`. The size of
|
28
|
+
# the policy is limited to a few 10s of KB. An empty policy is a
|
29
|
+
# valid policy but certain Cloud Platform services (such as Projects)
|
30
|
+
# might reject them.
|
31
|
+
class SetIamPolicyRequest; end
|
32
|
+
|
33
|
+
# Request message for `GetIamPolicy` method.
|
34
|
+
# @!attribute [rw] resource
|
35
|
+
# @return [String]
|
36
|
+
# REQUIRED: The resource for which the policy is being requested.
|
37
|
+
# `resource` is usually specified as a path. For example, a Project
|
38
|
+
# resource is specified as `projects/{project}`.
|
39
|
+
class GetIamPolicyRequest; end
|
40
|
+
|
41
|
+
# Request message for `TestIamPermissions` method.
|
42
|
+
# @!attribute [rw] resource
|
43
|
+
# @return [String]
|
44
|
+
# REQUIRED: The resource for which the policy detail is being requested.
|
45
|
+
# `resource` is usually specified as a path. For example, a Project
|
46
|
+
# resource is specified as `projects/{project}`.
|
47
|
+
# @!attribute [rw] permissions
|
48
|
+
# @return [Array<String>]
|
49
|
+
# The set of permissions to check for the `resource`. Permissions with
|
50
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
51
|
+
# information see
|
52
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
53
|
+
class TestIamPermissionsRequest; end
|
54
|
+
|
55
|
+
# Response message for `TestIamPermissions` method.
|
56
|
+
# @!attribute [rw] permissions
|
57
|
+
# @return [Array<String>]
|
58
|
+
# A subset of `TestPermissionsRequest.permissions` that the caller is
|
59
|
+
# allowed.
|
60
|
+
class TestIamPermissionsResponse; end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Iam
|
18
|
+
module V1
|
19
|
+
# Defines an Identity and Access Management (IAM) policy. It is used to
|
20
|
+
# specify access control policies for Cloud Platform resources.
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# A `Policy` consists of a list of `bindings`. A `Binding` binds a list of
|
24
|
+
# `members` to a `role`, where the members can be user accounts, Google groups,
|
25
|
+
# Google domains, and service accounts. A `role` is a named list of permissions
|
26
|
+
# defined by IAM.
|
27
|
+
#
|
28
|
+
# **Example**
|
29
|
+
#
|
30
|
+
# {
|
31
|
+
# "bindings": [
|
32
|
+
# {
|
33
|
+
# "role": "roles/owner",
|
34
|
+
# "members": [
|
35
|
+
# "user:mike@example.com",
|
36
|
+
# "group:admins@example.com",
|
37
|
+
# "domain:google.com",
|
38
|
+
# "serviceAccount:my-other-app@appspot.gserviceaccount.com",
|
39
|
+
# ]
|
40
|
+
# },
|
41
|
+
# {
|
42
|
+
# "role": "roles/viewer",
|
43
|
+
# "members": ["user:sean@example.com"]
|
44
|
+
# }
|
45
|
+
# ]
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# For a description of IAM and its features, see the
|
49
|
+
# [IAM developer's guide](https://cloud.google.com/iam).
|
50
|
+
# @!attribute [rw] version
|
51
|
+
# @return [Integer]
|
52
|
+
# Version of the `Policy`. The default version is 0.
|
53
|
+
# @!attribute [rw] bindings
|
54
|
+
# @return [Array<Google::Iam::V1::Binding>]
|
55
|
+
# Associates a list of `members` to a `role`.
|
56
|
+
# Multiple `bindings` must not be specified for the same `role`.
|
57
|
+
# `bindings` with no members will result in an error.
|
58
|
+
# @!attribute [rw] etag
|
59
|
+
# @return [String]
|
60
|
+
# `etag` is used for optimistic concurrency control as a way to help
|
61
|
+
# prevent simultaneous updates of a policy from overwriting each other.
|
62
|
+
# It is strongly suggested that systems make use of the `etag` in the
|
63
|
+
# read-modify-write cycle to perform policy updates in order to avoid race
|
64
|
+
# conditions: An `etag` is returned in the response to `getIamPolicy`, and
|
65
|
+
# systems are expected to put that etag in the request to `setIamPolicy` to
|
66
|
+
# ensure that their change will be applied to the same version of the policy.
|
67
|
+
#
|
68
|
+
# If no `etag` is provided in the call to `setIamPolicy`, then the existing
|
69
|
+
# policy is overwritten blindly.
|
70
|
+
class Policy; end
|
71
|
+
|
72
|
+
# Associates `members` with a `role`.
|
73
|
+
# @!attribute [rw] role
|
74
|
+
# @return [String]
|
75
|
+
# Role that is assigned to `members`.
|
76
|
+
# For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
|
77
|
+
# Required
|
78
|
+
# @!attribute [rw] members
|
79
|
+
# @return [Array<String>]
|
80
|
+
# Specifies the identities requesting access for a Cloud Platform resource.
|
81
|
+
# `members` can have the following values:
|
82
|
+
#
|
83
|
+
# * `allUsers`: A special identifier that represents anyone who is
|
84
|
+
# on the internet; with or without a Google account.
|
85
|
+
#
|
86
|
+
# * `allAuthenticatedUsers`: A special identifier that represents anyone
|
87
|
+
# who is authenticated with a Google account or a service account.
|
88
|
+
#
|
89
|
+
# * `user:{emailid}`: An email address that represents a specific Google
|
90
|
+
# account. For example, `alice@gmail.com` or `joe@example.com`.
|
91
|
+
#
|
92
|
+
#
|
93
|
+
# * `serviceAccount:{emailid}`: An email address that represents a service
|
94
|
+
# account. For example, `my-other-app@appspot.gserviceaccount.com`.
|
95
|
+
#
|
96
|
+
# * `group:{emailid}`: An email address that represents a Google group.
|
97
|
+
# For example, `admins@example.com`.
|
98
|
+
#
|
99
|
+
# * `domain:{domain}`: A Google Apps domain name that represents all the
|
100
|
+
# users of that domain. For example, `google.com` or `example.com`.
|
101
|
+
class Binding; end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Longrunning
|
18
|
+
# This resource represents a long-running operation that is the result of a
|
19
|
+
# network API call.
|
20
|
+
# @!attribute [rw] name
|
21
|
+
# @return [String]
|
22
|
+
# The server-assigned name, which is only unique within the same service that
|
23
|
+
# originally returns it. If you use the default HTTP mapping, the
|
24
|
+
# `name` should have the format of `operations/some/unique/name`.
|
25
|
+
# @!attribute [rw] metadata
|
26
|
+
# @return [Google::Protobuf::Any]
|
27
|
+
# Service-specific metadata associated with the operation. It typically
|
28
|
+
# contains progress information and common metadata such as create time.
|
29
|
+
# Some services might not provide such metadata. Any method that returns a
|
30
|
+
# long-running operation should document the metadata type, if any.
|
31
|
+
# @!attribute [rw] done
|
32
|
+
# @return [true, false]
|
33
|
+
# If the value is `false`, it means the operation is still in progress.
|
34
|
+
# If `true`, the operation is completed, and either `error` or `response` is
|
35
|
+
# available.
|
36
|
+
# @!attribute [rw] error
|
37
|
+
# @return [Google::Rpc::Status]
|
38
|
+
# The error result of the operation in case of failure or cancellation.
|
39
|
+
# @!attribute [rw] response
|
40
|
+
# @return [Google::Protobuf::Any]
|
41
|
+
# The normal response of the operation in case of success. If the original
|
42
|
+
# method returns no data on success, such as `Delete`, the response is
|
43
|
+
# `google.protobuf.Empty`. If the original method is standard
|
44
|
+
# `Get`/`Create`/`Update`, the response should be the resource. For other
|
45
|
+
# methods, the response should have the type `XxxResponse`, where `Xxx`
|
46
|
+
# is the original method name. For example, if the original method name
|
47
|
+
# is `TakeSnapshot()`, the inferred response type is
|
48
|
+
# `TakeSnapshotResponse`.
|
49
|
+
class Operation; end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Protobuf
|
18
|
+
# `Any` contains an arbitrary serialized protocol buffer message along with a
|
19
|
+
# URL that describes the type of the serialized message.
|
20
|
+
#
|
21
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
22
|
+
# of utility functions or additional generated methods of the Any type.
|
23
|
+
#
|
24
|
+
# Example 1: Pack and unpack a message in C++.
|
25
|
+
#
|
26
|
+
# Foo foo = ...;
|
27
|
+
# Any any;
|
28
|
+
# any.PackFrom(foo);
|
29
|
+
# ...
|
30
|
+
# if (any.UnpackTo(&foo)) {
|
31
|
+
# ...
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# Example 2: Pack and unpack a message in Java.
|
35
|
+
#
|
36
|
+
# Foo foo = ...;
|
37
|
+
# Any any = Any.pack(foo);
|
38
|
+
# ...
|
39
|
+
# if (any.is(Foo.class)) {
|
40
|
+
# foo = any.unpack(Foo.class);
|
41
|
+
# }
|
42
|
+
#
|
43
|
+
# Example 3: Pack and unpack a message in Python.
|
44
|
+
#
|
45
|
+
# foo = Foo(...)
|
46
|
+
# any = Any()
|
47
|
+
# any.Pack(foo)
|
48
|
+
# ...
|
49
|
+
# if any.Is(Foo.DESCRIPTOR):
|
50
|
+
# any.Unpack(foo)
|
51
|
+
# ...
|
52
|
+
#
|
53
|
+
# Example 4: Pack and unpack a message in Go
|
54
|
+
#
|
55
|
+
# foo := &pb.Foo{...}
|
56
|
+
# any, err := ptypes.MarshalAny(foo)
|
57
|
+
# ...
|
58
|
+
# foo := &pb.Foo{}
|
59
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
60
|
+
# ...
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
# The pack methods provided by protobuf library will by default use
|
64
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
65
|
+
# methods only use the fully qualified type name after the last '/'
|
66
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
67
|
+
# name "y.z".
|
68
|
+
#
|
69
|
+
#
|
70
|
+
# = JSON
|
71
|
+
#
|
72
|
+
# The JSON representation of an `Any` value uses the regular
|
73
|
+
# representation of the deserialized, embedded message, with an
|
74
|
+
# additional field `@type` which contains the type URL. Example:
|
75
|
+
#
|
76
|
+
# package google.profile;
|
77
|
+
# message Person {
|
78
|
+
# string first_name = 1;
|
79
|
+
# string last_name = 2;
|
80
|
+
# }
|
81
|
+
#
|
82
|
+
# {
|
83
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
84
|
+
# "firstName": <string>,
|
85
|
+
# "lastName": <string>
|
86
|
+
# }
|
87
|
+
#
|
88
|
+
# If the embedded message type is well-known and has a custom JSON
|
89
|
+
# representation, that representation will be embedded adding a field
|
90
|
+
# `value` which holds the custom JSON in addition to the `@type`
|
91
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
92
|
+
#
|
93
|
+
# {
|
94
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
95
|
+
# "value": "1.212s"
|
96
|
+
# }
|
97
|
+
# @!attribute [rw] type_url
|
98
|
+
# @return [String]
|
99
|
+
# A URL/resource name that uniquely identifies the type of the serialized
|
100
|
+
# protocol buffer message. This string must contain at least
|
101
|
+
# one "/" character. The last segment of the URL's path must represent
|
102
|
+
# the fully qualified name of the type (as in
|
103
|
+
# `path/google.protobuf.Duration`). The name should be in a canonical form
|
104
|
+
# (e.g., leading "." is not accepted).
|
105
|
+
#
|
106
|
+
# In practice, teams usually precompile into the binary all types that they
|
107
|
+
# expect it to use in the context of Any. However, for URLs which use the
|
108
|
+
# scheme `http`, `https`, or no scheme, one can optionally set up a type
|
109
|
+
# server that maps type URLs to message definitions as follows:
|
110
|
+
#
|
111
|
+
# * If no scheme is provided, `https` is assumed.
|
112
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
113
|
+
# value in binary format, or produce an error.
|
114
|
+
# * Applications are allowed to cache lookup results based on the
|
115
|
+
# URL, or have them precompiled into a binary to avoid any
|
116
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
117
|
+
# on changes to types. (Use versioned type names to manage
|
118
|
+
# breaking changes.)
|
119
|
+
#
|
120
|
+
# Note: this functionality is not currently available in the official
|
121
|
+
# protobuf release, and it is not used for type URLs beginning with
|
122
|
+
# type.googleapis.com.
|
123
|
+
#
|
124
|
+
# Schemes other than `http`, `https` (or the empty scheme) might be
|
125
|
+
# used with implementation specific semantics.
|
126
|
+
# @!attribute [rw] value
|
127
|
+
# @return [String]
|
128
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
129
|
+
class Any; end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Protobuf
|
18
|
+
# A Duration represents a signed, fixed-length span of time represented
|
19
|
+
# as a count of seconds and fractions of seconds at nanosecond
|
20
|
+
# resolution. It is independent of any calendar and concepts like "day"
|
21
|
+
# or "month". It is related to Timestamp in that the difference between
|
22
|
+
# two Timestamp values is a Duration and it can be added or subtracted
|
23
|
+
# from a Timestamp. Range is approximately +-10,000 years.
|
24
|
+
#
|
25
|
+
# = Examples
|
26
|
+
#
|
27
|
+
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
28
|
+
#
|
29
|
+
# Timestamp start = ...;
|
30
|
+
# Timestamp end = ...;
|
31
|
+
# Duration duration = ...;
|
32
|
+
#
|
33
|
+
# duration.seconds = end.seconds - start.seconds;
|
34
|
+
# duration.nanos = end.nanos - start.nanos;
|
35
|
+
#
|
36
|
+
# if (duration.seconds < 0 && duration.nanos > 0) {
|
37
|
+
# duration.seconds += 1;
|
38
|
+
# duration.nanos -= 1000000000;
|
39
|
+
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
40
|
+
# duration.seconds -= 1;
|
41
|
+
# duration.nanos += 1000000000;
|
42
|
+
# }
|
43
|
+
#
|
44
|
+
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
45
|
+
#
|
46
|
+
# Timestamp start = ...;
|
47
|
+
# Duration duration = ...;
|
48
|
+
# Timestamp end = ...;
|
49
|
+
#
|
50
|
+
# end.seconds = start.seconds + duration.seconds;
|
51
|
+
# end.nanos = start.nanos + duration.nanos;
|
52
|
+
#
|
53
|
+
# if (end.nanos < 0) {
|
54
|
+
# end.seconds -= 1;
|
55
|
+
# end.nanos += 1000000000;
|
56
|
+
# } else if (end.nanos >= 1000000000) {
|
57
|
+
# end.seconds += 1;
|
58
|
+
# end.nanos -= 1000000000;
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# Example 3: Compute Duration from datetime.timedelta in Python.
|
62
|
+
#
|
63
|
+
# td = datetime.timedelta(days=3, minutes=10)
|
64
|
+
# duration = Duration()
|
65
|
+
# duration.FromTimedelta(td)
|
66
|
+
#
|
67
|
+
# = JSON Mapping
|
68
|
+
#
|
69
|
+
# In JSON format, the Duration type is encoded as a string rather than an
|
70
|
+
# object, where the string ends in the suffix "s" (indicating seconds) and
|
71
|
+
# is preceded by the number of seconds, with nanoseconds expressed as
|
72
|
+
# fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
73
|
+
# encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
74
|
+
# be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
75
|
+
# microsecond should be expressed in JSON format as "3.000001s".
|
76
|
+
# @!attribute [rw] seconds
|
77
|
+
# @return [Integer]
|
78
|
+
# Signed seconds of the span of time. Must be from -315,576,000,000
|
79
|
+
# to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
80
|
+
# 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
81
|
+
# @!attribute [rw] nanos
|
82
|
+
# @return [Integer]
|
83
|
+
# Signed fractions of a second at nanosecond resolution of the span
|
84
|
+
# of time. Durations less than one second are represented with a 0
|
85
|
+
# `seconds` field and a positive or negative `nanos` field. For durations
|
86
|
+
# of one second or more, a non-zero value for the `nanos` field must be
|
87
|
+
# of the same sign as the `seconds` field. Must be from -999,999,999
|
88
|
+
# to +999,999,999 inclusive.
|
89
|
+
class Duration; end
|
90
|
+
end
|
91
|
+
end
|