Skip to content

Commit

Permalink
Merge from upstream master
Browse files Browse the repository at this point in the history
  • Loading branch information
KieranBrantnerMagee committed Sep 8, 2020
2 parents 2e0b7b4 + 3b1432a commit 1b02419
Show file tree
Hide file tree
Showing 231 changed files with 5,334 additions and 4,496 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/sdk/identity/ @chlowell @schaabs

# PRLabel: %Event Hubs
/sdk/eventhub/ @annatisch @yunhaoling @YijunXieMS
/sdk/eventhub/ @annatisch @yunhaoling @KieranBrantnerMagee

# PRLabel: %Storage
/sdk/storage/ @amishra-dev @zezha-msft @annatisch @rakshith91 @xiafu-msft @tasherif-msft @kasobol-msft
Expand Down Expand Up @@ -77,7 +77,7 @@
/sql/sql/ @jaredmoo

# PRLabel: %Service Bus
/sdk/servicebus/ @annatisch @yunhaoling @YijunXieMS @KieranBrantnerMagee
/sdk/servicebus/ @annatisch @yunhaoling @KieranBrantnerMagee

# PRLabel: %Synapse
/sdk/synapse/ @aim-for-better @idear1203
Expand Down
4 changes: 2 additions & 2 deletions eng/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ The 'Sync eng/common directory' PRs will be created in the language repositories
3. More changes pushed to the **Tools PR**, will automatically triggered new pipeline runs in the respective **Sync PRs**. The **Sync PRs** are used to make sure the changes would not break any of the connected pipelines.
4. Once satisfied with the changes;
- First make sure all checks in the **Sync PRs** are green and approved. The **Tools PR** contains links to all the **Sync PRs**. If for some reason the PRs is blocked by a CI gate get someone with permission to override and manually merge the PR.
- To test the state of all the **Sync PRs**, you can download the `PRsCreated.txt` artifact from the `azure-sdk-tools - sync - eng-common` pipeline, with that run the [Verify-And-Merge-PRs.ps1](https://github.com/Azure/azure-sdk-tools/blob/master/scripts/powershell/Verify-And-Merge-PRs.ps1) passing the downloaded `PRsCreated.txt` file path for `PRDataArtifactPath` and `false` to `ShouldMerge`.
- Next approve the `VerifyAndMerge` job for the `azure-sdk-tools - sync - eng-common` pipeline triggered by your **Tools PR** which will automatically merge all the **Sync PRs**. You need `azure-sdk` devops contributor permissions to reach the `azure-sdk-tools - sync - eng-common` pipeline.
- To test the state of all the **Sync PRs**, you can download the `PRsCreated.txt` artifact from your `azure-sdk-tools - sync - eng-common` pipeline, then run `./eng/scripts/Verify-And-Merge.ps1 <path to PRsCreated.txt>` which will output the status of each associated PR.
- Next approve the `VerifyAndMerge` job for the `azure-sdk-tools - sync - eng-common` pipeline triggered by your **Tools PR** which will automatically merge all the **Sync PRs**. You need `azure-sdk` devops contributor permissions to reach the `azure-sdk-tools - sync - eng-common` pipeline.
- Finally merge the **Tools PR**.
1 change: 0 additions & 1 deletion eng/tox/allowed_pylint_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"azure-common",
"azure-nspkg",
"azure-servicemanagement-legacy",
"azure-eventgrid",
"azure-graphrbac",
"azure-loganalytics",
"azure-servicefabric",
Expand Down
3 changes: 3 additions & 0 deletions sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

-------------------

## 1.1.1 (Unreleased)


## 1.1.0 (2020-09-08)

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Licensed under the MIT License.
# ------------------------------------

VERSION = "1.1.0"
VERSION = "1.1.1"
3 changes: 3 additions & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# Release History

## 1.8.2 (Unreleased)


## 1.8.1 (2020-09-08)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "1.8.1"
VERSION = "1.8.2"
2 changes: 1 addition & 1 deletion sdk/eventgrid/azure-eventgrid/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
6 changes: 3 additions & 3 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from ._publisher_client import EventGridPublisherClient
from ._consumer import EventGridConsumer
from ._helpers import generate_shared_access_signature
from ._models import CloudEvent, CustomEvent, EventGridEvent, StorageBlobCreatedEventData
from ._models import CloudEvent, CustomEvent, EventGridEvent
from ._shared_access_signature_credential import EventGridSharedAccessSignatureCredential
from ._version import VERSION

__all__ = ['EventGridPublisherClient', 'EventGridConsumer',
'CloudEvent', 'CustomEvent', 'EventGridEvent', 'StorageBlobCreatedEventData',
'generate_shared_access_signature', 'EventGridSharedAccessSignatureCredential']
'CloudEvent', 'CustomEvent', 'EventGridEvent', 'generate_shared_access_signature',
'EventGridSharedAccessSignatureCredential']
__version__ = VERSION
43 changes: 21 additions & 22 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,21 @@
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING
import json
import six
import logging

