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\Dataset;
21use Google\Service\Bigquery\DatasetList;
22
23/**
24 * The "datasets" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $bigqueryService = new Google\Service\Bigquery(...);
28 *   $datasets = $bigqueryService->datasets;
29 *  </code>
30 */
31class Datasets extends \Google\Service\Resource
32{
33  /**
34   * Deletes the dataset specified by the datasetId value. Before you can delete a
35   * dataset, you must delete all its tables, either manually or by specifying
36   * deleteContents. Immediately after deletion, you can create another dataset
37   * with the same name. (datasets.delete)
38   *
39   * @param string $projectId Project ID of the dataset being deleted
40   * @param string $datasetId Dataset ID of dataset being deleted
41   * @param array $optParams Optional parameters.
42   *
43   * @opt_param bool deleteContents If True, delete all the tables in the dataset.
44   * If False and the dataset contains tables, the request will fail. Default is
45   * False
46   */
47  public function delete($projectId, $datasetId, $optParams = [])
48  {
49    $params = ['projectId' => $projectId, 'datasetId' => $datasetId];
50    $params = array_merge($params, $optParams);
51    return $this->call('delete', [$params]);
52  }
53  /**
54   * Returns the dataset specified by datasetID. (datasets.get)
55   *
56   * @param string $projectId Project ID of the requested dataset
57   * @param string $datasetId Dataset ID of the requested dataset
58   * @param array $optParams Optional parameters.
59   * @return Dataset
60   */
61  public function get($projectId, $datasetId, $optParams = [])
62  {
63    $params = ['projectId' => $projectId, 'datasetId' => $datasetId];
64    $params = array_merge($params, $optParams);
65    return $this->call('get', [$params], Dataset::class);
66  }
67  /**
68   * Creates a new empty dataset. (datasets.insert)
69   *
70   * @param string $projectId Project ID of the new dataset
71   * @param Dataset $postBody
72   * @param array $optParams Optional parameters.
73   * @return Dataset
74   */
75  public function insert($projectId, Dataset $postBody, $optParams = [])
76  {
77    $params = ['projectId' => $projectId, 'postBody' => $postBody];
78    $params = array_merge($params, $optParams);
79    return $this->call('insert', [$params], Dataset::class);
80  }
81  /**
82   * Lists all datasets in the specified project to which you have been granted
83   * the READER dataset role. (datasets.listDatasets)
84   *
85   * @param string $projectId Project ID of the datasets to be listed
86   * @param array $optParams Optional parameters.
87   *
88   * @opt_param bool all Whether to list all datasets, including hidden ones
89   * @opt_param string filter An expression for filtering the results of the
90   * request by label. The syntax is "labels.[:]". Multiple filters can be ANDed
91   * together by connecting with a space. Example: "labels.department:receiving
92   * labels.active". See Filtering datasets using labels for details.
93   * @opt_param string maxResults The maximum number of results to return
94   * @opt_param string pageToken Page token, returned by a previous call, to
95   * request the next page of results
96   * @return DatasetList
97   */
98  public function listDatasets($projectId, $optParams = [])
99  {
100    $params = ['projectId' => $projectId];
101    $params = array_merge($params, $optParams);
102    return $this->call('list', [$params], DatasetList::class);
103  }
104  /**
105   * Updates information in an existing dataset. The update method replaces the
106   * entire dataset resource, whereas the patch method only replaces fields that
107   * are provided in the submitted dataset resource. This method supports patch
108   * semantics. (datasets.patch)
109   *
110   * @param string $projectId Project ID of the dataset being updated
111   * @param string $datasetId Dataset ID of the dataset being updated
112   * @param Dataset $postBody
113   * @param array $optParams Optional parameters.
114   * @return Dataset
115   */
116  public function patch($projectId, $datasetId, Dataset $postBody, $optParams = [])
117  {
118    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'postBody' => $postBody];
119    $params = array_merge($params, $optParams);
120    return $this->call('patch', [$params], Dataset::class);
121  }
122  /**
123   * Updates information in an existing dataset. The update method replaces the
124   * entire dataset resource, whereas the patch method only replaces fields that
125   * are provided in the submitted dataset resource. (datasets.update)
126   *
127   * @param string $projectId Project ID of the dataset being updated
128   * @param string $datasetId Dataset ID of the dataset being updated
129   * @param Dataset $postBody
130   * @param array $optParams Optional parameters.
131   * @return Dataset
132   */
133  public function update($projectId, $datasetId, Dataset $postBody, $optParams = [])
134  {
135    $params = ['projectId' => $projectId, 'datasetId' => $datasetId, 'postBody' => $postBody];
136    $params = array_merge($params, $optParams);
137    return $this->call('update', [$params], Dataset::class);
138  }
139}
140
141// Adding a class alias for backwards compatibility with the previous class name.
142class_alias(Datasets::class, 'Google_Service_Bigquery_Resource_Datasets');
143