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\Storagetransfer\Resource; 19 20use Google\Service\Storagetransfer\CancelOperationRequest; 21use Google\Service\Storagetransfer\ListOperationsResponse; 22use Google\Service\Storagetransfer\Operation; 23use Google\Service\Storagetransfer\PauseTransferOperationRequest; 24use Google\Service\Storagetransfer\ResumeTransferOperationRequest; 25use Google\Service\Storagetransfer\StoragetransferEmpty; 26 27/** 28 * The "transferOperations" collection of methods. 29 * Typical usage is: 30 * <code> 31 * $storagetransferService = new Google\Service\Storagetransfer(...); 32 * $transferOperations = $storagetransferService->transferOperations; 33 * </code> 34 */ 35class TransferOperations extends \Google\Service\Resource 36{ 37 /** 38 * Cancels a transfer. Use the transferOperations.get method to check if the 39 * cancellation succeeded or if the operation completed despite the `cancel` 40 * request. When you cancel an operation, the currently running transfer is 41 * interrupted. For recurring transfer jobs, the next instance of the transfer 42 * job will still run. For example, if your job is configured to run every day 43 * at 1pm and you cancel Monday's operation at 1:05pm, Monday's transfer will 44 * stop. However, a transfer job will still be attempted on Tuesday. This 45 * applies only to currently running operations. If an operation is not 46 * currently running, `cancel` does nothing. *Caution:* Canceling a transfer job 47 * can leave your data in an unknown state. We recommend that you restore the 48 * state at both the destination and the source after the `cancel` request 49 * completes so that your data is in a consistent state. When you cancel a job, 50 * the next job computes a delta of files and may repair any inconsistent state. 51 * For instance, if you run a job every day, and today's job found 10 new files 52 * and transferred five files before you canceled the job, tomorrow's transfer 53 * operation will compute a new delta with the five files that were not copied 54 * today plus any new files discovered tomorrow. (transferOperations.cancel) 55 * 56 * @param string $name The name of the operation resource to be cancelled. 57 * @param CancelOperationRequest $postBody 58 * @param array $optParams Optional parameters. 59 * @return StoragetransferEmpty 60 */ 61 public function cancel($name, CancelOperationRequest $postBody, $optParams = []) 62 { 63 $params = ['name' => $name, 'postBody' => $postBody]; 64 $params = array_merge($params, $optParams); 65 return $this->call('cancel', [$params], StoragetransferEmpty::class); 66 } 67 /** 68 * Gets the latest state of a long-running operation. Clients can use this 69 * method to poll the operation result at intervals as recommended by the API 70 * service. (transferOperations.get) 71 * 72 * @param string $name The name of the operation resource. 73 * @param array $optParams Optional parameters. 74 * @return Operation 75 */ 76 public function get($name, $optParams = []) 77 { 78 $params = ['name' => $name]; 79 $params = array_merge($params, $optParams); 80 return $this->call('get', [$params], Operation::class); 81 } 82 /** 83 * Lists transfer operations. Operations are ordered by their creation time in 84 * reverse chronological order. (transferOperations.listTransferOperations) 85 * 86 * @param string $name Required. The name of the type being listed; must be 87 * `transferOperations`. 88 * @param string $filter Required. A list of query parameters specified as JSON 89 * text in the form of: `{"projectId":"my_project_id", 90 * "jobNames":["jobid1","jobid2",...], "operationNames":["opid1","opid2",...], 91 * "transferStatuses":["status1","status2",...]}` Since `jobNames`, 92 * `operationNames`, and `transferStatuses` support multiple values, they must 93 * be specified with array notation. `projectId` is required. `jobNames`, 94 * `operationNames`, and `transferStatuses` are optional. The valid values for 95 * `transferStatuses` are case-insensitive: IN_PROGRESS, PAUSED, SUCCESS, 96 * FAILED, and ABORTED. 97 * @param array $optParams Optional parameters. 98 * 99 * @opt_param int pageSize The list page size. The max allowed value is 256. 100 * @opt_param string pageToken The list page token. 101 * @return ListOperationsResponse 102 */ 103 public function listTransferOperations($name, $filter, $optParams = []) 104 { 105 $params = ['name' => $name, 'filter' => $filter]; 106 $params = array_merge($params, $optParams); 107 return $this->call('list', [$params], ListOperationsResponse::class); 108 } 109 /** 110 * Pauses a transfer operation. (transferOperations.pause) 111 * 112 * @param string $name Required. The name of the transfer operation. 113 * @param PauseTransferOperationRequest $postBody 114 * @param array $optParams Optional parameters. 115 * @return StoragetransferEmpty 116 */ 117 public function pause($name, PauseTransferOperationRequest $postBody, $optParams = []) 118 { 119 $params = ['name' => $name, 'postBody' => $postBody]; 120 $params = array_merge($params, $optParams); 121 return $this->call('pause', [$params], StoragetransferEmpty::class); 122 } 123 /** 124 * Resumes a transfer operation that is paused. (transferOperations.resume) 125 * 126 * @param string $name Required. The name of the transfer operation. 127 * @param ResumeTransferOperationRequest $postBody 128 * @param array $optParams Optional parameters. 129 * @return StoragetransferEmpty 130 */ 131 public function resume($name, ResumeTransferOperationRequest $postBody, $optParams = []) 132 { 133 $params = ['name' => $name, 'postBody' => $postBody]; 134 $params = array_merge($params, $optParams); 135 return $this->call('resume', [$params], StoragetransferEmpty::class); 136 } 137} 138 139// Adding a class alias for backwards compatibility with the previous class name. 140class_alias(TransferOperations::class, 'Google_Service_Storagetransfer_Resource_TransferOperations'); 141