From b4512d54267054b68d4d1c12676a956fbea52ba8 Mon Sep 17 00:00:00 2001 From: changlong-liu <59815250+changlong-liu@users.noreply.github.com> Date: Thu, 7 May 2020 14:26:39 +0800 Subject: [PATCH] check simple array (#349) * check simple array * revert unintentional change * check simplearray for custom * format code --- src/plugins/azgenerator/CodeModelAzImpl.ts | 2 +- .../azgenerator/TemplateAzureCliCustom.ts | 2 +- .../azgenerator/TemplateAzureCliParams.ts | 2 +- .../azgenerator/TemplateAzureCliTestPrepare.ts | 2 +- .../datafactory/input/datafactory.json | 18 ++++++++++++++++++ .../azext_datafactory/generated/_params.py | 5 +++-- .../azext_datafactory/generated/action.py | 2 ++ .../azext_datafactory/generated/custom.py | 6 ++++-- .../_factory_operations_async.py | 7 +++++-- .../datafactory/models/_models.py | 8 ++++++++ .../datafactory/models/_models_py3.py | 10 ++++++++++ .../operations/_factory_operations.py | 7 +++++-- .../output/src/datafactory/report.md | 1 + 13 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/plugins/azgenerator/CodeModelAzImpl.ts b/src/plugins/azgenerator/CodeModelAzImpl.ts index b9078e0e0..8165a45b8 100644 --- a/src/plugins/azgenerator/CodeModelAzImpl.ts +++ b/src/plugins/azgenerator/CodeModelAzImpl.ts @@ -313,7 +313,7 @@ export class CodeModelCliImpl implements CodeModelAz { if (this.Parameter_IsPolyOfSimple()) { continue; } - if (this.MethodParameter_IsList && this.MethodParameter_IsListOfSimple) { + if (this.MethodParameter_IsList && this.MethodParameter_IsListOfSimple && !this.MethodParameter_IsSimpleArray) { let groupOpParamName: string = "Add" + Capitalize(ToCamelCase(this.Command_FunctionName + "_" + this.MethodParameter_MapsTo)); let groupParamName: string = "Add" + Capitalize(ToCamelCase(this.CommandGroup_Key + "_" + this.MethodParameter_MapsTo)); let actionName: string = "Add" + Capitalize(ToCamelCase(this.MethodParameter_MapsTo)); diff --git a/src/plugins/azgenerator/TemplateAzureCliCustom.ts b/src/plugins/azgenerator/TemplateAzureCliCustom.ts index 6907cc0b7..511150813 100644 --- a/src/plugins/azgenerator/TemplateAzureCliCustom.ts +++ b/src/plugins/azgenerator/TemplateAzureCliCustom.ts @@ -248,7 +248,7 @@ function GetSingleCommandBody(model: CodeModelAz, required, originalOperation: O do { if (model.SelectFirstMethodParameter()) { do { - if (model.MethodParameter_IsList && !model.MethodParameter_IsListOfSimple) { + if (model.MethodParameter_IsList && !model.MethodParameter_IsListOfSimple && !model.MethodParameter_IsSimpleArray) { if (model.Parameter_IsPolyOfSimple(model.MethodParameter)) { let baseParam = model.MethodParameter; let baseName = model.MethodParameter_MapsTo; diff --git a/src/plugins/azgenerator/TemplateAzureCliParams.ts b/src/plugins/azgenerator/TemplateAzureCliParams.ts index c3461f280..b9dd580f2 100644 --- a/src/plugins/azgenerator/TemplateAzureCliParams.ts +++ b/src/plugins/azgenerator/TemplateAzureCliParams.ts @@ -267,7 +267,7 @@ function getCommandBody(model: CodeModelAz, needUpdate: boolean = false, needGen if (!needSkip) { argument += ", help='" + EscapeString(model.MethodParameter_Description).trimRight(); - if (model.MethodParameter_IsList) { + if (model.MethodParameter_IsList && !model.MethodParameter_IsSimpleArray) { let netDescription = model.MethodParameter_Description.trim(); if (netDescription.length>0 && netDescription[netDescription.length-1].match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+[0-9a-z]+$/i)) { argument += "."; diff --git a/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts b/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts index b0dac2cca..6aa2ffc63 100644 --- a/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts +++ b/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts @@ -1,7 +1,7 @@ import { CodeModelAz } from "./CodeModelAz" import { HeaderGenerator } from "./Header"; -export function GenerateAzureCliTestPrepare(model: CodeModelAz) : string[] { +export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] { let header: HeaderGenerator = new HeaderGenerator(); var output: string[] = header.getLines(); output.push(""); diff --git a/src/test/scenarios/datafactory/input/datafactory.json b/src/test/scenarios/datafactory/input/datafactory.json index 9a6122b95..26e45d4e4 100644 --- a/src/test/scenarios/datafactory/input/datafactory.json +++ b/src/test/scenarios/datafactory/input/datafactory.json @@ -758,6 +758,10 @@ "fakeIdentity": { "$ref": "#/definitions/FakeFactoryIdentity", "description": "This is only for az test." + }, + "zones": { + "$ref": "#/definitions/Zone", + "description": "This is only for az test." } } }, @@ -831,12 +835,26 @@ "type" ] }, + "Zone": { + "type": "array", + "items": { + "type": "string" + }, + "description": "sample of simple array" + }, "FakeFactoryIdentity": { "description": "This is only for az test.", "properties": { "name": { "type": "string", "description": ".." + }, + "zonesInside": { + "type": "array", + "items": { + "type": "string" + }, + "description": "sample of simple array" } }, "required": [ diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_params.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_params.py index 456f475b1..1307204df 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_params.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_params.py @@ -54,8 +54,9 @@ 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.') + c.argument('fake_identity', action=AddFakeIdentity, nargs='+', help='This is only for az test. Expect value: KE' + 'Y1=VALUE1 KEY2=VALUE2 ... , available KEYs are: name, zones-inside.') + c.argument('zones', nargs='+', help='This is only for az test.') with self.argument_context('datafactory update') as c: c.argument('resource_group_name', resource_group_name_type) diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py index 6f24d3ccf..e8e063c26 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py @@ -125,4 +125,6 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use v = properties[k] if kl == 'name': d['name'] = v[0] + elif kl == 'zones-inside': + d['zones_inside'] = v return d diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py index 793b2bed2..a2f5b42ba 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py @@ -37,7 +37,8 @@ def datafactory_create(cmd, client, identity=None, factory_vsts_configuration=None, factory_git_hub_configuration=None, - fake_identity=None): + fake_identity=None, + zones=None): all_repo_configuration = [] if factory_vsts_configuration is not None: all_repo_configuration.append(factory_vsts_configuration) @@ -53,7 +54,8 @@ def datafactory_create(cmd, client, location=location, tags=tags, identity=identity, - repo_configuration=repo_configuration) + repo_configuration=repo_configuration, + zones=zones) def datafactory_update(cmd, client, diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/aio/operations_async/_factory_operations_async.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/aio/operations_async/_factory_operations_async.py index 9891c6b6d..a94fde969 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/aio/operations_async/_factory_operations_async.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/aio/operations_async/_factory_operations_async.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -247,6 +247,7 @@ async def create_or_update( identity: Optional["models.FactoryIdentity"] = None, repo_configuration: Optional["models.FactoryRepoConfiguration"] = None, fake_identity: Optional["models.FakeFactoryIdentity"] = None, + zones: Optional[List[str]] = None, **kwargs ) -> "models.Factory": """Creates or updates a factory. @@ -268,6 +269,8 @@ async def create_or_update( :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 + :param zones: This is only for az test. + :type zones: list[str] :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 @@ -277,7 +280,7 @@ async def create_or_update( error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) - _factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity) + _factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity, zones=zones) api_version = "2018-06-01" content_type = kwargs.pop("content_type", "application/json") diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models.py index cbae7d0f2..44563797e 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models.py @@ -154,6 +154,8 @@ class Factory(Resource): :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 + :param zones: This is only for az test. + :type zones: list[str] """ _validation = { @@ -180,6 +182,7 @@ class Factory(Resource): 'version': {'key': 'properties.version', 'type': 'str'}, 'repo_configuration': {'key': 'properties.repoConfiguration', 'type': 'FactoryRepoConfiguration'}, 'fake_identity': {'key': 'properties.fakeIdentity', 'type': 'FakeFactoryIdentity'}, + 'zones': {'key': 'properties.zones', 'type': '[str]'}, } def __init__( @@ -194,6 +197,7 @@ def __init__( self.version = None self.repo_configuration = kwargs.get('repo_configuration', None) self.fake_identity = kwargs.get('fake_identity', None) + self.zones = kwargs.get('zones', None) class FactoryRepoConfiguration(msrest.serialization.Model): @@ -474,6 +478,8 @@ class FakeFactoryIdentity(msrest.serialization.Model): :param name: Required. .. :type name: str + :param zones_inside: sample of simple array. + :type zones_inside: list[str] """ _validation = { @@ -482,6 +488,7 @@ class FakeFactoryIdentity(msrest.serialization.Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, + 'zones_inside': {'key': 'zonesInside', 'type': '[str]'}, } def __init__( @@ -490,6 +497,7 @@ def __init__( ): super(FakeFactoryIdentity, self).__init__(**kwargs) self.name = kwargs['name'] + self.zones_inside = kwargs.get('zones_inside', None) class GitHubAccessTokenRequest(msrest.serialization.Model): diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models_py3.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models_py3.py index f83848458..fd6115758 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models_py3.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/models/_models_py3.py @@ -168,6 +168,8 @@ class Factory(Resource): :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 + :param zones: This is only for az test. + :type zones: list[str] """ _validation = { @@ -194,6 +196,7 @@ class Factory(Resource): 'version': {'key': 'properties.version', 'type': 'str'}, 'repo_configuration': {'key': 'properties.repoConfiguration', 'type': 'FactoryRepoConfiguration'}, 'fake_identity': {'key': 'properties.fakeIdentity', 'type': 'FakeFactoryIdentity'}, + 'zones': {'key': 'properties.zones', 'type': '[str]'}, } def __init__( @@ -205,6 +208,7 @@ def __init__( identity: Optional["FactoryIdentity"] = None, repo_configuration: Optional["FactoryRepoConfiguration"] = None, fake_identity: Optional["FakeFactoryIdentity"] = None, + zones: Optional[List[str]] = None, **kwargs ): super(Factory, self).__init__(location=location, tags=tags, **kwargs) @@ -215,6 +219,7 @@ def __init__( self.version = None self.repo_configuration = repo_configuration self.fake_identity = fake_identity + self.zones = zones class FactoryRepoConfiguration(msrest.serialization.Model): @@ -525,6 +530,8 @@ class FakeFactoryIdentity(msrest.serialization.Model): :param name: Required. .. :type name: str + :param zones_inside: sample of simple array. + :type zones_inside: list[str] """ _validation = { @@ -533,16 +540,19 @@ class FakeFactoryIdentity(msrest.serialization.Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, + 'zones_inside': {'key': 'zonesInside', 'type': '[str]'}, } def __init__( self, *, name: str, + zones_inside: Optional[List[str]] = None, **kwargs ): super(FakeFactoryIdentity, self).__init__(**kwargs) self.name = name + self.zones_inside = zones_inside class GitHubAccessTokenRequest(msrest.serialization.Model): diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/operations/_factory_operations.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/operations/_factory_operations.py index bf886fd7a..a0bbae5ed 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/operations/_factory_operations.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/vendored_sdks/datafactory/operations/_factory_operations.py @@ -18,7 +18,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -254,6 +254,7 @@ def create_or_update( identity=None, # type: Optional["models.FactoryIdentity"] repo_configuration=None, # type: Optional["models.FactoryRepoConfiguration"] fake_identity=None, # type: Optional["models.FakeFactoryIdentity"] + zones=None, # type: Optional[List[str]] **kwargs # type: Any ): # type: (...) -> "models.Factory" @@ -276,6 +277,8 @@ def create_or_update( :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 + :param zones: This is only for az test. + :type zones: list[str] :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 @@ -285,7 +288,7 @@ def create_or_update( error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) - _factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity) + _factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity, zones=zones) api_version = "2018-06-01" content_type = kwargs.pop("content_type", "application/json") diff --git a/src/test/scenarios/datafactory/output/src/datafactory/report.md b/src/test/scenarios/datafactory/output/src/datafactory/report.md index 51995ae57..63f5b0575 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/report.md +++ b/src/test/scenarios/datafactory/output/src/datafactory/report.md @@ -25,6 +25,7 @@ create a datafactory. |**--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| +|**--zones**|array|This is only for az test.|zones| ### datafactory delete delete a datafactory.