Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EG] Regenerate Code #17053

Merged
merged 3 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 16 additions & 10 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ class SystemEventNames(str, Enum):
visit https://docs.microsoft.com/azure/event-grid/system-topics.
"""

ACSChatMemberAddedToThreadWithUserEventName = (
AcsChatMemberAddedToThreadWithUserEventName = (
Copy link
Contributor

@yunhaoling yunhaoling Mar 3, 2021

Choose a reason for hiding this comment

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

Is this something public in the previous release?
naming change seems to be a breaking change to me (although it's just ACS* to Acs*, probably something worth to mention in the changelog.

If those are just added in this release, then I have no concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was on fence to add this in the changelog, but i agree -updated

"Microsoft.Communication.ChatMemberAddedToThreadWithUser"
)
ACSChatMemberRemovedFromThreadWithUserEventName = (
AcsChatMemberRemovedFromThreadWithUserEventName = (
"Microsoft.Communication.ChatMemberRemovedFromThreadWithUser"
)
ACSChatMessageDeletedEventName = "Microsoft.Communication.ChatMessageDeleted"
ACSChatMessageEditedEventName = "Microsoft.Communication.ChatMessageEdited"
ACSChatMessageReceivedEventName = "Microsoft.Communication.ChatMessageReceived"
ACSChatThreadCreatedWithUserEventName = (
AcsChatMessageDeletedEventName = "Microsoft.Communication.ChatMessageDeleted"
AcsChatMessageEditedEventName = "Microsoft.Communication.ChatMessageEdited"
AcsChatMessageReceivedEventName = "Microsoft.Communication.ChatMessageReceived"
AcsChatThreadCreatedWithUserEventName = (
"Microsoft.Communication.ChatThreadCreatedWithUser"
)
ACSChatThreadPropertiesUpdatedPerUserEventName = (
AcsChatThreadPropertiesUpdatedPerUserEventName = (
"Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser"
)
ACSChatThreadWithUserDeletedEventName = (
AcsChatThreadWithUserDeletedEventName = (
"Microsoft.Communication.ChatThreadWithUserDeleted"
)
ACSSMSDeliveryReportReceivedEventName = (
AcsSmsDeliveryReportReceivedEventName = (
"Microsoft.Communication.SMSDeliveryReportReceived"
)
ACSSMSReceivedEventName = "Microsoft.Communication.SMSReceived"
AcsSmsReceivedEventName = "Microsoft.Communication.SMSReceived"
AppConfigurationKeyValueDeletedEventName = (
"Microsoft.AppConfiguration.KeyValueDeleted"
)
Expand Down Expand Up @@ -143,6 +143,12 @@ class SystemEventNames(str, Enum):
ServiceBusDeadletterMessagesAvailableWithNoListenerEventName = (
"Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener"
)
ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventName = (
"Microsoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotifications"
)
ServiceBusActiveMessagesAvailablePeriodicNotificationsEventName = (
"Microsoft.ServiceBus.ActiveMessagesAvailablePeriodicNotifications"
)
StorageBlobCreatedEventName = "Microsoft.Storage.BlobCreated"
StorageBlobDeletedEventName = "Microsoft.Storage.BlobDeleted"
StorageBlobRenamedEventName = "Microsoft.Storage.BlobRenamed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.pipeline.transport import HttpRequest, HttpResponse

from ._configuration import EventGridPublisherClientConfiguration
from .operations import EventGridPublisherClientOperationsMixin
from . import models
Expand All @@ -36,9 +38,25 @@ def __init__(

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)


def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
"""Runs the network request through the client's chained policies.

:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.HttpResponse
"""
http_request.url = self._client.format_url(http_request.url)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

def close(self):
# type: () -> None
self._client.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._event_grid_publisher_client_async import EventGridPublisherClient
from ._event_grid_publisher_client import EventGridPublisherClient
__all__ = ['EventGridPublisherClient']
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Any

from azure.core import AsyncPipelineClient
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from msrest import Deserializer, Serializer

from ._configuration import EventGridPublisherClientConfiguration
Expand All @@ -31,9 +32,24 @@ def __init__(

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)


async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
"""Runs the network request through the client's chained policies.

:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
"""
http_request.url = self._client.format_url(http_request.url)
stream = kwargs.pop("stream", True)
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

async def close(self) -> None:
await self._client.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
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.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
from ... import models as _models

T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
Expand All @@ -22,7 +22,7 @@ class EventGridPublisherClientOperationsMixin:
async def publish_events(
self,
topic_hostname: str,
events: List["models.EventGridEvent"],
events: List["_models.EventGridEvent"],
Copy link
Contributor

Choose a reason for hiding this comment

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

random question: how would this be rendered on doc/type hint?

wondering if users would get confused that how they create EventGridEvent from _models module.
(ignore me if this could be rendered corrected by python/sphinx)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not much concerned about this - this is an autogenerated method from swagger which is not used anywhere in our code. (we just need this in the swagger for the sake of other languages)

**kwargs
) -> None:
"""Publishes a batch of events to an Azure Event Grid topic.
Expand All @@ -37,7 +37,9 @@ async def publish_events(
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
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")
Expand Down Expand Up @@ -76,7 +78,7 @@ async def publish_events(
async def publish_cloud_event_events(
self,
topic_hostname: str,
events: List["models.CloudEvent"],
events: List["_models.CloudEvent"],
**kwargs
) -> None:
"""Publishes a batch of events to an Azure Event Grid topic.
Expand All @@ -91,7 +93,9 @@ async def publish_cloud_event_events(
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
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")
Expand Down Expand Up @@ -145,7 +149,9 @@ async def publish_custom_event_events(
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
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")
Expand Down
Loading