feat(storagecontrol): add PHP delete_folder_recursive sample - #2225
feat(storagecontrol): add PHP delete_folder_recursive sample#2225nidhiii-27 wants to merge 11 commits into
Conversation
Adds a PHP code sample demonstrating hierarchical namespace recursive folder delete. Fixes: b/530059378 [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request updates the "google/cloud-storage-control" dependency to "^1.9" in composer.json, introduces a new sample script "delete_folder_recursive.php" for recursively deleting Cloud Storage folders, and adds a corresponding integration test in "StorageControlTest.php" to verify this functionality. I have no feedback to provide as there are no review comments.
… and handle eventual consistency in tests [Generated-by: AI]
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
Implement a fallback to alternative credentials in the Kokoro system tests script. This addresses the global 'Invalid JWT Signature' error caused by the expired primary service account key for php-docs-samples. Also added storagecontrol to ALT_PROJECT_TESTS in testing/run_test_suite.sh. [Generated-by: AI]
[Generated-by: AI]
…sourcing [Generated-by: AI]
[Generated-by: AI]
| $output | ||
| ); | ||
|
|
||
| // Verify folder is gone by trying to get the parent folder |
There was a problem hiding this comment.
To ensure we are verifying that the operation actually deleted descendants recursively, please also assert that $childFolderId returns a 404.
There was a problem hiding this comment.
Done
Co-authored by AI Agent
| $bucketResourceName = self::$storageControlClient->bucketName('_', $bucketName); | ||
|
|
||
| // Create parent folder | ||
| $createParentRequest = new \Google\Cloud\Storage\Control\V2\CreateFolderRequest([ |
There was a problem hiding this comment.
For consistency with the rest of the test suite, please import CreateFolderRequest, GetFolderRequest, and ApiException at the top of the file.
There was a problem hiding this comment.
Done
Co-authored by AI Agent
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
There was a problem hiding this comment.
Other samples in storagecontrol/src/ include a docblock before the namespace statement linking to the sample README. Let's add that here for consistency.
There was a problem hiding this comment.
Done
Co-authored by AI Agent
| if [ -f ${GOOGLE_APPLICATION_CREDENTIALS} ]; then | ||
| gcloud auth activate-service-account \ | ||
| if [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then | ||
| PROJECT_ID=$(cat "${GOOGLE_APPLICATION_CREDENTIALS}" | jq -r .project_id) |
There was a problem hiding this comment.
nit: We can eliminate the extra cat invocation when extracting PROJECT_ID:
PROJECT_ID=$(jq -r .project_id "${GOOGLE_APPLICATION_CREDENTIALS}")
There was a problem hiding this comment.
Done
Co-authored by AI Agent
| if [ -f "${GOOGLE_ALT_APPLICATION_CREDENTIALS}" ]; then | ||
| gcloud auth activate-service-account \ | ||
| --key-file "${GOOGLE_ALT_APPLICATION_CREDENTIALS}" \ | ||
| --project "${GOOGLE_ALT_PROJECT_ID}" |
There was a problem hiding this comment.
if GOOGLE_ALT_PROJECT_ID is not explicitly exported in the environment, --project "${GOOGLE_ALT_PROJECT_ID}" may be empty. Should we extract it from the alternate credentials file if unset?
Side note: can we have someone familiar with this file verify that the fallback logic behaves as expected across all test pipelines?
There was a problem hiding this comment.
Done
Co-authored by AI Agent
There was a problem hiding this comment.
bshaffer could you please review the fallback logic in this file.
[Generated-by: AI]
Adds a PHP code sample demonstrating hierarchical namespace recursive folder delete.
Fixes: b/530059378
[Generated-by: AI]