Skip to content

feat(compute): generate resource_name with sidekick#4826

Closed
haphungw wants to merge 3 commits intogoogleapis:mainfrom
haphungw:resource-name-showcase
Closed

feat(compute): generate resource_name with sidekick#4826
haphungw wants to merge 3 commits intogoogleapis:mainfrom
haphungw:resource-name-showcase

Conversation

@haphungw
Copy link
Copy Markdown
Contributor

@haphungw haphungw commented Feb 25, 2026

This PR is a demo of the generated Rust code for resource_name within google-cloud-compute-v1.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.01%. Comparing base (3727639) to head (2836b8c).
⚠️ Report is 52 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4826      +/-   ##
==========================================
- Coverage   95.02%   95.01%   -0.02%     
==========================================
  Files         204      204              
  Lines        7877     7877              
==========================================
- Hits         7485     7484       -1     
- Misses        392      393       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

haphungw added a commit to googleapis/librarian that referenced this pull request Feb 25, 2026
When generating the `Template` for resource names, the parser was incorrectly capturing preceding elements in the HTTP URL (e.g., `/v1`).

Adding `firstIndex` tracking allows the parser to identify when the valid `collection/id` chain begin.

The next PRs will add the necessary blocks in `transport.rs.mustache`.
The generated Rust snippets should look like something below:
```
#[cfg(google_cloud_unstable_resource_name)]
let options = if let Some(resource_name) = (|| {
    Some(format!(
        "//compute.googleapis.com/projects/{}/zones/{}/acceleratorTypes/{}",
        Some(&req)
            .map(|m| &m.project)
            .map(|s| s.as_str())
            .filter(|s| !s.is_empty())?,
        Some(&req)
            .map(|m| &m.zone)
            .map(|s| s.as_str())
            .filter(|s| !s.is_empty())?,
        Some(&req)
            .map(|m| &m.accelerator_type)
            .map(|s| s.as_str())
            .filter(|s| !s.is_empty())?,
    ))
})() {
    use google_cloud_gax::options::internal::{RequestOptionsExt, ResourceName};
    options.insert_extension(ResourceName(resource_name))
} else {
    options
};
```
Staged at: googleapis/google-cloud-rust#4826

For #4018
Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

nit: the PR title is wrong, and you may want to try DNS first, it would be easier to review.

@haphungw haphungw force-pushed the resource-name-showcase branch from c44b709 to 388343a Compare February 27, 2026 05:05
@haphungw haphungw changed the title feat(showcase): generate resource_name for compute feat(compute): generate resource_name with sidekick Feb 27, 2026
@haphungw haphungw force-pushed the resource-name-showcase branch from 388343a to 2836b8c Compare February 27, 2026 05:47
@haphungw haphungw closed this Mar 4, 2026
@haphungw haphungw deleted the resource-name-showcase branch April 17, 2026 17:07
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.

2 participants