diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/call_function.php b/Functions/samples/V1/CloudFunctionsServiceClient/call_function.php new file mode 100644 index 000000000000..3d3ca5a7669a --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/call_function.php @@ -0,0 +1,37 @@ +cloudFunctionName('[PROJECT]', '[LOCATION]', '[FUNCTION]'); + $data = 'data'; + $response = $cloudFunctionsServiceClient->callFunction($formattedName, $data); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_CallFunction_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/create_function.php b/Functions/samples/V1/CloudFunctionsServiceClient/create_function.php new file mode 100644 index 000000000000..2b68b32f3de8 --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/create_function.php @@ -0,0 +1,66 @@ +locationName('[PROJECT]', '[LOCATION]'); + $function = new CloudFunction(); + $operationResponse = $cloudFunctionsServiceClient->createFunction($formattedLocation, $function); + $operationResponse->pollUntilComplete(); + if ($operationResponse->operationSucceeded()) { + $result = $operationResponse->getResult(); + // doSomethingWith($result) + } else { + $error = $operationResponse->getError(); + // handleError($error) + } + + // Alternatively: + // start the operation, keep the operation name, and resume later + $operationResponse = $cloudFunctionsServiceClient->createFunction($formattedLocation, $function); + $operationName = $operationResponse->getName(); + // ... do other work + $newOperationResponse = $cloudFunctionsServiceClient->resumeOperation($operationName, 'createFunction'); + while (!$newOperationResponse->isDone()) { + // ... do other work + $newOperationResponse->reload(); + } + + if ($newOperationResponse->operationSucceeded()) { + $result = $newOperationResponse->getResult(); + // doSomethingWith($result) + } else { + $error = $newOperationResponse->getError(); + // handleError($error) + } + +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_CreateFunction_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/delete_function.php b/Functions/samples/V1/CloudFunctionsServiceClient/delete_function.php new file mode 100644 index 000000000000..e08d958418f4 --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/delete_function.php @@ -0,0 +1,62 @@ +cloudFunctionName('[PROJECT]', '[LOCATION]', '[FUNCTION]'); + $operationResponse = $cloudFunctionsServiceClient->deleteFunction($formattedName); + $operationResponse->pollUntilComplete(); + if ($operationResponse->operationSucceeded()) { + // operation succeeded and returns no value + } else { + $error = $operationResponse->getError(); + // handleError($error) + } + + // Alternatively: + // start the operation, keep the operation name, and resume later + $operationResponse = $cloudFunctionsServiceClient->deleteFunction($formattedName); + $operationName = $operationResponse->getName(); + // ... do other work + $newOperationResponse = $cloudFunctionsServiceClient->resumeOperation($operationName, 'deleteFunction'); + while (!$newOperationResponse->isDone()) { + // ... do other work + $newOperationResponse->reload(); + } + + if ($newOperationResponse->operationSucceeded()) { + // operation succeeded and returns no value + } else { + $error = $newOperationResponse->getError(); + // handleError($error) + } + +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_DeleteFunction_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/generate_download_url.php b/Functions/samples/V1/CloudFunctionsServiceClient/generate_download_url.php new file mode 100644 index 000000000000..d293d6fce3ac --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/generate_download_url.php @@ -0,0 +1,35 @@ +generateDownloadUrl(); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_GenerateDownloadUrl_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/generate_upload_url.php b/Functions/samples/V1/CloudFunctionsServiceClient/generate_upload_url.php new file mode 100644 index 000000000000..990439418ae0 --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/generate_upload_url.php @@ -0,0 +1,35 @@ +generateUploadUrl(); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_GenerateUploadUrl_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/get_function.php b/Functions/samples/V1/CloudFunctionsServiceClient/get_function.php new file mode 100644 index 000000000000..3fcf61a798ab --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/get_function.php @@ -0,0 +1,36 @@ +cloudFunctionName('[PROJECT]', '[LOCATION]', '[FUNCTION]'); + $response = $cloudFunctionsServiceClient->getFunction($formattedName); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_GetFunction_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/get_iam_policy.php b/Functions/samples/V1/CloudFunctionsServiceClient/get_iam_policy.php new file mode 100644 index 000000000000..2cc4516baecc --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/get_iam_policy.php @@ -0,0 +1,36 @@ +getIamPolicy($resource); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_GetIamPolicy_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/list_functions.php b/Functions/samples/V1/CloudFunctionsServiceClient/list_functions.php new file mode 100644 index 000000000000..c0ebe02bb105 --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/list_functions.php @@ -0,0 +1,50 @@ +listFunctions(); + foreach ($pagedResponse->iteratePages() as $page) { + foreach ($page as $element) { + // doSomethingWith($element); + } + + } + + // Alternatively: + // Iterate through all elements + $pagedResponse = $cloudFunctionsServiceClient->listFunctions(); + foreach ($pagedResponse->iterateAllElements() as $element) { + // doSomethingWith($element); + } + +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_ListFunctions_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/set_iam_policy.php b/Functions/samples/V1/CloudFunctionsServiceClient/set_iam_policy.php new file mode 100644 index 000000000000..8470ddf0fc16 --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/set_iam_policy.php @@ -0,0 +1,38 @@ +setIamPolicy($resource, $policy); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_SetIamPolicy_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/test_iam_permissions.php b/Functions/samples/V1/CloudFunctionsServiceClient/test_iam_permissions.php new file mode 100644 index 000000000000..527434ee567f --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/test_iam_permissions.php @@ -0,0 +1,37 @@ +testIamPermissions($resource, $permissions); +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_TestIamPermissions_sync] diff --git a/Functions/samples/V1/CloudFunctionsServiceClient/update_function.php b/Functions/samples/V1/CloudFunctionsServiceClient/update_function.php new file mode 100644 index 000000000000..2b8a0afd5cd1 --- /dev/null +++ b/Functions/samples/V1/CloudFunctionsServiceClient/update_function.php @@ -0,0 +1,65 @@ +updateFunction($function); + $operationResponse->pollUntilComplete(); + if ($operationResponse->operationSucceeded()) { + $result = $operationResponse->getResult(); + // doSomethingWith($result) + } else { + $error = $operationResponse->getError(); + // handleError($error) + } + + // Alternatively: + // start the operation, keep the operation name, and resume later + $operationResponse = $cloudFunctionsServiceClient->updateFunction($function); + $operationName = $operationResponse->getName(); + // ... do other work + $newOperationResponse = $cloudFunctionsServiceClient->resumeOperation($operationName, 'updateFunction'); + while (!$newOperationResponse->isDone()) { + // ... do other work + $newOperationResponse->reload(); + } + + if ($newOperationResponse->operationSucceeded()) { + $result = $newOperationResponse->getResult(); + // doSomethingWith($result) + } else { + $error = $newOperationResponse->getError(); + // handleError($error) + } + +} finally { + $cloudFunctionsServiceClient->close(); +} + +// [END cloudfunctions_v1_generated_CloudFunctionsService_UpdateFunction_sync]