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\AllocateIdsRequest;
21use Google\Service\Datastore\AllocateIdsResponse;
22use Google\Service\Datastore\BeginTransactionRequest;
23use Google\Service\Datastore\BeginTransactionResponse;
24use Google\Service\Datastore\CommitRequest;
25use Google\Service\Datastore\CommitResponse;
26use Google\Service\Datastore\GoogleDatastoreAdminV1ExportEntitiesRequest;
27use Google\Service\Datastore\GoogleDatastoreAdminV1ImportEntitiesRequest;
28use Google\Service\Datastore\GoogleLongrunningOperation;
29use Google\Service\Datastore\LookupRequest;
30use Google\Service\Datastore\LookupResponse;
31use Google\Service\Datastore\ReserveIdsRequest;
32use Google\Service\Datastore\ReserveIdsResponse;
33use Google\Service\Datastore\RollbackRequest;
34use Google\Service\Datastore\RollbackResponse;
35use Google\Service\Datastore\RunQueryRequest;
36use Google\Service\Datastore\RunQueryResponse;
37
38/**
39 * The "projects" collection of methods.
40 * Typical usage is:
41 *  <code>
42 *   $datastoreService = new Google\Service\Datastore(...);
43 *   $projects = $datastoreService->projects;
44 *  </code>
45 */
46class Projects extends \Google\Service\Resource
47{
48  /**
49   * Allocates IDs for the given keys, which is useful for referencing an entity
50   * before it is inserted. (projects.allocateIds)
51   *
52   * @param string $projectId Required. The ID of the project against which to
53   * make the request.
54   * @param AllocateIdsRequest $postBody
55   * @param array $optParams Optional parameters.
56   * @return AllocateIdsResponse
57   */
58  public function allocateIds($projectId, AllocateIdsRequest $postBody, $optParams = [])
59  {
60    $params = ['projectId' => $projectId, 'postBody' => $postBody];
61    $params = array_merge($params, $optParams);
62    return $this->call('allocateIds', [$params], AllocateIdsResponse::class);
63  }
64  /**
65   * Begins a new transaction. (projects.beginTransaction)
66   *
67   * @param string $projectId Required. The ID of the project against which to
68   * make the request.
69   * @param BeginTransactionRequest $postBody
70   * @param array $optParams Optional parameters.
71   * @return BeginTransactionResponse
72   */
73  public function beginTransaction($projectId, BeginTransactionRequest $postBody, $optParams = [])
74  {
75    $params = ['projectId' => $projectId, 'postBody' => $postBody];
76    $params = array_merge($params, $optParams);
77    return $this->call('beginTransaction', [$params], BeginTransactionResponse::class);
78  }
79  /**
80   * Commits a transaction, optionally creating, deleting or modifying some
81   * entities. (projects.commit)
82   *
83   * @param string $projectId Required. The ID of the project against which to
84   * make the request.
85   * @param CommitRequest $postBody
86   * @param array $optParams Optional parameters.
87   * @return CommitResponse
88   */
89  public function commit($projectId, CommitRequest $postBody, $optParams = [])
90  {
91    $params = ['projectId' => $projectId, 'postBody' => $postBody];
92    $params = array_merge($params, $optParams);
93    return $this->call('commit', [$params], CommitResponse::class);
94  }
95  /**
96   * Exports a copy of all or a subset of entities from Google Cloud Datastore to
97   * another storage system, such as Google Cloud Storage. Recent updates to
98   * entities may not be reflected in the export. The export occurs in the
99   * background and its progress can be monitored and managed via the Operation
100   * resource that is created. The output of an export may only be used once the
101   * associated operation is done. If an export operation is cancelled before
102   * completion it may leave partial data behind in Google Cloud Storage.
103   * (projects.export)
104   *
105   * @param string $projectId Required. Project ID against which to make the
106   * request.
107   * @param GoogleDatastoreAdminV1ExportEntitiesRequest $postBody
108   * @param array $optParams Optional parameters.
109   * @return GoogleLongrunningOperation
110   */
111  public function export($projectId, GoogleDatastoreAdminV1ExportEntitiesRequest $postBody, $optParams = [])
112  {
113    $params = ['projectId' => $projectId, 'postBody' => $postBody];
114    $params = array_merge($params, $optParams);
115    return $this->call('export', [$params], GoogleLongrunningOperation::class);
116  }
117  /**
118   * Imports entities into Google Cloud Datastore. Existing entities with the same
119   * key are overwritten. The import occurs in the background and its progress can
120   * be monitored and managed via the Operation resource that is created. If an
121   * ImportEntities operation is cancelled, it is possible that a subset of the
122   * data has already been imported to Cloud Datastore. (projects.import)
123   *
124   * @param string $projectId Required. Project ID against which to make the
125   * request.
126   * @param GoogleDatastoreAdminV1ImportEntitiesRequest $postBody
127   * @param array $optParams Optional parameters.
128   * @return GoogleLongrunningOperation
129   */
130  public function import($projectId, GoogleDatastoreAdminV1ImportEntitiesRequest $postBody, $optParams = [])
131  {
132    $params = ['projectId' => $projectId, 'postBody' => $postBody];
133    $params = array_merge($params, $optParams);
134    return $this->call('import', [$params], GoogleLongrunningOperation::class);
135  }
136  /**
137   * Looks up entities by key. (projects.lookup)
138   *
139   * @param string $projectId Required. The ID of the project against which to
140   * make the request.
141   * @param LookupRequest $postBody
142   * @param array $optParams Optional parameters.
143   * @return LookupResponse
144   */
145  public function lookup($projectId, LookupRequest $postBody, $optParams = [])
146  {
147    $params = ['projectId' => $projectId, 'postBody' => $postBody];
148    $params = array_merge($params, $optParams);
149    return $this->call('lookup', [$params], LookupResponse::class);
150  }
151  /**
152   * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
153   * (projects.reserveIds)
154   *
155   * @param string $projectId Required. The ID of the project against which to
156   * make the request.
157   * @param ReserveIdsRequest $postBody
158   * @param array $optParams Optional parameters.
159   * @return ReserveIdsResponse
160   */
161  public function reserveIds($projectId, ReserveIdsRequest $postBody, $optParams = [])
162  {
163    $params = ['projectId' => $projectId, 'postBody' => $postBody];
164    $params = array_merge($params, $optParams);
165    return $this->call('reserveIds', [$params], ReserveIdsResponse::class);
166  }
167  /**
168   * Rolls back a transaction. (projects.rollback)
169   *
170   * @param string $projectId Required. The ID of the project against which to
171   * make the request.
172   * @param RollbackRequest $postBody
173   * @param array $optParams Optional parameters.
174   * @return RollbackResponse
175   */
176  public function rollback($projectId, RollbackRequest $postBody, $optParams = [])
177  {
178    $params = ['projectId' => $projectId, 'postBody' => $postBody];
179    $params = array_merge($params, $optParams);
180    return $this->call('rollback', [$params], RollbackResponse::class);
181  }
182  /**
183   * Queries for entities. (projects.runQuery)
184   *
185   * @param string $projectId Required. The ID of the project against which to
186   * make the request.
187   * @param RunQueryRequest $postBody
188   * @param array $optParams Optional parameters.
189   * @return RunQueryResponse
190   */
191  public function runQuery($projectId, RunQueryRequest $postBody, $optParams = [])
192  {
193    $params = ['projectId' => $projectId, 'postBody' => $postBody];
194    $params = array_merge($params, $optParams);
195    return $this->call('runQuery', [$params], RunQueryResponse::class);
196  }
197}
198
199// Adding a class alias for backwards compatibility with the previous class name.
200class_alias(Projects::class, 'Google_Service_Datastore_Resource_Projects');
201