google-cloud-dlp 0.1.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 +7 -0
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +48 -0
- data/lib/google/cloud/dlp.rb +126 -0
- data/lib/google/cloud/dlp/credentials.rb +30 -0
- data/lib/google/cloud/dlp/v2beta1.rb +119 -0
- data/lib/google/cloud/dlp/v2beta1/dlp_service_client.rb +638 -0
- data/lib/google/cloud/dlp/v2beta1/dlp_service_client_config.json +66 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/privacy/dlp/v2beta1/dlp.rb +1241 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/privacy/dlp/v2beta1/storage.rb +258 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/type/date.rb +37 -0
- data/lib/google/cloud/dlp/v2beta1/doc/google/type/timeofday.rb +36 -0
- data/lib/google/cloud/dlp/v2beta1/doc/overview.rb +71 -0
- data/lib/google/privacy/dlp/v2beta1/dlp_pb.rb +562 -0
- data/lib/google/privacy/dlp/v2beta1/dlp_services_pb.rb +69 -0
- data/lib/google/privacy/dlp/v2beta1/storage_pb.rb +130 -0
- metadata +118 -0
@@ -0,0 +1,258 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Privacy
|
17
|
+
module Dlp
|
18
|
+
module V2beta1
|
19
|
+
# Type of information detected by the API.
|
20
|
+
# @!attribute [rw] name
|
21
|
+
# @return [String]
|
22
|
+
# Name of the information type.
|
23
|
+
class InfoType; end
|
24
|
+
|
25
|
+
# Custom information type provided by the user. Used to find domain-specific
|
26
|
+
# sensitive information configurable to the data in question.
|
27
|
+
# @!attribute [rw] info_type
|
28
|
+
# @return [Google::Privacy::Dlp::V2beta1::InfoType]
|
29
|
+
# Info type configuration. All custom info types must have configurations
|
30
|
+
# that do not conflict with built-in info types or other custom info types.
|
31
|
+
# @!attribute [rw] dictionary
|
32
|
+
# @return [Google::Privacy::Dlp::V2beta1::CustomInfoType::Dictionary]
|
33
|
+
# Dictionary-based custom info type.
|
34
|
+
class CustomInfoType
|
35
|
+
# Custom information type based on a dictionary of words or phrases. This can
|
36
|
+
# be used to match sensitive information specific to the data, such as a list
|
37
|
+
# of employee IDs or job titles.
|
38
|
+
#
|
39
|
+
# Dictionary words are case-insensitive and all characters other than letters
|
40
|
+
# and digits in the unicode [Basic Multilingual
|
41
|
+
# Plane](https://en.wikipedia.org/wiki/Plane_%28Unicode%29#Basic_Multilingual_Plane)
|
42
|
+
# will be replaced with whitespace when scanning for matches, so the
|
43
|
+
# dictionary phrase "Sam Johnson" will match all three phrases "sam johnson",
|
44
|
+
# "Sam, Johnson", and "Sam (Johnson)". Additionally, the characters
|
45
|
+
# surrounding any match must be of a different type than the adjacent
|
46
|
+
# characters within the word, so letters must be next to non-letters and
|
47
|
+
# digits next to non-digits. For example, the dictionary word "jen" will
|
48
|
+
# match the first three letters of the text "jen123" but will return no
|
49
|
+
# matches for "jennifer".
|
50
|
+
#
|
51
|
+
# Dictionary words containing a large number of characters that are not
|
52
|
+
# letters or digits may result in unexpected findings because such characters
|
53
|
+
# are treated as whitespace.
|
54
|
+
# @!attribute [rw] word_list
|
55
|
+
# @return [Google::Privacy::Dlp::V2beta1::CustomInfoType::Dictionary::WordList]
|
56
|
+
# List of words or phrases to search for.
|
57
|
+
class Dictionary
|
58
|
+
# Message defining a list of words or phrases to search for in the data.
|
59
|
+
# @!attribute [rw] words
|
60
|
+
# @return [Array<String>]
|
61
|
+
# Words or phrases defining the dictionary. The dictionary must contain
|
62
|
+
# at least one phrase and every phrase must contain at least 2 characters
|
63
|
+
# that are letters or digits. [required]
|
64
|
+
class WordList; end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# General identifier of a data field in a storage service.
|
69
|
+
# @!attribute [rw] column_name
|
70
|
+
# @return [String]
|
71
|
+
# Name describing the field.
|
72
|
+
class FieldId; end
|
73
|
+
|
74
|
+
# Datastore partition ID.
|
75
|
+
# A partition ID identifies a grouping of entities. The grouping is always
|
76
|
+
# by project and namespace, however the namespace ID may be empty.
|
77
|
+
#
|
78
|
+
# A partition ID contains several dimensions:
|
79
|
+
# project ID and namespace ID.
|
80
|
+
# @!attribute [rw] project_id
|
81
|
+
# @return [String]
|
82
|
+
# The ID of the project to which the entities belong.
|
83
|
+
# @!attribute [rw] namespace_id
|
84
|
+
# @return [String]
|
85
|
+
# If not empty, the ID of the namespace to which the entities belong.
|
86
|
+
class PartitionId; end
|
87
|
+
|
88
|
+
# A representation of a Datastore kind.
|
89
|
+
# @!attribute [rw] name
|
90
|
+
# @return [String]
|
91
|
+
# The name of the kind.
|
92
|
+
class KindExpression; end
|
93
|
+
|
94
|
+
# A reference to a property relative to the Datastore kind expressions.
|
95
|
+
# @!attribute [rw] name
|
96
|
+
# @return [String]
|
97
|
+
# The name of the property.
|
98
|
+
# If name includes "."s, it may be interpreted as a property name path.
|
99
|
+
class PropertyReference; end
|
100
|
+
|
101
|
+
# A representation of a Datastore property in a projection.
|
102
|
+
# @!attribute [rw] property
|
103
|
+
# @return [Google::Privacy::Dlp::V2beta1::PropertyReference]
|
104
|
+
# The property to project.
|
105
|
+
class Projection; end
|
106
|
+
|
107
|
+
# Options defining a data set within Google Cloud Datastore.
|
108
|
+
# @!attribute [rw] partition_id
|
109
|
+
# @return [Google::Privacy::Dlp::V2beta1::PartitionId]
|
110
|
+
# A partition ID identifies a grouping of entities. The grouping is always
|
111
|
+
# by project and namespace, however the namespace ID may be empty.
|
112
|
+
# @!attribute [rw] kind
|
113
|
+
# @return [Google::Privacy::Dlp::V2beta1::KindExpression]
|
114
|
+
# The kind to process.
|
115
|
+
# @!attribute [rw] projection
|
116
|
+
# @return [Array<Google::Privacy::Dlp::V2beta1::Projection>]
|
117
|
+
# Properties to scan. If none are specified, all properties will be scanned
|
118
|
+
# by default.
|
119
|
+
class DatastoreOptions; end
|
120
|
+
|
121
|
+
# Options defining a file or a set of files (path ending with *) within
|
122
|
+
# a Google Cloud Storage bucket.
|
123
|
+
# @!attribute [rw] file_set
|
124
|
+
# @return [Google::Privacy::Dlp::V2beta1::CloudStorageOptions::FileSet]
|
125
|
+
class CloudStorageOptions
|
126
|
+
# Set of files to scan.
|
127
|
+
# @!attribute [rw] url
|
128
|
+
# @return [String]
|
129
|
+
# The url, in the format +gs://<bucket>/<path>+. Trailing wildcard in the
|
130
|
+
# path is allowed.
|
131
|
+
class FileSet; end
|
132
|
+
end
|
133
|
+
|
134
|
+
# A location in Cloud Storage.
|
135
|
+
# @!attribute [rw] path
|
136
|
+
# @return [String]
|
137
|
+
# The url, in the format of +gs://bucket/<path>+.
|
138
|
+
class CloudStoragePath; end
|
139
|
+
|
140
|
+
# Options defining BigQuery table and row identifiers.
|
141
|
+
# @!attribute [rw] table_reference
|
142
|
+
# @return [Google::Privacy::Dlp::V2beta1::BigQueryTable]
|
143
|
+
# Complete BigQuery table reference.
|
144
|
+
# @!attribute [rw] identifying_fields
|
145
|
+
# @return [Array<Google::Privacy::Dlp::V2beta1::FieldId>]
|
146
|
+
# References to fields uniquely identifying rows within the table.
|
147
|
+
# Nested fields in the format, like +person.birthdate.year+, are allowed.
|
148
|
+
class BigQueryOptions; end
|
149
|
+
|
150
|
+
# Shared message indicating Cloud storage type.
|
151
|
+
# @!attribute [rw] datastore_options
|
152
|
+
# @return [Google::Privacy::Dlp::V2beta1::DatastoreOptions]
|
153
|
+
# Google Cloud Datastore options specification.
|
154
|
+
# @!attribute [rw] cloud_storage_options
|
155
|
+
# @return [Google::Privacy::Dlp::V2beta1::CloudStorageOptions]
|
156
|
+
# Google Cloud Storage options specification.
|
157
|
+
# @!attribute [rw] big_query_options
|
158
|
+
# @return [Google::Privacy::Dlp::V2beta1::BigQueryOptions]
|
159
|
+
# BigQuery options specification.
|
160
|
+
class StorageConfig; end
|
161
|
+
|
162
|
+
# Record key for a finding in a Cloud Storage file.
|
163
|
+
# @!attribute [rw] file_path
|
164
|
+
# @return [String]
|
165
|
+
# Path to the file.
|
166
|
+
# @!attribute [rw] start_offset
|
167
|
+
# @return [Integer]
|
168
|
+
# Byte offset of the referenced data in the file.
|
169
|
+
class CloudStorageKey; end
|
170
|
+
|
171
|
+
# Record key for a finding in Cloud Datastore.
|
172
|
+
# @!attribute [rw] entity_key
|
173
|
+
# @return [Google::Privacy::Dlp::V2beta1::Key]
|
174
|
+
# Datastore entity key.
|
175
|
+
class DatastoreKey; end
|
176
|
+
|
177
|
+
# A unique identifier for a Datastore entity.
|
178
|
+
# If a key's partition ID or any of its path kinds or names are
|
179
|
+
# reserved/read-only, the key is reserved/read-only.
|
180
|
+
# A reserved/read-only key is forbidden in certain documented contexts.
|
181
|
+
# @!attribute [rw] partition_id
|
182
|
+
# @return [Google::Privacy::Dlp::V2beta1::PartitionId]
|
183
|
+
# Entities are partitioned into subsets, currently identified by a project
|
184
|
+
# ID and namespace ID.
|
185
|
+
# Queries are scoped to a single partition.
|
186
|
+
# @!attribute [rw] path
|
187
|
+
# @return [Array<Google::Privacy::Dlp::V2beta1::Key::PathElement>]
|
188
|
+
# The entity path.
|
189
|
+
# An entity path consists of one or more elements composed of a kind and a
|
190
|
+
# string or numerical identifier, which identify entities. The first
|
191
|
+
# element identifies a _root entity_, the second element identifies
|
192
|
+
# a _child_ of the root entity, the third element identifies a child of the
|
193
|
+
# second entity, and so forth. The entities identified by all prefixes of
|
194
|
+
# the path are called the element's _ancestors_.
|
195
|
+
#
|
196
|
+
# A path can never be empty, and a path can have at most 100 elements.
|
197
|
+
class Key
|
198
|
+
# A (kind, ID/name) pair used to construct a key path.
|
199
|
+
#
|
200
|
+
# If either name or ID is set, the element is complete.
|
201
|
+
# If neither is set, the element is incomplete.
|
202
|
+
# @!attribute [rw] kind
|
203
|
+
# @return [String]
|
204
|
+
# The kind of the entity.
|
205
|
+
# A kind matching regex +__.*__+ is reserved/read-only.
|
206
|
+
# A kind must not contain more than 1500 bytes when UTF-8 encoded.
|
207
|
+
# Cannot be +""+.
|
208
|
+
# @!attribute [rw] id
|
209
|
+
# @return [Integer]
|
210
|
+
# The auto-allocated ID of the entity.
|
211
|
+
# Never equal to zero. Values less than zero are discouraged and may not
|
212
|
+
# be supported in the future.
|
213
|
+
# @!attribute [rw] name
|
214
|
+
# @return [String]
|
215
|
+
# The name of the entity.
|
216
|
+
# A name matching regex +__.*__+ is reserved/read-only.
|
217
|
+
# A name must not be more than 1500 bytes when UTF-8 encoded.
|
218
|
+
# Cannot be +""+.
|
219
|
+
class PathElement; end
|
220
|
+
end
|
221
|
+
|
222
|
+
# Message for a unique key indicating a record that contains a finding.
|
223
|
+
# @!attribute [rw] cloud_storage_key
|
224
|
+
# @return [Google::Privacy::Dlp::V2beta1::CloudStorageKey]
|
225
|
+
# @!attribute [rw] datastore_key
|
226
|
+
# @return [Google::Privacy::Dlp::V2beta1::DatastoreKey]
|
227
|
+
class RecordKey; end
|
228
|
+
|
229
|
+
# Message defining the location of a BigQuery table. A table is uniquely
|
230
|
+
# identified by its project_id, dataset_id, and table_name. Within a query
|
231
|
+
# a table is often referenced with a string in the format of:
|
232
|
+
# +<project_id>:<dataset_id>.<table_id>+ or
|
233
|
+
# +<project_id>.<dataset_id>.<table_id>+.
|
234
|
+
# @!attribute [rw] project_id
|
235
|
+
# @return [String]
|
236
|
+
# The Google Cloud Platform project ID of the project containing the table.
|
237
|
+
# If omitted, project ID is inferred from the API call.
|
238
|
+
# @!attribute [rw] dataset_id
|
239
|
+
# @return [String]
|
240
|
+
# Dataset ID of the table.
|
241
|
+
# @!attribute [rw] table_id
|
242
|
+
# @return [String]
|
243
|
+
# Name of the table.
|
244
|
+
class BigQueryTable; end
|
245
|
+
|
246
|
+
# An entity in a dataset is a field or set of fields that correspond to a
|
247
|
+
# single person. For example, in medical records the +EntityId+ might be
|
248
|
+
# a patient identifier, or for financial records it might be an account
|
249
|
+
# identifier. This message is used when generalizations or analysis must be
|
250
|
+
# consistent across multiple rows pertaining to the same entity.
|
251
|
+
# @!attribute [rw] field
|
252
|
+
# @return [Google::Privacy::Dlp::V2beta1::FieldId]
|
253
|
+
# Composite key indicating which field contains the entity identifier.
|
254
|
+
class EntityId; end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# Example 3: Pack and unpack a message in Python.
|
43
|
+
#
|
44
|
+
# foo = Foo(...)
|
45
|
+
# any = Any()
|
46
|
+
# any.Pack(foo)
|
47
|
+
# ...
|
48
|
+
# if any.Is(Foo.DESCRIPTOR):
|
49
|
+
# any.Unpack(foo)
|
50
|
+
# ...
|
51
|
+
#
|
52
|
+
# Example 4: Pack and unpack a message in Go
|
53
|
+
#
|
54
|
+
# foo := &pb.Foo{...}
|
55
|
+
# any, err := ptypes.MarshalAny(foo)
|
56
|
+
# ...
|
57
|
+
# foo := &pb.Foo{}
|
58
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
59
|
+
# ...
|
60
|
+
# }
|
61
|
+
#
|
62
|
+
# The pack methods provided by protobuf library will by default use
|
63
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
64
|
+
# methods only use the fully qualified type name after the last '/'
|
65
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
66
|
+
# name "y.z".
|
67
|
+
#
|
68
|
+
#
|
69
|
+
# = JSON
|
70
|
+
#
|
71
|
+
# The JSON representation of an +Any+ value uses the regular
|
72
|
+
# representation of the deserialized, embedded message, with an
|
73
|
+
# additional field +@type+ which contains the type URL. Example:
|
74
|
+
#
|
75
|
+
# package google.profile;
|
76
|
+
# message Person {
|
77
|
+
# string first_name = 1;
|
78
|
+
# string last_name = 2;
|
79
|
+
# }
|
80
|
+
#
|
81
|
+
# {
|
82
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
83
|
+
# "firstName": <string>,
|
84
|
+
# "lastName": <string>
|
85
|
+
# }
|
86
|
+
#
|
87
|
+
# If the embedded message type is well-known and has a custom JSON
|
88
|
+
# representation, that representation will be embedded adding a field
|
89
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
90
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
91
|
+
#
|
92
|
+
# {
|
93
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
94
|
+
# "value": "1.212s"
|
95
|
+
# }
|
96
|
+
# @!attribute [rw] type_url
|
97
|
+
# @return [String]
|
98
|
+
# A URL/resource name whose content describes the type of the
|
99
|
+
# serialized protocol buffer message.
|
100
|
+
#
|
101
|
+
# For URLs which use the scheme +http+, +https+, or no scheme, the
|
102
|
+
# following restrictions and interpretations apply:
|
103
|
+
#
|
104
|
+
# * If no scheme is provided, +https+ is assumed.
|
105
|
+
# * The last segment of the URL's path must represent the fully
|
106
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
107
|
+
# The name should be in a canonical form (e.g., leading "." is
|
108
|
+
# not accepted).
|
109
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
110
|
+
# value in binary format, or produce an error.
|
111
|
+
# * Applications are allowed to cache lookup results based on the
|
112
|
+
# URL, or have them precompiled into a binary to avoid any
|
113
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
114
|
+
# on changes to types. (Use versioned type names to manage
|
115
|
+
# breaking changes.)
|
116
|
+
#
|
117
|
+
# Schemes other than +http+, +https+ (or the empty scheme) might be
|
118
|
+
# used with implementation specific semantics.
|
119
|
+
# @!attribute [rw] value
|
120
|
+
# @return [String]
|
121
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
122
|
+
class Any; end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# A Timestamp represents a point in time independent of any time zone
|
18
|
+
# or calendar, represented as seconds and fractions of seconds at
|
19
|
+
# nanosecond resolution in UTC Epoch time. It is encoded using the
|
20
|
+
# Proleptic Gregorian Calendar which extends the Gregorian calendar
|
21
|
+
# backwards to year one. It is encoded assuming all minutes are 60
|
22
|
+
# seconds long, i.e. leap seconds are "smeared" so that no leap second
|
23
|
+
# table is needed for interpretation. Range is from
|
24
|
+
# 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
|
25
|
+
# By restricting to that range, we ensure that we can convert to
|
26
|
+
# and from RFC 3339 date strings.
|
27
|
+
# See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
|
28
|
+
#
|
29
|
+
# = Examples
|
30
|
+
#
|
31
|
+
# Example 1: Compute Timestamp from POSIX +time()+.
|
32
|
+
#
|
33
|
+
# Timestamp timestamp;
|
34
|
+
# timestamp.set_seconds(time(NULL));
|
35
|
+
# timestamp.set_nanos(0);
|
36
|
+
#
|
37
|
+
# Example 2: Compute Timestamp from POSIX +gettimeofday()+.
|
38
|
+
#
|
39
|
+
# struct timeval tv;
|
40
|
+
# gettimeofday(&tv, NULL);
|
41
|
+
#
|
42
|
+
# Timestamp timestamp;
|
43
|
+
# timestamp.set_seconds(tv.tv_sec);
|
44
|
+
# timestamp.set_nanos(tv.tv_usec * 1000);
|
45
|
+
#
|
46
|
+
# Example 3: Compute Timestamp from Win32 +GetSystemTimeAsFileTime()+.
|
47
|
+
#
|
48
|
+
# FILETIME ft;
|
49
|
+
# GetSystemTimeAsFileTime(&ft);
|
50
|
+
# UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
51
|
+
#
|
52
|
+
# // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
53
|
+
# // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
54
|
+
# Timestamp timestamp;
|
55
|
+
# timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
56
|
+
# timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
57
|
+
#
|
58
|
+
# Example 4: Compute Timestamp from Java +System.currentTimeMillis()+.
|
59
|
+
#
|
60
|
+
# long millis = System.currentTimeMillis();
|
61
|
+
#
|
62
|
+
# Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
63
|
+
# .setNanos((int) ((millis % 1000) * 1000000)).build();
|
64
|
+
#
|
65
|
+
#
|
66
|
+
# Example 5: Compute Timestamp from current time in Python.
|
67
|
+
#
|
68
|
+
# timestamp = Timestamp()
|
69
|
+
# timestamp.GetCurrentTime()
|
70
|
+
#
|
71
|
+
# = JSON Mapping
|
72
|
+
#
|
73
|
+
# In JSON format, the Timestamp type is encoded as a string in the
|
74
|
+
# [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
75
|
+
# format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
76
|
+
# where {year} is always expressed using four digits while {month}, {day},
|
77
|
+
# {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
78
|
+
# seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
79
|
+
# are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
80
|
+
# is required, though only UTC (as indicated by "Z") is presently supported.
|
81
|
+
#
|
82
|
+
# For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
83
|
+
# 01:30 UTC on January 15, 2017.
|
84
|
+
#
|
85
|
+
# In JavaScript, one can convert a Date object to this format using the
|
86
|
+
# standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
|
87
|
+
# method. In Python, a standard +datetime.datetime+ object can be converted
|
88
|
+
# to this format using [+strftime+](https://docs.python.org/2/library/time.html#time.strftime)
|
89
|
+
# with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
|
90
|
+
# can use the Joda Time's [+ISODateTimeFormat.dateTime()+](
|
91
|
+
# http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
|
92
|
+
# to obtain a formatter capable of generating timestamps in this format.
|
93
|
+
# @!attribute [rw] seconds
|
94
|
+
# @return [Integer]
|
95
|
+
# Represents seconds of UTC time since Unix epoch
|
96
|
+
# 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
97
|
+
# 9999-12-31T23:59:59Z inclusive.
|
98
|
+
# @!attribute [rw] nanos
|
99
|
+
# @return [Integer]
|
100
|
+
# Non-negative fractions of a second at nanosecond resolution. Negative
|
101
|
+
# second values with fractions must still have non-negative nanos values
|
102
|
+
# that count forward in time. Must be from 0 to 999,999,999
|
103
|
+
# inclusive.
|
104
|
+
class Timestamp; end
|
105
|
+
end
|
106
|
+
end
|