[e3d4e0a] | 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\CloudBuild\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\CloudBuild\BuildTrigger;
|
---|
| 21 | use Google\Service\CloudBuild\CloudbuildEmpty;
|
---|
| 22 | use Google\Service\CloudBuild\HttpBody;
|
---|
| 23 | use Google\Service\CloudBuild\ListBuildTriggersResponse;
|
---|
| 24 | use Google\Service\CloudBuild\Operation;
|
---|
| 25 | use Google\Service\CloudBuild\ReceiveTriggerWebhookResponse;
|
---|
| 26 | use 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->projects_triggers;
|
---|
| 34 | * </code>
|
---|
| 35 | */
|
---|
| 36 | class 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 | *
|
---|
| 123 | * @opt_param string updateMask Update mask for the resource. If this is set,
|
---|
| 124 | * the server will only update the fields specified in the field mask.
|
---|
| 125 | * Otherwise, a full update of the mutable resource fields will be performed.
|
---|
| 126 | * @return BuildTrigger
|
---|
| 127 | */
|
---|
| 128 | public function patch($projectId, $triggerId, BuildTrigger $postBody, $optParams = [])
|
---|
| 129 | {
|
---|
| 130 | $params = ['projectId' => $projectId, 'triggerId' => $triggerId, 'postBody' => $postBody];
|
---|
| 131 | $params = array_merge($params, $optParams);
|
---|
| 132 | return $this->call('patch', [$params], BuildTrigger::class);
|
---|
| 133 | }
|
---|
| 134 | /**
|
---|
| 135 | * Runs a `BuildTrigger` at a particular source revision. To run a regional or
|
---|
| 136 | * global trigger, use the POST request that includes the location endpoint in
|
---|
| 137 | * the path (ex.
|
---|
| 138 | * v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The
|
---|
| 139 | * POST request that does not include the location endpoint in the path can only
|
---|
| 140 | * be used when running global triggers. (triggers.run)
|
---|
| 141 | *
|
---|
| 142 | * @param string $projectId Required. ID of the project.
|
---|
| 143 | * @param string $triggerId Required. ID of the trigger.
|
---|
| 144 | * @param RepoSource $postBody
|
---|
| 145 | * @param array $optParams Optional parameters.
|
---|
| 146 | *
|
---|
| 147 | * @opt_param string name The name of the `Trigger` to run. Format:
|
---|
| 148 | * `projects/{project}/locations/{location}/triggers/{trigger}`
|
---|
| 149 | * @return Operation
|
---|
| 150 | */
|
---|
| 151 | public function run($projectId, $triggerId, RepoSource $postBody, $optParams = [])
|
---|
| 152 | {
|
---|
| 153 | $params = ['projectId' => $projectId, 'triggerId' => $triggerId, 'postBody' => $postBody];
|
---|
| 154 | $params = array_merge($params, $optParams);
|
---|
| 155 | return $this->call('run', [$params], Operation::class);
|
---|
| 156 | }
|
---|
| 157 | /**
|
---|
| 158 | * ReceiveTriggerWebhook [Experimental] is called when the API receives a
|
---|
| 159 | * webhook request targeted at a specific trigger. (triggers.webhook)
|
---|
| 160 | *
|
---|
| 161 | * @param string $projectId Project in which the specified trigger lives
|
---|
| 162 | * @param string $trigger Name of the trigger to run the payload against
|
---|
| 163 | * @param HttpBody $postBody
|
---|
| 164 | * @param array $optParams Optional parameters.
|
---|
| 165 | *
|
---|
| 166 | * @opt_param string name The name of the `ReceiveTriggerWebhook` to retrieve.
|
---|
| 167 | * Format: `projects/{project}/locations/{location}/triggers/{trigger}`
|
---|
| 168 | * @opt_param string secret Secret token used for authorization if an OAuth
|
---|
| 169 | * token isn't provided.
|
---|
| 170 | * @return ReceiveTriggerWebhookResponse
|
---|
| 171 | */
|
---|
| 172 | public function webhook($projectId, $trigger, HttpBody $postBody, $optParams = [])
|
---|
| 173 | {
|
---|
| 174 | $params = ['projectId' => $projectId, 'trigger' => $trigger, 'postBody' => $postBody];
|
---|
| 175 | $params = array_merge($params, $optParams);
|
---|
| 176 | return $this->call('webhook', [$params], ReceiveTriggerWebhookResponse::class);
|
---|
| 177 | }
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 181 | class_alias(ProjectsTriggers::class, 'Google_Service_CloudBuild_Resource_ProjectsTriggers');
|
---|