Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LongRunning/.OwlBot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ deep-copy-regex:
dest: /owl-bot-staging/LongRunning/tests/$1
- source: /google/longrunning/.*-php/proto/src/(.*)
dest: /owl-bot-staging/LongRunning/proto/src/$1
- source: /google/longrunning/.*-php/samples/(.*)
dest: /owl-bot-staging/LongRunning/samples/$1
api-name: LongRunning
5 changes: 2 additions & 3 deletions LongRunning/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"description": "Google LongRunning Client for PHP",
"license": "Apache-2.0",
"minimum-stability": "stable",
"version": "0.7.0",
"version": "1.0.0",
"autoload": {
"psr-4": {
"Google\\ApiCore\\LongRunning\\": "src/ApiCore/LongRunning",
"Google\\LongRunning\\": "src/LongRunning",
"GPBMetadata\\Google\\Longrunning\\": "metadata/Longrunning"
}
Expand All @@ -20,7 +19,7 @@
}
},
"require-dev": {
"google/gax": "^1.38.0",
"google/gax": "2.x-dev",
"phpunit/phpunit": "^9.0"
}
}
6 changes: 0 additions & 6 deletions LongRunning/metadata/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions LongRunning/owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,6 @@
version_string="longrunning",
)

# Add an alias for the previous namespace
s.replace(
"src/LongRunning/OperationsClient.php",
r"^}$\n",
r"}\n\nclass_alias('Google\\LongRunning\\OperationsClient', 'Google\\ApiCore\\LongRunning\\OperationsClient');\n")

### [START] protoc backwards compatibility fixes

# roll back to private properties.
s.replace(
"src/**/**/*.php",
r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$",
r"""Generated from protobuf field \1
*/
private $""")

# prevent proto messages from being marked final
s.replace(
"src/**/**/*.php",
r"final class",
r"class")

### [END] protoc backwards compatibility fixes

# fix relative cloud.google.com links
s.replace(
"src/**/**/*.php",
r"(.{0,})\]\((/.{0,})\)",
r"\1](https://cloud.google.com\2)"
)

# format generated clients
subprocess.run([
'npm',
Expand Down
78 changes: 78 additions & 0 deletions LongRunning/samples/OperationsClient/cancel_operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START longrunning_generated_Operations_CancelOperation_sync]
use Google\ApiCore\ApiException;
use Google\LongRunning\CancelOperationRequest;
use Google\LongRunning\Client\OperationsClient;

/**
* Starts asynchronous cancellation on a long-running operation. The server
* makes a best effort to cancel the operation, but success is not
* guaranteed. If the server doesn't support this method, it returns
* `google.rpc.Code.UNIMPLEMENTED`. Clients can use
* [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
* other methods to check whether the cancellation succeeded or whether the
* operation completed despite cancellation. On successful cancellation,
* the operation is not deleted; instead, it becomes an operation with
* an [Operation.error][google.longrunning.Operation.error] value with a
* [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to
* `Code.CANCELLED`.
*
* @param string $name The name of the operation resource to be cancelled.
*/
function cancel_operation_sample(string $name): void
{
// Create a client.
$operationsClient = new OperationsClient();

// Prepare the request message.
$request = (new CancelOperationRequest())
->setName($name);

// Call the API and handle any network failures.
try {
$operationsClient->cancelOperation($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$name = '[NAME]';

cancel_operation_sample($name);
}
// [END longrunning_generated_Operations_CancelOperation_sync]
71 changes: 71 additions & 0 deletions LongRunning/samples/OperationsClient/delete_operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START longrunning_generated_Operations_DeleteOperation_sync]
use Google\ApiCore\ApiException;
use Google\LongRunning\Client\OperationsClient;
use Google\LongRunning\DeleteOperationRequest;

/**
* Deletes a long-running operation. This method indicates that the client is
* no longer interested in the operation result. It does not cancel the
* operation. If the server doesn't support this method, it returns
* `google.rpc.Code.UNIMPLEMENTED`.
*
* @param string $name The name of the operation resource to be deleted.
*/
function delete_operation_sample(string $name): void
{
// Create a client.
$operationsClient = new OperationsClient();

// Prepare the request message.
$request = (new DeleteOperationRequest())
->setName($name);

// Call the API and handle any network failures.
try {
$operationsClient->deleteOperation($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$name = '[NAME]';

delete_operation_sample($name);
}
// [END longrunning_generated_Operations_DeleteOperation_sync]
72 changes: 72 additions & 0 deletions LongRunning/samples/OperationsClient/get_operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START longrunning_generated_Operations_GetOperation_sync]
use Google\ApiCore\ApiException;
use Google\LongRunning\Client\OperationsClient;
use Google\LongRunning\GetOperationRequest;
use Google\LongRunning\Operation;

/**
* Gets the latest state of a long-running operation. Clients can use this
* method to poll the operation result at intervals as recommended by the API
* service.
*
* @param string $name The name of the operation resource.
*/
function get_operation_sample(string $name): void
{
// Create a client.
$operationsClient = new OperationsClient();

// Prepare the request message.
$request = (new GetOperationRequest())
->setName($name);

// Call the API and handle any network failures.
try {
/** @var Operation $response */
$response = $operationsClient->getOperation($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$name = '[NAME]';

get_operation_sample($name);
}
// [END longrunning_generated_Operations_GetOperation_sync]
79 changes: 79 additions & 0 deletions LongRunning/samples/OperationsClient/list_operations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START longrunning_generated_Operations_ListOperations_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\LongRunning\Client\OperationsClient;
use Google\LongRunning\ListOperationsRequest;
use Google\LongRunning\Operation;

/**
* Lists operations that match the specified filter in the request. If the
* server doesn't support this method, it returns `UNIMPLEMENTED`.
*
* @param string $name The name of the operation's parent resource.
* @param string $filter The standard list filter.
*/
function list_operations_sample(string $name, string $filter): void
{
// Create a client.
$operationsClient = new OperationsClient();

// Prepare the request message.
$request = (new ListOperationsRequest())
->setName($name)
->setFilter($filter);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $operationsClient->listOperations($request);

/** @var Operation $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$name = '[NAME]';
$filter = '[FILTER]';

list_operations_sample($name, $filter);
}
// [END longrunning_generated_Operations_ListOperations_sync]
Loading
Loading