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\BuildBazelRemoteExecutionV2BatchReadBlobsRequest;
21use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2BatchReadBlobsResponse;
22use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2BatchUpdateBlobsRequest;
23use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2BatchUpdateBlobsResponse;
24use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2FindMissingBlobsRequest;
25use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2FindMissingBlobsResponse;
26use Google\Service\RemoteBuildExecution\BuildBazelRemoteExecutionV2GetTreeResponse;
27
28/**
29 * The "blobs" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $remotebuildexecutionService = new Google\Service\RemoteBuildExecution(...);
33 *   $blobs = $remotebuildexecutionService->blobs;
34 *  </code>
35 */
36class Blobs extends \Google\Service\Resource
37{
38  /**
39   * Download many blobs at once. The server may enforce a limit of the combined
40   * total size of blobs to be downloaded using this API. This limit may be
41   * obtained using the Capabilities API. Requests exceeding the limit should
42   * either be split into smaller chunks or downloaded using the ByteStream API,
43   * as appropriate. This request is equivalent to calling a Bytestream `Read`
44   * request on each individual blob, in parallel. The requests may succeed or
45   * fail independently. Errors: * `INVALID_ARGUMENT`: The client attempted to
46   * read more than the server supported limit. Every error on individual read
47   * will be returned in the corresponding digest status. (blobs.batchRead)
48   *
49   * @param string $instanceName The instance of the execution system to operate
50   * against. A server may support multiple instances of the execution system
51   * (with their own workers, storage, caches, etc.). The server MAY require use
52   * of this field to select between them in an implementation-defined fashion,
53   * otherwise it can be omitted.
54   * @param BuildBazelRemoteExecutionV2BatchReadBlobsRequest $postBody
55   * @param array $optParams Optional parameters.
56   * @return BuildBazelRemoteExecutionV2BatchReadBlobsResponse
57   */
58  public function batchRead($instanceName, BuildBazelRemoteExecutionV2BatchReadBlobsRequest $postBody, $optParams = [])
59  {
60    $params = ['instanceName' => $instanceName, 'postBody' => $postBody];
61    $params = array_merge($params, $optParams);
62    return $this->call('batchRead', [$params], BuildBazelRemoteExecutionV2BatchReadBlobsResponse::class);
63  }
64  /**
65   * Upload many blobs at once. The server may enforce a limit of the combined
66   * total size of blobs to be uploaded using this API. This limit may be obtained
67   * using the Capabilities API. Requests exceeding the limit should either be
68   * split into smaller chunks or uploaded using the ByteStream API, as
69   * appropriate. This request is equivalent to calling a Bytestream `Write`
70   * request on each individual blob, in parallel. The requests may succeed or
71   * fail independently. Errors: * `INVALID_ARGUMENT`: The client attempted to
72   * upload more than the server supported limit. Individual requests may return
73   * the following errors, additionally: * `RESOURCE_EXHAUSTED`: There is
74   * insufficient disk quota to store the blob. * `INVALID_ARGUMENT`: The Digest
75   * does not match the provided data. (blobs.batchUpdate)
76   *
77   * @param string $instanceName The instance of the execution system to operate
78   * against. A server may support multiple instances of the execution system
79   * (with their own workers, storage, caches, etc.). The server MAY require use
80   * of this field to select between them in an implementation-defined fashion,
81   * otherwise it can be omitted.
82   * @param BuildBazelRemoteExecutionV2BatchUpdateBlobsRequest $postBody
83   * @param array $optParams Optional parameters.
84   * @return BuildBazelRemoteExecutionV2BatchUpdateBlobsResponse
85   */
86  public function batchUpdate($instanceName, BuildBazelRemoteExecutionV2BatchUpdateBlobsRequest $postBody, $optParams = [])
87  {
88    $params = ['instanceName' => $instanceName, 'postBody' => $postBody];
89    $params = array_merge($params, $optParams);
90    return $this->call('batchUpdate', [$params], BuildBazelRemoteExecutionV2BatchUpdateBlobsResponse::class);
91  }
92  /**
93   * Determine if blobs are present in the CAS. Clients can use this API before
94   * uploading blobs to determine which ones are already present in the CAS and do
95   * not need to be uploaded again. Servers SHOULD increase the lifetimes of the
96   * referenced blobs if necessary and applicable. There are no method-specific
97   * errors. (blobs.findMissing)
98   *
99   * @param string $instanceName The instance of the execution system to operate
100   * against. A server may support multiple instances of the execution system
101   * (with their own workers, storage, caches, etc.). The server MAY require use
102   * of this field to select between them in an implementation-defined fashion,
103   * otherwise it can be omitted.
104   * @param BuildBazelRemoteExecutionV2FindMissingBlobsRequest $postBody
105   * @param array $optParams Optional parameters.
106   * @return BuildBazelRemoteExecutionV2FindMissingBlobsResponse
107   */
108  public function findMissing($instanceName, BuildBazelRemoteExecutionV2FindMissingBlobsRequest $postBody, $optParams = [])
109  {
110    $params = ['instanceName' => $instanceName, 'postBody' => $postBody];
111    $params = array_merge($params, $optParams);
112    return $this->call('findMissing', [$params], BuildBazelRemoteExecutionV2FindMissingBlobsResponse::class);
113  }
114  /**
115   * Fetch the entire directory tree rooted at a node. This request must be
116   * targeted at a Directory stored in the ContentAddressableStorage (CAS). The
117   * server will enumerate the `Directory` tree recursively and return every node
118   * descended from the root. The GetTreeRequest.page_token parameter can be used
119   * to skip ahead in the stream (e.g. when retrying a partially completed and
120   * aborted request), by setting it to a value taken from
121   * GetTreeResponse.next_page_token of the last successfully processed
122   * GetTreeResponse). The exact traversal order is unspecified and, unless
123   * retrieving subsequent pages from an earlier request, is not guaranteed to be
124   * stable across multiple invocations of `GetTree`. If part of the tree is
125   * missing from the CAS, the server will return the portion present and omit the
126   * rest. Errors: * `NOT_FOUND`: The requested tree root is not present in the
127   * CAS. (blobs.getTree)
128   *
129   * @param string $instanceName The instance of the execution system to operate
130   * against. A server may support multiple instances of the execution system
131   * (with their own workers, storage, caches, etc.). The server MAY require use
132   * of this field to select between them in an implementation-defined fashion,
133   * otherwise it can be omitted.
134   * @param string $hash The hash. In the case of SHA-256, it will always be a
135   * lowercase hex string exactly 64 characters long.
136   * @param string $sizeBytes The size of the blob, in bytes.
137   * @param array $optParams Optional parameters.
138   *
139   * @opt_param int pageSize A maximum page size to request. If present, the
140   * server will request no more than this many items. Regardless of whether a
141   * page size is specified, the server may place its own limit on the number of
142   * items to be returned and require the client to retrieve more items using a
143   * subsequent request.
144   * @opt_param string pageToken A page token, which must be a value received in a
145   * previous GetTreeResponse. If present, the server will use that token as an
146   * offset, returning only that page and the ones that succeed it.
147   * @return BuildBazelRemoteExecutionV2GetTreeResponse
148   */
149  public function getTree($instanceName, $hash, $sizeBytes, $optParams = [])
150  {
151    $params = ['instanceName' => $instanceName, 'hash' => $hash, 'sizeBytes' => $sizeBytes];
152    $params = array_merge($params, $optParams);
153    return $this->call('getTree', [$params], BuildBazelRemoteExecutionV2GetTreeResponse::class);
154  }
155}
156
157// Adding a class alias for backwards compatibility with the previous class name.
158class_alias(Blobs::class, 'Google_Service_RemoteBuildExecution_Resource_Blobs');
159