Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a kwargs "add_to_user_agent" #8941

Closed
lmazuel opened this issue Dec 3, 2019 · 8 comments
Closed

Expose a kwargs "add_to_user_agent" #8941

lmazuel opened this issue Dec 3, 2019 · 8 comments
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.

Comments

@lmazuel
Copy link
Member

lmazuel commented Dec 3, 2019

Right now it's not possible to add anything to the user-agent unless you create your own policy UserAgentPolicy yourself, which means create your own pipeline.

@lmazuel lmazuel added Client This issue points to a problem in the data-plane of the library. Azure.Core labels Dec 3, 2019
@annatisch
Copy link
Member

We do support this per request:
https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/azure/core/pipeline/policies/_universal.py#L209

But you're right - seem that we (probably I) forgot to add it on init..... :)

@xiangyan99
Copy link
Member

Do you mean we want to expose "add_to_user_agent" for every pipeline run?

@lmazuel
Copy link
Member Author

lmazuel commented Jan 3, 2020

@annatisch yes, user_agent achieves this purpose, but we need one in init as you say :)
@xiangyan99 I don't understand your comment, as @annatisch says the idea is to have one in the init, so people can customize as a whole the user-agent, and not force them to do that per request

@jsntcy
Copy link
Member

jsntcy commented Jan 9, 2020

@xiangyan99 Previously we use something like "client.config.add_user_agent(UA_AGENT_1); client.config.add_user_agent(UA_AGENT_2)" to append our own user agents in Azure CLI code, after your PR #9355 , how can I use kwargs to achieve the same goal?
cc @lmazuel

@lmazuel
Copy link
Member Author

lmazuel commented Jan 9, 2020

@jsntcy the kwargs will be called "user_agent"

@jsntcy
Copy link
Member

jsntcy commented Jan 10, 2020

@lmazuel , so if I want to add two use agents as I did before like

client.config.add_user_agent(UA_AGENT_1)
client.config.add_user_agent(UA_AGENT_2)

do I need use as follows?

policy = UserAgentPolicy(),
policy.add_user_agent(UA_AGENT_1),
policy.add_user_agent(UA_AGENT_2),
kwargs['user_agent'] = policy
client(**kwargs)

@lmazuel
Copy link
Member Author

lmazuel commented Jan 10, 2020

Nope, you would have to build the string and pass one kwarg:

kwargs['user_agent'] = " ".join(UA_AGENT_1, UA_AGENT_2)
client(**kwargs)

You don't instantiate the UserAgentPolicy, that's internal

@xiangyan99
Copy link
Member

Fixed

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

No branches or pull requests

4 participants