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\Bigquery\Resource;
19
20use Google\Service\Bigquery\GetIamPolicyRequest;
21use Google\Service\Bigquery\Policy;
22use Google\Service\Bigquery\SetIamPolicyRequest;
23use Google\Service\Bigquery\Table;
24use Google\Service\Bigquery\TableList;
25use Google\Service\Bigquery\TestIamPermissionsRequest;
26use Google\Service\Bigquery\TestIamPermissionsResponse;
27
28/**
29 * The "tables" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $bigqueryService = new Google\Service\Bigquery(...);
33 *   $tables = $bigqueryService->tables;
34 *  </code>
35 */
36class Tables extends \Google\Service\Resource
37{
38  /**
39   * Deletes the table specified by tableId from the dataset. If the table
40   * contains data, all the data will be deleted. (tables.delete)
41   *
42   * @param string $projectId Project ID of the table to delete
43   * @param string $datasetId Dataset ID of the table to delete
44   * @param string $tableId Table ID of the table to delete
45   * @param array $optParams Optional parameters.
46   */
47  public function delete($projectId, $datasetId, $tableId, $optParams = [])
48  {
49    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'tableId' => $tableId];
50    $params = array_merge($params, $optParams);
51    return $this->call('delete', [$params]);
52  }
53  /**
54   * Gets the specified table resource by table ID. This method does not return
55   * the data in the table, it only returns the table resource, which describes
56   * the structure of this table. (tables.get)
57   *
58   * @param string $projectId Project ID of the requested table
59   * @param string $datasetId Dataset ID of the requested table
60   * @param string $tableId Table ID of the requested table
61   * @param array $optParams Optional parameters.
62   *
63   * @opt_param string selectedFields List of fields to return (comma-separated).
64   * If unspecified, all fields are returned
65   * @return Table
66   */
67  public function get($projectId, $datasetId, $tableId, $optParams = [])
68  {
69    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'tableId' => $tableId];
70    $params = array_merge($params, $optParams);
71    return $this->call('get', [$params], Table::class);
72  }
73  /**
74   * Gets the access control policy for a resource. Returns an empty policy if the
75   * resource exists and does not have a policy set. (tables.getIamPolicy)
76   *
77   * @param string $resource REQUIRED: The resource for which the policy is being
78   * requested. See the operation documentation for the appropriate value for this
79   * field.
80   * @param GetIamPolicyRequest $postBody
81   * @param array $optParams Optional parameters.
82   * @return Policy
83   */
84  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
85  {
86    $params = ['resource' => $resource, 'postBody' => $postBody];
87    $params = array_merge($params, $optParams);
88    return $this->call('getIamPolicy', [$params], Policy::class);
89  }
90  /**
91   * Creates a new, empty table in the dataset. (tables.insert)
92   *
93   * @param string $projectId Project ID of the new table
94   * @param string $datasetId Dataset ID of the new table
95   * @param Table $postBody
96   * @param array $optParams Optional parameters.
97   * @return Table
98   */
99  public function insert($projectId, $datasetId, Table $postBody, $optParams = [])
100  {
101    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'postBody' => $postBody];
102    $params = array_merge($params, $optParams);
103    return $this->call('insert', [$params], Table::class);
104  }
105  /**
106   * Lists all tables in the specified dataset. Requires the READER dataset role.
107   * (tables.listTables)
108   *
109   * @param string $projectId Project ID of the tables to list
110   * @param string $datasetId Dataset ID of the tables to list
111   * @param array $optParams Optional parameters.
112   *
113   * @opt_param string maxResults Maximum number of results to return
114   * @opt_param string pageToken Page token, returned by a previous call, to
115   * request the next page of results
116   * @return TableList
117   */
118  public function listTables($projectId, $datasetId, $optParams = [])
119  {
120    $params = ['projectId' => $projectId, 'datasetId' => $datasetId];
121    $params = array_merge($params, $optParams);
122    return $this->call('list', [$params], TableList::class);
123  }
124  /**
125   * Updates information in an existing table. The update method replaces the
126   * entire table resource, whereas the patch method only replaces fields that are
127   * provided in the submitted table resource. This method supports patch
128   * semantics. (tables.patch)
129   *
130   * @param string $projectId Project ID of the table to update
131   * @param string $datasetId Dataset ID of the table to update
132   * @param string $tableId Table ID of the table to update
133   * @param Table $postBody
134   * @param array $optParams Optional parameters.
135   *
136   * @opt_param bool autodetect_schema When true will autodetect schema, else will
137   * keep original schema
138   * @return Table
139   */
140  public function patch($projectId, $datasetId, $tableId, Table $postBody, $optParams = [])
141  {
142    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'tableId' => $tableId, 'postBody' => $postBody];
143    $params = array_merge($params, $optParams);
144    return $this->call('patch', [$params], Table::class);
145  }
146  /**
147   * Sets the access control policy on the specified resource. Replaces any
148   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
149   * `PERMISSION_DENIED` errors. (tables.setIamPolicy)
150   *
151   * @param string $resource REQUIRED: The resource for which the policy is being
152   * specified. See the operation documentation for the appropriate value for this
153   * field.
154   * @param SetIamPolicyRequest $postBody
155   * @param array $optParams Optional parameters.
156   * @return Policy
157   */
158  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
159  {
160    $params = ['resource' => $resource, 'postBody' => $postBody];
161    $params = array_merge($params, $optParams);
162    return $this->call('setIamPolicy', [$params], Policy::class);
163  }
164  /**
165   * Returns permissions that a caller has on the specified resource. If the
166   * resource does not exist, this will return an empty set of permissions, not a
167   * `NOT_FOUND` error. Note: This operation is designed to be used for building
168   * permission-aware UIs and command-line tools, not for authorization checking.
169   * This operation may "fail open" without warning. (tables.testIamPermissions)
170   *
171   * @param string $resource REQUIRED: The resource for which the policy detail is
172   * being requested. See the operation documentation for the appropriate value
173   * for this field.
174   * @param TestIamPermissionsRequest $postBody
175   * @param array $optParams Optional parameters.
176   * @return TestIamPermissionsResponse
177   */
178  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
179  {
180    $params = ['resource' => $resource, 'postBody' => $postBody];
181    $params = array_merge($params, $optParams);
182    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
183  }
184  /**
185   * Updates information in an existing table. The update method replaces the
186   * entire table resource, whereas the patch method only replaces fields that are
187   * provided in the submitted table resource. (tables.update)
188   *
189   * @param string $projectId Project ID of the table to update
190   * @param string $datasetId Dataset ID of the table to update
191   * @param string $tableId Table ID of the table to update
192   * @param Table $postBody
193   * @param array $optParams Optional parameters.
194   *
195   * @opt_param bool autodetect_schema When true will autodetect schema, else will
196   * keep original schema
197   * @return Table
198   */
199  public function update($projectId, $datasetId, $tableId, Table $postBody, $optParams = [])
200  {
201    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'tableId' => $tableId, 'postBody' => $postBody];
202    $params = array_merge($params, $optParams);
203    return $this->call('update', [$params], Table::class);
204  }
205}
206
207// Adding a class alias for backwards compatibility with the previous class name.
208class_alias(Tables::class, 'Google_Service_Bigquery_Resource_Tables');
209