Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix-issue-282-273
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha authored Apr 23, 2020
2 parents be6106e + f8d15ac commit 33d3e25
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/plugins/azgenerator/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function GenerateAll(model: CodeModelAz,
do
{
let pathTop = "";
let path = "azext_" + model.Extension_Name.replace("-", "_") + "/";
let path = "azext_" + model.Extension_Name.split("-").join("_") + "/";

files[path + "generated/_params.py"] = GenerateAzureCliParams(model);
files[path + "generated/commands.py"] = GenerateAzureCliCommands(model);
Expand Down
34 changes: 17 additions & 17 deletions src/plugins/azgenerator/TemplateAzureCliActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ export function GenerateAzureCliActions(model: CodeModelAz): string[] {
do {
if (model.SelectFirstMethod()) {
do {
let baseParam = null;
if (model.SelectFirstMethodParameter()) {
do {
if (baseParam && model.MethodParameter['polyBaseParam'] == baseParam) {
let keyToMatch = baseParam.schema?.['discriminator']?.property?.language['python']?.name;
let valueToMatch = model.MethodParameter.schema?.['discriminatorValue'];
let subActionName = model.Schema_ActionName(model.MethodParameter.schema);
if (isNullOrUndefined(subActionName) || allActions.has(subActionName)) {
continue;
}
output = output.concat(GetAction(model, subActionName, model.MethodParameter, keyToMatch, valueToMatch))
}
let actionName = model.Schema_ActionName(model.MethodParameter.schema);
if (isNullOrUndefined(actionName)) {
if (model.Parameter_IsPolyOfSimple(model.MethodParameter)) {
let baseParam = model.MethodParameter;
while (model.SelectNextMethodParameter() && model.MethodParameter['polyBaseParam'] == baseParam) {
let keyToMatch = baseParam.schema?.['discriminator']?.property?.language['python']?.name;
let valueToMatch = model.MethodParameter.schema?.['discriminatorValue'];
let subActionName = model.Schema_ActionName(model.MethodParameter.schema);
if (isNullOrUndefined(subActionName) || allActions.has(subActionName)) {
continue;
}
output = output.concat(GetAction(model, subActionName, model.MethodParameter, keyToMatch, valueToMatch))
}
continue;
}
continue;
baseParam = model.MethodParameter;
}
}
if (allActions.has(actionName)) {
continue;
else {
if (allActions.has(actionName)) {
continue;
}
output = output.concat(GetAction(model, actionName, model.MethodParameter))
}
output = output.concat(GetAction(model, actionName, model.MethodParameter))

} while (model.SelectNextMethodParameter());
}
} while (model.SelectNextMethod());
Expand Down
16 changes: 16 additions & 0 deletions src/test/scenarios/datafactory/input/datafactory.json
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@
"repoConfiguration": {
"$ref": "#/definitions/FactoryRepoConfiguration",
"description": "Git repo information of the factory."
},
"fakeIdentity": {
"$ref": "#/definitions/FakeFactoryIdentity",
"description": "This is only for az test."
}
}
},
Expand Down Expand Up @@ -826,6 +830,18 @@
"required": [
"type"
]
},
"FakeFactoryIdentity": {
"description": "This is only for az test.",
"properties": {
"name": {
"type": "string",
"description": ".."
}
},
"required": [
"name"
]
}
},
"parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from azext_datafactory.action import (
AddIdentity,
AddFactoryVstsConfiguration,
AddFactoryGitHubConfiguration
AddFactoryGitHubConfiguration,
AddFakeIdentity
)


Expand Down Expand Up @@ -53,6 +54,8 @@ def load_arguments(self, _):
'itHub repo information. Expect value: KEY1=VALUE1 KEY2=VALUE2 ... , available KEYs are: host-name, '
'account-name, repository-name, collaboration-branch, root-folder, last-commit-id.', arg_group='Repo'
'Configuration')
c.argument('fake_identity', action=AddFakeIdentity, nargs='+', help='This is only for az test. Expect value: na'
'me=xx.')

