1818 from azure .core .credentials import TokenCredential
1919
2020
21- class EventGridClientConfiguration : # pylint: disable=too-many-instance-attributes,name-too-long
21+ class EventGridClientConfiguration : # pylint: disable=too-many-instance-attributes,name-too-long
2222 """Configuration for EventGridClient.
2323
2424 Note that all parameters used to create this instance are saved as instance
@@ -27,7 +27,7 @@ class EventGridClientConfiguration: # pylint: disable=too-many-instance-attri
2727 :param endpoint: The host name of the namespace, e.g.
2828 namespaceName1.westus-1.eventgrid.azure.net. Required.
2929 :type endpoint: str
30- :param credential: Credential needed for the client to connect to Azure . Is either a
30+ :param credential: Credential used to authenticate requests to the service . Is either a
3131 AzureKeyCredential type or a TokenCredential type. Required.
3232 :type credential: ~azure.core.credentials.AzureKeyCredential or
3333 ~azure.core.credentials.TokenCredential
@@ -37,13 +37,8 @@ class EventGridClientConfiguration: # pylint: disable=too-many-instance-attri
3737 :paramtype api_version: str
3838 """
3939
40- def __init__ (
41- self ,
42- endpoint : str ,
43- credential : Union [AzureKeyCredential , "TokenCredential" ],
44- ** kwargs : Any
45- ) -> None :
46- api_version : str = kwargs .pop ('api_version' , "2023-10-01-preview" )
40+ def __init__ (self , endpoint : str , credential : Union [AzureKeyCredential , "TokenCredential" ], ** kwargs : Any ) -> None :
41+ api_version : str = kwargs .pop ("api_version" , "2023-10-01-preview" )
4742
4843 if endpoint is None :
4944 raise ValueError ("Parameter 'endpoint' must not be None." )
@@ -53,30 +48,29 @@ def __init__(
5348 self .endpoint = endpoint
5449 self .credential = credential
5550 self .api_version = api_version
56- self .credential_scopes = kwargs .pop (' credential_scopes' , [' https://eventgrid.azure.net/.default' ])
57- kwargs .setdefault (' sdk_moniker' , ' eventgrid/{}' .format (VERSION ))
51+ self .credential_scopes = kwargs .pop (" credential_scopes" , [" https://eventgrid.azure.net/.default" ])
52+ kwargs .setdefault (" sdk_moniker" , " eventgrid/{}" .format (VERSION ))
5853 self .polling_interval = kwargs .get ("polling_interval" , 30 )
5954 self ._configure (** kwargs )
6055
6156 def _infer_policy (self , ** kwargs ):
6257 if isinstance (self .credential , AzureKeyCredential ):
63- return policies .AzureKeyCredentialPolicy (self .credential , "Authorization" , prefix = "SharedAccessKey" , ** kwargs )
64- if hasattr (self .credential , 'get_token' ):
58+ return policies .AzureKeyCredentialPolicy (
59+ self .credential , "Authorization" , prefix = "SharedAccessKey" , ** kwargs
60+ )
61+ if hasattr (self .credential , "get_token" ):
6562 return policies .BearerTokenCredentialPolicy (self .credential , * self .credential_scopes , ** kwargs )
6663 raise TypeError (f"Unsupported credential: { self .credential } " )
6764
68- def _configure (
69- self ,
70- ** kwargs : Any
71- ) -> None :
72- self .user_agent_policy = kwargs .get ('user_agent_policy' ) or policies .UserAgentPolicy (** kwargs )
73- self .headers_policy = kwargs .get ('headers_policy' ) or policies .HeadersPolicy (** kwargs )
74- self .proxy_policy = kwargs .get ('proxy_policy' ) or policies .ProxyPolicy (** kwargs )
75- self .logging_policy = kwargs .get ('logging_policy' ) or policies .NetworkTraceLoggingPolicy (** kwargs )
76- self .http_logging_policy = kwargs .get ('http_logging_policy' ) or policies .HttpLoggingPolicy (** kwargs )
77- self .custom_hook_policy = kwargs .get ('custom_hook_policy' ) or policies .CustomHookPolicy (** kwargs )
78- self .redirect_policy = kwargs .get ('redirect_policy' ) or policies .RedirectPolicy (** kwargs )
79- self .retry_policy = kwargs .get ('retry_policy' ) or policies .RetryPolicy (** kwargs )
80- self .authentication_policy = kwargs .get ('authentication_policy' )
65+ def _configure (self , ** kwargs : Any ) -> None :
66+ self .user_agent_policy = kwargs .get ("user_agent_policy" ) or policies .UserAgentPolicy (** kwargs )
67+ self .headers_policy = kwargs .get ("headers_policy" ) or policies .HeadersPolicy (** kwargs )
68+ self .proxy_policy = kwargs .get ("proxy_policy" ) or policies .ProxyPolicy (** kwargs )
69+ self .logging_policy = kwargs .get ("logging_policy" ) or policies .NetworkTraceLoggingPolicy (** kwargs )
70+ self .http_logging_policy = kwargs .get ("http_logging_policy" ) or policies .HttpLoggingPolicy (** kwargs )
71+ self .custom_hook_policy = kwargs .get ("custom_hook_policy" ) or policies .CustomHookPolicy (** kwargs )
72+ self .redirect_policy = kwargs .get ("redirect_policy" ) or policies .RedirectPolicy (** kwargs )
73+ self .retry_policy = kwargs .get ("retry_policy" ) or policies .RetryPolicy (** kwargs )
74+ self .authentication_policy = kwargs .get ("authentication_policy" )
8175 if self .credential and not self .authentication_policy :
8276 self .authentication_policy = self ._infer_policy (** kwargs )
0 commit comments