source: vendor/google/apiclient-services/src/Spanner/Resource/ProjectsInstancesDatabasesSessions.php

Last change on this file was e3d4e0a, checked in by Vlado 222039 <vlado.popovski@…>, 10 days ago

Upload project files

  • Property mode set to 100644
File size: 18.9 KB
Line 
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\Spanner\Resource;
19
20use Google\Service\Spanner\BatchCreateSessionsRequest;
21use Google\Service\Spanner\BatchCreateSessionsResponse;
22use Google\Service\Spanner\BatchWriteRequest;
23use Google\Service\Spanner\BatchWriteResponse;
24use Google\Service\Spanner\BeginTransactionRequest;
25use Google\Service\Spanner\CommitRequest;
26use Google\Service\Spanner\CommitResponse;
27use Google\Service\Spanner\CreateSessionRequest;
28use Google\Service\Spanner\ExecuteBatchDmlRequest;
29use Google\Service\Spanner\ExecuteBatchDmlResponse;
30use Google\Service\Spanner\ExecuteSqlRequest;
31use Google\Service\Spanner\ListSessionsResponse;
32use Google\Service\Spanner\PartialResultSet;
33use Google\Service\Spanner\PartitionQueryRequest;
34use Google\Service\Spanner\PartitionReadRequest;
35use Google\Service\Spanner\PartitionResponse;
36use Google\Service\Spanner\ReadRequest;
37use Google\Service\Spanner\ResultSet;
38use Google\Service\Spanner\RollbackRequest;
39use Google\Service\Spanner\Session;
40use Google\Service\Spanner\SpannerEmpty;
41use Google\Service\Spanner\Transaction;
42
43/**
44 * The "sessions" collection of methods.
45 * Typical usage is:
46 * <code>
47 * $spannerService = new Google\Service\Spanner(...);
48 * $sessions = $spannerService->projects_instances_databases_sessions;
49 * </code>
50 */
51class ProjectsInstancesDatabasesSessions extends \Google\Service\Resource
52{
53 /**
54 * Creates multiple new sessions. This API can be used to initialize a session
55 * cache on the clients. See https://goo.gl/TgSFN2 for best practices on session
56 * cache management. (sessions.batchCreate)
57 *
58 * @param string $database Required. The database in which the new sessions are
59 * created.
60 * @param BatchCreateSessionsRequest $postBody
61 * @param array $optParams Optional parameters.
62 * @return BatchCreateSessionsResponse
63 * @throws \Google\Service\Exception
64 */
65 public function batchCreate($database, BatchCreateSessionsRequest $postBody, $optParams = [])
66 {
67 $params = ['database' => $database, 'postBody' => $postBody];
68 $params = array_merge($params, $optParams);
69 return $this->call('batchCreate', [$params], BatchCreateSessionsResponse::class);
70 }
71 /**
72 * Batches the supplied mutation groups in a collection of efficient
73 * transactions. All mutations in a group are committed atomically. However,
74 * mutations across groups can be committed non-atomically in an unspecified
75 * order and thus, they must be independent of each other. Partial failure is
76 * possible, i.e., some groups may have been committed successfully, while some
77 * may have failed. The results of individual batches are streamed into the
78 * response as the batches are applied. BatchWrite requests are not replay
79 * protected, meaning that each mutation group may be applied more than once.
80 * Replays of non-idempotent mutations may have undesirable effects. For
81 * example, replays of an insert mutation may produce an already exists error or
82 * if you use generated or commit timestamp-based keys, it may result in
83 * additional rows being added to the mutation's table. We recommend structuring
84 * your mutation groups to be idempotent to avoid this issue.
85 * (sessions.batchWrite)
86 *
87 * @param string $session Required. The session in which the batch request is to
88 * be run.
89 * @param BatchWriteRequest $postBody
90 * @param array $optParams Optional parameters.
91 * @return BatchWriteResponse
92 * @throws \Google\Service\Exception
93 */
94 public function batchWrite($session, BatchWriteRequest $postBody, $optParams = [])
95 {
96 $params = ['session' => $session, 'postBody' => $postBody];
97 $params = array_merge($params, $optParams);
98 return $this->call('batchWrite', [$params], BatchWriteResponse::class);
99 }
100 /**
101 * Begins a new transaction. This step can often be skipped: Read, ExecuteSql
102 * and Commit can begin a new transaction as a side-effect.
103 * (sessions.beginTransaction)
104 *
105 * @param string $session Required. The session in which the transaction runs.
106 * @param BeginTransactionRequest $postBody
107 * @param array $optParams Optional parameters.
108 * @return Transaction
109 * @throws \Google\Service\Exception
110 */
111 public function beginTransaction($session, BeginTransactionRequest $postBody, $optParams = [])
112 {
113 $params = ['session' => $session, 'postBody' => $postBody];
114 $params = array_merge($params, $optParams);
115 return $this->call('beginTransaction', [$params], Transaction::class);
116 }
117 /**
118 * Commits a transaction. The request includes the mutations to be applied to
119 * rows in the database. `Commit` might return an `ABORTED` error. This can
120 * occur at any time; commonly, the cause is conflicts with concurrent
121 * transactions. However, it can also happen for a variety of other reasons. If
122 * `Commit` returns `ABORTED`, the caller should re-attempt the transaction from
123 * the beginning, re-using the same session. On very rare occasions, `Commit`
124 * might return `UNKNOWN`. This can happen, for example, if the client job
125 * experiences a 1+ hour networking failure. At that point, Cloud Spanner has
126 * lost track of the transaction outcome and we recommend that you perform
127 * another read from the database to see the state of things as they are now.
128 * (sessions.commit)
129 *
130 * @param string $session Required. The session in which the transaction to be
131 * committed is running.
132 * @param CommitRequest $postBody
133 * @param array $optParams Optional parameters.
134 * @return CommitResponse
135 * @throws \Google\Service\Exception
136 */
137 public function commit($session, CommitRequest $postBody, $optParams = [])
138 {
139 $params = ['session' => $session, 'postBody' => $postBody];
140 $params = array_merge($params, $optParams);
141 return $this->call('commit', [$params], CommitResponse::class);
142 }
143 /**
144 * Creates a new session. A session can be used to perform transactions that
145 * read and/or modify data in a Cloud Spanner database. Sessions are meant to be
146 * reused for many consecutive transactions. Sessions can only execute one
147 * transaction at a time. To execute multiple concurrent read-write/write-only
148 * transactions, create multiple sessions. Note that standalone reads and
149 * queries use a transaction internally, and count toward the one transaction
150 * limit. Active sessions use additional server resources, so it is a good idea
151 * to delete idle and unneeded sessions. Aside from explicit deletes, Cloud
152 * Spanner may delete sessions for which no operations are sent for more than an
153 * hour. If a session is deleted, requests to it return `NOT_FOUND`. Idle
154 * sessions can be kept alive by sending a trivial SQL query periodically, e.g.,
155 * `"SELECT 1"`. (sessions.create)
156 *
157 * @param string $database Required. The database in which the new session is
158 * created.
159 * @param CreateSessionRequest $postBody
160 * @param array $optParams Optional parameters.
161 * @return Session
162 * @throws \Google\Service\Exception
163 */
164 public function create($database, CreateSessionRequest $postBody, $optParams = [])
165 {
166 $params = ['database' => $database, 'postBody' => $postBody];
167 $params = array_merge($params, $optParams);
168 return $this->call('create', [$params], Session::class);
169 }
170 /**
171 * Ends a session, releasing server resources associated with it. This will
172 * asynchronously trigger cancellation of any operations that are running with
173 * this session. (sessions.delete)
174 *
175 * @param string $name Required. The name of the session to delete.
176 * @param array $optParams Optional parameters.
177 * @return SpannerEmpty
178 * @throws \Google\Service\Exception
179 */
180 public function delete($name, $optParams = [])
181 {
182 $params = ['name' => $name];
183 $params = array_merge($params, $optParams);
184 return $this->call('delete', [$params], SpannerEmpty::class);
185 }
186 /**
187 * Executes a batch of SQL DML statements. This method allows many statements to
188 * be run with lower latency than submitting them sequentially with ExecuteSql.
189 * Statements are executed in sequential order. A request can succeed even if a
190 * statement fails. The ExecuteBatchDmlResponse.status field in the response
191 * provides information about the statement that failed. Clients must inspect
192 * this field to determine whether an error occurred. Execution stops after the
193 * first failed statement; the remaining statements are not executed.
194 * (sessions.executeBatchDml)
195 *
196 * @param string $session Required. The session in which the DML statements
197 * should be performed.
198 * @param ExecuteBatchDmlRequest $postBody
199 * @param array $optParams Optional parameters.
200 * @return ExecuteBatchDmlResponse
201 * @throws \Google\Service\Exception
202 */
203 public function executeBatchDml($session, ExecuteBatchDmlRequest $postBody, $optParams = [])
204 {
205 $params = ['session' => $session, 'postBody' => $postBody];
206 $params = array_merge($params, $optParams);
207 return $this->call('executeBatchDml', [$params], ExecuteBatchDmlResponse::class);
208 }
209 /**
210 * Executes an SQL statement, returning all results in a single reply. This
211 * method cannot be used to return a result set larger than 10 MiB; if the query
212 * yields more data than that, the query fails with a `FAILED_PRECONDITION`
213 * error. Operations inside read-write transactions might return `ABORTED`. If
214 * this occurs, the application should restart the transaction from the
215 * beginning. See Transaction for more details. Larger result sets can be
216 * fetched in streaming fashion by calling ExecuteStreamingSql instead.
217 * (sessions.executeSql)
218 *
219 * @param string $session Required. The session in which the SQL query should be
220 * performed.
221 * @param ExecuteSqlRequest $postBody
222 * @param array $optParams Optional parameters.
223 * @return ResultSet
224 * @throws \Google\Service\Exception
225 */
226 public function executeSql($session, ExecuteSqlRequest $postBody, $optParams = [])
227 {
228 $params = ['session' => $session, 'postBody' => $postBody];
229 $params = array_merge($params, $optParams);
230 return $this->call('executeSql', [$params], ResultSet::class);
231 }
232 /**
233 * Like ExecuteSql, except returns the result set as a stream. Unlike
234 * ExecuteSql, there is no limit on the size of the returned result set.
235 * However, no individual row in the result set can exceed 100 MiB, and no
236 * column value can exceed 10 MiB. (sessions.executeStreamingSql)
237 *
238 * @param string $session Required. The session in which the SQL query should be
239 * performed.
240 * @param ExecuteSqlRequest $postBody
241 * @param array $optParams Optional parameters.
242 * @return PartialResultSet
243 * @throws \Google\Service\Exception
244 */
245 public function executeStreamingSql($session, ExecuteSqlRequest $postBody, $optParams = [])
246 {
247 $params = ['session' => $session, 'postBody' => $postBody];
248 $params = array_merge($params, $optParams);
249 return $this->call('executeStreamingSql', [$params], PartialResultSet::class);
250 }
251 /**
252 * Gets a session. Returns `NOT_FOUND` if the session does not exist. This is
253 * mainly useful for determining whether a session is still alive.
254 * (sessions.get)
255 *
256 * @param string $name Required. The name of the session to retrieve.
257 * @param array $optParams Optional parameters.
258 * @return Session
259 * @throws \Google\Service\Exception
260 */
261 public function get($name, $optParams = [])
262 {
263 $params = ['name' => $name];
264 $params = array_merge($params, $optParams);
265 return $this->call('get', [$params], Session::class);
266 }
267 /**
268 * Lists all sessions in a given database.
269 * (sessions.listProjectsInstancesDatabasesSessions)
270 *
271 * @param string $database Required. The database in which to list sessions.
272 * @param array $optParams Optional parameters.
273 *
274 * @opt_param string filter An expression for filtering the results of the
275 * request. Filter rules are case insensitive. The fields eligible for filtering
276 * are: * `labels.key` where key is the name of a label Some examples of using
277 * filters are: * `labels.env:*` --> The session has the label "env". *
278 * `labels.env:dev` --> The session has the label "env" and the value of the
279 * label contains the string "dev".
280 * @opt_param int pageSize Number of sessions to be returned in the response. If
281 * 0 or less, defaults to the server's maximum allowed page size.
282 * @opt_param string pageToken If non-empty, `page_token` should contain a
283 * next_page_token from a previous ListSessionsResponse.
284 * @return ListSessionsResponse
285 * @throws \Google\Service\Exception
286 */
287 public function listProjectsInstancesDatabasesSessions($database, $optParams = [])
288 {
289 $params = ['database' => $database];
290 $params = array_merge($params, $optParams);
291 return $this->call('list', [$params], ListSessionsResponse::class);
292 }
293 /**
294 * Creates a set of partition tokens that can be used to execute a query
295 * operation in parallel. Each of the returned partition tokens can be used by
296 * ExecuteStreamingSql to specify a subset of the query result to read. The same
297 * session and read-only transaction must be used by the PartitionQueryRequest
298 * used to create the partition tokens and the ExecuteSqlRequests that use the
299 * partition tokens. Partition tokens become invalid when the session used to
300 * create them is deleted, is idle for too long, begins a new transaction, or
301 * becomes too old. When any of these happen, it is not possible to resume the
302 * query, and the whole operation must be restarted from the beginning.
303 * (sessions.partitionQuery)
304 *
305 * @param string $session Required. The session used to create the partitions.
306 * @param PartitionQueryRequest $postBody
307 * @param array $optParams Optional parameters.
308 * @return PartitionResponse
309 * @throws \Google\Service\Exception
310 */
311 public function partitionQuery($session, PartitionQueryRequest $postBody, $optParams = [])
312 {
313 $params = ['session' => $session, 'postBody' => $postBody];
314 $params = array_merge($params, $optParams);
315 return $this->call('partitionQuery', [$params], PartitionResponse::class);
316 }
317 /**
318 * Creates a set of partition tokens that can be used to execute a read
319 * operation in parallel. Each of the returned partition tokens can be used by
320 * StreamingRead to specify a subset of the read result to read. The same
321 * session and read-only transaction must be used by the PartitionReadRequest
322 * used to create the partition tokens and the ReadRequests that use the
323 * partition tokens. There are no ordering guarantees on rows returned among the
324 * returned partition tokens, or even within each individual StreamingRead call
325 * issued with a partition_token. Partition tokens become invalid when the
326 * session used to create them is deleted, is idle for too long, begins a new
327 * transaction, or becomes too old. When any of these happen, it is not possible
328 * to resume the read, and the whole operation must be restarted from the
329 * beginning. (sessions.partitionRead)
330 *
331 * @param string $session Required. The session used to create the partitions.
332 * @param PartitionReadRequest $postBody
333 * @param array $optParams Optional parameters.
334 * @return PartitionResponse
335 * @throws \Google\Service\Exception
336 */
337 public function partitionRead($session, PartitionReadRequest $postBody, $optParams = [])
338 {
339 $params = ['session' => $session, 'postBody' => $postBody];
340 $params = array_merge($params, $optParams);
341 return $this->call('partitionRead', [$params], PartitionResponse::class);
342 }
343 /**
344 * Reads rows from the database using key lookups and scans, as a simple
345 * key/value style alternative to ExecuteSql. This method cannot be used to
346 * return a result set larger than 10 MiB; if the read matches more data than
347 * that, the read fails with a `FAILED_PRECONDITION` error. Reads inside read-
348 * write transactions might return `ABORTED`. If this occurs, the application
349 * should restart the transaction from the beginning. See Transaction for more
350 * details. Larger result sets can be yielded in streaming fashion by calling
351 * StreamingRead instead. (sessions.read)
352 *
353 * @param string $session Required. The session in which the read should be
354 * performed.
355 * @param ReadRequest $postBody
356 * @param array $optParams Optional parameters.
357 * @return ResultSet
358 * @throws \Google\Service\Exception
359 */
360 public function read($session, ReadRequest $postBody, $optParams = [])
361 {
362 $params = ['session' => $session, 'postBody' => $postBody];
363 $params = array_merge($params, $optParams);
364 return $this->call('read', [$params], ResultSet::class);
365 }
366 /**
367 * Rolls back a transaction, releasing any locks it holds. It is a good idea to
368 * call this for any transaction that includes one or more Read or ExecuteSql
369 * requests and ultimately decides not to commit. `Rollback` returns `OK` if it
370 * successfully aborts the transaction, the transaction was already aborted, or
371 * the transaction is not found. `Rollback` never returns `ABORTED`.
372 * (sessions.rollback)
373 *
374 * @param string $session Required. The session in which the transaction to roll
375 * back is running.
376 * @param RollbackRequest $postBody
377 * @param array $optParams Optional parameters.
378 * @return SpannerEmpty
379 * @throws \Google\Service\Exception
380 */
381 public function rollback($session, RollbackRequest $postBody, $optParams = [])
382 {
383 $params = ['session' => $session, 'postBody' => $postBody];
384 $params = array_merge($params, $optParams);
385 return $this->call('rollback', [$params], SpannerEmpty::class);
386 }
387 /**
388 * Like Read, except returns the result set as a stream. Unlike Read, there is
389 * no limit on the size of the returned result set. However, no individual row
390 * in the result set can exceed 100 MiB, and no column value can exceed 10 MiB.
391 * (sessions.streamingRead)
392 *
393 * @param string $session Required. The session in which the read should be
394 * performed.
395 * @param ReadRequest $postBody
396 * @param array $optParams Optional parameters.
397 * @return PartialResultSet
398 * @throws \Google\Service\Exception
399 */
400 public function streamingRead($session, ReadRequest $postBody, $optParams = [])
401 {
402 $params = ['session' => $session, 'postBody' => $postBody];
403 $params = array_merge($params, $optParams);
404 return $this->call('streamingRead', [$params], PartialResultSet::class);
405 }
406}
407
408// Adding a class alias for backwards compatibility with the previous class name.
409class_alias(ProjectsInstancesDatabasesSessions::class, 'Google_Service_Spanner_Resource_ProjectsInstancesDatabasesSessions');
Note: See TracBrowser for help on using the repository browser.