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

Commit

Permalink
fix-parameter-missing-after-polysimple (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha authored May 28, 2020
1 parent 2387952 commit eff27cf
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 5 deletions.
48 changes: 43 additions & 5 deletions src/plugins/azgenerator/TemplateAzureCliCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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']);
Expand All @@ -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;
}
Expand Down Expand Up @@ -431,7 +449,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;
}
Expand Down Expand Up @@ -460,6 +480,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--;
}
}
}

Expand Down Expand Up @@ -489,6 +512,7 @@ function GetMethodCall(model: CodeModelAz, prefix: any): string[] {
}


let skip = false;
if (model.SelectFirstMethodParameter(true)) {
do {
let param = model.MethodParameter;
Expand Down Expand Up @@ -521,12 +545,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 += ")";
Expand Down
12 changes: 12 additions & 0 deletions src/test/scenarios/datafactory/input/datafactory.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def datafactory_create(client,
tags=tags,
identity=None,
repo_configuration=repo_configuration,
fake_identity=fake_identity,
zones=zones)


Expand Down Expand Up @@ -284,15 +285,31 @@ 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):
type_properties_ssis_properties = json.loads(type_properties_ssis_properties)
properties = {}
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'},
}
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'},
}
Expand All @@ -2319,13 +2328,19 @@ 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
):
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eff27cf

Please sign in to comment.