from azure.core import PipelineClient
from msrest import Deserializer, Serializer
from ._models import CloudEvent, EventGridEvent

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

_LOGGER = logging.getLogger(__name__)

from ._models import CloudEvent, EventGridEvent

class EventGridConsumer(object):
"""
A consumer responsible for deserializing event handler messages, to allow for access to strongly typed Event objects.
A consumer responsible for deserializing event handler messages, to allow for
access to strongly typed Event objects.
"""
def decode_cloud_event(self, cloud_event, **kwargs):
def decode_cloud_event(self, cloud_event, **kwargs): # pylint: disable=no-self-use
# type: (Union[str, dict, bytes], Any) -> CloudEvent
"""Single event following CloudEvent schema will be parsed and returned as Deserialized Event.
:param cloud_event: The event to be deserialized.
Expand All @@ -37,17 +32,19 @@ def decode_cloud_event(self, cloud_event, **kwargs):
"""
encode = kwargs.pop('encoding', 'utf-8')
try:
cloud_event = CloudEvent._from_json(cloud_event, encode)
deserialized_event = CloudEvent._from_generated(cloud_event)
CloudEvent._deserialize_data(deserialized_event, deserialized_event.type)
return deserialized_event
cloud_event = CloudEvent._from_json(cloud_event, encode) # pylint: disable=protected-access
deserialized_event = CloudEvent._from_generated(cloud_event) # pylint: disable=protected-access
CloudEvent._deserialize_data(deserialized_event, deserialized_event.type) # pylint: disable=protected-access
return deserialized_event
except Exception as err:
_LOGGER.error('Error: cannot deserialize event. Event does not have a valid format. Event must be a string, dict, or bytes following the CloudEvent schema.')
_LOGGER.error('Your event: {}'.format(cloud_event))
_LOGGER.error('Error: cannot deserialize event. Event does not have a valid format. \
Event must be a string, dict, or bytes following the CloudEvent schema.')
_LOGGER.error('Your event: %s', cloud_event)
_LOGGER.error(err)
raise ValueError('Error: cannot deserialize event. Event does not have a valid format. Event must be a string, dict, or bytes following the CloudEvent schema.')
raise ValueError('Error: cannot deserialize event. Event does not have a valid format. \
Event must be a string, dict, or bytes following the CloudEvent schema.')

