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\CloudScheduler\Resource;
19
20use Google\Service\CloudScheduler\CloudschedulerEmpty;
21use Google\Service\CloudScheduler\Job;
22use Google\Service\CloudScheduler\ListJobsResponse;
23use Google\Service\CloudScheduler\PauseJobRequest;
24use Google\Service\CloudScheduler\ResumeJobRequest;
25use Google\Service\CloudScheduler\RunJobRequest;
26
27/**
28 * The "jobs" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $cloudschedulerService = new Google\Service\CloudScheduler(...);
32 *   $jobs = $cloudschedulerService->jobs;
33 *  </code>
34 */
35class ProjectsLocationsJobs extends \Google\Service\Resource
36{
37  /**
38   * Creates a job. (jobs.create)
39   *
40   * @param string $parent Required. The location name. For example:
41   * `projects/PROJECT_ID/locations/LOCATION_ID`.
42   * @param Job $postBody
43   * @param array $optParams Optional parameters.
44   * @return Job
45   */
46  public function create($parent, Job $postBody, $optParams = [])
47  {
48    $params = ['parent' => $parent, 'postBody' => $postBody];
49    $params = array_merge($params, $optParams);
50    return $this->call('create', [$params], Job::class);
51  }
52  /**
53   * Deletes a job. (jobs.delete)
54   *
55   * @param string $name Required. The job name. For example:
56   * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
57   * @param array $optParams Optional parameters.
58   * @return CloudschedulerEmpty
59   */
60  public function delete($name, $optParams = [])
61  {
62    $params = ['name' => $name];
63    $params = array_merge($params, $optParams);
64    return $this->call('delete', [$params], CloudschedulerEmpty::class);
65  }
66  /**
67   * Gets a job. (jobs.get)
68   *
69   * @param string $name Required. The job name. For example:
70   * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
71   * @param array $optParams Optional parameters.
72   * @return Job
73   */
74  public function get($name, $optParams = [])
75  {
76    $params = ['name' => $name];
77    $params = array_merge($params, $optParams);
78    return $this->call('get', [$params], Job::class);
79  }
80  /**
81   * Lists jobs. (jobs.listProjectsLocationsJobs)
82   *
83   * @param string $parent Required. The location name. For example:
84   * `projects/PROJECT_ID/locations/LOCATION_ID`.
85   * @param array $optParams Optional parameters.
86   *
87   * @opt_param int pageSize Requested page size. The maximum page size is 500. If
88   * unspecified, the page size will be the maximum. Fewer jobs than requested
89   * might be returned, even if more jobs exist; use next_page_token to determine
90   * if more jobs exist.
91   * @opt_param string pageToken A token identifying a page of results the server
92   * will return. To request the first page results, page_token must be empty. To
93   * request the next page of results, page_token must be the value of
94   * next_page_token returned from the previous call to ListJobs. It is an error
95   * to switch the value of filter or order_by while iterating through pages.
96   * @return ListJobsResponse
97   */
98  public function listProjectsLocationsJobs($parent, $optParams = [])
99  {
100    $params = ['parent' => $parent];
101    $params = array_merge($params, $optParams);
102    return $this->call('list', [$params], ListJobsResponse::class);
103  }
104  /**
105   * Updates a job. If successful, the updated Job is returned. If the job does
106   * not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully
107   * return, it is possible for the job to be in an Job.State.UPDATE_FAILED state.
108   * A job in this state may not be executed. If this happens, retry the UpdateJob
109   * request until a successful response is received. (jobs.patch)
110   *
111   * @param string $name Optionally caller-specified in CreateJob, after which it
112   * becomes output only. The job name. For example:
113   * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. * `PROJECT_ID` can
114   * contain letters ([A-Za-z]), numbers ([0-9]), hyphens (-), colons (:), or
115   * periods (.). For more information, see [Identifying
116   * projects](https://cloud.google.com/resource-manager/docs/creating-managing-
117   * projects#identifying_projects) * `LOCATION_ID` is the canonical ID for the
118   * job's location. The list of available locations can be obtained by calling
119   * ListLocations. For more information, see
120   * https://cloud.google.com/about/locations/. * `JOB_ID` can contain only
121   * letters ([A-Za-z]), numbers ([0-9]), hyphens (-), or underscores (_). The
122   * maximum length is 500 characters.
123   * @param Job $postBody
124   * @param array $optParams Optional parameters.
125   *
126   * @opt_param string updateMask A mask used to specify which fields of the job
127   * are being updated.
128   * @return Job
129   */
130  public function patch($name, Job $postBody, $optParams = [])
131  {
132    $params = ['name' => $name, 'postBody' => $postBody];
133    $params = array_merge($params, $optParams);
134    return $this->call('patch', [$params], Job::class);
135  }
136  /**
137   * Pauses a job. If a job is paused then the system will stop executing the job
138   * until it is re-enabled via ResumeJob. The state of the job is stored in
139   * state; if paused it will be set to Job.State.PAUSED. A job must be in
140   * Job.State.ENABLED to be paused. (jobs.pause)
141   *
142   * @param string $name Required. The job name. For example:
143   * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
144   * @param PauseJobRequest $postBody
145   * @param array $optParams Optional parameters.
146   * @return Job
147   */
148  public function pause($name, PauseJobRequest $postBody, $optParams = [])
149  {
150    $params = ['name' => $name, 'postBody' => $postBody];
151    $params = array_merge($params, $optParams);
152    return $this->call('pause', [$params], Job::class);
153  }
154  /**
155   * Resume a job. This method reenables a job after it has been Job.State.PAUSED.
156   * The state of a job is stored in Job.state; after calling this method it will
157   * be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
158   * (jobs.resume)
159   *
160   * @param string $name Required. The job name. For example:
161   * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
162   * @param ResumeJobRequest $postBody
163   * @param array $optParams Optional parameters.
164   * @return Job
165   */
166  public function resume($name, ResumeJobRequest $postBody, $optParams = [])
167  {
168    $params = ['name' => $name, 'postBody' => $postBody];
169    $params = array_merge($params, $optParams);
170    return $this->call('resume', [$params], Job::class);
171  }
172  /**
173   * Forces a job to run now. When this method is called, Cloud Scheduler will
174   * dispatch the job, even if the job is already running. (jobs.run)
175   *
176   * @param string $name Required. The job name. For example:
177   * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
178   * @param RunJobRequest $postBody
179   * @param array $optParams Optional parameters.
180   * @return Job
181   */
182  public function run($name, RunJobRequest $postBody, $optParams = [])
183  {
184    $params = ['name' => $name, 'postBody' => $postBody];
185    $params = array_merge($params, $optParams);
186    return $this->call('run', [$params], Job::class);
187  }
188}
189
190// Adding a class alias for backwards compatibility with the previous class name.
191class_alias(ProjectsLocationsJobs::class, 'Google_Service_CloudScheduler_Resource_ProjectsLocationsJobs');
192