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\CloudBuild\Resource;
19
20use Google\Service\CloudBuild\BuildTrigger;
21use Google\Service\CloudBuild\CloudbuildEmpty;
22use Google\Service\CloudBuild\HttpBody;
23use Google\Service\CloudBuild\ListBuildTriggersResponse;
24use Google\Service\CloudBuild\Operation;
25use Google\Service\CloudBuild\ReceiveTriggerWebhookResponse;
26use Google\Service\CloudBuild\RepoSource;
27
28/**
29 * The "triggers" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $cloudbuildService = new Google\Service\CloudBuild(...);
33 *   $triggers = $cloudbuildService->triggers;
34 *  </code>
35 */
36class ProjectsTriggers extends \Google\Service\Resource
37{
38  /**
39   * Creates a new `BuildTrigger`. This API is experimental. (triggers.create)
40   *
41   * @param string $projectId Required. ID of the project for which to configure
42   * automatic builds.
43   * @param BuildTrigger $postBody
44   * @param array $optParams Optional parameters.
45   *
46   * @opt_param string parent The parent resource where this trigger will be
47   * created. Format: `projects/{project}/locations/{location}`
48   * @return BuildTrigger
49   */
50  public function create($projectId, BuildTrigger $postBody, $optParams = [])
51  {
52    $params = ['projectId' => $projectId, 'postBody' => $postBody];
53    $params = array_merge($params, $optParams);
54    return $this->call('create', [$params], BuildTrigger::class);
55  }
56  /**
57   * Deletes a `BuildTrigger` by its project ID and trigger ID. This API is
58   * experimental. (triggers.delete)
59   *
60   * @param string $projectId Required. ID of the project that owns the trigger.
61   * @param string $triggerId Required. ID of the `BuildTrigger` to delete.
62   * @param array $optParams Optional parameters.
63   *
64   * @opt_param string name The name of the `Trigger` to delete. Format:
65   * `projects/{project}/locations/{location}/triggers/{trigger}`
66   * @return CloudbuildEmpty
67   */
68  public function delete($projectId, $triggerId, $optParams = [])
69  {
70    $params = ['projectId' => $projectId, 'triggerId' => $triggerId];
71    $params = array_merge($params, $optParams);
72    return $this->call('delete', [$params], CloudbuildEmpty::class);
73  }
74  /**
75   * Returns information about a `BuildTrigger`. This API is experimental.
76   * (triggers.get)
77   *
78   * @param string $projectId Required. ID of the project that owns the trigger.
79   * @param string $triggerId Required. Identifier (`id` or `name`) of the
80   * `BuildTrigger` to get.
81   * @param array $optParams Optional parameters.
82   *
83   * @opt_param string name The name of the `Trigger` to retrieve. Format:
84   * `projects/{project}/locations/{location}/triggers/{trigger}`
85   * @return BuildTrigger
86   */
87  public function get($projectId, $triggerId, $optParams = [])
88  {
89    $params = ['projectId' => $projectId, 'triggerId' => $triggerId];
90    $params = array_merge($params, $optParams);
91    return $this->call('get', [$params], BuildTrigger::class);
92  }
93  /**
94   * Lists existing `BuildTrigger`s. This API is experimental.
95   * (triggers.listProjectsTriggers)
96   *
97   * @param string $projectId Required. ID of the project for which to list
98   * BuildTriggers.
99   * @param array $optParams Optional parameters.
100   *
101   * @opt_param int pageSize Number of results to return in the list.
102   * @opt_param string pageToken Token to provide to skip to a particular spot in
103   * the list.
104   * @opt_param string parent The parent of the collection of `Triggers`. Format:
105   * `projects/{project}/locations/{location}`
106   * @return ListBuildTriggersResponse
107   */
108  public function listProjectsTriggers($projectId, $optParams = [])
109  {
110    $params = ['projectId' => $projectId];
111    $params = array_merge($params, $optParams);
112    return $this->call('list', [$params], ListBuildTriggersResponse::class);
113  }
114  /**
115   * Updates a `BuildTrigger` by its project ID and trigger ID. This API is
116   * experimental. (triggers.patch)
117   *
118   * @param string $projectId Required. ID of the project that owns the trigger.
119   * @param string $triggerId Required. ID of the `BuildTrigger` to update.
120   * @param BuildTrigger $postBody
121   * @param array $optParams Optional parameters.
122   * @return BuildTrigger
123   */
124  public function patch($projectId, $triggerId, BuildTrigger $postBody, $optParams = [])
125  {
126    $params = ['projectId' => $projectId, 'triggerId' => $triggerId, 'postBody' => $postBody];
127    $params = array_merge($params, $optParams);
128    return $this->call('patch', [$params], BuildTrigger::class);
129  }
130  /**
131   * Runs a `BuildTrigger` at a particular source revision. (triggers.run)
132   *
133   * @param string $projectId Required. ID of the project.
134   * @param string $triggerId Required. ID of the trigger.
135   * @param RepoSource $postBody
136   * @param array $optParams Optional parameters.
137   *
138   * @opt_param string name The name of the `Trigger` to run. Format:
139   * `projects/{project}/locations/{location}/triggers/{trigger}`
140   * @return Operation
141   */
142  public function run($projectId, $triggerId, RepoSource $postBody, $optParams = [])
143  {
144    $params = ['projectId' => $projectId, 'triggerId' => $triggerId, 'postBody' => $postBody];
145    $params = array_merge($params, $optParams);
146    return $this->call('run', [$params], Operation::class);
147  }
148  /**
149   * ReceiveTriggerWebhook [Experimental] is called when the API receives a
150   * webhook request targeted at a specific trigger. (triggers.webhook)
151   *
152   * @param string $projectId Project in which the specified trigger lives
153   * @param string $trigger Name of the trigger to run the payload against
154   * @param HttpBody $postBody
155   * @param array $optParams Optional parameters.
156   *
157   * @opt_param string name The name of the `ReceiveTriggerWebhook` to retrieve.
158   * Format: `projects/{project}/locations/{location}/triggers/{trigger}`
159   * @opt_param string secret Secret token used for authorization if an OAuth
160   * token isn't provided.
161   * @return ReceiveTriggerWebhookResponse
162   */
163  public function webhook($projectId, $trigger, HttpBody $postBody, $optParams = [])
164  {
165    $params = ['projectId' => $projectId, 'trigger' => $trigger, 'postBody' => $postBody];
166    $params = array_merge($params, $optParams);
167    return $this->call('webhook', [$params], ReceiveTriggerWebhookResponse::class);
168  }
169}
170
171// Adding a class alias for backwards compatibility with the previous class name.
172class_alias(ProjectsTriggers::class, 'Google_Service_CloudBuild_Resource_ProjectsTriggers');
173