Skip to content

Commit

Permalink
[EventGrid] Ignite Release generate with new typespec (#32652)
Browse files Browse the repository at this point in the history
* Beta LiveTests (#30728)

* add bicep file for tests

* update output

* update test

* secret sanitization

* refactor failing test

* update conftest

* update assets and sanitizers

* update preparer loc

* update conftest

* conftest

* update conftest

* remove variables for now

* update assets

* update tests

* try to update regex

* update recordings

* update conftest

* update preparer

* update test

* update exception test

* update tests

* update asset

* update conftest

* pr comments

* default needs to be eastus

* import

* [EGv2] Binary mode  (#32922)

* [EGv2] Build Release (#30325)

* move old sdk under legacy

* gen typespec code

* naming changes from archboard

* samples

* update patch naming

* update imports with new gen

* update samples

* update client naming on aio

* update receive op

* update async to close client

* update receive()

* update gen code

* moving around samples

* updating samples

* update samples

* update patch and samples

* patch internalmodels

* spacing

* updating model patch

* update patch models

* add both models back

* update docstring

* update docs

* updating patch for receive

* old EG models

* add reject samples

* patch

* update format

* update patch

* eventgrid_client exceptions

* update test imports

* update total sample

* receive patch fix

* add in more tests

* update test file

* remove locktoken model

* remove LockToken in patch

* remove event delivery delay

* eg client exceptions

* .8.5 generation, and deliveryCount

* rename sample

* update version for beta

* changelog

* updating for gen

* regen

* generate via commit

* publish result

* fix docstring

* publish docstring

* return type

* publish result

* return publish result -- is none

* format

* update Publish result model

* deliverycount patch

* update from main

* add copyright

* added to readme

* remove from readme

* force publish_result response

* update patch tp unindent

* cspell

* update mypy.ini

* import order

* mark livetest

* update operations init

* rename async

* mypy

* ignore mypy

* pylint

* pylint

* ignore pylint for now to avoid gen code errors

* ignore samples until ARM setup

* update patches

* remove publish result

* remove PublishResult

* remove publishresult

* comma

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* update publishResult

* change to .value

* gen code " to '

* remove comment

* ran black

* update changelog

* update sample readme

* gen code without query name

* gen code

* update tsp commit

* remove publishresult

* readme disclaimer

* update changelog

---------

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* Beta LiveTests (#30728)

* add bicep file for tests

* update output

* update test

* secret sanitization

* refactor failing test

* update conftest

* update assets and sanitizers

* update preparer loc

* update conftest

* conftest

* update conftest

* remove variables for now

* update assets

* update tests

* try to update regex

* update recordings

* update conftest

* update preparer

* update test

* update exception test

* update tests

* update asset

* update conftest

* pr comments

* default needs to be eastus

* import

* [EGv2] Build Release (#30325)

* move old sdk under legacy

* gen typespec code

* naming changes from archboard

* samples

* update patch naming

* update imports with new gen

* update samples

* update client naming on aio

* update receive op

* update async to close client

* update receive()

* update gen code

* moving around samples

* updating samples

* update samples

* update patch and samples

* patch internalmodels

* spacing

* updating model patch

* update patch models

* add both models back

* update docstring

* update docs

* updating patch for receive

* old EG models

* add reject samples

* patch

* update format

* update patch

* eventgrid_client exceptions

* update test imports

* update total sample

* receive patch fix

* add in more tests

* update test file

* remove locktoken model

* remove LockToken in patch

* remove event delivery delay

* eg client exceptions

* .8.5 generation, and deliveryCount

* rename sample

* update version for beta

* changelog

* updating for gen

* regen

* generate via commit

* publish result

* fix docstring

* publish docstring

* return type

* publish result

* return publish result -- is none

* format

* update Publish result model

* deliverycount patch

* update from main

* add copyright

* added to readme

* remove from readme

* force publish_result response

* update patch tp unindent

* cspell

* update mypy.ini

* import order

* mark livetest

* update operations init

* rename async

* mypy

* ignore mypy

* pylint

* pylint

* ignore pylint for now to avoid gen code errors

* ignore samples until ARM setup

* update patches

* remove publish result

* remove PublishResult

* remove publishresult

* comma

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* update publishResult

* change to .value

* gen code " to '

* remove comment

* ran black

* update changelog

* update sample readme

* gen code without query name

* gen code

* update tsp commit

* remove publishresult

* readme disclaimer

* update changelog

---------

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* fix merge

* dont go to generated before binary

* update patch

* update patches

* eventgrid client patch

* changes

* add

* update test

* update tyoe checking

* pass through binary_mode for now --

* update patch aio

* add async func

* update

* sys

* update kwargs

* add Todo and start adding more tests

* update

* differentiate between binary and not

* update binary

* no base64 in binary mode

* binary

* try JSONEncoder on everything if not str/bytes

* update test

* update test

* update changes

* whitespace

* space

* remove commented

* str serialize extensions?

* xml test

* encode extensions as object

* update test

* update extension serialization for  deserialize

* move flag to operation level

* extra comma

* dont raise httpresponse

* update patch

* accept dict cloud events

* spacing

* remove content_type check

* add live test

* remove live test mark

* update

* use env vars

* update test

* only run live test

* comment

* typo

* error incorrect

* start comments

* update test

* add sample

* update tests

* update docstrings to add clarity

* update err message

* remove generated cloud event

* update sample

* update

* update samples to include dict

* update patch

* spacing

* add comments

* formatting

* update doc

* update tests

* update tests

* tests

* skip tests for now

* typo

* add dict binary mode

* update docstring

* update patch to allow throw error

* first pass at comments

* update patch eror

* nit

---------

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* [EGv2] Build Release (#30325)

* move old sdk under legacy

* gen typespec code

* naming changes from archboard

* samples

* update patch naming

* update imports with new gen

* update samples

* update client naming on aio

* update receive op

* update async to close client

* update receive()

* update gen code

* moving around samples

* updating samples

* update samples

* update patch and samples

* patch internalmodels

* spacing

* updating model patch

* update patch models

* add both models back

* update docstring

* update docs

* updating patch for receive

* old EG models

* add reject samples

* patch

* update format

* update patch

* eventgrid_client exceptions

* update test imports

* update total sample

* receive patch fix

* add in more tests

* update test file

* remove locktoken model

* remove LockToken in patch

* remove event delivery delay

* eg client exceptions

* .8.5 generation, and deliveryCount

* rename sample

* update version for beta

* changelog

* updating for gen

* regen

* generate via commit

* publish result

* fix docstring

* publish docstring

* return type

* publish result

* return publish result -- is none

* format

* update Publish result model

* deliverycount patch

* update from main

* add copyright

* added to readme

* remove from readme

* force publish_result response

* update patch tp unindent

* cspell

* update mypy.ini

* import order

* mark livetest

* update operations init

* rename async

* mypy

* ignore mypy

* pylint

* pylint

* ignore pylint for now to avoid gen code errors

* ignore samples until ARM setup

* update patches

* remove publish result

* remove PublishResult

* remove publishresult

* comma

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* update publishResult

* change to .value

* gen code " to '

* remove comment

* ran black

* update changelog

* update sample readme

* gen code without query name

* gen code

* update tsp commit

* remove publishresult

* readme disclaimer

* update changelog

---------

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>

* Beta LiveTests (#30728)

* add bicep file for tests

* update output

* update test

* secret sanitization

* refactor failing test

* update conftest

* update assets and sanitizers

* update preparer loc

* update conftest

* conftest

* update conftest

* remove variables for now

* update assets

* update tests

* try to update regex

* update recordings

* update conftest

* update preparer

* update test

* update exception test

* update tests

* update asset

* update conftest

* pr comments

* default needs to be eastus

* import

* regen

* new api version

* samples for new features

* update test-resources.json

* update operation samples

* add samples

* more sample

* update tests

* add mros

* gen

* fix changelog

* update tests

* update preparer

* point at canary until release

* update test deployment area

* update

* add

* try this tests

* update samples

* livetest mark

* update tests

* eastus working?

* regen - removed azure refs in gen code

* update comments

* add other sample

* update

* remove stream - no response

* update version and date for release

---------

Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com>
  • Loading branch information
l0lawrence and swathipil committed Apr 22, 2024
1 parent 8c9da89 commit 52f7a74
Show file tree
Hide file tree
Showing 42 changed files with 1,398 additions and 437 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
"mibps",
"mgmt",
"mhsm",
"mros",
"Nify",
"mipsle",
"mktime",
Expand Down
7 changes: 7 additions & 0 deletions sdk/eventgrid/azure-eventgrid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ This version and all future versions will require Python 3.8+.
### Features Added

- Added new enums values to `SystemEventNames` related to Azure Storage and Azure VMware Solution.
## 4.17.0b1 (2023-11-09)

### Features Added

- Added new features to the EventGridClient that supports `publish_cloud_events`, `receive_cloud_events`, `acknowledge_cloud_events` , `release_cloud_events`, and `reject_cloud_events` operations. These features include a `renew_cloud_event_locks` operation, as well as a `release_with_delay` parameter on the `release_cloud_events` operation.
- `lock_tokens` parameter in `reject_cloud_events`, `release_cloud_events`, and `acknowledge_cloud_events` renamed to `reject_options`, `release_options`, and `acknowledge_options`.
- Added new models to support these new operations on EventGridClient.

## 4.16.0 (2023-11-08)

Expand Down
2 changes: 1 addition & 1 deletion sdk/eventgrid/azure-eventgrid/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/eventgrid/azure-eventgrid",
"Tag": "python/eventgrid/azure-eventgrid_fce4958e09"
"Tag": "python/eventgrid/azure-eventgrid_f155c8ac2d"
}
13 changes: 9 additions & 4 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from azure.core import PipelineClient
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse

from ._configuration import EventGridClientConfiguration
Expand All @@ -32,7 +33,7 @@ class EventGridClient(EventGridClientOperationsMixin): # pylint: disable=client
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is
"2023-06-01-preview". Note that overriding this default value may result in unsupported
"2023-10-01-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""
Expand All @@ -45,7 +46,11 @@ def __init__(
) -> None:
_endpoint = '{endpoint}'
self._config = EventGridClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
_policies = kwargs.pop('policies', None)
if _policies is None:
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,self._config.user_agent_policy,self._config.proxy_policy,policies.ContentDecodePolicy(**kwargs),self._config.redirect_policy,self._config.retry_policy,self._config.authentication_policy,self._config.custom_hook_policy,self._config.logging_policy,policies.DistributedTracingPolicy(**kwargs),policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,self._config.http_logging_policy]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)


self._serialize = Serializer()
self._deserialize = Deserializer()
Expand All @@ -54,7 +59,7 @@ def __init__(

def send_request(
self,
request: HttpRequest,
request: HttpRequest, *, stream: bool = False,
**kwargs: Any
) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand All @@ -80,7 +85,7 @@ def send_request(
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
return self._client.send_request(request_copy, **kwargs)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
self._client.close()
Expand Down
13 changes: 5 additions & 8 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from typing import Any, TYPE_CHECKING, Union

from azure.core.configuration import Configuration
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline import policies

Expand All @@ -19,9 +18,7 @@
from azure.core.credentials import TokenCredential


class EventGridClientConfiguration( # pylint: disable=too-many-instance-attributes,name-too-long
Configuration
):
class EventGridClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
"""Configuration for EventGridClient.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -35,7 +32,7 @@ class EventGridClientConfiguration( # pylint: disable=too-many-instance-attri
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is
"2023-06-01-preview". Note that overriding this default value may result in unsupported
"2023-10-01-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""
Expand All @@ -46,8 +43,7 @@ def __init__(
credential: Union[AzureKeyCredential, "TokenCredential"],
**kwargs: Any
) -> None:
super(EventGridClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop('api_version', "2023-06-01-preview")
api_version: str = kwargs.pop('api_version', "2023-10-01-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand All @@ -59,6 +55,7 @@ def __init__(
self.api_version = api_version
self.credential_scopes = kwargs.pop('credential_scopes', ['https://eventgrid.azure.net/.default'])
kwargs.setdefault('sdk_moniker', 'eventgrid/{}'.format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _infer_policy(self, **kwargs):
Expand All @@ -77,9 +74,9 @@ def _configure(
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = self._infer_policy(**kwargs)
13 changes: 8 additions & 5 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

_LOGGER = logging.getLogger(__name__)

__all__ = ["AzureJSONEncoder", "Model", "rest_field", "rest_discriminator"]
__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"]

TZ_UTC = timezone.utc

Expand Down Expand Up @@ -125,7 +125,7 @@ def _is_readonly(p):
return False


class AzureJSONEncoder(JSONEncoder):
class SdkJSONEncoder(JSONEncoder):
"""A JSON encoder that's capable of serializing datetime objects and bytes."""

def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs):
Expand All @@ -140,7 +140,7 @@ def default(self, o): # pylint: disable=too-many-return-statements
return {k: v for k, v in o.items() if k not in readonly_props}
return dict(o.items())
try:
return super(AzureJSONEncoder, self).default(o)
return super(SdkJSONEncoder, self).default(o)
except TypeError:
if isinstance(o, _Null):
return None
Expand All @@ -157,7 +157,7 @@ def default(self, o): # pylint: disable=too-many-return-statements
except AttributeError:
# This will be raised when it hits value.total_seconds in the method above
pass
return super(AzureJSONEncoder, self).default(o)
return super(SdkJSONEncoder, self).default(o)


_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?")
Expand Down Expand Up @@ -553,7 +553,7 @@ def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.
if exclude_readonly:
readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)]
for k, v in self.items():
if exclude_readonly and k in readonly_props: # pyright: reportUnboundVariable=false
if exclude_readonly and k in readonly_props: # pyright: ignore[reportUnboundVariable]
continue
result[k] = Model._as_dict_value(v, exclude_readonly=exclude_readonly)
return result
Expand Down Expand Up @@ -754,9 +754,12 @@ def _deserialize(
value: typing.Any,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
if isinstance(value, PipelineResponse):
value = value.http_response.json()
if rf is None and format:
rf = _RestField(format=format)
deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf)
return _deserialize_with_callable(deserializer, value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._patch import EventGridClientOperationsMixin
from ._operations import EventGridClientOperationsMixin

from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
Expand Down
Loading

0 comments on commit 52f7a74

Please sign in to comment.