def decode_eventgrid_event(self, eventgrid_event, **kwargs):
def decode_eventgrid_event(self, eventgrid_event, **kwargs): # pylint: disable=no-self-use
# type: (Union[str, dict, bytes], Any) -> EventGridEvent
"""Single event following EventGridEvent schema will be parsed and returned as Deserialized Event.
:param eventgrid_event: The event to be deserialized.
Expand All @@ -58,12 +55,14 @@ def decode_eventgrid_event(self, eventgrid_event, **kwargs):
"""
encode = kwargs.pop('encoding', 'utf-8')
try:
eventgrid_event = EventGridEvent._from_json(eventgrid_event, encode)
eventgrid_event = EventGridEvent._from_json(eventgrid_event, encode) # pylint: disable=protected-access
deserialized_event = EventGridEvent.deserialize(eventgrid_event)
EventGridEvent._deserialize_data(deserialized_event, deserialized_event.event_type)
EventGridEvent._deserialize_data(deserialized_event, deserialized_event.event_type) # pylint: disable=protected-access
return deserialized_event
except Exception as err:
_LOGGER.error('Error: cannot deserialize event. Event does not have a valid format. Event must be a string, dict, or bytes following the CloudEvent schema.')
_LOGGER.error('Your event: {}'.format(eventgrid_event))
_LOGGER.error('Error: cannot deserialize event. Event does not have a valid format. \
Event must be a string, dict, or bytes following the CloudEvent schema.')
_LOGGER.error('Your event: %s', eventgrid_event)
_LOGGER.error(err)
raise ValueError('Error: cannot deserialize event. Event does not have a valid format. Event must be a string, dict, or bytes following the CloudEvent schema.')
raise ValueError('Error: cannot deserialize event. Event does not have a valid format. \
Event must be a string, dict, or bytes following the CloudEvent schema.')
14 changes: 9 additions & 5 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"Microsoft.EventGrid.SubscriptionValidationEvent": models.SubscriptionValidationEventData,
"Microsoft.EventGrid.SubscriptionDeletedEvent": models.SubscriptionDeletedEventData,
"Microsoft.EventHub.CaptureFileCreated": models.EventHubCaptureFileCreatedEventData,
"Microsoft.MachineLearningServices.DatasetDriftDetected": models.MachineLearningServicesDatasetDriftDetectedEventData,
"Microsoft.MachineLearningServices.DatasetDriftDetected":
models.MachineLearningServicesDatasetDriftDetectedEventData,
"Microsoft.MachineLearningServices.ModelDeployed": models.MachineLearningServicesModelDeployedEventData,
"Microsoft.MachineLearningServices.ModelRegistered": models.MachineLearningServicesModelRegisteredEventData,
"Microsoft.MachineLearningServices.RunCompleted": models.MachineLearningServicesRunCompletedEventData,
Expand Down Expand Up @@ -47,7 +48,8 @@
"Microsoft.Media.LiveEventEncoderDisconnected": models.MediaLiveEventEncoderDisconnectedEventData,
"Microsoft.Media.LiveEventIncomingStreamReceived": models.MediaLiveEventIncomingStreamReceivedEventData,
"Microsoft.Media.LiveEventIncomingStreamsOutOfSync": models.MediaLiveEventIncomingStreamsOutOfSyncEventData,
"Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync": models.MediaLiveEventIncomingVideoStreamsOutOfSyncEventData,
"Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync":
models.MediaLiveEventIncomingVideoStreamsOutOfSyncEventData,
"Microsoft.Media.LiveEventIncomingDataChunkDropped": models.MediaLiveEventIncomingDataChunkDroppedEventData,
"Microsoft.Media.LiveEventIngestHeartbeat": models.MediaLiveEventIngestHeartbeatEventData,
"Microsoft.Media.LiveEventTrackDiscontinuityDetected": models.MediaLiveEventTrackDiscontinuityDetectedEventData,
Expand All @@ -60,8 +62,10 @@
"Microsoft.Resources.ResourceActionSuccess": models.ResourceActionSuccessData,
"Microsoft.Resources.ResourceActionFailure": models.ResourceActionFailureData,
"Microsoft.Resources.ResourceActionCancel": models.ResourceActionCancelData,
"Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners": models.ServiceBusActiveMessagesAvailableWithNoListenersEventData,
"Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener": models.ServiceBusDeadletterMessagesAvailableWithNoListenersEventData,
"Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners":
models.ServiceBusActiveMessagesAvailableWithNoListenersEventData,
"Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener":
models.ServiceBusDeadletterMessagesAvailableWithNoListenersEventData,
"Microsoft.Storage.BlobCreated": models.StorageBlobCreatedEventData,
"Microsoft.Storage.BlobDeleted": models.StorageBlobDeletedEventData,
"Microsoft.Storage.BlobRenamed": models.StorageBlobRenamedEventData,
Expand All @@ -82,4 +86,4 @@
"Microsoft.Web.SlotSwapWithPreviewStarted": models.WebSlotSwapWithPreviewStartedEventData,
"Microsoft.Web.SlotSwapWithPreviewCancelled": models.WebSlotSwapWithPreviewCancelledEventData,
"Microsoft.Web.AppServicePlanUpdated": models.WebAppServicePlanUpdatedEventData,
}
}
23 changes: 16 additions & 7 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import hashlib
import hmac
import base64
try:
from urllib.parse import quote
except ImportError:
from urllib2 import quote # type: ignore
import datetime

from azure.core.pipeline.policies import AzureKeyCredentialPolicy
from azure.core.credentials import AzureKeyCredential
from ._shared_access_signature_credential import EventGridSharedAccessSignatureCredential
from ._signature_credential_policy import EventGridSharedAccessSignatureCredentialPolicy
from . import _constants as constants
from ._event_mappings import _event_mappings