with self.argument_context('datafactory update') as c:
c.argument('resource_group_name', resource_group_name_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,26 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
d['last_commit_id'] = v[0]
d['type'] = 'FactoryGitHubConfiguration'
return d


class AddFakeIdentity(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
namespace.fake_identity = 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 == 'name':
d['name'] = v[0]
return d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def datafactory_create(cmd, client,
tags=None,
identity=None,
factory_vsts_configuration=None,
factory_git_hub_configuration=None):
factory_git_hub_configuration=None,
fake_identity=None):
all_repo_configuration = []
if factory_vsts_configuration is not None:
all_repo_configuration.append(factory_vsts_configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ async def create_or_update(
tags: Optional[Dict[str, str]] = None,
identity: Optional["models.FactoryIdentity"] = None,
repo_configuration: Optional["models.FactoryRepoConfiguration"] = None,
fake_identity: Optional["models.FakeFactoryIdentity"] = None,
**kwargs
) -> "models.Factory":
"""Creates or updates a factory.
Expand All @@ -262,6 +263,8 @@ async def create_or_update(
:type identity: ~azure.mgmt.datafactory.models.FactoryIdentity
:param repo_configuration: Git repo information of the factory.
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Factory or the result of cls(response)
:rtype: ~azure.mgmt.datafactory.models.Factory
Expand All @@ -270,7 +273,7 @@ async def create_or_update(
cls = kwargs.pop('cls', None) # type: ClsType["models.Factory"]
error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError})

_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration)
_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity)
api_version = "2018-06-01"
content_type = kwargs.pop("content_type", "application/json")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ._models_py3 import FactoryRepoUpdate
from ._models_py3 import FactoryUpdateParameters
from ._models_py3 import FactoryVstsConfiguration
from ._models_py3 import FakeFactoryIdentity
from ._models_py3 import GitHubAccessTokenRequest
from ._models_py3 import GitHubAccessTokenResponse
from ._models_py3 import Resource
Expand All @@ -32,6 +33,7 @@
from ._models import FactoryRepoUpdate # type: ignore
from ._models import FactoryUpdateParameters # type: ignore
from ._models import FactoryVstsConfiguration # type: ignore
from ._models import FakeFactoryIdentity # type: ignore
from ._models import GitHubAccessTokenRequest # type: ignore
from ._models import GitHubAccessTokenResponse # type: ignore
from ._models import Resource # type: ignore
Expand All @@ -48,6 +50,7 @@
'FactoryRepoUpdate',
'FactoryUpdateParameters',
'FactoryVstsConfiguration',
'FakeFactoryIdentity',
'GitHubAccessTokenRequest',
'GitHubAccessTokenResponse',
'Resource',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ class Factory(Resource):
:vartype version: str
:param repo_configuration: Git repo information of the factory.
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
"""

_validation = {
Expand All @@ -177,6 +179,7 @@ class Factory(Resource):
'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'},
'version': {'key': 'properties.version', 'type': 'str'},
'repo_configuration': {'key': 'properties.repoConfiguration', 'type': 'FactoryRepoConfiguration'},
'fake_identity': {'key': 'properties.fakeIdentity', 'type': 'FakeFactoryIdentity'},
}

def __init__(
Expand All @@ -190,6 +193,7 @@ def __init__(
self.create_time = None
self.version = None
self.repo_configuration = kwargs.get('repo_configuration', None)
self.fake_identity = kwargs.get('fake_identity', None)


class FactoryRepoConfiguration(msrest.serialization.Model):
Expand Down Expand Up @@ -463,6 +467,31 @@ def __init__(
self.tenant_id = kwargs.get('tenant_id', None)


class FakeFactoryIdentity(msrest.serialization.Model):
"""This is only for az test.
All required parameters must be populated in order to send to Azure.
:param name: Required. ..
:type name: str
"""

_validation = {
'name': {'required': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
}

def __init__(
self,
**kwargs
):
super(FakeFactoryIdentity, self).__init__(**kwargs)
self.name = kwargs['name']


class GitHubAccessTokenRequest(msrest.serialization.Model):
"""Get GitHub access token request definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class Factory(Resource):
:vartype version: str
:param repo_configuration: Git repo information of the factory.
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
"""

_validation = {
Expand All @@ -191,6 +193,7 @@ class Factory(Resource):
'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'},
'version': {'key': 'properties.version', 'type': 'str'},
'repo_configuration': {'key': 'properties.repoConfiguration', 'type': 'FactoryRepoConfiguration'},
'fake_identity': {'key': 'properties.fakeIdentity', 'type': 'FakeFactoryIdentity'},
}

def __init__(
Expand All @@ -201,6 +204,7 @@ def __init__(
additional_properties: Optional[Dict[str, object]] = None,
identity: Optional["FactoryIdentity"] = None,
repo_configuration: Optional["FactoryRepoConfiguration"] = None,
fake_identity: Optional["FakeFactoryIdentity"] = None,
**kwargs
):
super(Factory, self).__init__(location=location, tags=tags, **kwargs)
Expand All @@ -210,6 +214,7 @@ def __init__(
self.create_time = None
self.version = None
self.repo_configuration = repo_configuration
self.fake_identity = fake_identity


class FactoryRepoConfiguration(msrest.serialization.Model):
Expand Down Expand Up @@ -513,6 +518,33 @@ def __init__(
self.tenant_id = tenant_id


class FakeFactoryIdentity(msrest.serialization.Model):
"""This is only for az test.
All required parameters must be populated in order to send to Azure.
:param name: Required. ..
:type name: str
"""

_validation = {
'name': {'required': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
}

def __init__(
self,
*,
name: str,
**kwargs
):
super(FakeFactoryIdentity, self).__init__(**kwargs)
self.name = name


class GitHubAccessTokenRequest(msrest.serialization.Model):
"""Get GitHub access token request definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def create_or_update(
tags=None, # type: Optional[Dict[str, str]]
identity=None, # type: Optional["models.FactoryIdentity"]
repo_configuration=None, # type: Optional["models.FactoryRepoConfiguration"]
fake_identity=None, # type: Optional["models.FakeFactoryIdentity"]
**kwargs # type: Any
):
# type: (...) -> "models.Factory"
Expand All @@ -270,6 +271,8 @@ def create_or_update(
:type identity: ~azure.mgmt.datafactory.models.FactoryIdentity
:param repo_configuration: Git repo information of the factory.
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Factory or the result of cls(response)
:rtype: ~azure.mgmt.datafactory.models.Factory
Expand All @@ -278,7 +281,7 @@ def create_or_update(
cls = kwargs.pop('cls', None) # type: ClsType["models.Factory"]
error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError})

_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration)
_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity)
api_version = "2018-06-01"
content_type = kwargs.pop("content_type", "application/json")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ create a datafactory.
|**--identity**|object|Managed service identity of the factory.|identity|
|**--factory-vsts-configuration**|object|Factory's VSTS repo information.|factory_vsts_configuration|
|**--factory-git-hub-configuration**|object|Factory's GitHub repo information.|factory_git_hub_configuration|
|**--fake-identity**|object|This is only for az test.|fake_identity|
### datafactory delete

delete a datafactory.
Expand Down

0 comments on commit 33d3e25

Please sign in to comment.