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

Commit

Permalink
fix-generic-update-apply-param (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha authored Jun 23, 2020
1 parent 767d943 commit b50e035
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
21 changes: 13 additions & 8 deletions src/plugins/azgenerator/TemplateAzureCliCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric: boolean =
originalParameterStack.push(model.MethodParameter);
originalParameterNameStack.push(model.MethodParameter_Name);
if (!needGeneric) {
output_body.push(ConstructValuation(needGeneric, prefixIndent, originalParameterNameStack, null, "{}"));
output_body = output_body.concat(ConstructValuation(needGeneric, prefixIndent, originalParameterNameStack, null, "{}"));
}
}
else if (originalParameterStack.length > 0) {
if (model.MethodParameter['originalParameter'] == originalParameterStack[originalParameterStack.length - 1]) {
let access = "";
let access = [];
let paramName = model.Parameter_NamePython(model.MethodParameter['targetProperty']);

if (model.MethodParameter['targetProperty']?.['isDiscriminator'] == true) {
Expand All @@ -126,7 +126,7 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric: boolean =
access = ConstructValuation(needGeneric, prefixIndent, originalParameterNameStack, paramName, ToPythonString(model.MethodParameter_DefaultValue, model.MethodParameter_Type));
}
}
output_body.push(access);
output_body = output_body.concat(access);
if (model.Parameter_IsPolyOfSimple(model.MethodParameter)) {
let baseParam = model.MethodParameter;
let hasNext = false;
Expand All @@ -151,12 +151,17 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric: boolean =
return output_body;
}

function ConstructValuation(isGeneric: boolean, prefix: string, classNames: string[], paramName: string, value: string, defaultValue: string = null): string {
let str = "";
function ConstructValuation(isGeneric: boolean, prefix: string, classNames: string[], paramName: string, value: string, defaultValue: string = null): string[] {
let str = [];
if (isNullOrUndefined(defaultValue)) {
let left = "";
if (isGeneric) {
left = prefix + "instance.";
if(value.startsWith("'") && value.endsWith("'")) {
left = prefix + "instance.";
} else {
str.push(prefix + "if " + paramName + " is not None:");
left = prefix + " instance.";
}
for (var i = 1; i < classNames.length; ++i) {
left = left + classNames[i] + ".";
}
Expand All @@ -172,10 +177,10 @@ function ConstructValuation(isGeneric: boolean, prefix: string, classNames: stri
left = left + "['" + paramName + "']";
}
}
str = left + " = " + value;
str.push(left + " = " + value);
}
else {
str = ConstructValuation(isGeneric, prefix, classNames, paramName, defaultValue) + " if " + value + " == None else " + value;
str = str.concat(ConstructValuation(isGeneric, prefix, classNames, paramName, defaultValue) + " if " + value + " == None else " + value);
}
return str;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ def datafactory_trigger_update(instance,
if_match=None,
description=None,
annotations=None):
instance.description = description
instance.annotations = annotations
if description is not None:
instance.description = description
if annotations is not None:
instance.annotations = annotations
return instance


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ def managed_network_managed_network_peering_policy_hub_and_spoke_topology_update
mesh=None,
no_wait=False):
instance.type = 'HubAndSpokeTopology'
instance.hub = hub
instance.spokes = spokes
instance.mesh = mesh
if hub is not None:
instance.hub = hub
if spokes is not None:
instance.spokes = spokes
if mesh is not None:
instance.mesh = mesh
return instance


Expand All @@ -270,9 +273,12 @@ def managed_network_managed_network_peering_policy_mesh_topology_update(instance
mesh=None,
no_wait=False):
instance.type = 'MeshTopology'
instance.hub = hub
instance.spokes = spokes
instance.mesh = mesh
if hub is not None:
instance.hub = hub
if spokes is not None:
instance.spokes = spokes
if mesh is not None:
instance.mesh = mesh
return instance


Expand Down

0 comments on commit b50e035

Please sign in to comment.