44
44
EventGridPublisherClient as EventGridPublisherClientImpl ,
45
45
)
46
46
from ._policies import CloudEventDistributedTracingPolicy
47
+ from ._constants import DEFAULT_API_VERSION
47
48
from ._version import VERSION
48
49
49
50
if TYPE_CHECKING :
@@ -79,6 +80,9 @@ class EventGridPublisherClient(object): # pylint: disable=client-accepts-api-ver
79
80
implements SAS key authentication or SAS token authentication or a TokenCredential.
80
81
:type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.AzureSasCredential or
81
82
~azure.core.credentials.TokenCredential
83
+ :keyword api_version: Api Version. Will default to the most recent Api Version. Note that overriding this
84
+ default value may result in unsupported behavior.
85
+ :paramtype api_version: str
82
86
:rtype: None
83
87
84
88
.. admonition:: Example:
@@ -98,12 +102,19 @@ class EventGridPublisherClient(object): # pylint: disable=client-accepts-api-ver
98
102
:caption: Creating the EventGridPublisherClient with an endpoint and AzureSasCredential.
99
103
"""
100
104
101
- def __init__ (self , endpoint , credential , ** kwargs ):
102
- # type: (str, Union[AzureKeyCredential, AzureSasCredential, TokenCredential], Any) -> None
105
+ def __init__ (
106
+ self ,
107
+ endpoint : str ,
108
+ credential : Union ["AzureKeyCredential" , "AzureSasCredential" , "TokenCredential" ],
109
+ * ,
110
+ api_version : Optional [str ] = None ,
111
+ ** kwargs : Any
112
+ ) -> None :
103
113
self ._endpoint = endpoint
104
114
self ._client = EventGridPublisherClientImpl (
105
115
policies = EventGridPublisherClient ._policies (credential , ** kwargs ), ** kwargs
106
116
)
117
+ self ._api_version = api_version if api_version is not None else DEFAULT_API_VERSION
107
118
108
119
@staticmethod
109
120
def _policies (credential , ** kwargs ):
@@ -221,7 +232,9 @@ def send(
221
232
for event in events :
222
233
_eventgrid_data_typecheck (event )
223
234
response = self ._client .send_request ( # pylint: disable=protected-access
224
- _build_request (self ._endpoint , content_type , events , channel_name = channel_name ), ** kwargs
235
+ _build_request (
236
+ self ._endpoint ,content_type , events , channel_name = channel_name , api_version = self ._api_version ),
237
+ ** kwargs
225
238
)
226
239
error_map = {401 : ClientAuthenticationError , 404 : ResourceNotFoundError , 409 : ResourceExistsError }
227
240
if response .status_code != 200 :
0 commit comments