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 |
|
---|
18 | namespace Google\Service\Bigquery\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Bigquery\GetQueryResultsResponse;
|
---|
21 | use Google\Service\Bigquery\Job;
|
---|
22 | use Google\Service\Bigquery\JobCancelResponse;
|
---|
23 | use Google\Service\Bigquery\JobList;
|
---|
24 | use Google\Service\Bigquery\QueryRequest;
|
---|
25 | use Google\Service\Bigquery\QueryResponse;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * The "jobs" collection of methods.
|
---|
29 | * Typical usage is:
|
---|
30 | * <code>
|
---|
31 | * $bigqueryService = new Google\Service\Bigquery(...);
|
---|
32 | * $jobs = $bigqueryService->jobs;
|
---|
33 | * </code>
|
---|
34 | */
|
---|
35 | class Jobs extends \Google\Service\Resource
|
---|
36 | {
|
---|
37 | /**
|
---|
38 | * Requests that a job be cancelled. This call will return immediately, and the
|
---|
39 | * client will need to poll for the job status to see if the cancel completed
|
---|
40 | * successfully. Cancelled jobs may still incur costs. (jobs.cancel)
|
---|
41 | *
|
---|
42 | * @param string $projectId Required. Project ID of the job to cancel
|
---|
43 | * @param string $jobId Required. Job ID of the job to cancel
|
---|
44 | * @param array $optParams Optional parameters.
|
---|
45 | *
|
---|
46 | * @opt_param string location The geographic location of the job. You must
|
---|
47 | * specify the location to run the job for the following scenarios: * If the
|
---|
48 | * location to run a job is not in the `us` or the `eu` multi-regional location
|
---|
49 | * * If the job's location is in a single region (for example, `us-central1`)
|
---|
50 | * For more information, see
|
---|
51 | * https://cloud.google.com/bigquery/docs/locations#specifying_your_location.
|
---|
52 | * @return JobCancelResponse
|
---|
53 | * @throws \Google\Service\Exception
|
---|
54 | */
|
---|
55 | public function cancel($projectId, $jobId, $optParams = [])
|
---|
56 | {
|
---|
57 | $params = ['projectId' => $projectId, 'jobId' => $jobId];
|
---|
58 | $params = array_merge($params, $optParams);
|
---|
59 | return $this->call('cancel', [$params], JobCancelResponse::class);
|
---|
60 | }
|
---|
61 | /**
|
---|
62 | * Requests the deletion of the metadata of a job. This call returns when the
|
---|
63 | * job's metadata is deleted. (jobs.delete)
|
---|
64 | *
|
---|
65 | * @param string $projectId Required. Project ID of the job for which metadata
|
---|
66 | * is to be deleted.
|
---|
67 | * @param string $jobId Required. Job ID of the job for which metadata is to be
|
---|
68 | * deleted. If this is a parent job which has child jobs, the metadata from all
|
---|
69 | * child jobs will be deleted as well. Direct deletion of the metadata of child
|
---|
70 | * jobs is not allowed.
|
---|
71 | * @param array $optParams Optional parameters.
|
---|
72 | *
|
---|
73 | * @opt_param string location The geographic location of the job. Required. See
|
---|
74 | * details at:
|
---|
75 | * https://cloud.google.com/bigquery/docs/locations#specifying_your_location.
|
---|
76 | * @throws \Google\Service\Exception
|
---|
77 | */
|
---|
78 | public function delete($projectId, $jobId, $optParams = [])
|
---|
79 | {
|
---|
80 | $params = ['projectId' => $projectId, 'jobId' => $jobId];
|
---|
81 | $params = array_merge($params, $optParams);
|
---|
82 | return $this->call('delete', [$params]);
|
---|
83 | }
|
---|
84 | /**
|
---|
85 | * Returns information about a specific job. Job information is available for a
|
---|
86 | * six month period after creation. Requires that you're the person who ran the
|
---|
87 | * job, or have the Is Owner project role. (jobs.get)
|
---|
88 | *
|
---|
89 | * @param string $projectId Required. Project ID of the requested job.
|
---|
90 | * @param string $jobId Required. Job ID of the requested job.
|
---|
91 | * @param array $optParams Optional parameters.
|
---|
92 | *
|
---|
93 | * @opt_param string location The geographic location of the job. You must
|
---|
94 | * specify the location to run the job for the following scenarios: * If the
|
---|
95 | * location to run a job is not in the `us` or the `eu` multi-regional location
|
---|
96 | * * If the job's location is in a single region (for example, `us-central1`)
|
---|
97 | * For more information, see
|
---|
98 | * https://cloud.google.com/bigquery/docs/locations#specifying_your_location.
|
---|
99 | * @return Job
|
---|
100 | * @throws \Google\Service\Exception
|
---|
101 | */
|
---|
102 | public function get($projectId, $jobId, $optParams = [])
|
---|
103 | {
|
---|
104 | $params = ['projectId' => $projectId, 'jobId' => $jobId];
|
---|
105 | $params = array_merge($params, $optParams);
|
---|
106 | return $this->call('get', [$params], Job::class);
|
---|
107 | }
|
---|
108 | /**
|
---|
109 | * RPC to get the results of a query job. (jobs.getQueryResults)
|
---|
110 | *
|
---|
111 | * @param string $projectId Required. Project ID of the query job.
|
---|
112 | * @param string $jobId Required. Job ID of the query job.
|
---|
113 | * @param array $optParams Optional parameters.
|
---|
114 | *
|
---|
115 | * @opt_param bool formatOptions.useInt64Timestamp Optional. Output timestamp as
|
---|
116 | * usec int64. Default is false.
|
---|
117 | * @opt_param string location The geographic location of the job. You must
|
---|
118 | * specify the location to run the job for the following scenarios: * If the
|
---|
119 | * location to run a job is not in the `us` or the `eu` multi-regional location
|
---|
120 | * * If the job's location is in a single region (for example, `us-central1`)
|
---|
121 | * For more information, see
|
---|
122 | * https://cloud.google.com/bigquery/docs/locations#specifying_your_location.
|
---|
123 | * @opt_param string maxResults Maximum number of results to read.
|
---|
124 | * @opt_param string pageToken Page token, returned by a previous call, to
|
---|
125 | * request the next page of results.
|
---|
126 | * @opt_param string startIndex Zero-based index of the starting row.
|
---|
127 | * @opt_param string timeoutMs Optional: Specifies the maximum amount of time,
|
---|
128 | * in milliseconds, that the client is willing to wait for the query to
|
---|
129 | * complete. By default, this limit is 10 seconds (10,000 milliseconds). If the
|
---|
130 | * query is complete, the jobComplete field in the response is true. If the
|
---|
131 | * query has not yet completed, jobComplete is false. You can request a longer
|
---|
132 | * timeout period in the timeoutMs field. However, the call is not guaranteed to
|
---|
133 | * wait for the specified timeout; it typically returns after around 200 seconds
|
---|
134 | * (200,000 milliseconds), even if the query is not complete. If jobComplete is
|
---|
135 | * false, you can continue to wait for the query to complete by calling the
|
---|
136 | * getQueryResults method until the jobComplete field in the getQueryResults
|
---|
137 | * response is true.
|
---|
138 | * @return GetQueryResultsResponse
|
---|
139 | * @throws \Google\Service\Exception
|
---|
140 | */
|
---|
141 | public function getQueryResults($projectId, $jobId, $optParams = [])
|
---|
142 | {
|
---|
143 | $params = ['projectId' => $projectId, 'jobId' => $jobId];
|
---|
144 | $params = array_merge($params, $optParams);
|
---|
145 | return $this->call('getQueryResults', [$params], GetQueryResultsResponse::class);
|
---|
146 | }
|
---|
147 | /**
|
---|
148 | * Starts a new asynchronous job. This API has two different kinds of endpoint
|
---|
149 | * URIs, as this method supports a variety of use cases. * The *Metadata* URI is
|
---|
150 | * used for most interactions, as it accepts the job configuration directly. *
|
---|
151 | * The *Upload* URI is ONLY for the case when you're sending both a load job
|
---|
152 | * configuration and a data stream together. In this case, the Upload URI
|
---|
153 | * accepts the job configuration and the data as two distinct multipart MIME
|
---|
154 | * parts. (jobs.insert)
|
---|
155 | *
|
---|
156 | * @param string $projectId Project ID of project that will be billed for the
|
---|
157 | * job.
|
---|
158 | * @param Job $postBody
|
---|
159 | * @param array $optParams Optional parameters.
|
---|
160 | * @return Job
|
---|
161 | * @throws \Google\Service\Exception
|
---|
162 | */
|
---|
163 | public function insert($projectId, Job $postBody, $optParams = [])
|
---|
164 | {
|
---|
165 | $params = ['projectId' => $projectId, 'postBody' => $postBody];
|
---|
166 | $params = array_merge($params, $optParams);
|
---|
167 | return $this->call('insert', [$params], Job::class);
|
---|
168 | }
|
---|
169 | /**
|
---|
170 | * Lists all jobs that you started in the specified project. Job information is
|
---|
171 | * available for a six month period after creation. The job list is sorted in
|
---|
172 | * reverse chronological order, by job creation time. Requires the Can View
|
---|
173 | * project role, or the Is Owner project role if you set the allUsers property.
|
---|
174 | * (jobs.listJobs)
|
---|
175 | *
|
---|
176 | * @param string $projectId Project ID of the jobs to list.
|
---|
177 | * @param array $optParams Optional parameters.
|
---|
178 | *
|
---|
179 | * @opt_param bool allUsers Whether to display jobs owned by all users in the
|
---|
180 | * project. Default False.
|
---|
181 | * @opt_param string maxCreationTime Max value for job creation time, in
|
---|
182 | * milliseconds since the POSIX epoch. If set, only jobs created before or at
|
---|
183 | * this timestamp are returned.
|
---|
184 | * @opt_param string maxResults The maximum number of results to return in a
|
---|
185 | * single response page. Leverage the page tokens to iterate through the entire
|
---|
186 | * collection.
|
---|
187 | * @opt_param string minCreationTime Min value for job creation time, in
|
---|
188 | * milliseconds since the POSIX epoch. If set, only jobs created after or at
|
---|
189 | * this timestamp are returned.
|
---|
190 | * @opt_param string pageToken Page token, returned by a previous call, to
|
---|
191 | * request the next page of results.
|
---|
192 | * @opt_param string parentJobId If set, show only child jobs of the specified
|
---|
193 | * parent. Otherwise, show all top-level jobs.
|
---|
194 | * @opt_param string projection Restrict information returned to a set of
|
---|
195 | * selected fields
|
---|
196 | * @opt_param string stateFilter Filter for job state
|
---|
197 | * @return JobList
|
---|
198 | * @throws \Google\Service\Exception
|
---|
199 | */
|
---|
200 | public function listJobs($projectId, $optParams = [])
|
---|
201 | {
|
---|
202 | $params = ['projectId' => $projectId];
|
---|
203 | $params = array_merge($params, $optParams);
|
---|
204 | return $this->call('list', [$params], JobList::class);
|
---|
205 | }
|
---|
206 | /**
|
---|
207 | * Runs a BigQuery SQL query synchronously and returns query results if the
|
---|
208 | * query completes within a specified timeout. (jobs.query)
|
---|
209 | *
|
---|
210 | * @param string $projectId Required. Project ID of the query request.
|
---|
211 | * @param QueryRequest $postBody
|
---|
212 | * @param array $optParams Optional parameters.
|
---|
213 | * @return QueryResponse
|
---|
214 | * @throws \Google\Service\Exception
|
---|
215 | */
|
---|
216 | public function query($projectId, QueryRequest $postBody, $optParams = [])
|
---|
217 | {
|
---|
218 | $params = ['projectId' => $projectId, 'postBody' => $postBody];
|
---|
219 | $params = array_merge($params, $optParams);
|
---|
220 | return $this->call('query', [$params], QueryResponse::class);
|
---|
221 | }
|
---|
222 | }
|
---|
223 |
|
---|
224 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
225 | class_alias(Jobs::class, 'Google_Service_Bigquery_Resource_Jobs');
|
---|