google-cloud-firestore 1.0.0 → 1.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 +4 -4
- data/CHANGELOG.md +11 -0
- data/LOGGING.md +1 -1
- data/lib/google-cloud-firestore.rb +1 -0
- data/lib/google/cloud/firestore.rb +9 -4
- data/lib/google/cloud/firestore/admin.rb +144 -0
- data/lib/google/cloud/firestore/admin/v1.rb +151 -0
- data/lib/google/cloud/firestore/admin/v1/credentials.rb +44 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/field.rb +88 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/firestore_admin.rb +161 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/index.rb +139 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/rpc/status.rb +87 -0
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +761 -0
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +71 -0
- data/lib/google/cloud/firestore/v1.rb +2 -2
- data/lib/google/cloud/firestore/v1beta1.rb +2 -2
- data/lib/google/cloud/firestore/version.rb +1 -1
- data/lib/google/firestore/admin/v1/field_pb.rb +31 -0
- data/lib/google/firestore/admin/v1/firestore_admin_pb.rb +81 -0
- data/lib/google/firestore/admin/v1/firestore_admin_services_pb.rb +94 -0
- data/lib/google/firestore/admin/v1/index_pb.rb +56 -0
- data/lib/google/firestore/admin/v1/location_pb.rb +22 -0
- data/lib/google/firestore/admin/v1/operation_pb.rb +90 -0
- metadata +22 -3
@@ -0,0 +1,161 @@
|
|
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 Firestore
|
18
|
+
module Admin
|
19
|
+
module V1
|
20
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::CreateIndex FirestoreAdmin::CreateIndex}.
|
21
|
+
# @!attribute [rw] parent
|
22
|
+
# @return [String]
|
23
|
+
# A parent name of the form
|
24
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
|
25
|
+
# @!attribute [rw] index
|
26
|
+
# @return [Google::Firestore::Admin::V1::Index]
|
27
|
+
# The composite index to create.
|
28
|
+
class CreateIndexRequest; end
|
29
|
+
|
30
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::ListIndexes FirestoreAdmin::ListIndexes}.
|
31
|
+
# @!attribute [rw] parent
|
32
|
+
# @return [String]
|
33
|
+
# A parent name of the form
|
34
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
|
35
|
+
# @!attribute [rw] filter
|
36
|
+
# @return [String]
|
37
|
+
# The filter to apply to list results.
|
38
|
+
# @!attribute [rw] page_size
|
39
|
+
# @return [Integer]
|
40
|
+
# The number of results to return.
|
41
|
+
# @!attribute [rw] page_token
|
42
|
+
# @return [String]
|
43
|
+
# A page token, returned from a previous call to
|
44
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListIndexes FirestoreAdmin::ListIndexes}, that may be used to get the next
|
45
|
+
# page of results.
|
46
|
+
class ListIndexesRequest; end
|
47
|
+
|
48
|
+
# The response for {Google::Firestore::Admin::V1::FirestoreAdmin::ListIndexes FirestoreAdmin::ListIndexes}.
|
49
|
+
# @!attribute [rw] indexes
|
50
|
+
# @return [Array<Google::Firestore::Admin::V1::Index>]
|
51
|
+
# The requested indexes.
|
52
|
+
# @!attribute [rw] next_page_token
|
53
|
+
# @return [String]
|
54
|
+
# A page token that may be used to request another page of results. If blank,
|
55
|
+
# this is the last page.
|
56
|
+
class ListIndexesResponse; end
|
57
|
+
|
58
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::GetIndex FirestoreAdmin::GetIndex}.
|
59
|
+
# @!attribute [rw] name
|
60
|
+
# @return [String]
|
61
|
+
# A name of the form
|
62
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
63
|
+
class GetIndexRequest; end
|
64
|
+
|
65
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::DeleteIndex FirestoreAdmin::DeleteIndex}.
|
66
|
+
# @!attribute [rw] name
|
67
|
+
# @return [String]
|
68
|
+
# A name of the form
|
69
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
70
|
+
class DeleteIndexRequest; end
|
71
|
+
|
72
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::UpdateField FirestoreAdmin::UpdateField}.
|
73
|
+
# @!attribute [rw] field
|
74
|
+
# @return [Google::Firestore::Admin::V1::Field]
|
75
|
+
# The field to be updated.
|
76
|
+
# @!attribute [rw] update_mask
|
77
|
+
# @return [Google::Protobuf::FieldMask]
|
78
|
+
# A mask, relative to the field. If specified, only configuration specified
|
79
|
+
# by this field_mask will be updated in the field.
|
80
|
+
class UpdateFieldRequest; end
|
81
|
+
|
82
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::GetField FirestoreAdmin::GetField}.
|
83
|
+
# @!attribute [rw] name
|
84
|
+
# @return [String]
|
85
|
+
# A name of the form
|
86
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
|
87
|
+
class GetFieldRequest; end
|
88
|
+
|
89
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields}.
|
90
|
+
# @!attribute [rw] parent
|
91
|
+
# @return [String]
|
92
|
+
# A parent name of the form
|
93
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
|
94
|
+
# @!attribute [rw] filter
|
95
|
+
# @return [String]
|
96
|
+
# The filter to apply to list results. Currently,
|
97
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} only supports listing fields
|
98
|
+
# that have been explicitly overridden. To issue this query, call
|
99
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} with the filter set to
|
100
|
+
# `indexConfig.usesAncestorConfig:false`.
|
101
|
+
# @!attribute [rw] page_size
|
102
|
+
# @return [Integer]
|
103
|
+
# The number of results to return.
|
104
|
+
# @!attribute [rw] page_token
|
105
|
+
# @return [String]
|
106
|
+
# A page token, returned from a previous call to
|
107
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields}, that may be used to get the next
|
108
|
+
# page of results.
|
109
|
+
class ListFieldsRequest; end
|
110
|
+
|
111
|
+
# The response for {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields}.
|
112
|
+
# @!attribute [rw] fields
|
113
|
+
# @return [Array<Google::Firestore::Admin::V1::Field>]
|
114
|
+
# The requested fields.
|
115
|
+
# @!attribute [rw] next_page_token
|
116
|
+
# @return [String]
|
117
|
+
# A page token that may be used to request another page of results. If blank,
|
118
|
+
# this is the last page.
|
119
|
+
class ListFieldsResponse; end
|
120
|
+
|
121
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::ExportDocuments FirestoreAdmin::ExportDocuments}.
|
122
|
+
# @!attribute [rw] name
|
123
|
+
# @return [String]
|
124
|
+
# Database to export. Should be of the form:
|
125
|
+
# `projects/{project_id}/databases/{database_id}`.
|
126
|
+
# @!attribute [rw] collection_ids
|
127
|
+
# @return [Array<String>]
|
128
|
+
# Which collection ids to export. Unspecified means all collections.
|
129
|
+
# @!attribute [rw] output_uri_prefix
|
130
|
+
# @return [String]
|
131
|
+
# The output URI. Currently only supports Google Cloud Storage URIs of the
|
132
|
+
# form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
|
133
|
+
# of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
|
134
|
+
# Google Cloud Storage namespace path. When
|
135
|
+
# choosing a name, be sure to consider Google Cloud Storage naming
|
136
|
+
# guidelines: https://cloud.google.com/storage/docs/naming.
|
137
|
+
# If the URI is a bucket (without a namespace path), a prefix will be
|
138
|
+
# generated based on the start time.
|
139
|
+
class ExportDocumentsRequest; end
|
140
|
+
|
141
|
+
# The request for {Google::Firestore::Admin::V1::FirestoreAdmin::ImportDocuments FirestoreAdmin::ImportDocuments}.
|
142
|
+
# @!attribute [rw] name
|
143
|
+
# @return [String]
|
144
|
+
# Database to import into. Should be of the form:
|
145
|
+
# `projects/{project_id}/databases/{database_id}`.
|
146
|
+
# @!attribute [rw] collection_ids
|
147
|
+
# @return [Array<String>]
|
148
|
+
# Which collection ids to import. Unspecified means all collections included
|
149
|
+
# in the import.
|
150
|
+
# @!attribute [rw] input_uri_prefix
|
151
|
+
# @return [String]
|
152
|
+
# Location of the exported files.
|
153
|
+
# This must match the output_uri_prefix of an ExportDocumentsResponse from
|
154
|
+
# an export that has completed successfully.
|
155
|
+
# See:
|
156
|
+
# {Google::Firestore::Admin::V1::ExportDocumentsResponse#output_uri_prefix}.
|
157
|
+
class ImportDocumentsRequest; end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,139 @@
|
|
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 Firestore
|
18
|
+
module Admin
|
19
|
+
module V1
|
20
|
+
# Cloud Firestore indexes enable simple and complex queries against
|
21
|
+
# documents in a database.
|
22
|
+
# @!attribute [rw] name
|
23
|
+
# @return [String]
|
24
|
+
# Output only.
|
25
|
+
# A server defined name for this index.
|
26
|
+
# The form of this name for composite indexes will be:
|
27
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
|
28
|
+
# For single field indexes, this field will be empty.
|
29
|
+
# @!attribute [rw] query_scope
|
30
|
+
# @return [Google::Firestore::Admin::V1::Index::QueryScope]
|
31
|
+
# Indexes with a collection query scope specified allow queries
|
32
|
+
# against a collection that is the child of a specific document, specified at
|
33
|
+
# query time, and that has the same collection id.
|
34
|
+
#
|
35
|
+
# Indexes with a collection group query scope specified allow queries against
|
36
|
+
# all collections descended from a specific document, specified at query
|
37
|
+
# time, and that have the same collection id as this index.
|
38
|
+
# @!attribute [rw] fields
|
39
|
+
# @return [Array<Google::Firestore::Admin::V1::Index::IndexField>]
|
40
|
+
# The fields supported by this index.
|
41
|
+
#
|
42
|
+
# For composite indexes, this is always 2 or more fields.
|
43
|
+
# The last field entry is always for the field path `__name__`. If, on
|
44
|
+
# creation, `__name__` was not specified as the last field, it will be added
|
45
|
+
# automatically with the same direction as that of the last field defined. If
|
46
|
+
# the final field in a composite index is not directional, the `__name__`
|
47
|
+
# will be ordered ASCENDING (unless explicitly specified).
|
48
|
+
#
|
49
|
+
# For single field indexes, this will always be exactly one entry with a
|
50
|
+
# field path equal to the field path of the associated field.
|
51
|
+
# @!attribute [rw] state
|
52
|
+
# @return [Google::Firestore::Admin::V1::Index::State]
|
53
|
+
# Output only.
|
54
|
+
# The serving state of the index.
|
55
|
+
class Index
|
56
|
+
# A field in an index.
|
57
|
+
# The field_path describes which field is indexed, the value_mode describes
|
58
|
+
# how the field value is indexed.
|
59
|
+
# @!attribute [rw] field_path
|
60
|
+
# @return [String]
|
61
|
+
# Can be __name__.
|
62
|
+
# For single field indexes, this must match the name of the field or may
|
63
|
+
# be omitted.
|
64
|
+
# @!attribute [rw] order
|
65
|
+
# @return [Google::Firestore::Admin::V1::Index::IndexField::Order]
|
66
|
+
# Indicates that this field supports ordering by the specified order or
|
67
|
+
# comparing using =, <, <=, >, >=.
|
68
|
+
# @!attribute [rw] array_config
|
69
|
+
# @return [Google::Firestore::Admin::V1::Index::IndexField::ArrayConfig]
|
70
|
+
# Indicates that this field supports operations on `array_value`s.
|
71
|
+
class IndexField
|
72
|
+
# The supported array value configurations.
|
73
|
+
module ArrayConfig
|
74
|
+
# The index does not support additional array queries.
|
75
|
+
ARRAY_CONFIG_UNSPECIFIED = 0
|
76
|
+
|
77
|
+
# The index supports array containment queries.
|
78
|
+
CONTAINS = 1
|
79
|
+
end
|
80
|
+
|
81
|
+
# The supported orderings.
|
82
|
+
module Order
|
83
|
+
# The ordering is unspecified. Not a valid option.
|
84
|
+
ORDER_UNSPECIFIED = 0
|
85
|
+
|
86
|
+
# The field is ordered by ascending field value.
|
87
|
+
ASCENDING = 1
|
88
|
+
|
89
|
+
# The field is ordered by descending field value.
|
90
|
+
DESCENDING = 2
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Query Scope defines the scope at which a query is run. This is specified on
|
95
|
+
# a StructuredQuery's `from` field.
|
96
|
+
module QueryScope
|
97
|
+
# The query scope is unspecified. Not a valid option.
|
98
|
+
QUERY_SCOPE_UNSPECIFIED = 0
|
99
|
+
|
100
|
+
# Indexes with a collection query scope specified allow queries
|
101
|
+
# against a collection that is the child of a specific document, specified
|
102
|
+
# at query time, and that has the collection id specified by the index.
|
103
|
+
COLLECTION = 1
|
104
|
+
end
|
105
|
+
|
106
|
+
# The state of an index. During index creation, an index will be in the
|
107
|
+
# `CREATING` state. If the index is created successfully, it will transition
|
108
|
+
# to the `READY` state. If the index creation encounters a problem, the index
|
109
|
+
# will transition to the `NEEDS_REPAIR` state.
|
110
|
+
module State
|
111
|
+
# The state is unspecified.
|
112
|
+
STATE_UNSPECIFIED = 0
|
113
|
+
|
114
|
+
# The index is being created.
|
115
|
+
# There is an active long-running operation for the index.
|
116
|
+
# The index is updated when writing a document.
|
117
|
+
# Some index data may exist.
|
118
|
+
CREATING = 1
|
119
|
+
|
120
|
+
# The index is ready to be used.
|
121
|
+
# The index is updated when writing a document.
|
122
|
+
# The index is fully populated from all stored documents it applies to.
|
123
|
+
READY = 2
|
124
|
+
|
125
|
+
# The index was being created, but something went wrong.
|
126
|
+
# There is no active long-running operation for the index,
|
127
|
+
# and the most recently finished long-running operation failed.
|
128
|
+
# The index is not updated when writing a document.
|
129
|
+
# Some index data may exist.
|
130
|
+
# Use the google.longrunning.Operations API to determine why the operation
|
131
|
+
# that last attempted to create this index failed, then re-create the
|
132
|
+
# index.
|
133
|
+
NEEDS_REPAIR = 3
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
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
|