18
18
from azure .core .credentials import TokenCredential
19
19
20
20
21
- class EventGridClientConfiguration : # pylint: disable=too-many-instance-attributes,name-too-long
21
+ class EventGridClientConfiguration : # pylint: disable=too-many-instance-attributes,name-too-long
22
22
"""Configuration for EventGridClient.
23
23
24
24
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
27
27
:param endpoint: The host name of the namespace, e.g.
28
28
namespaceName1.westus-1.eventgrid.azure.net. Required.
29
29
: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
31
31
AzureKeyCredential type or a TokenCredential type. Required.
32
32
:type credential: ~azure.core.credentials.AzureKeyCredential or
33
33
~azure.core.credentials.TokenCredential
@@ -37,13 +37,8 @@ class EventGridClientConfiguration: # pylint: disable=too-many-instance-attri
37
37
:paramtype api_version: str
38
38
"""
39
39
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" )
47
42
48
43
if endpoint is None :
49
44
raise ValueError ("Parameter 'endpoint' must not be None." )
@@ -53,30 +48,29 @@ def __init__(
53
48
self .endpoint = endpoint
54
49
self .credential = credential
55
50
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 ))
58
53
self .polling_interval = kwargs .get ("polling_interval" , 30 )
59
54
self ._configure (** kwargs )
60
55
61
56
def _infer_policy (self , ** kwargs ):
62
57
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" ):
65
62
return policies .BearerTokenCredentialPolicy (self .credential , * self .credential_scopes , ** kwargs )
66
63
raise TypeError (f"Unsupported credential: { self .credential } " )
67
64
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" )
81
75
if self .credential and not self .authentication_policy :
82
76
self .authentication_policy = self ._infer_policy (** kwargs )
0 commit comments