1 | <?php
|
---|
2 | /*
|
---|
3 | * Copyright 2014 Google Inc.
|
---|
4 | *
|
---|
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
---|
6 | * use this file except in compliance with the License. You may obtain a copy of
|
---|
7 | * the License at
|
---|
8 | *
|
---|
9 | * http://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, WITHOUT
|
---|
13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
---|
14 | * License for the specific language governing permissions and limitations under
|
---|
15 | * the License.
|
---|
16 | */
|
---|
17 |
|
---|
18 | namespace Google\Service\Firestore\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Firestore\GoogleFirestoreAdminV1BulkDeleteDocumentsRequest;
|
---|
21 | use Google\Service\Firestore\GoogleFirestoreAdminV1Database;
|
---|
22 | use Google\Service\Firestore\GoogleFirestoreAdminV1ExportDocumentsRequest;
|
---|
23 | use Google\Service\Firestore\GoogleFirestoreAdminV1ImportDocumentsRequest;
|
---|
24 | use Google\Service\Firestore\GoogleFirestoreAdminV1ListDatabasesResponse;
|
---|
25 | use Google\Service\Firestore\GoogleFirestoreAdminV1RestoreDatabaseRequest;
|
---|
26 | use Google\Service\Firestore\GoogleLongrunningOperation;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * The "databases" collection of methods.
|
---|
30 | * Typical usage is:
|
---|
31 | * <code>
|
---|
32 | * $firestoreService = new Google\Service\Firestore(...);
|
---|
33 | * $databases = $firestoreService->projects_databases;
|
---|
34 | * </code>
|
---|
35 | */
|
---|
36 | class ProjectsDatabases extends \Google\Service\Resource
|
---|
37 | {
|
---|
38 | /**
|
---|
39 | * Bulk deletes a subset of documents from Google Cloud Firestore. Documents
|
---|
40 | * created or updated after the underlying system starts to process the request
|
---|
41 | * will not be deleted. The bulk delete occurs in the background and its
|
---|
42 | * progress can be monitored and managed via the Operation resource that is
|
---|
43 | * created. For more details on bulk delete behavior, refer to:
|
---|
44 | * https://cloud.google.com/firestore/docs/manage-data/bulk-delete
|
---|
45 | * (databases.bulkDeleteDocuments)
|
---|
46 | *
|
---|
47 | * @param string $name Required. Database to operate. Should be of the form:
|
---|
48 | * `projects/{project_id}/databases/{database_id}`.
|
---|
49 | * @param GoogleFirestoreAdminV1BulkDeleteDocumentsRequest $postBody
|
---|
50 | * @param array $optParams Optional parameters.
|
---|
51 | * @return GoogleLongrunningOperation
|
---|
52 | * @throws \Google\Service\Exception
|
---|
53 | */
|
---|
54 | public function bulkDeleteDocuments($name, GoogleFirestoreAdminV1BulkDeleteDocumentsRequest $postBody, $optParams = [])
|
---|
55 | {
|
---|
56 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
57 | $params = array_merge($params, $optParams);
|
---|
58 | return $this->call('bulkDeleteDocuments', [$params], GoogleLongrunningOperation::class);
|
---|
59 | }
|
---|
60 | /**
|
---|
61 | * Create a database. (databases.create)
|
---|
62 | *
|
---|
63 | * @param string $parent Required. A parent name of the form
|
---|
64 | * `projects/{project_id}`
|
---|
65 | * @param GoogleFirestoreAdminV1Database $postBody
|
---|
66 | * @param array $optParams Optional parameters.
|
---|
67 | *
|
---|
68 | * @opt_param string databaseId Required. The ID to use for the database, which
|
---|
69 | * will become the final component of the database's resource name. This value
|
---|
70 | * should be 4-63 characters. Valid characters are /a-z-/ with first character a
|
---|
71 | * letter and the last a letter or a number. Must not be UUID-like
|
---|
72 | * /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. "(default)" database ID is also
|
---|
73 | * valid.
|
---|
74 | * @return GoogleLongrunningOperation
|
---|
75 | * @throws \Google\Service\Exception
|
---|
76 | */
|
---|
77 | public function create($parent, GoogleFirestoreAdminV1Database $postBody, $optParams = [])
|
---|
78 | {
|
---|
79 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
80 | $params = array_merge($params, $optParams);
|
---|
81 | return $this->call('create', [$params], GoogleLongrunningOperation::class);
|
---|
82 | }
|
---|
83 | /**
|
---|
84 | * Deletes a database. (databases.delete)
|
---|
85 | *
|
---|
86 | * @param string $name Required. A name of the form
|
---|
87 | * `projects/{project_id}/databases/{database_id}`
|
---|
88 | * @param array $optParams Optional parameters.
|
---|
89 | *
|
---|
90 | * @opt_param string etag The current etag of the Database. If an etag is
|
---|
91 | * provided and does not match the current etag of the database, deletion will
|
---|
92 | * be blocked and a FAILED_PRECONDITION error will be returned.
|
---|
93 | * @return GoogleLongrunningOperation
|
---|
94 | * @throws \Google\Service\Exception
|
---|
95 | */
|
---|
96 | public function delete($name, $optParams = [])
|
---|
97 | {
|
---|
98 | $params = ['name' => $name];
|
---|
99 | $params = array_merge($params, $optParams);
|
---|
100 | return $this->call('delete', [$params], GoogleLongrunningOperation::class);
|
---|
101 | }
|
---|
102 | /**
|
---|
103 | * Exports a copy of all or a subset of documents from Google Cloud Firestore to
|
---|
104 | * another storage system, such as Google Cloud Storage. Recent updates to
|
---|
105 | * documents may not be reflected in the export. The export occurs in the
|
---|
106 | * background and its progress can be monitored and managed via the Operation
|
---|
107 | * resource that is created. The output of an export may only be used once the
|
---|
108 | * associated operation is done. If an export operation is cancelled before
|
---|
109 | * completion it may leave partial data behind in Google Cloud Storage. For more
|
---|
110 | * details on export behavior and output format, refer to:
|
---|
111 | * https://cloud.google.com/firestore/docs/manage-data/export-import
|
---|
112 | * (databases.exportDocuments)
|
---|
113 | *
|
---|
114 | * @param string $name Required. Database to export. Should be of the form:
|
---|
115 | * `projects/{project_id}/databases/{database_id}`.
|
---|
116 | * @param GoogleFirestoreAdminV1ExportDocumentsRequest $postBody
|
---|
117 | * @param array $optParams Optional parameters.
|
---|
118 | * @return GoogleLongrunningOperation
|
---|
119 | * @throws \Google\Service\Exception
|
---|
120 | */
|
---|
121 | public function exportDocuments($name, GoogleFirestoreAdminV1ExportDocumentsRequest $postBody, $optParams = [])
|
---|
122 | {
|
---|
123 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
124 | $params = array_merge($params, $optParams);
|
---|
125 | return $this->call('exportDocuments', [$params], GoogleLongrunningOperation::class);
|
---|
126 | }
|
---|
127 | /**
|
---|
128 | * Gets information about a database. (databases.get)
|
---|
129 | *
|
---|
130 | * @param string $name Required. A name of the form
|
---|
131 | * `projects/{project_id}/databases/{database_id}`
|
---|
132 | * @param array $optParams Optional parameters.
|
---|
133 | * @return GoogleFirestoreAdminV1Database
|
---|
134 | * @throws \Google\Service\Exception
|
---|
135 | */
|
---|
136 | public function get($name, $optParams = [])
|
---|
137 | {
|
---|
138 | $params = ['name' => $name];
|
---|
139 | $params = array_merge($params, $optParams);
|
---|
140 | return $this->call('get', [$params], GoogleFirestoreAdminV1Database::class);
|
---|
141 | }
|
---|
142 | /**
|
---|
143 | * Imports documents into Google Cloud Firestore. Existing documents with the
|
---|
144 | * same name are overwritten. The import occurs in the background and its
|
---|
145 | * progress can be monitored and managed via the Operation resource that is
|
---|
146 | * created. If an ImportDocuments operation is cancelled, it is possible that a
|
---|
147 | * subset of the data has already been imported to Cloud Firestore.
|
---|
148 | * (databases.importDocuments)
|
---|
149 | *
|
---|
150 | * @param string $name Required. Database to import into. Should be of the form:
|
---|
151 | * `projects/{project_id}/databases/{database_id}`.
|
---|
152 | * @param GoogleFirestoreAdminV1ImportDocumentsRequest $postBody
|
---|
153 | * @param array $optParams Optional parameters.
|
---|
154 | * @return GoogleLongrunningOperation
|
---|
155 | * @throws \Google\Service\Exception
|
---|
156 | */
|
---|
157 | public function importDocuments($name, GoogleFirestoreAdminV1ImportDocumentsRequest $postBody, $optParams = [])
|
---|
158 | {
|
---|
159 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
160 | $params = array_merge($params, $optParams);
|
---|
161 | return $this->call('importDocuments', [$params], GoogleLongrunningOperation::class);
|
---|
162 | }
|
---|
163 | /**
|
---|
164 | * List all the databases in the project. (databases.listProjectsDatabases)
|
---|
165 | *
|
---|
166 | * @param string $parent Required. A parent name of the form
|
---|
167 | * `projects/{project_id}`
|
---|
168 | * @param array $optParams Optional parameters.
|
---|
169 | *
|
---|
170 | * @opt_param bool showDeleted If true, also returns deleted resources.
|
---|
171 | * @return GoogleFirestoreAdminV1ListDatabasesResponse
|
---|
172 | * @throws \Google\Service\Exception
|
---|
173 | */
|
---|
174 | public function listProjectsDatabases($parent, $optParams = [])
|
---|
175 | {
|
---|
176 | $params = ['parent' => $parent];
|
---|
177 | $params = array_merge($params, $optParams);
|
---|
178 | return $this->call('list', [$params], GoogleFirestoreAdminV1ListDatabasesResponse::class);
|
---|
179 | }
|
---|
180 | /**
|
---|
181 | * Updates a database. (databases.patch)
|
---|
182 | *
|
---|
183 | * @param string $name The resource name of the Database. Format:
|
---|
184 | * `projects/{project}/databases/{database}`
|
---|
185 | * @param GoogleFirestoreAdminV1Database $postBody
|
---|
186 | * @param array $optParams Optional parameters.
|
---|
187 | *
|
---|
188 | * @opt_param string updateMask The list of fields to be updated.
|
---|
189 | * @return GoogleLongrunningOperation
|
---|
190 | * @throws \Google\Service\Exception
|
---|
191 | */
|
---|
192 | public function patch($name, GoogleFirestoreAdminV1Database $postBody, $optParams = [])
|
---|
193 | {
|
---|
194 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
195 | $params = array_merge($params, $optParams);
|
---|
196 | return $this->call('patch', [$params], GoogleLongrunningOperation::class);
|
---|
197 | }
|
---|
198 | /**
|
---|
199 | * Creates a new database by restoring from an existing backup. The new database
|
---|
200 | * must be in the same cloud region or multi-region location as the existing
|
---|
201 | * backup. This behaves similar to FirestoreAdmin.CreateDatabase except instead
|
---|
202 | * of creating a new empty database, a new database is created with the database
|
---|
203 | * type, index configuration, and documents from an existing backup. The long-
|
---|
204 | * running operation can be used to track the progress of the restore, with the
|
---|
205 | * Operation's metadata field type being the RestoreDatabaseMetadata. The
|
---|
206 | * response type is the Database if the restore was successful. The new database
|
---|
207 | * is not readable or writeable until the LRO has completed. (databases.restore)
|
---|
208 | *
|
---|
209 | * @param string $parent Required. The project to restore the database in.
|
---|
210 | * Format is `projects/{project_id}`.
|
---|
211 | * @param GoogleFirestoreAdminV1RestoreDatabaseRequest $postBody
|
---|
212 | * @param array $optParams Optional parameters.
|
---|
213 | * @return GoogleLongrunningOperation
|
---|
214 | * @throws \Google\Service\Exception
|
---|
215 | */
|
---|
216 | public function restore($parent, GoogleFirestoreAdminV1RestoreDatabaseRequest $postBody, $optParams = [])
|
---|
217 | {
|
---|
218 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
219 | $params = array_merge($params, $optParams);
|
---|
220 | return $this->call('restore', [$params], GoogleLongrunningOperation::class);
|
---|
221 | }
|
---|
222 | }
|
---|
223 |
|
---|
224 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
225 | class_alias(ProjectsDatabases::class, 'Google_Service_Firestore_Resource_ProjectsDatabases');
|
---|