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\RemoteBuildExecution\Resource;
19
20use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2ExecuteRequest;
21use Google\Service\RemoteBuildExecution\GoogleLongrunningOperation;
22
23/**
24 * The "actions" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $remotebuildexecutionService = new Google\Service\RemoteBuildExecution(...);
28 *   $actions = $remotebuildexecutionService->actions;
29 *  </code>
30 */
31class Actions extends \Google\Service\Resource
32{
33  /**
34   * Execute an action remotely. In order to execute an action, the client must
35   * first upload all of the inputs, the Command to run, and the Action into the
36   * ContentAddressableStorage. It then calls `Execute` with an `action_digest`
37   * referring to them. The server will run the action and eventually return the
38   * result. The input `Action`'s fields MUST meet the various canonicalization
39   * requirements specified in the documentation for their types so that it has
40   * the same digest as other logically equivalent `Action`s. The server MAY
41   * enforce the requirements and return errors if a non-canonical input is
42   * received. It MAY also proceed without verifying some or all of the
43   * requirements, such as for performance reasons. If the server does not verify
44   * the requirement, then it will treat the `Action` as distinct from another
45   * logically equivalent action if they hash differently. Returns a stream of
46   * google.longrunning.Operation messages describing the resulting execution,
47   * with eventual `response` ExecuteResponse. The `metadata` on the operation is
48   * of type ExecuteOperationMetadata. If the client remains connected after the
49   * first response is returned after the server, then updates are streamed as if
50   * the client had called WaitExecution until the execution completes or the
51   * request reaches an error. The operation can also be queried using Operations
52   * API. The server NEED NOT implement other methods or functionality of the
53   * Operations API. Errors discovered during creation of the `Operation` will be
54   * reported as gRPC Status errors, while errors that occurred while running the
55   * action will be reported in the `status` field of the `ExecuteResponse`. The
56   * server MUST NOT set the `error` field of the `Operation` proto. The possible
57   * errors include: * `INVALID_ARGUMENT`: One or more arguments are invalid. *
58   * `FAILED_PRECONDITION`: One or more errors occurred in setting up the action
59   * requested, such as a missing input or command or no worker being available.
60   * The client may be able to fix the errors and retry. * `RESOURCE_EXHAUSTED`:
61   * There is insufficient quota of some resource to run the action. *
62   * `UNAVAILABLE`: Due to a transient condition, such as all workers being
63   * occupied (and the server does not support a queue), the action could not be
64   * started. The client should retry. * `INTERNAL`: An internal error occurred in
65   * the execution engine or the worker. * `DEADLINE_EXCEEDED`: The execution
66   * timed out. * `CANCELLED`: The operation was cancelled by the client. This
67   * status is only possible if the server implements the Operations API
68   * CancelOperation method, and it was called for the current execution. In the
69   * case of a missing input or command, the server SHOULD additionally send a
70   * PreconditionFailure error detail where, for each requested blob not present
71   * in the CAS, there is a `Violation` with a `type` of `MISSING` and a `subject`
72   * of `"blobs/{hash}/{size}"` indicating the digest of the missing blob. The
73   * server does not need to guarantee that a call to this method leads to at most
74   * one execution of the action. The server MAY execute the action multiple
75   * times, potentially in parallel. These redundant executions MAY continue to
76   * run, even if the operation is completed. (actions.execute)
77   *
78   * @param string $instanceName The instance of the execution system to operate
79   * against. A server may support multiple instances of the execution system
80   * (with their own workers, storage, caches, etc.). The server MAY require use
81   * of this field to select between them in an implementation-defined fashion,
82   * otherwise it can be omitted.
83   * @param BuildBazelRemoteExecutionV2ExecuteRequest $postBody
84   * @param array $optParams Optional parameters.
85   * @return GoogleLongrunningOperation
86   */
87  public function execute($instanceName, BuildBazelRemoteExecutionV2ExecuteRequest $postBody, $optParams = [])
88  {
89    $params = ['instanceName' => $instanceName, 'postBody' => $postBody];
90    $params = array_merge($params, $optParams);
91    return $this->call('execute', [$params], GoogleLongrunningOperation::class);
92  }
93}
94
95// Adding a class alias for backwards compatibility with the previous class name.
96class_alias(Actions::class, 'Google_Service_RemoteBuildExecution_Resource_Actions');
97