コード例 #1
0
ファイル: __init__.py プロジェクト: yugangw-msft/azure-cli
    def generic_update_command(self, name, getter_name='get', getter_type=None,
                               setter_name='create_or_update', setter_type=None, setter_arg_name='parameters',
                               child_collection_prop_name=None, child_collection_key='name', child_arg_name='item_name',
                               custom_func_name=None, custom_func_type=None, **kwargs):
        from azure.cli.core.commands.arm import _cli_generic_update_command
        self._check_stale()
        merged_kwargs = self._flatten_kwargs(kwargs, get_command_type_kwarg())
        merged_kwargs_custom = self._flatten_kwargs(kwargs, get_command_type_kwarg(custom_command=True))
        # don't inherit deprecation info from command group
        merged_kwargs['deprecate_info'] = kwargs.get('deprecate_info', None)

        getter_op = self._resolve_operation(merged_kwargs, getter_name, getter_type)
        setter_op = self._resolve_operation(merged_kwargs, setter_name, setter_type)
        custom_func_op = self._resolve_operation(merged_kwargs_custom, custom_func_name, custom_func_type,
                                                 custom_command=True) if custom_func_name else None
        _cli_generic_update_command(
            self.command_loader,
            '{} {}'.format(self.group_name, name),
            getter_op=getter_op,
            setter_op=setter_op,
            setter_arg_name=setter_arg_name,
            custom_function_op=custom_func_op,
            child_collection_prop_name=child_collection_prop_name,
            child_collection_key=child_collection_key,
            child_arg_name=child_arg_name,
            **merged_kwargs)
コード例 #2
0
ファイル: __init__.py プロジェクト: shabbirh/azure-cli
    def generic_update_command(self, name, getter_name='get', getter_type=None,
                               setter_name='create_or_update', setter_type=None, setter_arg_name='parameters',
                               child_collection_prop_name=None, child_collection_key='name', child_arg_name='item_name',
                               custom_func_name=None, custom_func_type=None, **kwargs):
        from azure.cli.core.commands.arm import _cli_generic_update_command
        self._check_stale()
        merged_kwargs = self._flatten_kwargs(kwargs, get_command_type_kwarg())
        merged_kwargs_custom = self._flatten_kwargs(kwargs, get_command_type_kwarg(custom_command=True))
        # don't inherit deprecation info from command group
        merged_kwargs['deprecate_info'] = kwargs.get('deprecate_info', None)

        getter_op = self._resolve_operation(merged_kwargs, getter_name, getter_type)
        setter_op = self._resolve_operation(merged_kwargs, setter_name, setter_type)
        custom_func_op = self._resolve_operation(merged_kwargs_custom, custom_func_name, custom_func_type,
                                                 custom_command=True) if custom_func_name else None
        _cli_generic_update_command(
            self.command_loader,
            '{} {}'.format(self.group_name, name),
            getter_op=getter_op,
            setter_op=setter_op,
            setter_arg_name=setter_arg_name,
            custom_function_op=custom_func_op,
            child_collection_prop_name=child_collection_prop_name,
            child_collection_key=child_collection_key,
            child_arg_name=child_arg_name,
            **merged_kwargs)
コード例 #3
0
ファイル: __init__.py プロジェクト: mevtorres/Azure-CLI
    def _resolve_operation(self,
                           kwargs,
                           name,
                           command_type=None,
                           custom_command=False):
        source_kwarg = get_command_type_kwarg(custom_command)

        operations_tmpl = None
        if command_type:
            # Top priority: specified command_type for the parameter
            operations_tmpl = command_type.settings.get(
                'operations_tmpl', None)

        if not operations_tmpl:
            # Second source: general operations_tmpl set for the command kwargs
            operations_tmpl = kwargs.get('operations_tmpl', None)

        if not operations_tmpl:
            # Final source: retrieve the operations_tmpl from the relevant 'command_type' or 'custom_command_type'
            command_type = kwargs.get(source_kwarg, None)
            operations_tmpl = command_type.settings.get(
                'operations_tmpl', None)

        if not operations_tmpl:
            raise ValueError(
                "command authoring error: unable to resolve 'operations_tmpl'")

        return operations_tmpl.format(name)
コード例 #4
0
ファイル: __init__.py プロジェクト: mevtorres/Azure-CLI
    def _show_command(self,
                      name,
                      getter_name='get',
                      getter_type=None,
                      custom_command=False,
                      **kwargs):
        from azure.cli.core.commands.arm import _cli_show_command
        self._check_stale()
        merged_kwargs = self._flatten_kwargs(
            kwargs, get_command_type_kwarg(custom_command))
        # don't inherit deprecation info from command group
        merged_kwargs['deprecate_info'] = kwargs.get('deprecate_info', None)

        if getter_type:
            merged_kwargs = _merge_kwargs(getter_type.settings, merged_kwargs,
                                          CLI_COMMAND_KWARGS)
        getter_op = self._resolve_operation(merged_kwargs,
                                            getter_name,
                                            getter_type,
                                            custom_command=custom_command)
        _cli_show_command(self.command_loader,
                          '{} {}'.format(self.group_name, name),
                          getter_op=getter_op,
                          custom_command=custom_command,
                          **merged_kwargs)
