Skip to content
Draft
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@
/src/azure-cli/azure/cli/command_modules/util/ @jiasli @zhoxing-ms @evelyn-ys
/src/azure-cli/azure/cli/command_modules/vm/ @zhoxing-ms @jsntcy @wangzelin007 @yanzhudd @Drewm3 @TravisCragg-MSFT @nikhilpatel909 @sandeepraichura @hilaryw29 @GabstaMSFT @ramankumarlive @ushnaarshadkhan
/src/azure-cli/azure/cli/command_modules/containerapp/ @zhoxing-ms @yanzhudd @ruslany @sanchitmehta @ebencarek @JennyLawrance @howang-ms @vinisoto @chinadragon0515 @vturecek @torosent @pagariyaalok @Juliehzl @jijohn14 @Greedygre @ShichaoQiu
/src/azure-cli/azure/cli/command_modules/daniel_module/ @DanielMicrosoft
3 changes: 2 additions & 1 deletion doc/sphinx/azhelpgen/doc_source_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
"term": "src/azure-cli/azure/cli/command_modules/marketplaceordering/_help.py",
"util": "src/azure-cli/azure/cli/command_modules/util/_help.py",
"vm": "src/azure-cli/azure/cli/command_modules/vm/_help.py",
"vmss": "src/azure-cli/azure/cli/command_modules/vm/_help.py"
"vmss": "src/azure-cli/azure/cli/command_modules/vm/_help.py",
"daniel_module": "src/azure-cli/azure/cli/command_modules/daniel_module/_help.py"
}
32 changes: 32 additions & 0 deletions src/azure-cli/azure/cli/command_modules/daniel_module/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader

from azure.cli.command_modules.daniel_module._help import helps # pylint: disable=unused-import


class Daniel_moduleCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azure.cli.command_modules.daniel_module._client_factory import cf_daniel_module
daniel_module_custom = CliCommandType(
operations_tmpl='azure.cli.command_modules.daniel_module.custom#{}',
client_factory=cf_daniel_module)
super(Daniel_moduleCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=daniel_module_custom)

def load_command_table(self, args):
from azure.cli.command_modules.daniel_module.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azure.cli.command_modules.daniel_module._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = Daniel_moduleCommandsLoader
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

def cf_daniel_module(cli_ctx, *_):

from azure.cli.core.commands.client_factory import get_mgmt_service_client
# TODO: Replace CONTOSO with the appropriate label and uncomment
# from azure.mgmt.CONTOSO import CONTOSOManagementClient
# return get_mgmt_service_client(cli_ctx, CONTOSOManagementClient)
return None
38 changes: 38 additions & 0 deletions src/azure-cli/azure/cli/command_modules/daniel_module/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.help_files import helps # pylint: disable=unused-import


helps['daniel_module'] = """
type: group
short-summary: Commands to manage Daniel_modules.
"""

helps['daniel_module create'] = """
type: command
short-summary: Create a Daniel_module.
"""

helps['daniel_module list'] = """
type: command
short-summary: List Daniel_modules.
"""

# helps['daniel_module delete'] = """
# type: command
# short-summary: Delete a Daniel_module.
# """

# helps['daniel_module show'] = """
# type: command
# short-summary: Show details of a Daniel_module.
# """

# helps['daniel_module update'] = """
# type: command
# short-summary: Update a Daniel_module.
# """
26 changes: 26 additions & 0 deletions src/azure-cli/azure/cli/command_modules/daniel_module/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long

from knack.arguments import CLIArgumentType


def load_arguments(self, _):

from azure.cli.core.commands.parameters import tags_type
from azure.cli.core.commands.validators import get_default_location_from_resource_group

daniel_module_name_type = CLIArgumentType(
help='Name of the Daniel_module.',
id_part='name'
)

with self.argument_context('daniel_module') as c:
c.argument('tags', tags_type)
c.argument('location', validator=get_default_location_from_resource_group)
c.argument('daniel_module_name', daniel_module_name_type, options_list=['--name', '-n'])

with self.argument_context('daniel_module list') as c:
c.argument('daniel_module_name', daniel_module_name_type, options_list=['--name', '-n'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def example_name_or_id_validator(cmd, namespace):
# Example of a storage account name or ID validator.
# See: https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters
from azure.cli.core.commands.client_factory import get_subscription_id
from msrestazure.tools import is_valid_resource_id, resource_id
if namespace.storage_account:
if not is_valid_resource_id(namespace.RESOURCE):
namespace.storage_account = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='Microsoft.Storage',
type='storageAccounts',
name=namespace.storage_account
)
33 changes: 33 additions & 0 deletions src/azure-cli/azure/cli/command_modules/daniel_module/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
from azure.cli.core.commands import CliCommandType
from azure.cli.command_modules.daniel_module._client_factory import cf_daniel_module


def load_command_table(self, _):

# TODO: Add command type here
# daniel_module_sdk = CliCommandType(
# operations_tmpl='<PATH>.operations#.{}',
# client_factory=cf_daniel_module)


with self.command_group('daniel_module') as g:
g.custom_command('create', 'create_daniel_module')
# g.command('delete', 'delete')
g.custom_command('list', 'list_daniel_module')
# g.show_command('show', 'get')
# g.generic_update_command('update', setter_name='update', custom_func_name='update_daniel_module')


with self.command_group('daniel_module', is_preview=True):
pass


def create_daniel_module(cmd, client, name, location):
# Your create logic here
return f"Created {name} at {location}!"
27 changes: 27 additions & 0 deletions src/azure-cli/azure/cli/command_modules/daniel_module/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.util import CLIError


def create_daniel_module(cmd, daniel_module_name, location=None, tags=None):
# Simulate creation logic; normally you'd call SDK or service client here
result = {
'name': daniel_module_name,
'location': location,
'tags': tags or {}
}
# Just returning the result dictionary as example
return result


def list_daniel_module(cmd, resource_group_name=None):
raise CLIError('TODO: Implement `daniel_module list`')


def update_daniel_module(cmd, instance, tags=None):
with cmd.update_context(instance) as c:
c.set_param('tags', tags)
return instance
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import os
import unittest

from azure_devtools.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer)


TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))


class Daniel_moduleScenarioTest(ScenarioTest):

@ResourceGroupPreparer(name_prefix='cli_test_daniel_module')
def test_daniel_module(self, resource_group):

self.kwargs.update({
'name': 'test1'
})

self.cmd('daniel_module create -g {rg} -n {name} --tags foo=doo', checks=[
self.check('tags.foo', 'doo'),
self.check('name', '{name}')
])
self.cmd('daniel_module update -g {rg} -n {name} --tags foo=boo', checks=[
self.check('tags.foo', 'boo')
])
count = len(self.cmd('daniel_module list').get_output_in_json())
self.cmd('daniel_module show - {rg} -n {name}', checks=[
self.check('name', '{name}'),
self.check('resourceGroup', '{rg}'),
self.check('tags.foo', 'boo')
])
self.cmd('daniel_module delete -g {rg} -n {name}')
final_count = len(self.cmd('daniel_module list').get_output_in_json())
self.assertTrue(final_count, count - 1)