fix: add field headers for other http verbs by busunkim96 · Pull Request #443 · googleapis/gapic-generator-python · GitHub
Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

fix: add field headers for other http verbs#443

Merged
software-dov merged 11 commits into
masterfrom
field-headers
Jun 9, 2020
Merged

fix: add field headers for other http verbs#443
software-dov merged 11 commits into
masterfrom
field-headers

Conversation

@busunkim96

@busunkim96 busunkim96 commented Jun 4, 2020

Copy link
Copy Markdown
Contributor

Closes #401

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 4, 2020

@software-dov software-dov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, just some nitpicky codegolf on my end :P
I'll look into why the tests are failing.

Comment thread gapic/schema/wrappers.py Outdated
Comment thread tests/unit/schema/wrappers/test_method.py Outdated
@software-dov

Copy link
Copy Markdown
Contributor

@codecov

codecov Bot commented Jun 9, 2020

Copy link
Copy Markdown

Codecov Report

Merging #443 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #443   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines         1453      1453           
  Branches       300       300           
=========================================
  Hits          1453      1453           
Impacted Files Coverage Δ
gapic/schema/wrappers.py 100.00% <100.00%> (ø)

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 decae37...8ed787d. Read the comment docs.

@busunkim96 busunkim96 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

with mock.patch.object(
type(client._transport.{{ method.name|snake_case }}),
'__call__') as call:
{% if method.void -%}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy-pasted from the unit test below this.

)
request = {{ method.input.ident }}()

{%- for field_header in method.field_headers %}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tweaking this slightly for field headers like "/v1beta1/{endpoint.name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}"

https://github.com/googleapis/googleapis/blob/52701da10fec2a5f9796e8d12518c0fe574488fe/google/cloud/servicedirectory/v1beta1/registration_service.proto#L171-L177

metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((
{%- for field_header in method.field_headers %}
{%- if not method.client_streaming %}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this for a failing showcase test (see streaming method in proto and failing test).

Not sure if this is the right call though. What's the correct way to handle metadata/headers for streaming methods? @software-dov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was under the impression that headers for streaming methods don't make a lot of sense because they're not tightly bound to http semantics. If that's not correct, then I think we would need to ask someone who knows better.

@busunkim96 busunkim96 requested a review from software-dov June 9, 2020 17:59

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was under the impression that headers for streaming methods don't make a lot of sense because they're not tightly bound to http semantics. If that's not correct, then I think we would need to ask someone who knows better.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated clients are missing routing headers

3 participants