Skip to content

feat: add storage batch operations samples#2

Open
thiyaguk09 wants to merge 40 commits into
mainfrom
storagebatchoperations-samples
Open

feat: add storage batch operations samples#2
thiyaguk09 wants to merge 40 commits into
mainfrom
storagebatchoperations-samples

Conversation

@thiyaguk09

Copy link
Copy Markdown
Owner

Description

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Note: Any check with (dev), (experimental), or (legacy) can be ignored and should not block your PR from merging (see CI testing).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a set of new Node.js samples for Google Cloud Storage Batch Operations, covering essential functionalities like creating, retrieving, listing, canceling, and deleting jobs. My review highlights a recurring critical issue across all the new JavaScript files: asynchronous operations are not being properly awaited. This could cause the scripts to terminate prematurely before the operations complete. I have provided suggestions to refactor the code to use async/await correctly and implement a more robust error handling pattern. Additionally, I've noted a minor naming inconsistency in one file and a formatting issue in the package.json file.

Comment thread storagebatchoperations/listJobs.js
Comment thread storagebatchoperations/cancelJob.js
Comment thread storagebatchoperations/quickstart.js
Comment thread storagebatchoperations/getJob.js
Comment thread storagebatchoperations/createJob.js
Comment thread storagebatchoperations/deleteJob.js
Comment thread storagebatchoperations/listJobs.js
Comment thread storagebatchoperations/package.json Outdated
Comment thread storagebatchoperations/cancelJob.js
Comment thread storagebatchoperations/quickstart.js
@thiyaguk09 thiyaguk09 marked this pull request as ready for review September 12, 2025 07:18
@thiyaguk09 thiyaguk09 force-pushed the storagebatchoperations-samples branch from e7476df to c1d08bd Compare September 12, 2025 07:52
@thiyaguk09 thiyaguk09 force-pushed the storagebatchoperations-samples branch from c1d08bd to b424e2c Compare September 22, 2025 08:15
@thiyaguk09 thiyaguk09 force-pushed the storagebatchoperations-samples branch from fb51efe to 6f5d870 Compare October 17, 2025 13:38
…on & Error Handling)

Improve the robustness and clarity of the Storage Batch Operations API
samples:

