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\CloudRedis\Resource;
19
20use Google\Service\CloudRedis\ExportInstanceRequest;
21use Google\Service\CloudRedis\FailoverInstanceRequest;
22use Google\Service\CloudRedis\ImportInstanceRequest;
23use Google\Service\CloudRedis\Instance;
24use Google\Service\CloudRedis\InstanceAuthString;
25use Google\Service\CloudRedis\ListInstancesResponse;
26use Google\Service\CloudRedis\Operation;
27use Google\Service\CloudRedis\RescheduleMaintenanceRequest;
28use Google\Service\CloudRedis\UpgradeInstanceRequest;
29
30/**
31 * The "instances" collection of methods.
32 * Typical usage is:
33 *  <code>
34 *   $redisService = new Google\Service\CloudRedis(...);
35 *   $instances = $redisService->instances;
36 *  </code>
37 */
38class ProjectsLocationsInstances extends \Google\Service\Resource
39{
40  /**
41   * Creates a Redis instance based on the specified tier and memory size. By
42   * default, the instance is accessible from the project's [default
43   * network](https://cloud.google.com/vpc/docs/vpc). The creation is executed
44   * asynchronously and callers may check the returned operation to track its
45   * progress. Once the operation is completed the Redis instance will be fully
46   * functional. Completed longrunning.Operation will contain the new instance
47   * object in the response field. The returned operation is automatically deleted
48   * after a few hours, so there is no need to call DeleteOperation.
49   * (instances.create)
50   *
51   * @param string $parent Required. The resource name of the instance location
52   * using the form: `projects/{project_id}/locations/{location_id}` where
53   * `location_id` refers to a GCP region.
54   * @param Instance $postBody
55   * @param array $optParams Optional parameters.
56   *
57   * @opt_param string instanceId Required. The logical name of the Redis instance
58   * in the customer project with the following restrictions: * Must contain only
59   * lowercase letters, numbers, and hyphens. * Must start with a letter. * Must
60   * be between 1-40 characters. * Must end with a number or a letter. * Must be
61   * unique within the customer project / location
62   * @return Operation
63   */
64  public function create($parent, Instance $postBody, $optParams = [])
65  {
66    $params = ['parent' => $parent, 'postBody' => $postBody];
67    $params = array_merge($params, $optParams);
68    return $this->call('create', [$params], Operation::class);
69  }
70  /**
71   * Deletes a specific Redis instance. Instance stops serving and data is
72   * deleted. (instances.delete)
73   *
74   * @param string $name Required. Redis instance resource name using the form:
75   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
76   * `location_id` refers to a GCP region.
77   * @param array $optParams Optional parameters.
78   * @return Operation
79   */
80  public function delete($name, $optParams = [])
81  {
82    $params = ['name' => $name];
83    $params = array_merge($params, $optParams);
84    return $this->call('delete', [$params], Operation::class);
85  }
86  /**
87   * Export Redis instance data into a Redis RDB format file in Cloud Storage.
88   * Redis will continue serving during this operation. The returned operation is
89   * automatically deleted after a few hours, so there is no need to call
90   * DeleteOperation. (instances.export)
91   *
92   * @param string $name Required. Redis instance resource name using the form:
93   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
94   * `location_id` refers to a GCP region.
95   * @param ExportInstanceRequest $postBody
96   * @param array $optParams Optional parameters.
97   * @return Operation
98   */
99  public function export($name, ExportInstanceRequest $postBody, $optParams = [])
100  {
101    $params = ['name' => $name, 'postBody' => $postBody];
102    $params = array_merge($params, $optParams);
103    return $this->call('export', [$params], Operation::class);
104  }
105  /**
106   * Initiates a failover of the primary node to current replica node for a
107   * specific STANDARD tier Cloud Memorystore for Redis instance.
108   * (instances.failover)
109   *
110   * @param string $name Required. Redis instance resource name using the form:
111   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
112   * `location_id` refers to a GCP region.
113   * @param FailoverInstanceRequest $postBody
114   * @param array $optParams Optional parameters.
115   * @return Operation
116   */
117  public function failover($name, FailoverInstanceRequest $postBody, $optParams = [])
118  {
119    $params = ['name' => $name, 'postBody' => $postBody];
120    $params = array_merge($params, $optParams);
121    return $this->call('failover', [$params], Operation::class);
122  }
123  /**
124   * Gets the details of a specific Redis instance. (instances.get)
125   *
126   * @param string $name Required. Redis instance resource name using the form:
127   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
128   * `location_id` refers to a GCP region.
129   * @param array $optParams Optional parameters.
130   * @return Instance
131   */
132  public function get($name, $optParams = [])
133  {
134    $params = ['name' => $name];
135    $params = array_merge($params, $optParams);
136    return $this->call('get', [$params], Instance::class);
137  }
138  /**
139   * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the
140   * instance the response will be empty. This information is not included in the
141   * details returned to GetInstance. (instances.getAuthString)
142   *
143   * @param string $name Required. Redis instance resource name using the form:
144   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
145   * `location_id` refers to a GCP region.
146   * @param array $optParams Optional parameters.
147   * @return InstanceAuthString
148   */
149  public function getAuthString($name, $optParams = [])
150  {
151    $params = ['name' => $name];
152    $params = array_merge($params, $optParams);
153    return $this->call('getAuthString', [$params], InstanceAuthString::class);
154  }
155  /**
156   * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
157   * Redis may stop serving during this operation. Instance state will be
158   * IMPORTING for entire operation. When complete, the instance will contain only
159   * data from the imported file. The returned operation is automatically deleted
160   * after a few hours, so there is no need to call DeleteOperation.
161   * (instances.import)
162   *
163   * @param string $name Required. Redis instance resource name using the form:
164   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
165   * `location_id` refers to a GCP region.
166   * @param ImportInstanceRequest $postBody
167   * @param array $optParams Optional parameters.
168   * @return Operation
169   */
170  public function import($name, ImportInstanceRequest $postBody, $optParams = [])
171  {
172    $params = ['name' => $name, 'postBody' => $postBody];
173    $params = array_merge($params, $optParams);
174    return $this->call('import', [$params], Operation::class);
175  }
176  /**
177   * Lists all Redis instances owned by a project in either the specified location
178   * (region) or all locations. The location should have the following format: *
179   * `projects/{project_id}/locations/{location_id}` If `location_id` is specified
180   * as `-` (wildcard), then all regions available to the project are queried, and
181   * the results are aggregated. (instances.listProjectsLocationsInstances)
182   *
183   * @param string $parent Required. The resource name of the instance location
184   * using the form: `projects/{project_id}/locations/{location_id}` where
185   * `location_id` refers to a GCP region.
186   * @param array $optParams Optional parameters.
187   *
188   * @opt_param int pageSize The maximum number of items to return. If not
189   * specified, a default value of 1000 will be used by the service. Regardless of
190   * the page_size value, the response may include a partial list and a caller
191   * should only rely on response's `next_page_token` to determine if there are
192   * more instances left to be queried.
193   * @opt_param string pageToken The `next_page_token` value returned from a
194   * previous ListInstances request, if any.
195   * @return ListInstancesResponse
196   */
197  public function listProjectsLocationsInstances($parent, $optParams = [])
198  {
199    $params = ['parent' => $parent];
200    $params = array_merge($params, $optParams);
201    return $this->call('list', [$params], ListInstancesResponse::class);
202  }
203  /**
204   * Updates the metadata and configuration of a specific Redis instance.
205   * Completed longrunning.Operation will contain the new instance object in the
206   * response field. The returned operation is automatically deleted after a few
207   * hours, so there is no need to call DeleteOperation. (instances.patch)
208   *
209   * @param string $name Required. Unique name of the resource in this scope
210   * including project and location using the form:
211   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note:
212   * Redis instances are managed and addressed at regional level so location_id
213   * here refers to a GCP region; however, users may choose which specific zone
214   * (or collection of zones for cross-zone instances) an instance should be
215   * provisioned in. Refer to location_id and alternative_location_id fields for
216   * more details.
217   * @param Instance $postBody
218   * @param array $optParams Optional parameters.
219   *
220   * @opt_param string updateMask Required. Mask of fields to update. At least one
221   * path must be supplied in this field. The elements of the repeated paths field
222   * may only include these fields from Instance: * `displayName` * `labels` *
223   * `memorySizeGb` * `redisConfig` * `replica_count`
224   * @return Operation
225   */
226  public function patch($name, Instance $postBody, $optParams = [])
227  {
228    $params = ['name' => $name, 'postBody' => $postBody];
229    $params = array_merge($params, $optParams);
230    return $this->call('patch', [$params], Operation::class);
231  }
232  /**
233   * Reschedule maintenance for a given instance in a given project and location.
234   * (instances.rescheduleMaintenance)
235   *
236   * @param string $name Required. Redis instance resource name using the form:
237   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
238   * `location_id` refers to a GCP region.
239   * @param RescheduleMaintenanceRequest $postBody
240   * @param array $optParams Optional parameters.
241   * @return Operation
242   */
243  public function rescheduleMaintenance($name, RescheduleMaintenanceRequest $postBody, $optParams = [])
244  {
245    $params = ['name' => $name, 'postBody' => $postBody];
246    $params = array_merge($params, $optParams);
247    return $this->call('rescheduleMaintenance', [$params], Operation::class);
248  }
249  /**
250   * Upgrades Redis instance to the newer Redis version specified in the request.
251   * (instances.upgrade)
252   *
253   * @param string $name Required. Redis instance resource name using the form:
254   * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where
255   * `location_id` refers to a GCP region.
256   * @param UpgradeInstanceRequest $postBody
257   * @param array $optParams Optional parameters.
258   * @return Operation
259   */
260  public function upgrade($name, UpgradeInstanceRequest $postBody, $optParams = [])
261  {
262    $params = ['name' => $name, 'postBody' => $postBody];
263    $params = array_merge($params, $optParams);
264    return $this->call('upgrade', [$params], Operation::class);
265  }
266}
267
268// Adding a class alias for backwards compatibility with the previous class name.
269class_alias(ProjectsLocationsInstances::class, 'Google_Service_CloudRedis_Resource_ProjectsLocationsInstances');
270