コード例 #5
0
ファイル: arm.py プロジェクト: will373793/azure-cli
def _get_operations_tmpl(cmd, custom_command=False):
    operations_tmpl = cmd.command_kwargs.get('operations_tmpl') or \
        cmd.command_kwargs.get(get_command_type_kwarg(custom_command)).settings['operations_tmpl']
    if not operations_tmpl:
        raise CLIError(
            "command authoring error: cmd '{}' does not have an operations_tmpl."
            .format(cmd.name))
    return operations_tmpl
コード例 #6
0
ファイル: __init__.py プロジェクト: yugangw-msft/azure-cli
    def _show_command(self, name, getter_name='get', getter_type=None, custom_command=False, **kwargs):
        from azure.cli.core.commands.arm import _cli_show_command
        self._check_stale()
        merged_kwargs = self._flatten_kwargs(kwargs, get_command_type_kwarg(custom_command))
        # don't inherit deprecation info from command group
        merged_kwargs['deprecate_info'] = kwargs.get('deprecate_info', None)

        if getter_type:
            merged_kwargs = _merge_kwargs(getter_type.settings, merged_kwargs, CLI_COMMAND_KWARGS)
        getter_op = self._resolve_operation(merged_kwargs, getter_name, getter_type, custom_command=custom_command)
        _cli_show_command(self.command_loader, '{} {}'.format(self.group_name, name), getter_op=getter_op,
                          custom_command=custom_command, **merged_kwargs)
コード例 #7
0
ファイル: __init__.py プロジェクト: vermashi/azure-cli
    def _command(self, name, method_name, custom_command=False, **kwargs):
        self._check_stale()
        merged_kwargs = self._flatten_kwargs(kwargs, get_command_type_kwarg(custom_command))
        # don't inherit deprecation info from command group
        merged_kwargs['deprecate_info'] = kwargs.get('deprecate_info', None)

        operations_tmpl = merged_kwargs['operations_tmpl']
        command_name = '{} {}'.format(self.group_name, name) if self.group_name else name
        self.command_loader._cli_command(command_name,  # pylint: disable=protected-access
                                         operation=operations_tmpl.format(method_name),
                                         **merged_kwargs)

        return command_name
コード例 #8
0
ファイル: __init__.py プロジェクト: jiayexie/azure-cli
    def _resolve_operation(self, kwargs, name, command_type=None, custom_command=False):
        source_kwarg = get_command_type_kwarg(custom_command)

        operations_tmpl = None
        if command_type:
            # Top priority: specified command_type for the parameter
            operations_tmpl = command_type.settings.get('operations_tmpl', None)

        if not operations_tmpl:
            # Second source: general operations_tmpl set for the command kwargs
            operations_tmpl = kwargs.get('operations_tmpl', None)

        if not operations_tmpl:
            # Final source: retrieve the operations_tmpl from the relevant 'command_type' or 'custom_command_type'
            command_type = kwargs.get(source_kwarg, None)
            operations_tmpl = command_type.settings.get('operations_tmpl', None)

        if not operations_tmpl:
            raise ValueError("command authoring error: unable to resolve 'operations_tmpl'")

        return operations_tmpl.format(name)
コード例 #9
0
ファイル: arm.py プロジェクト: will373793/azure-cli
def _get_client_factory(_, custom_command=False, **kwargs):
    command_type = kwargs.get(get_command_type_kwarg(custom_command), None)
    factory = kwargs.get('client_factory', None)
    if not factory and command_type:
        factory = command_type.settings.get('client_factory', None)
    return factory
コード例 #10
0
ファイル: arm.py プロジェクト: tjprescott/azure-cli
def _get_client_factory(_, custom_command=False, **kwargs):
    command_type = kwargs.get(get_command_type_kwarg(custom_command), None)
    factory = kwargs.get('client_factory', None)
    if not factory and command_type:
        factory = command_type.settings.get('client_factory', None)
    return factory
コード例 #11
0
ファイル: arm.py プロジェクト: tjprescott/azure-cli
def _get_operations_tmpl(cmd, custom_command=False):
    operations_tmpl = cmd.command_kwargs.get('operations_tmpl') or \
        cmd.command_kwargs.get(get_command_type_kwarg(custom_command)).settings['operations_tmpl']
    if not operations_tmpl:
        raise CLIError("command authoring error: cmd '{}' does not have an operations_tmpl.".format(cmd.name))
    return operations_tmpl