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

Add Subscription RP commands #5453

Closed
wants to merge 16 commits into from

Conversation

wilcobmsft
Copy link
Member


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

Command Guidelines

@promptws
Copy link

promptws commented Feb 2, 2018

View a preview at https://prompt.ws/r/Azure/azure-cli/5453
This is an experimental preview for @microsoft users.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Some changes are needed here.


@Completer
def get_offer_type_completion_list(cmd, prefix, namespace): # pylint: disable=unused-argument
return ['MS-AZR-0017P', 'MS-AZR-0148P']
Copy link
Member

Choose a reason for hiding this comment

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

A completer is overkill for this. They are only used when you need to query the server for completions. Instead use: arg_type=get_enum_typ(['MS-AZR-0017P', 'MS-AZR-0148P']) in your params.py file for this parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

from knack.help_files import helps


helps['subscriptiondefinition'] = """
Copy link
Member

Choose a reason for hiding this comment

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

This is a very lengthy name for a top-level command. Also, the account subgroup is already designated for subscriptions, so it would be more logical for these command to live there. az account definition ....

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved it under the account subgroup. Agree the name is long, but unfortunately I believe "definition" is too generic. Is there precedent for using shortened names, such as "subdef", so it becomes "account subdef list"?

# pylint: disable=line-too-long
def load_arguments(self, _):
with self.argument_context('subscriptiondefinition show') as c:
c.argument('subscription_definition_name', options_list=['--name', '-n'], required=False, help='Name of the subscription definition to show.')
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to call out "...to show". That way you only need to apply this alias once, with a scope of account definition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.


with self.argument_context('subscriptiondefinition create') as c:
c.argument('name', options_list=['--name', '-n'], required=True, help='Name of the subscription definition.')
c.argument('offer_type', options_list=['--offer_type', '-ot'], required=True, help='The subscription\'s offer type.', completer=get_offer_type_completion_list)
Copy link
Member

Choose a reason for hiding this comment

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

You cannot have a two-character short option. If anything there shouldn't be a short option, but if you really want one, -t would be the most appropriate.

You cannot use underscore in you long options. --offer_type should be --offer-type.

Just use arg_type=get_enum_type(...) here instead of a completer.

Finally, you don't need/should not provide required=True/False. The CLI will infer that from your command signature based on whether you provided a default value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

with self.argument_context('subscriptiondefinition create') as c:
c.argument('name', options_list=['--name', '-n'], required=True, help='Name of the subscription definition.')
c.argument('offer_type', options_list=['--offer_type', '-ot'], required=True, help='The subscription\'s offer type.', completer=get_offer_type_completion_list)
c.argument('subscription_display_name', options_list=['--subscription_display_name', '-sdn'], required=False, help='The subscription display name of the subscription definition.')
Copy link
Member

Choose a reason for hiding this comment

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

Same comments as above. Also, I would recommend shortening --subscription-display-name to simply --display-name

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Regarding subscription-display-name - just "display-name" doesn't properly capture the semantic here, so I'm leaving that as-is.



def cli_subscription_create_subscription_definition(client, name, offer_type, subscription_display_name=None):
"""Create a subscription definition."""
Copy link
Member

Choose a reason for hiding this comment

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

Don't use custom command doc strings to populate help. Instead, add a command entry to you help.py file with this as the short-summary. The reason is because the live docs edit functionality will link directly to that, and will never find it here.

@@ -14,7 +14,7 @@
<LaunchProvider>Standard Python launcher</LaunchProvider>
<InterpreterId>MSBuild|{54f4b6dc-0859-46dc-99bb-b275c9d0aca3}|$(MSBuildProjectFullPath)</InterpreterId>
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
<CommandLineArguments></CommandLineArguments>
<CommandLineArguments>interactive</CommandLineArguments>
Copy link
Member

Choose a reason for hiding this comment

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

This should be reverted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@wilcobmsft
Copy link
Member Author

Replacing this PR with Azure/azure-cli-extensions#49.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants