From e986daabdaeb33d1d2bed6da41f806d3a2d7da0d Mon Sep 17 00:00:00 2001 From: qiaozha Date: Thu, 28 May 2020 11:51:43 +0800 Subject: [PATCH 1/2] fix-parameter-missing-after-polysimple --- .../azgenerator/TemplateAzureCliCustom.ts | 26 ++++++++++++-- .../datafactory/input/datafactory.json | 12 +++++++ .../azext_datafactory/generated/_help.py | 35 +++++++++++++++++++ .../azext_datafactory/generated/_params.py | 6 ++++ .../azext_datafactory/generated/custom.py | 17 +++++++-- .../datafactory/models/_models.py | 12 +++++++ .../datafactory/models/_models_py3.py | 15 ++++++++ .../output/src/datafactory/report.md | 4 +++ 8 files changed, 122 insertions(+), 5 deletions(-) diff --git a/src/plugins/azgenerator/TemplateAzureCliCustom.ts b/src/plugins/azgenerator/TemplateAzureCliCustom.ts index b0ee6cf33..24dc6887c 100644 --- a/src/plugins/azgenerator/TemplateAzureCliCustom.ts +++ b/src/plugins/azgenerator/TemplateAzureCliCustom.ts @@ -431,7 +431,9 @@ function GetPolyMethodCall(model: CodeModelAz, prefix: any, originalOperation: O } let cnt = 0; - for (let param of originalParameters) { + while (cnt < originalParameters.length) { + let param = originalParameters[cnt]; + cnt++; if (param.flattened) { continue; } @@ -460,6 +462,9 @@ function GetPolyMethodCall(model: CodeModelAz, prefix: any, originalOperation: O while (cnt < originalParameters.length && originalParameters[cnt]['polyBaseParam'] == baseParam) { cnt++; } + if (cnt > 0 && cnt < originalParameters.length && originalParameters[cnt]['polyBaseParam'] != baseParam) { + cnt--; + } } } @@ -489,6 +494,7 @@ function GetMethodCall(model: CodeModelAz, prefix: any): string[] { } + let skip = false; if (model.SelectFirstMethodParameter(true)) { do { let param = model.MethodParameter; @@ -521,12 +527,26 @@ function GetMethodCall(model: CodeModelAz, prefix: any): string[] { methodCall += "," + "\n" + indent + parameterPair; } + if (skip) { + skip = false; + } if (model.Parameter_IsPolyOfSimple(model.MethodParameter)) { let baseParam = model.MethodParameter; - while (model.SelectNextMethodParameter() && model.MethodParameter['polyBaseParam'] == baseParam); + let hasNext = false; + if(model.SelectNextMethodParameter(true)) { + hasNext = true; + while (hasNext && model.MethodParameter['polyBaseParam'] == baseParam) { + hasNext = model.SelectNextMethodParameter(true); + } + } + + if (hasNext && model.MethodParameter['polyBaseParam'] != baseParam) { + skip = true; + } + } } - while (model.SelectNextMethodParameter(true)); + while (skip || model.SelectNextMethodParameter(true)); } methodCall += ")"; diff --git a/src/test/scenarios/datafactory/input/datafactory.json b/src/test/scenarios/datafactory/input/datafactory.json index 652891a51..23758f46a 100644 --- a/src/test/scenarios/datafactory/input/datafactory.json +++ b/src/test/scenarios/datafactory/input/datafactory.json @@ -3099,6 +3099,18 @@ "description": "Managed integration runtime properties.", "x-ms-client-flatten": true, "$ref": "#/definitions/ManagedIntegrationRuntimeTypeProperties" + }, + "repoConfiguration": { + "$ref": "#/definitions/FactoryRepoConfiguration", + "description": "Git repo information of the factory." + }, + "fakeIdentity": { + "$ref": "#/definitions/FakeFactoryIdentity", + "description": "This is only for az test." + }, + "zones": { + "$ref": "#/definitions/Zone", + "description": "This is only for az test." } }, "required": [ diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_help.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_help.py index 20cbcbb3e..c997c5a8c 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_help.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_help.py @@ -358,6 +358,41 @@ helps['datafactory integration-runtime managed create'] = """ type: command short-summary: Creates or updates an integration runtime. + parameters: + - name: --factory-vsts-configuration + short-summary: Factory's VSTS repo information. + long-summary: | + Usage: --factory-vsts-configuration project-name=XX tenant-id=XX type=XX account-name=XX repository-name=XX\ + collaboration-branch=XX root-folder=XX last-commit-id=XX + + project-name: Required. VSTS project name. + tenant-id: VSTS tenant id. + type: Required. Type of repo configuration. + account-name: Required. Account name. + repository-name: Required. Repository name. + collaboration-branch: Required. Collaboration branch. + root-folder: Required. Root folder. + last-commit-id: Last commit id. + - name: --factory-git-hub-configuration + short-summary: Factory's GitHub repo information. + long-summary: | + Usage: --factory-git-hub-configuration host-name=XX type=XX account-name=XX repository-name=XX collaboratio\ +n-branch=XX root-folder=XX last-commit-id=XX + + host-name: GitHub Enterprise host name. For example: https://github.mydomain.com + type: Required. Type of repo configuration. + account-name: Required. Account name. + repository-name: Required. Repository name. + collaboration-branch: Required. Collaboration branch. + root-folder: Required. Root folder. + last-commit-id: Last commit id. + - name: --fake-identity + short-summary: This is only for az test. + long-summary: | + Usage: --fake-identity name=XX zones-inside=XX + + name: Required. .. + zones-inside: sample of simple array examples: - name: IntegrationRuntimes_Create text: |- 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 7ea62b3b7..b3b9035f3 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 @@ -193,6 +193,12 @@ def load_arguments(self, _): c.argument('if_match', help='ETag of the integration runtime entity. Should only be specified for update, for w' 'hich it should match existing entity or can be * for unconditional update.') c.argument('description', help='Integration runtime description.') + c.argument('factory_vsts_configuration', action=AddFactoryVstsConfiguration, nargs='+', help='Factory\'s VSTS r' + 'epo information.', arg_group='RepoConfiguration') + c.argument('factory_git_hub_configuration', action=AddFactoryGitHubConfiguration, nargs='+', help='Factory\'s G' + 'itHub repo information.', arg_group='RepoConfiguration') + c.argument('fake_identity', action=AddFakeIdentity, nargs='+', help='This is only for az test.') + c.argument('zones', nargs='+', help='This is only for az test.') c.argument('type_properties_compute_properties', arg_type=CLIArgumentType(options_list=['--type-properties-comp' 'ute-properties'], help='The compute resource for managed integration runtime. Expected value: json-' 'string/@json-file.')) 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 775a3cce6..6ef52c4a3 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 @@ -56,6 +56,7 @@ def datafactory_create(client, tags=tags, identity=None, repo_configuration=repo_configuration, + fake_identity=fake_identity, zones=zones) @@ -284,8 +285,21 @@ def datafactory_integration_runtime_managed_create(client, integration_runtime_name, if_match=None, description=None, + factory_vsts_configuration=None, + factory_git_hub_configuration=None, + fake_identity=None, + zones=None, type_properties_compute_properties=None, type_properties_ssis_properties=None): + all_repo_configuration = [] + if factory_vsts_configuration is not None: + all_repo_configuration.append(factory_vsts_configuration) + if factory_git_hub_configuration is not None: + all_repo_configuration.append(factory_git_hub_configuration) + if len(all_repo_configuration) > 1: + raise CLIError('at most one of factory_vsts_configuration, factory_git_hub_configuration is needed for repo_co' + 'nfiguration!') + repo_configuration = all_repo_configuration[0] if len(all_repo_configuration) == 1 else None if isinstance(type_properties_compute_properties, str): type_properties_compute_properties = json.loads(type_properties_compute_properties) if isinstance(type_properties_ssis_properties, str): @@ -293,8 +307,7 @@ def datafactory_integration_runtime_managed_create(client, properties = {} properties['type'] = 'Managed' properties['description'] = description - properties['compute_properties'] = type_properties_compute_properties - properties['ssis_properties'] = type_properties_ssis_properties + properties['repo_configuration'] = repo_configuration return client.create_or_update(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name, 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 ef9ce3e4e..3721f8a12 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 @@ -2099,6 +2099,12 @@ class ManagedIntegrationRuntime(IntegrationRuntime): Possible values include: "Initial", "Stopped", "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", "AccessDenied". :vartype state: str or ~dfaz_management_client.models.IntegrationRuntimeState + :param repo_configuration: Git repo information of the factory. + :type repo_configuration: ~dfaz_management_client.models.FactoryRepoConfiguration + :param fake_identity: This is only for az test. + :type fake_identity: ~dfaz_management_client.models.FakeFactoryIdentity + :param zones: This is only for az test. + :type zones: list[str] :param compute_properties: The compute resource for managed integration runtime. :type compute_properties: ~dfaz_management_client.models.IntegrationRuntimeComputeProperties :param ssis_properties: SSIS properties for managed integration runtime. @@ -2115,6 +2121,9 @@ class ManagedIntegrationRuntime(IntegrationRuntime): 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, 'state': {'key': 'state', 'type': 'str'}, + 'repo_configuration': {'key': 'repoConfiguration', 'type': 'FactoryRepoConfiguration'}, + 'fake_identity': {'key': 'fakeIdentity', 'type': 'FakeFactoryIdentity'}, + 'zones': {'key': 'zones', 'type': '[str]'}, 'compute_properties': {'key': 'typeProperties.computeProperties', 'type': 'IntegrationRuntimeComputeProperties'}, 'ssis_properties': {'key': 'typeProperties.ssisProperties', 'type': 'IntegrationRuntimeSsisProperties'}, } @@ -2126,6 +2135,9 @@ def __init__( super(ManagedIntegrationRuntime, self).__init__(**kwargs) self.type = 'Managed' self.state = None + self.repo_configuration = kwargs.get('repo_configuration', None) + self.fake_identity = kwargs.get('fake_identity', None) + self.zones = kwargs.get('zones', None) self.compute_properties = kwargs.get('compute_properties', None) self.ssis_properties = kwargs.get('ssis_properties', None) 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 bb473c67b..eddcf6792 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 @@ -2294,6 +2294,12 @@ class ManagedIntegrationRuntime(IntegrationRuntime): Possible values include: "Initial", "Stopped", "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", "AccessDenied". :vartype state: str or ~dfaz_management_client.models.IntegrationRuntimeState + :param repo_configuration: Git repo information of the factory. + :type repo_configuration: ~dfaz_management_client.models.FactoryRepoConfiguration + :param fake_identity: This is only for az test. + :type fake_identity: ~dfaz_management_client.models.FakeFactoryIdentity + :param zones: This is only for az test. + :type zones: list[str] :param compute_properties: The compute resource for managed integration runtime. :type compute_properties: ~dfaz_management_client.models.IntegrationRuntimeComputeProperties :param ssis_properties: SSIS properties for managed integration runtime. @@ -2310,6 +2316,9 @@ class ManagedIntegrationRuntime(IntegrationRuntime): 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, 'state': {'key': 'state', 'type': 'str'}, + 'repo_configuration': {'key': 'repoConfiguration', 'type': 'FactoryRepoConfiguration'}, + 'fake_identity': {'key': 'fakeIdentity', 'type': 'FakeFactoryIdentity'}, + 'zones': {'key': 'zones', 'type': '[str]'}, 'compute_properties': {'key': 'typeProperties.computeProperties', 'type': 'IntegrationRuntimeComputeProperties'}, 'ssis_properties': {'key': 'typeProperties.ssisProperties', 'type': 'IntegrationRuntimeSsisProperties'}, } @@ -2319,6 +2328,9 @@ def __init__( *, additional_properties: Optional[Dict[str, object]] = None, description: Optional[str] = None, + repo_configuration: Optional["FactoryRepoConfiguration"] = None, + fake_identity: Optional["FakeFactoryIdentity"] = None, + zones: Optional[List[str]] = None, compute_properties: Optional["IntegrationRuntimeComputeProperties"] = None, ssis_properties: Optional["IntegrationRuntimeSsisProperties"] = None, **kwargs @@ -2326,6 +2338,9 @@ def __init__( super(ManagedIntegrationRuntime, self).__init__(additional_properties=additional_properties, description=description, **kwargs) self.type: str = 'Managed' self.state = None + self.repo_configuration = repo_configuration + self.fake_identity = fake_identity + self.zones = zones self.compute_properties = compute_properties self.ssis_properties = ssis_properties diff --git a/src/test/scenarios/datafactory/output/src/datafactory/report.md b/src/test/scenarios/datafactory/output/src/datafactory/report.md index 891d099c9..75f87166e 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/report.md +++ b/src/test/scenarios/datafactory/output/src/datafactory/report.md @@ -134,6 +134,10 @@ managed create a datafactory integration-runtime. |**--integration-runtime-name**|string|The integration runtime name.|integration_runtime_name| |**--if-match**|string|ETag of the integration runtime entity. Should only be specified for update, for which it should match existing entity or can be * for unconditional update.|if_match| |**--description**|string|Integration runtime description.|managed_description| +|**--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.|managed_fake_identity| +|**--zones**|array|This is only for az test.|managed_zones| |**--type-properties-compute-properties**|object|The compute resource for managed integration runtime.|managed_compute_properties| |**--type-properties-ssis-properties**|object|SSIS properties for managed integration runtime.|managed_ssis_properties| ### datafactory integration-runtime regenerate-auth-key From d21c3b7737233648c10b3dfcf228efb43c5598cb Mon Sep 17 00:00:00 2001 From: qiaozha Date: Thu, 28 May 2020 13:08:05 +0800 Subject: [PATCH 2/2] considering poly split --- .../azgenerator/TemplateAzureCliCustom.ts | 22 +++++++++++++++++-- .../azext_datafactory/generated/custom.py | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/plugins/azgenerator/TemplateAzureCliCustom.ts b/src/plugins/azgenerator/TemplateAzureCliCustom.ts index 24dc6887c..4360798aa 100644 --- a/src/plugins/azgenerator/TemplateAzureCliCustom.ts +++ b/src/plugins/azgenerator/TemplateAzureCliCustom.ts @@ -89,7 +89,11 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric: boolean = let originalParameterNameStack: string[] = []; let prefixIndent = " "; + let skip = false; do { + if (skip) { + skip = false; + } if (model.MethodParameter_IsFlattened) { if (isNullOrUndefined(model.MethodParameter['extensions']?.['cli-poly-as-resource-base-schema'])) { continue; @@ -100,7 +104,7 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric: boolean = output_body.push(ConstructValuation(needGeneric, prefixIndent, originalParameterNameStack, null, "{}")); } } - else if (originalParameterStack.length > 0) + else if (originalParameterStack.length > 0) { if (model.MethodParameter['originalParameter'] == originalParameterStack[originalParameterStack.length - 1]) { let access = ""; let paramName = model.Parameter_NamePython(model.MethodParameter['targetProperty']); @@ -117,12 +121,26 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric: boolean = } } output_body.push(access); + if (model.Parameter_IsPolyOfSimple(model.MethodParameter)) { + let baseParam = model.MethodParameter; + let hasNext = false; + if(model.SelectNextMethodParameter(true)) { + hasNext = true; + while (hasNext && model.MethodParameter['polyBaseParam'] == baseParam) { + hasNext = model.SelectNextMethodParameter(true); + } + } + if (hasNext && model.MethodParameter['polyBaseParam'] != baseParam) { + skip = true; + } + } } else { originalParameterStack.pop(); originalParameterNameStack.pop(); } - } while (model.SelectNextMethodParameter(true)); + } + } while (skip || model.SelectNextMethodParameter(true)); } return output_body; } 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 6ef52c4a3..c2a28029c 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 @@ -308,6 +308,10 @@ def datafactory_integration_runtime_managed_create(client, properties['type'] = 'Managed' properties['description'] = description properties['repo_configuration'] = repo_configuration + properties['fake_identity'] = fake_identity + properties['zones'] = zones + properties['compute_properties'] = type_properties_compute_properties + properties['ssis_properties'] = type_properties_ssis_properties return client.create_or_update(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name,