* **Error Handling:** Wraps all asynchronous Batch Operations API
samples (Create, Get, List, Cancel) in `try...catch` blocks for
production readiness.
* **Specific Diagnostics:** Adds specific gRPC error code checks
(`NOT_FOUND`, `FAILED_PRECONDITION`) within the `catch` blocks to
provide detailed diagnostic feedback to users regarding job state or
non-existence.
* **Documentation:** Clarifies JSDoc for all function parameters (e.g.,
`projectId`, `jobId`, `objectPrefix`), ensuring examples and types are
clear for developers.
@thiyaguk09 thiyaguk09 force-pushed the storagebatchoperations-samples branch from 6f5d870 to 7dceecc Compare October 24, 2025 06:51
thiyaguk09 and others added 16 commits October 24, 2025 07:21
…orcement (GoogleCloudPlatform#4272)

* feat(storage): add samples and system tests for bucket encryption enforcement

Adds comprehensive code samples and system tests to verify
Google-managed,
Customer-managed, and Customer-supplied encryption enforcement logic.

- Add setBucketEncryptionEnforcementConfig.js sample
- Add getBucketEncryptionEnforcementConfig.js sample
- Add updateBucketEncryptionEnforcementConfig.js sample
- Add system tests to verify CLI output and backend metadata state
- Ensure server-side effectiveTime is correctly captured and displayed

* code refactor

* test(storage): refactor encryption tests to assert state over strings

* test: skip bucket encryption enforcement tests if defaultKmsKeyName is missing

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
…oudPlatform#4276)

* Feat(storage): add Object Contexts samples and system tests

- Add `setObjectContexts.js` to demonstrate CRUD and deletion of
contexts.
- Add `getObjectContexts.js` to show retrieval of structured metadata.
- Add `listObjectsWithContextFilter.js` to demonstrate server-side
filtering.
- Implement comprehensive system tests in `files.test.js` covering
  presence, absence (-), and existence (:) filter operators.
- Ensure samples use correct 'contexts' field with 'custom' map
structure.

* code refactor

* fix: typo corrections

* test(storage): refactor to state-based assertions

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
…using unique UUIDs (GoogleCloudPlatform#4320)

* test(secret-manager): fix ALREADY_EXISTS in delayed destroy tests by using unique UUIDs

* test(secret-manager): ensure resource cleanup on assertion failure using try-finally
…dPlatform#4317)

* test(talent): add explicit delay to wait for job indexing

* test(talent): move indexing delay to before hook to avoid waiting on every retry

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
…t api tests (GoogleCloudPlatform#4318)

* test(scc): fix concurrent modification error in custom module tests

* test(security-center): fix ALREADY_EXISTS resource leaks and unhandled API rejections

* chore(security-center): disable parallel test execution to prevent API concurrency collisions

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
angelcaamal and others added 19 commits June 1, 2026 12:31
…ples (GoogleCloudPlatform#4321)

* fix(genai): resolve module path and naming issues in count-tokens samples

* style: ensure consistent .js extension in require statements
…public access prevention (GoogleCloudPlatform#4327)

Co-authored-by: Jennifer Davis <sigje@google.com>
…sure conversation readiness (GoogleCloudPlatform#4322)

* fix: add delay to createAnalysis test to ensure conversation readiness

* fix: use delay helper for consistent analysis test stability

* test: increase delay in createAnalysis to improve CI stability

* test: refactor CreateAnalysis test to separate conversation creation into before hook

* fix: correct exponential backoff delay in tests to prevent RESOURCE_EXHAUSTED errors

* fix: resolve RESOURCE_EXHAUSTED quota errors in CI pipeline

* test: increase delays and backoff to fix flaky GCP quota errors

* test: add try-catch block to createAnalysis to expose hidden errors in CI

* test: skip on gRPC error 13 and reduce wait time in CI

- Intercept gRPC error 13 (INTERNAL) in createAnalysis test to skip execution and avoid false red pipelines.
- Keep default retry behavior for quota or other transient errors.
- Reduce initial setTimeout delay from 65s to 5s to optimize CI speed.

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
…vent 401 errors in CI pipeline (GoogleCloudPlatform#4325)

* fix: mock sendgrid SDK to prevent 401 errors in CI pipeline

* fix: mock sendgrid package and add payload assertions to function tests
…alidation (GoogleCloudPlatform#4313)

* fix(slack): replace deprecated @slack/events-api with native crypto validation

* fix(slack): inject fallback environment variables for unit test CI compatibility

* test(slack): apply code review feedback and add mock data for CI

* chore(slack): downgrade nock to v13 to support legacy Node.js versions in CI matrix

* refactor(slack): replace kgsearch callbacks with native async/await
…rors (GoogleCloudPlatform#4315)

* test(asset): add sleep retries to prevent RESOURCE_EXHAUSTED quota errors

* test(asset): removed unused Storage and BigQuery setup/teardown in org policy tests to reduce API quota consumption and execution time.

* test(asset): increase initial sleep timeout to 1 minute to mitigate ListAssets quota exhaustion

* test: add retry logic and skip fallback for ListAssets quota errors
…nai (GoogleCloudPlatform#4330)

* refactor: migrate countTokens samples to @google/genai, update config, and remove deprecated totalBillableCharacters

* refactor(samples): migrate function-calling samples to @google/genai using message structure for tool responses

* feat(generative-ai): migrate grounding samples to new GenAI SDK

* feat(generative-ai): migrate text and multimodal inference samples to @google/genai

* refactor(generative-ai): migrate first batch of inference samples to @google/genai and skip remaining tests

* refactor(generative-ai): update model to gemini-2.5-flash and fix streaming text accumulation
…#4177)

* feat(storagecontrol): Add samples for Storage Anywhere Cache

* add testcase

* lint fix

* fix: test case

* fix: remove cacheName

* skip test case

* test case remove projectId

* addressing review comments

* index on anywhere-cache-samples: e83ba77 addressing review comments

* feat(storage-control): Improve Anywhere Cache API samples

Improve Anywhere Cache API samples (Documentation & Error Handling)

* Wraps all asynchronous Anywhere Cache API samples (Create, Get, List,
Disable, Pause, Resume) in `try...catch` blocks for production
readiness.
* Adds specific gRPC error code checks (NOT_FOUND, FAILED_PRECONDITION)
to provide better diagnostic feedback to users.
* Clarifies documentation regarding the optional nature and default
values of `ttl` and `admissionPolicy` for cache creation.

* test(storagecontrol): Enhance Anywhere Cache test assertions and coverage

Updates tests for all Anywhere Cache management methods (Create, Get,
List, Resume, Disable, Pause) to align with enhanced sample script
output.

**(Tests were skipped due to reliance on Long-Running Operations (LROs)
in the sample code.)**

This includes:
* **Enhanced Assertions:** Asserting against all newly added detail
fields (e.g., Name, State, TTL) to verify full API response parsing in
Get and List samples.
* **Negative Scenario Coverage:** Adding explicit **negative scenario
tests** for state-dependent operations (Disable, Pause, Resume) to
assert graceful failure on expected errors like `FAILED_PRECONDITION`.

* Fix: Remove duplicate call to disableAnywhereCache

The function was being called twice due to an oversight during a recent try/catch restructure.

---------

Co-authored-by: Katie McLaughlin <katie@glasnt.com>
Co-authored-by: Jennifer Davis <sigje@google.com>
Co-authored-by: Chandra Shekhar Sirimala <chandrashekhar.siri@gmail.com>
…mentation (GoogleCloudPlatform#4332)

Co-authored-by: Angel Caamal <acaamalcanul@google.com>
Co-authored-by: Jennifer Davis <sigje@google.com>
…gle/genai (GoogleCloudPlatform#4331)

* refactor: migrate batch 2 generative-ai samples to @google/genai

* test: add LOCATION fallback and update model to gemini-2.5-flash in translate test

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
…udPlatform#4316)

* chore: remove unused datastore folder without region tags

* build: clean up dangling CI references to deleted datastore samples

* ci: temporarily restore datastore-functions.yaml to bypass zizmor

The datastore-functions samples and workflow were deleted in a previous commit. However, the Zizmor scanner fails with an 'invalid input' error when attempting to audit the deleted file from the PR diff. This commit restores a dummy workflow to unblock the CI pipeline until the scanning infrastructure is updated to ignore deleted files.

* chore: add missing Apache 2.0 copyright header to dummy workflow

* ci: add explicit permissions and trailing newline to satisfy CodeQL

---------

Co-authored-by: Jennifer Davis <sigje@google.com>
…nai folder (Batch 1)" (GoogleCloudPlatform#4339)

* Revert "refactor(genai): migrate region tags from generative-ai to genai folder (Batch 2) (GoogleCloudPlatform#4336)"

This reverts commit 7517761.

* Revert "refactor(genai): migrate region tags from generative-ai to genai folder (Batch 1) (GoogleCloudPlatform#4335)"

This reverts commit f2465a6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants