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

[Support RP] - Deprecated commands for Breaking Change Announcement #7412

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/support/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release History
===============

1.0.4
-----
* Add deprecated message for commands before new upcoming version

1.0.3
-----
* Migrate to track 2 SDK
Expand Down
8 changes: 5 additions & 3 deletions src/support/azext_support/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def load_tickets_argument(self, _):
help='Indicates if this requires a 24x7 response from Azure. Default is false.')
c.argument('partner_tenant_id', help='Partner tenant id for Admin On Behalf ' +
'of (AOBO) scenario. In addition to logging in to the customer tenant, logging in to the partner ' +
'tenant (PT) using "az login -t PT --allow-no-subscriptions" is required.')
'tenant (PT) using "az login -t PT --allow-no-subscriptions" is required.',
deprecate_info=c.deprecate())
RudraSharma93Microsoft marked this conversation as resolved.
Show resolved Hide resolved

with self.argument_context('support tickets create', arg_group="Contact") as c:
c.argument('contact_first_name', help='First Name', required=True)
Expand All @@ -126,10 +127,11 @@ def load_tickets_argument(self, _):
c.argument('quota_change_subtype', help='Required for certain quota types when there is a sub type that ' +
'you are requesting quota increase for. Example: Batch')
c.argument('quota_change_regions', nargs='+', help='Space-separated list of region for which ' +
'the quota increase request is being made.')
'the quota increase request is being made.', deprecate_info=c.deprecate())
c.argument('quota_change_payload', nargs='+', help='Space -separated list of serialized payload of the ' +
'quota increase request corresponding to regions. Visit ' +
'https://aka.ms/supportrpquotarequestpayload for details.')
'https://aka.ms/supportrpquotarequestpayload for details.',
deprecate_info=c.deprecate())


def load_communications_argument(self, _):
Expand Down
4 changes: 2 additions & 2 deletions src/support/azext_support/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def is_technical_ticket(service_name):
def parse_support_area_path(problem_classification_id):
service_id_prefix = "/providers/Microsoft.Support/services/".lower()
guid_regex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
sap_regex = re.compile('^{0}({1})/problemclassifications/({1})$'.format(service_id_prefix, guid_regex))
sap_regex = re.compile(f'^{service_id_prefix}({guid_regex})/problemclassifications/({guid_regex})$')
match = sap_regex.search(problem_classification_id.lower())

if match is not None and len(match.groups()) == 2:
Expand All @@ -50,7 +50,7 @@ def get_bearer_token(cmd, tenant_id):
logger.debug("Retrieving access token for tenant %s", tenant_id)
creds, _, _ = client.get_raw_token(tenant=tenant_id)
except CLIError as unauthorized_error:
raise UnauthorizedError("Can't find authorization for {0}. ".format(tenant_id) +
raise UnauthorizedError(f"Can't find authorization for {tenant_id}. " +
"Run \'az login -t <tenant_name> --allow-no-subscriptions\' and try again.") from \
unauthorized_error

Expand Down
8 changes: 4 additions & 4 deletions src/support/azext_support/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def datetime_type(string):
return datetime.strptime(string, form)
except ValueError:
continue
raise ValueError("Input '{0}' not valid. Valid example: 2017-02-11T23:59:59Z".format(string))
raise ValueError(f"Input '{string}' not valid. Valid example: 2017-02-11T23:59:59Z")


def validate_tickets_create(cmd, namespace):
Expand Down Expand Up @@ -67,18 +67,18 @@ def _validate_resource_name(cmd, resource_id):
if resource_id is None:
return

base_error_msg = "Technical resource argument {0} is invalid.".format(resource_id)
base_error_msg = f"Technical resource argument {resource_id} is invalid."
if not is_valid_resource_id(resource_id):
raise CLIError(base_error_msg)

parsed_resource = parse_resource_id(resource_id)
subid = parsed_resource["subscription"]
if not _is_guid(subid):
raise CLIError(base_error_msg + "Subscription id {0} is invalid.".format(subid))
raise CLIError(f"{base_error_msg} Subscription id {subid} is invalid.")

session_subid = get_subscription_id(cmd.cli_ctx)
if subid != session_subid:
raise CLIError("{0} {1} does not match with {2}".format(base_error_msg, subid, session_subid))
raise CLIError(f"{base_error_msg} {subid} does not match with {session_subid}")


def _is_guid(guid):
Expand Down
6 changes: 4 additions & 2 deletions src/support/azext_support/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ def load_command_table(self, _):
g.show_command('show', getter_name='get')

with self.command_group('support tickets', support_tickets,
client_factory=cf_support_tickets) as g:
client_factory=cf_support_tickets,
deprecate_info=self.deprecate()) as g:
g.custom_command('list', 'list_support_tickets')
g.custom_show_command('show', 'get_support_tickets')
g.custom_command('create', 'create_support_tickets', supports_no_wait=False, validator=validate_tickets_create)
g.custom_command('update', 'update_support_tickets')

with self.command_group('support tickets communications', support_communications,
client_factory=cf_communications) as g:
client_factory=cf_communications,
deprecate_info=self.deprecate()) as g:
g.custom_command('list', 'list_support_tickets_communications')
g.custom_show_command('show', 'get_support_tickets_communications')
g.custom_command('create', 'create_support_tickets_communications', supports_no_wait=False)
23 changes: 22 additions & 1 deletion src/support/azext_support/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@


def list_support_tickets(cmd, client, filters=None):
logger.warning("Command group 'az support tickets' will be replaced by 'az support in-subscription tickets'" +
" and 'az support no-subscription tickets'")
logger.warning("Parameter 'filters' argument will be replaced by 'filter'")
if filters is None:
filters = "CreatedDate ge " + str(date.today() - timedelta(days=7))
return client.list(top=100, filter=filters)


def get_support_tickets(cmd, client, ticket_name=None):
logger.warning("Command group 'az support tickets' will be replaced by 'az support in-subscription tickets'" +
RudraSharma93Microsoft marked this conversation as resolved.
Show resolved Hide resolved
" and 'az support no-subscription tickets'")
return client.get(support_ticket_name=ticket_name)


Expand All @@ -39,6 +44,8 @@ def update_support_tickets(cmd, client,
contact_timezone=None,
contact_country=None,
contact_language=None):
logger.warning("Command group 'az support tickets' will be replaced by 'az support in-subscription tickets'" +
" and 'az support no-subscription tickets'")
contactBody = {}
contactBody["first_name"] = contact_first_name
contactBody["last_name"] = contact_last_name
Expand All @@ -62,10 +69,17 @@ def update_support_tickets(cmd, client,


def list_support_tickets_communications(cmd, client, ticket_name=None, filters=None):
logger.warning("Command group 'az support tickets communications' will be replaced by" +
" 'az support in-subscription communication'" +
" and 'az support no-subscription communication'")
logger.warning("'filters' argument will be replaced by 'filter'")
return client.list(support_ticket_name=ticket_name, filter=filters)


def get_support_tickets_communications(cmd, client, ticket_name=None, communication_name=None):
logger.warning("Command group 'az support tickets communications' will be replaced by" +
" 'az support in-subscription communication'" +
" and 'az support no-subscription communication'")
return client.get(support_ticket_name=ticket_name, communication_name=communication_name)


Expand All @@ -92,8 +106,12 @@ def create_support_tickets(cmd, client,
quota_change_regions=None,
quota_change_payload=None,
partner_tenant_id=None):
logger.warning("Command group 'az support tickets' will be replaced by 'az support in-subscription tickets'" +
" and 'az support no-subscription tickets'")
logger.warning("Parameters 'quota-change-regions' and ''quota-change-payload' will be replaced by" +
" 'quota-change-requests[].region' and 'quota-change-requests[].payload'")
service_name = parse_support_area_path(problem_classification)["service_name"]
service = "/providers/Microsoft.Support/services/{0}".format(service_name)
service = f"/providers/Microsoft.Support/services/{service_name}"

contactBody = {}
contactBody["first_name"] = contact_first_name
Expand Down Expand Up @@ -149,6 +167,9 @@ def create_support_tickets_communications(cmd, client,
communication_body=None,
communication_subject=None,
communication_sender=None):
logger.warning("Command group 'az support tickets communications' will be replaced by" +
" 'az support in-subscription communication'" +
" and 'az support no-subscription communication'")
body = {}
body["sender"] = communication_sender
body["subject"] = communication_subject
Expand Down
Loading