Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def __init__(self, base_url, **kwargs):
)
per_call_policies = kwargs.get('per_call_policies', [])
if isinstance(per_call_policies, Iterable):
per_call_policies.append(ARMAutoResourceProviderRegistrationPolicy())
per_call_policies = list(per_call_policies).append(ARMAutoResourceProviderRegistrationPolicy())
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix #18238 (comment)

append will fail if per_call_policies is a tuple, instead of a list:

AttributeError: 'tuple' object has no attribute 'append'

Convert to per_call_policies to a list first.

else:
per_call_policies = [per_call_policies,
ARMAutoResourceProviderRegistrationPolicy()]
kwargs["per_call_policies"] = per_call_policies
config = kwargs.get('config')
if not config.http_logging_policy:
config.http_logging_policy = kwargs.get('http_logging_policy', ARMHttpLoggingPolicy(**kwargs))
config.http_logging_policy = ARMHttpLoggingPolicy(**kwargs)
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix #18238 (comment)

We should forbid the usage of setting http_logging_policy with kwargs here, because it

Copy link
Member

Choose a reason for hiding this comment

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

We have a clear priority order which is config > kwargs > default one.

I would suggest we keeping it because we want to align the priority with others.

Copy link
Member Author

Choose a reason for hiding this comment

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

However, in specific client like SubscriptionClient, http_logging_policy in kwargs is firstly used to set self._config.http_logging_policy:

self._config = SubscriptionClientConfiguration(credential, **kwargs)

self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)

Then it is used as the http_logging_policy attribute of the PipelineClient:

if not config.http_logging_policy:
config.http_logging_policy = kwargs.get('http_logging_policy', ARMHttpLoggingPolicy(**kwargs))

So the priority/flow here is more like kwargs > config > default one.

Also, since PipelineClient doesn't take any policies from kwargs, why don't we remove the support for passing a http_logging_policy via kwargs to ARMPipelineClient as well, just to keep ARMPipelineClient simple (only config is supported)? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

In auto generated code (90% of the case), we will generate config which accept http_logging_policy. So http_logging_policy in kwargs works in most of the case except the one in azure-core.

kwargs["config"] = config
super(ARMPipelineClient, self).__init__(base_url, **kwargs)