Skip to content
Closed
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
8 changes: 8 additions & 0 deletions src/dfp/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
42 changes: 42 additions & 0 deletions src/dfp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Azure CLI dfp Extension #
This is the extension for dfp

### How to use ###
Install this extension using the below CLI command
```
az extension add --name dfp
```

### Included Features ###
#### dfp instance ####
##### Create #####
```
az dfp instance create --name "azsdktest" --location "West US" \
--administration members="azsdktest@microsoft.com" members="azsdktest2@microsoft.com" --tags testKey="testValue" \
--resource-group "TestRG"

az dfp instance wait --created --name "{myInstance}" --resource-group "{rg}"
```
##### List #####
```
az dfp instance list --resource-group "TestRG"
```
##### Update #####
```
az dfp instance update --name "azsdktest" \
--administration members="azsdktest@microsoft.com" members="azsdktest2@microsoft.com" --tags testKey="testValue" \
--resource-group "TestRG"
```
##### Show-detail #####
```
az dfp instance show-detail --name "azsdktest" --resource-group "TestRG"
```
##### Delete #####
```
az dfp instance delete --name "azsdktest" --resource-group "TestRG"
```
#### dfp ####
##### List-operation #####
```
az dfp list-operation
```
50 changes: 50 additions & 0 deletions src/dfp/azext_dfp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# --------------------------------------------------------------------------
# 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 azure.cli.core import AzCommandsLoader
from azext_dfp.generated._help import helps # pylint: disable=unused-import
try:
from azext_dfp.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class DFPCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_dfp.generated._client_factory import cf_dfp_cl
dfp_custom = CliCommandType(
operations_tmpl='azext_dfp.custom#{}',
client_factory=cf_dfp_cl)
parent = super(DFPCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=dfp_custom)

def load_command_table(self, args):
from azext_dfp.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_dfp.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
from azext_dfp.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_dfp.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass


COMMAND_LOADER_CLS = DFPCommandsLoader
17 changes: 17 additions & 0 deletions src/dfp/azext_dfp/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/dfp/azext_dfp/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.15.0"
}
17 changes: 17 additions & 0 deletions src/dfp/azext_dfp/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
12 changes: 12 additions & 0 deletions src/dfp/azext_dfp/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
20 changes: 20 additions & 0 deletions src/dfp/azext_dfp/generated/_client_factory.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.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def cf_dfp_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_dfp.vendored_sdks.dfp import DFP
return get_mgmt_service_client(cli_ctx,
DFP)


def cf_instance(cli_ctx, *_):
return cf_dfp_cl(cli_ctx).instances
98 changes: 98 additions & 0 deletions src/dfp/azext_dfp/generated/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines

from knack.help_files import helps


helps['dfp instance'] = """
type: group
short-summary: Manage instance with dfp
"""

helps['dfp instance list'] = """
type: command
short-summary: "Gets all the Dedicated instance for the given resource group. And Lists all the Dedicated \
instances for the given subscription."
examples:
- name: List DFP instances in resource group
text: |-
az dfp instance list --resource-group "TestRG"
- name: Get details of a instance
text: |-
az dfp instance list
"""

helps['dfp instance create'] = """
type: command
short-summary: "Provisions the specified DFP instance based on the configuration specified in the request."
parameters:
- name: --administration
short-summary: "A collection of DFP instance administrators"
long-summary: |
Usage: --administration members=XX

members: An array of administrator user identities.
examples:
- name: Create instance
text: |-
az dfp instance create --name "azsdktest" --location "West US" --administration \
members="azsdktest@microsoft.com" members="azsdktest2@microsoft.com" --tags testKey="testValue" --resource-group \
"TestRG"
"""

helps['dfp instance update'] = """
type: command
short-summary: "Updates the current state of the specified DFP instance."
parameters:
- name: --administration
short-summary: "A collection of DFP instance administrators"
long-summary: |
Usage: --administration members=XX

members: An array of administrator user identities.
examples:
- name: Update instance parameters
text: |-
az dfp instance update --name "azsdktest" --administration members="azsdktest@microsoft.com" \
members="azsdktest2@microsoft.com" --tags testKey="testValue" --resource-group "TestRG"
"""

helps['dfp instance delete'] = """
type: command
short-summary: "Deletes the specified DFP instance."
examples:
- name: Get details of an instance
text: |-
az dfp instance delete --name "azsdktest" --resource-group "TestRG"
"""

helps['dfp instance show-detail'] = """
type: command
short-summary: "Gets details about the specified instances."
examples:
- name: Get details of an instance
text: |-
az dfp instance show-detail --name "azsdktest" --resource-group "TestRG"
"""

helps['dfp'] = """
type: group
short-summary: Manage with dfp
"""

helps['dfp list-operation'] = """
type: command
short-summary: "Lists all of the available DFP REST API operations."
examples:
- name: Get a list of operations supported by Microsoft.Dynamics365FraudProtection resource provider
text: |-
az dfp list-operation
"""
53 changes: 53 additions & 0 deletions src/dfp/azext_dfp/generated/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines
# pylint: disable=too-many-statements

from azure.cli.core.commands.parameters import (
tags_type,
resource_group_name_type,
get_location_type
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from azext_dfp.action import AddAdministration


def load_arguments(self, _):

with self.argument_context('dfp instance list') as c:
c.argument('resource_group_name', resource_group_name_type)

with self.argument_context('dfp instance create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('instance_name', options_list=['--name', '-n', '--instance-name'], type=str, help='The name of the '
'DFP instances. It must be a minimum of 3 characters, and a maximum of 63.')
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('administration', action=AddAdministration, nargs='+', help='A collection of DFP instance '
'administrators')

with self.argument_context('dfp instance update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('instance_name', options_list=['--name', '-n', '--instance-name'], type=str, help='The name of the '
'DFP instance. It must be at least 3 characters in length, and no more than 63.', id_part='name')
c.argument('tags', tags_type)
c.argument('administration', action=AddAdministration, nargs='+', help='A collection of DFP instance '
'administrators')

with self.argument_context('dfp instance delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('instance_name', options_list=['--name', '-n', '--instance-name'], type=str, help='The name of the '
'DFP instance. It must be at least 3 characters in length, and no more than 63.', id_part='name')

with self.argument_context('dfp instance show-detail') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('instance_name', options_list=['--name', '-n', '--instance-name'], type=str, help='The name of the '
'instance. It must be a minimum of 3 characters, and a maximum of 63.', id_part='name')
9 changes: 9 additions & 0 deletions src/dfp/azext_dfp/generated/_validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
39 changes: 39 additions & 0 deletions src/dfp/azext_dfp/generated/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
# pylint: disable=protected-access

import argparse
from collections import defaultdict
from knack.util import CLIError


class AddAdministration(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
namespace.administration = action

def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
properties[k].append(v)
properties = dict(properties)
except ValueError:
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:
kl = k.lower()
v = properties[k]
if kl == 'members':
d['members'] = v
else:
raise CLIError('Unsupported Key {} is provided for parameter administration. All possible keys are: '
'members'.format(k))
return d
Loading