Skip to content

Commit

Permalink
Make backwards compatible and update cookiecutter
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 6, 2024
1 parent d232fae commit dc7dcc7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ class Tap{{ cookiecutter.source_name }}({{ 'SQL' if cookiecutter.stream_type ==
default="https://api.mysample.com",
description="The url for the API service",
),
{%- if cookiecutter.stream_type in ("GraphQL", "REST") %}
th.Property(
"user_agent",
th.StringType,
description=(
"A custom User-Agent header to send with each request. Default is "
"'<tap_name>/<tap_version>'"
),
),
{%- endif %}
).to_dict()
{%- if cookiecutter.stream_type in ("GraphQL", "REST", "Other") %}

Expand Down
5 changes: 4 additions & 1 deletion singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def user_agent(self) -> str:
Returns:
The user agent string.
"""
return f"{self.tap_name}/{self._tap.plugin_version}"
return self.config.get(
"user_agent",
f"{self.tap_name}/{self._tap.plugin_version}",
)

def validate_response(self, response: requests.Response) -> None:
"""Validate HTTP response.
Expand Down

0 comments on commit dc7dcc7

Please sign in to comment.