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