From 7f151c8837b8cfc44f5ccc9ea552bb0da034925f Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 29 Sep 2021 15:41:32 -0700 Subject: [PATCH] New Events (#20951) * New Events * more generated code --- .../azure/eventgrid/_event_mappings.py | 34 ++++ .../_generated/_event_grid_client.py | 53 ----- .../aio/_event_grid_client_async.py | 45 ----- .../_generated/aio/operations/__init__.py | 13 -- ..._event_grid_publisher_client_operations.py | 188 ------------------ .../aio/operations_async/__init__.py | 13 -- .../_event_grid_client_operations_async.py | 185 ----------------- ..._grid_publisher_client_operations_async.py | 185 ----------------- .../models/_event_grid_client_enums.py | 104 ---------- .../_event_grid_publisher_client_enums.py | 159 --------------- .../swagger/postprocess_eventnames.py | 2 +- 11 files changed, 35 insertions(+), 946 deletions(-) delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/_event_grid_client.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/_event_grid_client_async.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/__init__.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/_event_grid_publisher_client_operations.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/__init__.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_client_operations_async.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_publisher_client_operations_async.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_client_enums.py delete mode 100644 sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_publisher_client_enums.py diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py index 315d8f7d0017..17f98d9a18ed 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py @@ -90,6 +90,38 @@ class SystemEventNames(str, Enum): AcsSmsReceivedEventName = 'Microsoft.Communication.SMSReceived' + AcsUserDisconnectedEventName = 'Microsoft.Communication.UserDisconnected' + + ApiManagementApiCreatedEventName = 'Microsoft.ApiManagement.ApiCreated' + + ApiManagementApiDeletedEventName = 'Microsoft.ApiManagement.ApiDeleted' + + ApiManagementApiReleaseCreatedEventName = 'Microsoft.ApiManagement.ApiReleaseCreated' + + ApiManagementApiReleaseDeletedEventName = 'Microsoft.ApiManagement.ApiReleaseDeleted' + + ApiManagementApiReleaseUpdatedEventName = 'Microsoft.ApiManagement.ApiReleaseUpdated' + + ApiManagementApiUpdatedEventName = 'Microsoft.ApiManagement.ApiUpdated' + + ApiManagementProductCreatedEventName = 'Microsoft.ApiManagement.ProductCreated' + + ApiManagementProductDeletedEventName = 'Microsoft.ApiManagement.ProductDeleted' + + ApiManagementProductUpdatedEventName = 'Microsoft.ApiManagement.ProductUpdated' + + ApiManagementSubscriptionCreatedEventName = 'Microsoft.ApiManagement.SubscriptionCreated' + + ApiManagementSubscriptionDeletedEventName = 'Microsoft.ApiManagement.SubscriptionDeleted' + + ApiManagementSubscriptionUpdatedEventName = 'Microsoft.ApiManagement.SubscriptionUpdated' + + ApiManagementUserCreatedEventName = 'Microsoft.ApiManagement.UserCreated' + + ApiManagementUserDeletedEventName = 'Microsoft.ApiManagement.UserDeleted' + + ApiManagementUserUpdatedEventName = 'Microsoft.ApiManagement.UserUpdated' + AppConfigurationKeyValueDeletedEventName = 'Microsoft.AppConfiguration.KeyValueDeleted' AppConfigurationKeyValueModifiedEventName = 'Microsoft.AppConfiguration.KeyValueModified' @@ -186,6 +218,8 @@ class SystemEventNames(str, Enum): MediaJobStateChangeEventName = 'Microsoft.Media.JobStateChange' + MediaLiveEventChannelArchiveHeartbeatEventName = 'Microsoft.Media.LiveEventChannelArchiveHeartbeatEventData' + MediaLiveEventConnectionRejectedEventName = 'Microsoft.Media.LiveEventConnectionRejected' MediaLiveEventEncoderConnectedEventName = 'Microsoft.Media.LiveEventEncoderConnected' diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/_event_grid_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/_event_grid_client.py deleted file mode 100644 index 408cab537fbf..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/_event_grid_client.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -from ._configuration import EventGridClientConfiguration -from .operations import EventGridClientOperationsMixin -from . import models - - -class EventGridClient(EventGridClientOperationsMixin): - """EventGrid Python Publisher Client. - - """ - - def __init__( - self, - **kwargs # type: Any - ): - # type: (...) -> None - base_url = 'https://{topicHostname}' - self._config = EventGridClientConfiguration(**kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> EventGridClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/_event_grid_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/_event_grid_client_async.py deleted file mode 100644 index 62cb5f1a2644..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/_event_grid_client_async.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core import AsyncPipelineClient -from msrest import Deserializer, Serializer - -from ._configuration_async import EventGridClientConfiguration -from .operations_async import EventGridClientOperationsMixin -from .. import models - - -class EventGridClient(EventGridClientOperationsMixin): - """EventGrid Python Publisher Client. - - """ - - def __init__( - self, - **kwargs: Any - ) -> None: - base_url = 'https://{topicHostname}' - self._config = EventGridClientConfiguration(**kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "EventGridClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/__init__.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/__init__.py deleted file mode 100644 index 842b4ec6d735..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._event_grid_publisher_client_operations import EventGridPublisherClientOperationsMixin - -__all__ = [ - 'EventGridPublisherClientOperationsMixin', -] diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/_event_grid_publisher_client_operations.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/_event_grid_publisher_client_operations.py deleted file mode 100644 index a2a3ee562e89..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations/_event_grid_publisher_client_operations.py +++ /dev/null @@ -1,188 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class EventGridPublisherClientOperationsMixin: - - async def publish_events( - self, - topic_hostname: str, - events: List["_models.EventGridEvent"], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[~event_grid_publisher_client.models.EventGridEvent] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.publish_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[EventGridEvent]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_events.metadata = {'url': '/api/events'} # type: ignore - - async def publish_cloud_event_events( - self, - topic_hostname: str, - events: List["_models.CloudEvent"], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[~event_grid_publisher_client.models.CloudEvent] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/cloudevents-batch+json; charset=utf-8") - - # Construct URL - url = self.publish_cloud_event_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[CloudEvent]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_cloud_event_events.metadata = {'url': '/api/events'} # type: ignore - - async def publish_custom_event_events( - self, - topic_hostname: str, - events: List[object], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[object] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.publish_custom_event_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[object]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_custom_event_events.metadata = {'url': '/api/events'} # type: ignore diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/__init__.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/__init__.py deleted file mode 100644 index f0c46bab822e..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._event_grid_publisher_client_operations_async import EventGridPublisherClientOperationsMixin - -__all__ = [ - 'EventGridPublisherClientOperationsMixin', -] diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_client_operations_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_client_operations_async.py deleted file mode 100644 index 06b8eee9b289..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_client_operations_async.py +++ /dev/null @@ -1,185 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class EventGridClientOperationsMixin: - - async def publish_events( - self, - topic_hostname: str, - events: List["models.EventGridEvent"], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[~event_grid_client.models.EventGridEvent] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.publish_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[EventGridEvent]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_events.metadata = {'url': '/api/events'} # type: ignore - - async def publish_cloud_event_events( - self, - topic_hostname: str, - events: List["models.CloudEvent"], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[~event_grid_client.models.CloudEvent] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/cloudevents-batch+json; charset=utf-8") - - # Construct URL - url = self.publish_cloud_event_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[CloudEvent]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_cloud_event_events.metadata = {'url': '/api/events'} # type: ignore - - async def publish_custom_event_events( - self, - topic_hostname: str, - events: List[object], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[object] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.publish_custom_event_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[object]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_custom_event_events.metadata = {'url': '/api/events'} # type: ignore diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_publisher_client_operations_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_publisher_client_operations_async.py deleted file mode 100644 index 15c54919f3af..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/_event_grid_publisher_client_operations_async.py +++ /dev/null @@ -1,185 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class EventGridPublisherClientOperationsMixin: - - async def publish_events( - self, - topic_hostname: str, - events: List["models.EventGridEvent"], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[~event_grid_publisher_client.models.EventGridEvent] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.publish_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[EventGridEvent]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_events.metadata = {'url': '/api/events'} # type: ignore - - async def publish_cloud_event_events( - self, - topic_hostname: str, - events: List["models.CloudEvent"], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[~event_grid_publisher_client.models.CloudEvent] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/cloudevents-batch+json; charset=utf-8") - - # Construct URL - url = self.publish_cloud_event_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[CloudEvent]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_cloud_event_events.metadata = {'url': '/api/events'} # type: ignore - - async def publish_custom_event_events( - self, - topic_hostname: str, - events: List[object], - **kwargs - ) -> None: - """Publishes a batch of events to an Azure Event Grid topic. - - :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net. - :type topic_hostname: str - :param events: An array of events to be published to Event Grid. - :type events: list[object] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.publish_custom_event_events.metadata['url'] # type: ignore - path_format_arguments = { - 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(events, '[object]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - publish_custom_event_events.metadata = {'url': '/api/events'} # type: ignore diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_client_enums.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_client_enums.py deleted file mode 100644 index ae2189a9dc2b..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_client_enums.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AppAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of action of the operation. - """ - - RESTARTED = "Restarted" #: Web app was restarted. - STOPPED = "Stopped" #: Web app was stopped. - CHANGED_APP_SETTINGS = "ChangedAppSettings" #: There was an operation to change app setting on the web app. - STARTED = "Started" #: The job has started. - COMPLETED = "Completed" #: The job has completed. - FAILED = "Failed" #: The job has failed to complete. - -class AppServicePlanAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of action on the app service plan. - """ - - UPDATED = "Updated" #: App Service plan is being updated. - -class AsyncStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Asynchronous operation status of the operation on the app service plan. - """ - - STARTED = "Started" #: Async operation has started. - COMPLETED = "Completed" #: Async operation has completed. - FAILED = "Failed" #: Async operation failed to complete. - -class MediaJobErrorCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Helps with categorization of errors. - """ - - SERVICE = "Service" #: The error is service related. - DOWNLOAD = "Download" #: The error is download related. - UPLOAD = "Upload" #: The error is upload related. - CONFIGURATION = "Configuration" #: The error is configuration related. - CONTENT = "Content" #: The error is related to data in the input files. - -class MediaJobErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Error code describing the error. - """ - - SERVICE_ERROR = "ServiceError" #: Fatal service error, please contact support. - SERVICE_TRANSIENT_ERROR = "ServiceTransientError" #: Transient error, please retry, if retry is unsuccessful, please contact support. - DOWNLOAD_NOT_ACCESSIBLE = "DownloadNotAccessible" #: While trying to download the input files, the files were not accessible, please check the availability of the source. - DOWNLOAD_TRANSIENT_ERROR = "DownloadTransientError" #: While trying to download the input files, there was an issue during transfer (storage service, network errors), see details and check your source. - UPLOAD_NOT_ACCESSIBLE = "UploadNotAccessible" #: While trying to upload the output files, the destination was not reachable, please check the availability of the destination. - UPLOAD_TRANSIENT_ERROR = "UploadTransientError" #: While trying to upload the output files, there was an issue during transfer (storage service, network errors), see details and check your destination. - CONFIGURATION_UNSUPPORTED = "ConfigurationUnsupported" #: There was a problem with the combination of input files and the configuration settings applied, fix the configuration settings and retry with the same input, or change input to match the configuration. - CONTENT_MALFORMED = "ContentMalformed" #: There was a problem with the input content (for example: zero byte files, or corrupt/non-decodable files), check the input files. - CONTENT_UNSUPPORTED = "ContentUnsupported" #: There was a problem with the format of the input (not valid media file, or an unsupported file/codec), check the validity of the input files. - -class MediaJobRetry(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact - Azure support via Azure Portal. - """ - - DO_NOT_RETRY = "DoNotRetry" #: Issue needs to be investigated and then the job resubmitted with corrections or retried once the underlying issue has been corrected. - MAY_RETRY = "MayRetry" #: Issue may be resolved after waiting for a period of time and resubmitting the same Job. - -class MediaJobState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The previous state of the Job. - """ - - CANCELED = "Canceled" #: The job was canceled. This is a final state for the job. - CANCELING = "Canceling" #: The job is in the process of being canceled. This is a transient state for the job. - ERROR = "Error" #: The job has encountered an error. This is a final state for the job. - FINISHED = "Finished" #: The job is finished. This is a final state for the job. - PROCESSING = "Processing" #: The job is processing. This is a transient state for the job. - QUEUED = "Queued" #: The job is in a queued state, waiting for resources to become available. This is a transient state. - SCHEDULED = "Scheduled" #: The job is being scheduled to run on an available resource. This is a transient state, between queued and processing states. - -class StampKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Kind of environment where app service plan is. - """ - - PUBLIC = "Public" #: App Service Plan is running on a public stamp. - ASE_V1 = "AseV1" #: App Service Plan is running on an App Service Environment V1. - ASE_V2 = "AseV2" #: App Service Plan is running on an App Service Environment V2. diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_publisher_client_enums.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_publisher_client_enums.py deleted file mode 100644 index 31d1e2d6d0ff..000000000000 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/models/_event_grid_publisher_client_enums.py +++ /dev/null @@ -1,159 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AppAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of action of the operation. - """ - - #: Web app was restarted. - RESTARTED = "Restarted" - #: Web app was stopped. - STOPPED = "Stopped" - #: There was an operation to change app setting on the web app. - CHANGED_APP_SETTINGS = "ChangedAppSettings" - #: The job has started. - STARTED = "Started" - #: The job has completed. - COMPLETED = "Completed" - #: The job has failed to complete. - FAILED = "Failed" - -class AppServicePlanAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of action on the app service plan. - """ - - #: App Service plan is being updated. - UPDATED = "Updated" - -class AsyncStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Asynchronous operation status of the operation on the app service plan. - """ - - #: Async operation has started. - STARTED = "Started" - #: Async operation has completed. - COMPLETED = "Completed" - #: Async operation failed to complete. - FAILED = "Failed" - -class CommunicationCloudEnvironmentModel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The cloud that the identifier belongs to. - """ - - PUBLIC = "public" - DOD = "dod" - GCCH = "gcch" - -class MediaJobErrorCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Helps with categorization of errors. - """ - - #: The error is service related. - SERVICE = "Service" - #: The error is download related. - DOWNLOAD = "Download" - #: The error is upload related. - UPLOAD = "Upload" - #: The error is configuration related. - CONFIGURATION = "Configuration" - #: The error is related to data in the input files. - CONTENT = "Content" - -class MediaJobErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Error code describing the error. - """ - - #: Fatal service error, please contact support. - SERVICE_ERROR = "ServiceError" - #: Transient error, please retry, if retry is unsuccessful, please contact support. - SERVICE_TRANSIENT_ERROR = "ServiceTransientError" - #: While trying to download the input files, the files were not accessible, please check the - #: availability of the source. - DOWNLOAD_NOT_ACCESSIBLE = "DownloadNotAccessible" - #: While trying to download the input files, there was an issue during transfer (storage service, - #: network errors), see details and check your source. - DOWNLOAD_TRANSIENT_ERROR = "DownloadTransientError" - #: While trying to upload the output files, the destination was not reachable, please check the - #: availability of the destination. - UPLOAD_NOT_ACCESSIBLE = "UploadNotAccessible" - #: While trying to upload the output files, there was an issue during transfer (storage service, - #: network errors), see details and check your destination. - UPLOAD_TRANSIENT_ERROR = "UploadTransientError" - #: There was a problem with the combination of input files and the configuration settings applied, - #: fix the configuration settings and retry with the same input, or change input to match the - #: configuration. - CONFIGURATION_UNSUPPORTED = "ConfigurationUnsupported" - #: There was a problem with the input content (for example: zero byte files, or corrupt/non- - #: decodable files), check the input files. - CONTENT_MALFORMED = "ContentMalformed" - #: There was a problem with the format of the input (not valid media file, or an unsupported - #: file/codec), check the validity of the input files. - CONTENT_UNSUPPORTED = "ContentUnsupported" - -class MediaJobRetry(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact - Azure support via Azure Portal. - """ - - #: Issue needs to be investigated and then the job resubmitted with corrections or retried once - #: the underlying issue has been corrected. - DO_NOT_RETRY = "DoNotRetry" - #: Issue may be resolved after waiting for a period of time and resubmitting the same Job. - MAY_RETRY = "MayRetry" - -class MediaJobState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The previous state of the Job. - """ - - #: The job was canceled. This is a final state for the job. - CANCELED = "Canceled" - #: The job is in the process of being canceled. This is a transient state for the job. - CANCELING = "Canceling" - #: The job has encountered an error. This is a final state for the job. - ERROR = "Error" - #: The job is finished. This is a final state for the job. - FINISHED = "Finished" - #: The job is processing. This is a transient state for the job. - PROCESSING = "Processing" - #: The job is in a queued state, waiting for resources to become available. This is a transient - #: state. - QUEUED = "Queued" - #: The job is being scheduled to run on an available resource. This is a transient state, between - #: queued and processing states. - SCHEDULED = "Scheduled" - -class StampKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Kind of environment where app service plan is. - """ - - #: App Service Plan is running on a public stamp. - PUBLIC = "Public" - #: App Service Plan is running on an App Service Environment V1. - ASE_V1 = "AseV1" - #: App Service Plan is running on an App Service Environment V2. - ASE_V2 = "AseV2" diff --git a/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py b/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py index 65f8c22ce283..15b0bc4b1714 100644 --- a/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py +++ b/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py @@ -46,7 +46,7 @@ def generate_enum_content(tuples): print(k + " = '" + v + "'\n") print("# backward compat names end here.") for tup in tup_list: - print(tup[0] + " = '" + tup[1] + "'\n") + print(tup[0] + " = '" + tup[1].replace('API', 'Api') + "'\n") print("# servicebus alias") print("ServiceBusDeadletterMessagesAvailableWithNoListenerEventName = 'Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners'")