Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Fix compute resource parsing #2478

Merged
merged 6 commits into from
Dec 13, 2018
Merged

Conversation

andreamlin
Copy link
Contributor

@andreamlin andreamlin commented Dec 11, 2018

Fixes googleapis/google-cloud-java#3604.

All these changes have already been reviewed in #2474 and #2402; now I would like to merge these changes into the master branch (they were previously only merged onto the branch origin/fix_compute_resource_parsing).

This PR is used to generate googleapis/google-cloud-java#4213 and googleapis/discovery-artifact-manager#102. All three of these PR will have to be signed off, and then we can merge them all around at the same time. (First we would merge the discovery-artifact-manager PR so that the CircleCI job compute-discovery-test will pass).

andreamlin and others added 3 commits December 10, 2018 16:00
Partially addresses googleapis/google-cloud-java#3604.

Don't force pathtemplate strings to start with a literal string.

The status quo, for path templates, is to magically append a literal string to templated paths that begin with a bracketed string, e.g. the path {project}/zones/{zone} is rendered as projects/{project}/zones/{zone}. I don't remember exactly why we decided to do this, though it may have been related to purity of usage of PathTemplates, where all existing Google grpc path templates start with a projects (or possibly organizations) substring.

More importantly, this PR allows us to parse a resource string returned from the server (see issue googleapis/google-cloud-java#3604), which often looks like https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}. The compute.v1.json Discovery API specifies that the baseUrl is exactly https://www.googleapis.com/compute/v1/projects. We can then take a resource string from the server, remove the given baseUrl prefix, and then parse the remaining suffix {project}/zones/{zone} into a ProjectsZoneName.

See googleapis/google-cloud-java#3899 and googleapis/discovery-artifact-manager#95 for the resulting surface diffs from this generator change.
@andreamlin
Copy link
Contributor Author

@pongad PTAL

@codecov-io
Copy link

codecov-io commented Dec 13, 2018

Codecov Report

Merging #2478 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2478      +/-   ##
============================================
+ Coverage     86.77%   86.77%   +<.01%     
  Complexity     5367     5367              
============================================
  Files           459      459              
  Lines         21186    21183       -3     
  Branches       2309     2308       -1     
============================================
- Hits          18384    18382       -2     
  Misses         1975     1975              
+ Partials        827      826       -1
Impacted Files Coverage Δ Complexity Δ
...degen/viewmodel/StaticLangApiResourceNameView.java 75% <ø> (ø) 2 <0> (ø) ⬇️
...degen/discogapic/transformer/DiscoGapicParser.java 92.72% <ø> (+1.2%) 22 <0> (ø) ⬇️
...a/JavaDiscoGapicResourceNameToViewTransformer.java 100% <100%> (ø) 15 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9cc7b7...e0f99a4. Read the comment docs.

@andreamlin andreamlin merged commit 8818cce into master Dec 13, 2018
@andreamlin andreamlin deleted the fix_compute_resource_parsing branch February 21, 2019 23:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compute API v1: xxxResourceName.parse throws ValidationException
3 participants