Skip to content

Commit ac573e1

Browse files
committed
fix(python): expose user_agent on the config
1 parent 2e894c9 commit ac573e1

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

playground/python/app/search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def main():
1313
client = SearchClientSync(
1414
environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY")
1515
)
16+
client._config.user_agent.add("playground")
17+
1618
print("client initialized", client)
1719

1820
try:

playground/python/poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/python/config.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class {{#lambda.pascalcase}}{{client}}{{/lambda.pascalcase}}Config(BaseConfig):
1414
def __init__(self, app_id: Optional[str], api_key: Optional[str]{{#hasRegionalHost}}, region: {{#fallbackToAliasHost}}Optional[str] = None{{/fallbackToAliasHost}}{{^fallbackToAliasHost}}str = ""{{/fallbackToAliasHost}}{{/hasRegionalHost}}) -> None:
1515
super().__init__(app_id, api_key)
1616

17-
user_agent = UserAgent().add("{{#lambda.pascalcase}}{{client}}{{/lambda.pascalcase}}")
17+
self.user_agent = UserAgent().add("{{#lambda.pascalcase}}{{client}}{{/lambda.pascalcase}}")
1818

1919
if app_id is None or not app_id:
2020
raise ValueError("`app_id` is missing.")
@@ -25,7 +25,7 @@ class {{#lambda.pascalcase}}{{client}}{{/lambda.pascalcase}}Config(BaseConfig):
2525
self.headers = {
2626
"x-algolia-application-id": app_id,
2727
"x-algolia-api-key": api_key,
28-
"user-agent": user_agent.get(),
28+
"user-agent": self.user_agent.get(),
2929
"content-type": "application/json",
3030
}
3131

0 commit comments

Comments
 (0)