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\Datastore\Resource;
19
20use Google\Service\Datastore\GoogleDatastoreAdminV1Index;
21use Google\Service\Datastore\GoogleDatastoreAdminV1ListIndexesResponse;
22use Google\Service\Datastore\GoogleLongrunningOperation;
23
24/**
25 * The "indexes" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $datastoreService = new Google\Service\Datastore(...);
29 *   $indexes = $datastoreService->indexes;
30 *  </code>
31 */
32class ProjectsIndexes extends \Google\Service\Resource
33{
34  /**
35   * Creates the specified index. A newly created index's initial state is
36   * `CREATING`. On completion of the returned google.longrunning.Operation, the
37   * state will be `READY`. If the index already exists, the call will return an
38   * `ALREADY_EXISTS` status. During index creation, the process could result in
39   * an error, in which case the index will move to the `ERROR` state. The process
40   * can be recovered by fixing the data that caused the error, removing the index
41   * with delete, then re-creating the index with create. Indexes with a single
42   * property cannot be created. (indexes.create)
43   *
44   * @param string $projectId Project ID against which to make the request.
45   * @param GoogleDatastoreAdminV1Index $postBody
46   * @param array $optParams Optional parameters.
47   * @return GoogleLongrunningOperation
48   */
49  public function create($projectId, GoogleDatastoreAdminV1Index $postBody, $optParams = [])
50  {
51    $params = ['projectId' => $projectId, 'postBody' => $postBody];
52    $params = array_merge($params, $optParams);
53    return $this->call('create', [$params], GoogleLongrunningOperation::class);
54  }
55  /**
56   * Deletes an existing index. An index can only be deleted if it is in a `READY`
57   * or `ERROR` state. On successful execution of the request, the index will be
58   * in a `DELETING` state. And on completion of the returned
59   * google.longrunning.Operation, the index will be removed. During index
60   * deletion, the process could result in an error, in which case the index will
61   * move to the `ERROR` state. The process can be recovered by fixing the data
62   * that caused the error, followed by calling delete again. (indexes.delete)
63   *
64   * @param string $projectId Project ID against which to make the request.
65   * @param string $indexId The resource ID of the index to delete.
66   * @param array $optParams Optional parameters.
67   * @return GoogleLongrunningOperation
68   */
69  public function delete($projectId, $indexId, $optParams = [])
70  {
71    $params = ['projectId' => $projectId, 'indexId' => $indexId];
72    $params = array_merge($params, $optParams);
73    return $this->call('delete', [$params], GoogleLongrunningOperation::class);
74  }
75  /**
76   * Gets an index. (indexes.get)
77   *
78   * @param string $projectId Project ID against which to make the request.
79   * @param string $indexId The resource ID of the index to get.
80   * @param array $optParams Optional parameters.
81   * @return GoogleDatastoreAdminV1Index
82   */
83  public function get($projectId, $indexId, $optParams = [])
84  {
85    $params = ['projectId' => $projectId, 'indexId' => $indexId];
86    $params = array_merge($params, $optParams);
87    return $this->call('get', [$params], GoogleDatastoreAdminV1Index::class);
88  }
89  /**
90   * Lists the indexes that match the specified filters. Datastore uses an
91   * eventually consistent query to fetch the list of indexes and may occasionally
92   * return stale results. (indexes.listProjectsIndexes)
93   *
94   * @param string $projectId Project ID against which to make the request.
95   * @param array $optParams Optional parameters.
96   *
97   * @opt_param string filter
98   * @opt_param int pageSize The maximum number of items to return. If zero, then
99   * all results will be returned.
100   * @opt_param string pageToken The next_page_token value returned from a
101   * previous List request, if any.
102   * @return GoogleDatastoreAdminV1ListIndexesResponse
103   */
104  public function listProjectsIndexes($projectId, $optParams = [])
105  {
106    $params = ['projectId' => $projectId];
107    $params = array_merge($params, $optParams);
108    return $this->call('list', [$params], GoogleDatastoreAdminV1ListIndexesResponse::class);
109  }
110}
111
112// Adding a class alias for backwards compatibility with the previous class name.
113class_alias(ProjectsIndexes::class, 'Google_Service_Datastore_Resource_ProjectsIndexes');
114