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\FirebaseRealtimeDatabase\Resource;
19
20use Google\Service\FirebaseRealtimeDatabase\DatabaseInstance;
21use Google\Service\FirebaseRealtimeDatabase\DisableDatabaseInstanceRequest;
22use Google\Service\FirebaseRealtimeDatabase\ListDatabaseInstancesResponse;
23use Google\Service\FirebaseRealtimeDatabase\ReenableDatabaseInstanceRequest;
24use Google\Service\FirebaseRealtimeDatabase\UndeleteDatabaseInstanceRequest;
25
26/**
27 * The "instances" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $firebasedatabaseService = new Google\Service\FirebaseRealtimeDatabase(...);
31 *   $instances = $firebasedatabaseService->instances;
32 *  </code>
33 */
34class ProjectsLocationsInstances extends \Google\Service\Resource
35{
36  /**
37   * Requests that a new DatabaseInstance be created. The state of a successfully
38   * created DatabaseInstance is ACTIVE. Only available for projects on the Blaze
39   * plan. Projects can be upgraded using the Cloud Billing API https://cloud.goog
40   * le.com/billing/reference/rest/v1/projects/updateBillingInfo. Note that it
41   * might take a few minutes for billing enablement state to propagate to
42   * Firebase systems. (instances.create)
43   *
44   * @param string $parent The parent project for which to create a database
45   * instance, in the form: `projects/{project-number}/locations/{location-id}`.
46   * @param DatabaseInstance $postBody
47   * @param array $optParams Optional parameters.
48   *
49   * @opt_param string databaseId The globally unique identifier of the database
50   * instance.
51   * @opt_param bool validateOnly When set to true, the request will be validated
52   * but not submitted.
53   * @return DatabaseInstance
54   */
55  public function create($parent, DatabaseInstance $postBody, $optParams = [])
56  {
57    $params = ['parent' => $parent, 'postBody' => $postBody];
58    $params = array_merge($params, $optParams);
59    return $this->call('create', [$params], DatabaseInstance::class);
60  }
61  /**
62   * Marks a DatabaseInstance to be deleted. The DatabaseInstance will be purged
63   * within 30 days. The default database cannot be deleted. IDs for deleted
64   * database instances may never be recovered or re-used. The Database may only
65   * be deleted if it is already in a DISABLED state. (instances.delete)
66   *
67   * @param string $name The fully qualified resource name of the database
68   * instance, in the form: `projects/{project-number}/locations/{location-
69   * id}/instances/{database-id}`
70   * @param array $optParams Optional parameters.
71   * @return DatabaseInstance
72   */
73  public function delete($name, $optParams = [])
74  {
75    $params = ['name' => $name];
76    $params = array_merge($params, $optParams);
77    return $this->call('delete', [$params], DatabaseInstance::class);
78  }
79  /**
80   * Disables a DatabaseInstance. The database can be re-enabled later using
81   * ReenableDatabaseInstance. When a database is disabled, all reads and writes
82   * are denied, including view access in the Firebase console.
83   * (instances.disable)
84   *
85   * @param string $name The fully qualified resource name of the database
86   * instance, in the form: `projects/{project-number}/locations/{location-
87   * id}/instances/{database-id}`
88   * @param DisableDatabaseInstanceRequest $postBody
89   * @param array $optParams Optional parameters.
90   * @return DatabaseInstance
91   */
92  public function disable($name, DisableDatabaseInstanceRequest $postBody, $optParams = [])
93  {
94    $params = ['name' => $name, 'postBody' => $postBody];
95    $params = array_merge($params, $optParams);
96    return $this->call('disable', [$params], DatabaseInstance::class);
97  }
98  /**
99   * Gets the DatabaseInstance identified by the specified resource name.
100   * (instances.get)
101   *
102   * @param string $name The fully qualified resource name of the database
103   * instance, in the form: `projects/{project-number}/locations/{location-
104   * id}/instances/{database-id}`. `database-id` is a globally unique identifier
105   * across all parent collections. For convenience, this method allows you to
106   * supply `-` as a wildcard character in place of specific collections under
107   * `projects` and `locations`. The resulting wildcarding form of the method is:
108   * `projects/-/locations/-/instances/{database-id}`.
109   * @param array $optParams Optional parameters.
110   * @return DatabaseInstance
111   */
112  public function get($name, $optParams = [])
113  {
114    $params = ['name' => $name];
115    $params = array_merge($params, $optParams);
116    return $this->call('get', [$params], DatabaseInstance::class);
117  }
118  /**
119   * Lists each DatabaseInstance associated with the specified parent project. The
120   * list items are returned in no particular order, but will be a consistent view
121   * of the database instances when additional requests are made with a
122   * `pageToken`. The resulting list contains instances in any STATE. The list
123   * results may be stale by a few seconds. Use GetDatabaseInstance for consistent
124   * reads. (instances.listProjectsLocationsInstances)
125   *
126   * @param string $parent The parent project for which to list database
127   * instances, in the form: `projects/{project-number}/locations/{location-id}`
128   * To list across all locations, use a parent in the form: `projects/{project-
129   * number}/locations/-`
130   * @param array $optParams Optional parameters.
131   *
132   * @opt_param int pageSize The maximum number of database instances to return in
133   * the response. The server may return fewer than this at its discretion. If no
134   * value is specified (or too large a value is specified), then the server will
135   * impose its own limit.
136   * @opt_param string pageToken Token returned from a previous call to
137   * `ListDatabaseInstances` indicating where in the set of database instances to
138   * resume listing.
139   * @opt_param bool showDeleted Indicate that DatabaseInstances in the `DELETED`
140   * state should also be returned.
141   * @return ListDatabaseInstancesResponse
142   */
143  public function listProjectsLocationsInstances($parent, $optParams = [])
144  {
145    $params = ['parent' => $parent];
146    $params = array_merge($params, $optParams);
147    return $this->call('list', [$params], ListDatabaseInstancesResponse::class);
148  }
149  /**
150   * Enables a DatabaseInstance. The database must have been disabled previously
151   * using DisableDatabaseInstance. The state of a successfully reenabled
152   * DatabaseInstance is ACTIVE. (instances.reenable)
153   *
154   * @param string $name The fully qualified resource name of the database
155   * instance, in the form: `projects/{project-number}/locations/{location-
156   * id}/instances/{database-id}`
157   * @param ReenableDatabaseInstanceRequest $postBody
158   * @param array $optParams Optional parameters.
159   * @return DatabaseInstance
160   */
161  public function reenable($name, ReenableDatabaseInstanceRequest $postBody, $optParams = [])
162  {
163    $params = ['name' => $name, 'postBody' => $postBody];
164    $params = array_merge($params, $optParams);
165    return $this->call('reenable', [$params], DatabaseInstance::class);
166  }
167  /**
168   * Restores a DatabaseInstance that was previously marked to be deleted. This
169   * may only be used on a DatabaseInstance in the DELETED state. Purged
170   * DatabaseInstance's may not be recovered. (instances.undelete)
171   *
172   * @param string $name The fully qualified resource name of the database
173   * instance, in the form: `projects/{project-number}/locations/{location-
174   * id}/instances/{database-id}`
175   * @param UndeleteDatabaseInstanceRequest $postBody
176   * @param array $optParams Optional parameters.
177   * @return DatabaseInstance
178   */
179  public function undelete($name, UndeleteDatabaseInstanceRequest $postBody, $optParams = [])
180  {
181    $params = ['name' => $name, 'postBody' => $postBody];
182    $params = array_merge($params, $optParams);
183    return $this->call('undelete', [$params], DatabaseInstance::class);
184  }
185}
186
187// Adding a class alias for backwards compatibility with the previous class name.
188class_alias(ProjectsLocationsInstances::class, 'Google_Service_FirebaseRealtimeDatabase_Resource_ProjectsLocationsInstances');
189