def generate_shared_access_signature(topic_hostname, shared_access_key, expiration_date_utc, **kwargs):
# type: (str, str, datetime.Datetime, Any) -> str
Expand All @@ -21,13 +23,17 @@ def generate_shared_access_signature(topic_hostname, shared_access_key, expirati
Similar to <YOUR-TOPIC-NAME>.<YOUR-REGION-NAME>-1.eventgrid.azure.net
:param str shared_access_key: The shared access key to be used for generating the token
:param datetime.datetime expiration_date_utc: The expiration datetime in UTC for the signature.
:param str api_version: The API Version to include in the signature. If not provided, the default API version will be used.
:param str api_version: The API Version to include in the signature.
If not provided, the default API version will be used.
:rtype: str
"""

full_topic_hostname = _get_full_topic_hostname(topic_hostname)

full_topic_hostname = "{}?apiVersion={}".format(full_topic_hostname, kwargs.get('api_version', None) or constants.DEFAULT_API_VERSION)
full_topic_hostname = "{}?apiVersion={}".format(
full_topic_hostname,
kwargs.get('api_version', None) or constants.DEFAULT_API_VERSION
)
encoded_resource = quote(full_topic_hostname, safe=constants.SAFE_ENCODE)
encoded_expiration_utc = quote(str(expiration_date_utc), safe=constants.SAFE_ENCODE)

Expand All @@ -43,7 +49,7 @@ def _get_topic_hostname_only_fqdn(topic_hostname):
topic_hostname = topic_hostname.replace("https://", "")
if topic_hostname.endswith("/api/events"):
topic_hostname = topic_hostname.replace("/api/events", "")

return topic_hostname

def _get_full_topic_hostname(topic_hostname):
Expand All @@ -53,7 +59,7 @@ def _get_full_topic_hostname(topic_hostname):
topic_hostname = "https://{}".format(topic_hostname)
if not topic_hostname.endswith("/api/events"):
topic_hostname = "{}/api/events".format(topic_hostname)

return topic_hostname

def _generate_hmac(key, message):
Expand All @@ -69,7 +75,10 @@ def _get_authentication_policy(credential):
if isinstance(credential, AzureKeyCredential):
authentication_policy = AzureKeyCredentialPolicy(credential=credential, name=constants.EVENTGRID_KEY_HEADER)
if isinstance(credential, EventGridSharedAccessSignatureCredential):
authentication_policy = EventGridSharedAccessSignatureCredentialPolicy(credential=credential, name=constants.EVENTGRID_TOKEN_HEADER)
authentication_policy = EventGridSharedAccessSignatureCredentialPolicy(
credential=credential,
name=constants.EVENTGRID_TOKEN_HEADER
)
return authentication_policy

def _is_cloud_event(event):
Expand Down
21 changes: 9 additions & 12 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint:disable=protected-access
from typing import Optional
from msrest.serialization import UTC
import datetime as dt
import uuid
import json
import six
from ._generated import models
from ._generated.models import StorageBlobCreatedEventData, \
EventGridEvent as InternalEventGridEvent, \
CloudEvent as InternalCloudEvent
from msrest.serialization import UTC
from ._generated.models import EventGridEvent as InternalEventGridEvent, CloudEvent as InternalCloudEvent
from ._shared.mixins import DictMixin
from ._event_mappings import _event_mappings

Expand Down Expand Up @@ -55,8 +51,8 @@ class CloudEvent(EventMixin): #pylint:disable=too-many-instance-attributes
All required parameters must be populated in order to send to Azure.
:param source: Required. Identifies the context in which an event happened. The combination of id and source must be
unique for each distinct event. If publishing to a domain topic, source must be the domain name.
:param source: Required. Identifies the context in which an event happened. The combination of id and source must
be unique for each distinct event. If publishing to a domain topic, source must be the domain name.
:type source: str
:param data: Event data specific to the event type.
:type data: object
Expand All @@ -75,7 +71,7 @@ class CloudEvent(EventMixin): #pylint:disable=too-many-instance-attributes
unique for each distinct event.
:type id: Optional[str]
"""
def __init__(self, source, type, **kwargs):
def __init__(self, source, type, **kwargs): # pylint: disable=redefined-builtin
# type: (str, str, Any) -> None
self.source = source
self.type = type
Expand All @@ -87,13 +83,13 @@ def __init__(self, source, type, **kwargs):
self.dataschema = kwargs.pop("dataschema", None)
self.subject = kwargs.pop("subject", None)
self.extensions = {}
self.extensions.update({k:v for k, v in kwargs.pop('extensions', {}).items()})
self.extensions.update(dict(kwargs.pop('extensions', {})))

@classmethod
def _from_generated(cls, cloud_event, **kwargs):
generated = InternalCloudEvent.deserialize(cloud_event)
if generated.additional_properties:
extensions = {k:v for k, v in generated.additional_properties.items()}
extensions = dict(generated.additional_properties)
kwargs.setdefault('extensions', extensions)
return cls(
id=generated.id,
Expand Down Expand Up @@ -154,7 +150,8 @@ class EventGridEvent(InternalEventGridEvent, EventMixin):
:param id: Optional. An identifier for the event. The combination of id and source must be
unique for each distinct event.
:type id: Optional[str]
:param event_time: Optional.The time (in UTC) of the event. If not provided, it will be the time (in UTC) the event was generated.
:param event_time: Optional.The time (in UTC) of the event. If not provided,
it will be the time (in UTC) the event was generated.
:type event_time: Optional[~datetime.datetime]
"""

Expand Down
Loading

0 comments on commit 1b02419

Please sign in to comment.