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
18namespace Google\Service\Firestore\Resource;
19
20use Google\Service\Firestore\GoogleFirestoreAdminV1Database;
21use Google\Service\Firestore\GoogleFirestoreAdminV1ExportDocumentsRequest;
22use Google\Service\Firestore\GoogleFirestoreAdminV1ImportDocumentsRequest;
23use Google\Service\Firestore\GoogleFirestoreAdminV1ListDatabasesResponse;
24use Google\Service\Firestore\GoogleLongrunningOperation;
25
26/**
27 * The "databases" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $firestoreService = new Google\Service\Firestore(...);
31 *   $databases = $firestoreService->databases;
32 *  </code>
33 */
34class ProjectsDatabases extends \Google\Service\Resource
35{
36  /**
37   * Exports a copy of all or a subset of documents from Google Cloud Firestore to
38   * another storage system, such as Google Cloud Storage. Recent updates to
39   * documents may not be reflected in the export. The export occurs in the
40   * background and its progress can be monitored and managed via the Operation
41   * resource that is created. The output of an export may only be used once the
42   * associated operation is done. If an export operation is cancelled before
43   * completion it may leave partial data behind in Google Cloud Storage. For more
44   * details on export behavior and output format, refer to:
45   * https://cloud.google.com/firestore/docs/manage-data/export-import
46   * (databases.exportDocuments)
47   *
48   * @param string $name Required. Database to export. Should be of the form:
49   * `projects/{project_id}/databases/{database_id}`.
50   * @param GoogleFirestoreAdminV1ExportDocumentsRequest $postBody
51   * @param array $optParams Optional parameters.
52   * @return GoogleLongrunningOperation
53   */
54  public function exportDocuments($name, GoogleFirestoreAdminV1ExportDocumentsRequest $postBody, $optParams = [])
55  {
56    $params = ['name' => $name, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('exportDocuments', [$params], GoogleLongrunningOperation::class);
59  }
60  /**
61   * Gets information about a database. (databases.get)
62   *
63   * @param string $name Required. A name of the form
64   * `projects/{project_id}/databases/{database_id}`
65   * @param array $optParams Optional parameters.
66   * @return GoogleFirestoreAdminV1Database
67   */
68  public function get($name, $optParams = [])
69  {
70    $params = ['name' => $name];
71    $params = array_merge($params, $optParams);
72    return $this->call('get', [$params], GoogleFirestoreAdminV1Database::class);
73  }
74  /**
75   * Imports documents into Google Cloud Firestore. Existing documents with the
76   * same name are overwritten. The import occurs in the background and its
77   * progress can be monitored and managed via the Operation resource that is
78   * created. If an ImportDocuments operation is cancelled, it is possible that a
79   * subset of the data has already been imported to Cloud Firestore.
80   * (databases.importDocuments)
81   *
82   * @param string $name Required. Database to import into. Should be of the form:
83   * `projects/{project_id}/databases/{database_id}`.
84   * @param GoogleFirestoreAdminV1ImportDocumentsRequest $postBody
85   * @param array $optParams Optional parameters.
86   * @return GoogleLongrunningOperation
87   */
88  public function importDocuments($name, GoogleFirestoreAdminV1ImportDocumentsRequest $postBody, $optParams = [])
89  {
90    $params = ['name' => $name, 'postBody' => $postBody];
91    $params = array_merge($params, $optParams);
92    return $this->call('importDocuments', [$params], GoogleLongrunningOperation::class);
93  }
94  /**
95   * List all the databases in the project. (databases.listProjectsDatabases)
96   *
97   * @param string $parent Required. A parent name of the form
98   * `projects/{project_id}`
99   * @param array $optParams Optional parameters.
100   * @return GoogleFirestoreAdminV1ListDatabasesResponse
101   */
102  public function listProjectsDatabases($parent, $optParams = [])
103  {
104    $params = ['parent' => $parent];
105    $params = array_merge($params, $optParams);
106    return $this->call('list', [$params], GoogleFirestoreAdminV1ListDatabasesResponse::class);
107  }
108  /**
109   * Updates a database. (databases.patch)
110   *
111   * @param string $name The resource name of the Database. Format:
112   * `projects/{project}/databases/{database}`
113   * @param GoogleFirestoreAdminV1Database $postBody
114   * @param array $optParams Optional parameters.
115   *
116   * @opt_param string updateMask The list of fields to be updated.
117   * @return GoogleLongrunningOperation
118   */
119  public function patch($name, GoogleFirestoreAdminV1Database $postBody, $optParams = [])
120  {
121    $params = ['name' => $name, 'postBody' => $postBody];
122    $params = array_merge($params, $optParams);
123    return $this->call('patch', [$params], GoogleLongrunningOperation::class);
124  }
125}
126
127// Adding a class alias for backwards compatibility with the previous class name.
128class_alias(ProjectsDatabases::class, 'Google_Service_Firestore_Resource_ProjectsDatabases');
129