Skip to content

Commit

Permalink
base scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuInNZ committed Aug 17, 2019
1 parent 813a943 commit 26bbffe
Show file tree
Hide file tree
Showing 303 changed files with 22,244 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@
/src/vm-repair/ @swbae31

/src/netappfiles-preview/ @b-lefr

/src/azext_logicapp/ @ManuInNZ
8 changes: 8 additions & 0 deletions src/logicapp/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
5 changes: 5 additions & 0 deletions src/logicapp/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'logicapp' Extension
==========================================

This package is for the 'logicapp' extension.
i.e. 'az logicapp'
32 changes: 32 additions & 0 deletions src/logicapp/azext_logicapp/__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 azext_logicapp._help import helps # pylint: disable=unused-import


class LogicappCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_logicapp._client_factory import cf_logicapp
logicapp_custom = CliCommandType(
operations_tmpl='azext_logicapp.custom#{}',
client_factory=cf_logicapp)
super(LogicappCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=logicapp_custom)

def load_command_table(self, args):
from azext_logicapp.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_logicapp._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = LogicappCommandsLoader
10 changes: 10 additions & 0 deletions src/logicapp/azext_logicapp/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

def cf_logicapp(cli_ctx, *_):

from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_logicapp.vendored_sdks import LogicManagementClient
return get_mgmt_service_client(cli_ctx, LogicManagementClient)
38 changes: 38 additions & 0 deletions src/logicapp/azext_logicapp/_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['logicapp'] = """
type: group
short-summary: Commands to manage Logicapps.
"""

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

helps['logicapp list'] = """
type: command
short-summary: List Logicapps.
"""

helps['logicapp delete'] = """
type: command
short-summary: Delete a Logicapp.
"""

helps['logicapp show'] = """
type: command
short-summary: Show details of a Logicapp.
"""

helps['logicapp update'] = """
type: command
short-summary: Update a Logicapp.
"""
23 changes: 23 additions & 0 deletions src/logicapp/azext_logicapp/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# 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

workflow_name_type = CLIArgumentType(options_list='--workflow-name-name', help='Name of the Logicapp.', id_part='name')

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

with self.argument_context('logicapp list') as c:
c.argument('workflow_name', workflow_name_type, id_part=None)
20 changes: 20 additions & 0 deletions src/logicapp/azext_logicapp/_validators.py
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
)
5 changes: 5 additions & 0 deletions src/logicapp/azext_logicapp/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.0.67",
"azext.maxCliCoreVersion": "2.1.0"
}
28 changes: 28 additions & 0 deletions src/logicapp/azext_logicapp/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# --------------------------------------------------------------------------------------------
# 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 azext_logicapp._client_factory import cf_logicapp


def load_command_table(self, _):

logicapp_sdk = CliCommandType(
operations_tmpl='azext_logicapp.vendored_sdks.operations#WorkflowRunsOperations.{}',
client_factory=cf_logicapp)


with self.command_group('logicapp', logicapp_sdk, client_factory=cf_logicapp) as g:
g.custom_command('create', 'create_logicapp')
g.command('delete', 'delete')
g.custom_command('list', 'list_logicapp')
g.show_command('show', 'get')
g.generic_update_command('update', setter_name='update', custom_func_name='update_logicapp')


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

20 changes: 20 additions & 0 deletions src/logicapp/azext_logicapp/custom.py
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.
# --------------------------------------------------------------------------------------------

from knack.util import CLIError


def create_logicapp(cmd, client, resource_group_name, workflow_name, location=None, tags=None):
raise CLIError('TODO: Implement `logicapp create`')


def list_logicapp(cmd, client, resource_group_name=None):
raise CLIError('TODO: Implement `logicapp list`')


def update_logicapp(cmd, instance, tags=None):
with cmd.update_context(instance) as c:
c.set_param('tags', tags)
return instance
5 changes: 5 additions & 0 deletions src/logicapp/azext_logicapp/tests/__init__.py
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.
# -----------------------------------------------------------------------------
5 changes: 5 additions & 0 deletions src/logicapp/azext_logicapp/tests/latest/__init__.py
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.
# -----------------------------------------------------------------------------
40 changes: 40 additions & 0 deletions src/logicapp/azext_logicapp/tests/latest/test_logicapp_scenario.py
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 LogicappScenarioTest(ScenarioTest):

@ResourceGroupPreparer(name_prefix='cli_test_logicapp')
def test_logicapp(self, resource_group):

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

self.cmd('logicapp create -g {rg} -n {name} --tags foo=doo', checks=[
self.check('tags.foo', 'doo'),
self.check('name', '{name}')
])
self.cmd('logicapp update -g {rg} -n {name} --tags foo=boo', checks=[
self.check('tags.foo', 'boo')
])
count = len(self.cmd('logicapp list').get_output_in_json())
self.cmd('logicapp show - {rg} -n {name}', checks=[
self.check('name', '{name}'),
self.check('resourceGroup', '{rg}'),
self.check('tags.foo', 'boo')
])
self.cmd('logicapp delete -g {rg} -n {name}')
final_count = len(self.cmd('logicapp list').get_output_in_json())
self.assertTrue(final_count, count - 1)
18 changes: 18 additions & 0 deletions src/logicapp/azext_logicapp/vendored_sdks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from .logic_management_client import LogicManagementClient
from .version import VERSION

__all__ = ['LogicManagementClient']

__version__ = VERSION

Loading

0 comments on commit 26bbffe

Please sign in to comment.