Skip to content

Commit

Permalink
Email services domain initiate and cancel verification changes (#7404)
Browse files Browse the repository at this point in the history
* EmailServiceDomain Initiate and cancel verification

* Email service domain initiate cancel verification changes version update

* EmailServiceDomain Initiate and cancel verification - resolving version conflicts

* EmailService Domain - Initiate and Cancel verification

* Email Service -Domain - Sender username- Added examples

* Email Service - updated list example command
  • Loading branch information
v-vprasannak committed Apr 9, 2024
1 parent f4a404b commit df3c3c3
Show file tree
Hide file tree
Showing 91 changed files with 10,971 additions and 2,219 deletions.
6 changes: 5 additions & 1 deletion src/communication/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
Release History
===============
1.8.0
1.9.1
++++++
* Add Email communication Domain resource Initiate and Cancel verification operations

1.9.0
++++++
* Adding managed identity support for stable api version 2023-04-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
)
class Create(AAZCommand):
"""Create a new EmailService or update an existing EmailService.
:example: Create a email resource with tags
az communication email create -n ResourceName -g ResourceGroup --location global --data-location unitedstates --tags "{tag:tag}"
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
)
class Delete(AAZCommand):
"""Delete to delete a EmailService.
:example: Delete a email resource
az communication email delete -n ResourceName -g ResourceGroup
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
)
class List(AAZCommand):
"""List requests to list all resources in a subscription.
:example: Get all resources from a subscription
az communication email list --subscription SubscriptionId
:example: Get all resources from a resource group
az communication email list -g ResourceGroup
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
)
class Show(AAZCommand):
"""Get the EmailService and its properties.
:example: Get a email service's properties
az communication email show -n ResourceName -g ResourceGroup
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
)
class Update(AAZCommand):
"""Update a new EmailService or update an existing EmailService.
:example: Update a email resource with tags
az communication email update -n ResourceName -g ResourceGroup --tags "{tag:tag}"
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
# flake8: noqa

from .__cmd_group import *
from ._cancel_verification import *
from ._create import *
from ._delete import *
from ._initiate_verification import *
from ._list import *
from ._show import *
from ._update import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# --------------------------------------------------------------------------------------------
# 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 aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"communication email domain cancel-verification",
)
class CancelVerification(AAZCommand):
"""Cancel verification of DNS record.
:example: Cancel Domain Verification
az communication email domain cancel-verification --domain-name DomainName --email-service-name ResourceName -g ResourceGroup --verification-type Domain/SPF/DKIM/DKIM2
"""

_aaz_info = {
"version": "2023-04-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.communication/emailservices/{}/domains/{}/cancelverification", "2023-04-01"],
]
}

AZ_SUPPORT_NO_WAIT = True

def _handler(self, command_args):
super()._handler(command_args)
return self.build_lro_poller(self._execute_operations, None)

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.domain_name = AAZStrArg(
options=["--domain-name"],
help="The name of the Domains resource.",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
max_length=253,
min_length=1,
),
)
_args_schema.email_service_name = AAZStrArg(
options=["--email-service-name"],
help="The name of the EmailService resource.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]+$",
max_length=63,
min_length=1,
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)

# define Arg Group "Parameters"

_args_schema = cls._args_schema
_args_schema.verification_type = AAZStrArg(
options=["--verification-type"],
arg_group="Parameters",
help="Type of verification.",
required=True,
enum={"DKIM": "DKIM", "DKIM2": "DKIM2", "DMARC": "DMARC", "Domain": "Domain", "SPF": "SPF"},
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
yield self.DomainsCancelVerification(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

class DomainsCancelVerification(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [202]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200_201,
self.on_error,
lro_options={"final-state-via": "location"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [200, 201]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200_201,
self.on_error,
lro_options={"final-state-via": "location"},
path_format_arguments=self.url_parameters,
)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/cancelVerification",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"domainName", self.ctx.args.domain_name,
required=True,
),
**self.serialize_url_param(
"emailServiceName", self.ctx.args.email_service_name,
required=True,
),
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-04-01",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("verificationType", AAZStrType, ".verification_type", typ_kwargs={"flags": {"required": True}})

return self.serialize_content(_content_value)

def on_200_201(self, session):
pass


class _CancelVerificationHelper:
"""Helper class for CancelVerification"""


__all__ = ["CancelVerification"]
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
)
class Create(AAZCommand):
"""Create a new Domains resource under the parent EmailService resource or update an existing Domains resource.
:example: Create a domain with tags
az communication email domain create --domain-name DomainName --email-service-name ResourceName -g ResourceGroup --location global --domain-management AzureManaged/CustomerManaged --tags "{tag:tag}" --user-engmnt-tracking Enabled/Disabled
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
)
class Delete(AAZCommand):
"""Delete to delete a Domains resource.
:example: Delete a domain resource
az communication email domain delete --domain-name DomainName --email-service-name ResourceName -g ResourceGroup
"""

_aaz_info = {
Expand Down
Loading

0 comments on commit df3c3c3

Please sign in to comment.