Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com>
This commit is contained in:
changlong-liu 2020-06-23 10:23:11 +08:00 коммит произвёл GitHub
Родитель b50e035e9d
Коммит 549c834586
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 34 добавлений и 65 удалений

Просмотреть файл

@ -9,7 +9,7 @@ import { serialize, deserialize, EnglishPluralizationService, pascalCase } from
import { Session, startSession, Host, Channel } from "@azure-tools/autorest-extension-base";
import { ToSnakeCase, deepCopy, ToJsonString, Capitalize, ToCamelCase, EscapeString, parseResourceId } from '../../utils/helper';
import { values } from "@azure-tools/linq";
import { GenerateDefaultTestScenario, ResourcePool, GenerateDefaultTestScenarioByDependency } from './ScenarioTool'
import { GenerateDefaultTestScenario, ResourcePool, GenerateDefaultTestScenarioByDependency, PrintTestScenario } from './ScenarioTool'
import { timingSafeEqual } from "crypto";
import { isNullOrUndefined, isArray } from "util";
@ -855,6 +855,10 @@ export class CodeModelCliImpl implements CodeModelAz {
}
return polyOriginal;
}
public get Method_GetSplitOriginalOperation(): any {
return this.Method.extensions?.['cli-split-operation-original-operation'];
}
//=================================================================================================================
// Methods Parameters.
//
@ -1822,8 +1826,8 @@ export class CodeModelCliImpl implements CodeModelAz {
let cliKey = model.Method.language['cli'].cliKey;
if (cliKey) {
let names = cliKey.split('#');
if (names.length > 1) {
return names[1];
if (names && names.length > 1) {
return names[names.length-1];
}
}
return '';
@ -1833,7 +1837,7 @@ export class CodeModelCliImpl implements CodeModelAz {
function matchPolyClass(example: CommandExample, keyToMatch: string, valueToMatch: string) {
for (let param of example.Parameters) {
if (('--' + keyToMatch).toLowerCase() == param.name.toLowerCase() && typeof param.value == 'string') {
if ((('--' + keyToMatch).toLowerCase() == param.name.toLowerCase() || ('--' + keyToMatch + '-').toLowerCase() == param.name.toLowerCase()) && typeof param.value == 'string') {
return valueToMatch.toLowerCase() == param.value.toLowerCase();
}
}
@ -1873,6 +1877,13 @@ export class CodeModelCliImpl implements CodeModelAz {
example.Parameters = this.ConvertToCliParameters(params);
example.MethodResponses = this.Method.responses || [];
example.Method_IsLongRun = this.Method.extensions?.['x-ms-long-running-operation'] ? true : false;
if (this.Method_GetSplitOriginalOperation && Object.keys(this.Examples).length>1) {
//filter example by name for generic createorupdate
if(this.Command_MethodName.toLowerCase()=="update" && !id.toLowerCase().endsWith("_update"))
return;
if(this.Command_MethodName.toLowerCase()!="update" && id.toLowerCase().endsWith("_update"))
return;
}
if (this.filterExampleByPoly(example_obj, example)) {
for (let i=0;i<example.Parameters.length; i++) {
if (this.isDiscriminator(example.Parameters[i].methodParam.value) )
@ -2048,6 +2059,7 @@ export class CodeModelCliImpl implements CodeModelAz {
if (!this._configuredScenario) {
this._testScenario = GenerateDefaultTestScenarioByDependency(this.GetAllExamples(), this.resource_pool, this._testScenario);
this.SortExamplesByDependency();
PrintTestScenario(this._testScenario);
}
let commandParams = {};

Просмотреть файл

@ -15,11 +15,6 @@ function MethodToOrder(httpMethod: string): number {
export function GenerateDefaultTestScenario(
examples: CommandExample[]): any[] {
console.warn("");
console.warn("NO TEST SCENARIO PROVIDED - DEFAULT WILL BE USED");
console.warn("ADD FOLLOWING SECTION TO readme.cli.md FILE TO MODIFY IT");
console.warn("--------------------------------------------------------");
console.warn(" test-scenario:");
let testScenario = [];
@ -52,10 +47,8 @@ export function GenerateDefaultTestScenario(
for (var i = 0; i < sorted.length; i++) {
var example: CommandExample = sorted[i];
console.warn(" - name: " + example.Id);
testScenario.push({ name: example.Id })
}
console.warn("--------------------------------------------------------");
return testScenario;
}
@ -82,6 +75,21 @@ export function GenerateDefaultTestScenarioByDependency(
});
}
export function PrintTestScenario(testScenario: any[]) {
console.warn("");
console.warn("NO TEST SCENARIO PROVIDED - DEFAULT WILL BE USED");
console.warn("ADD FOLLOWING SECTION TO readme.cli.md FILE TO MODIFY IT");
console.warn("--------------------------------------------------------");
console.warn(" test-scenario:");
for (var i = 0; i < testScenario.length; i++) {
var step: any = testScenario[i];
console.warn(" - name: " + step.name);
}
console.warn("--------------------------------------------------------");
}
const SUBSCRIPTIONS = "subscriptions";
const RESOUREGROUP = "resource-group";

Просмотреть файл

@ -15,7 +15,6 @@ cli:
- name: /Factories/post/Factories_GetGitHubAccessToken
- name: /Factories/patch/Factories_Update
- name: /IntegrationRuntimes/put/IntegrationRuntimes_Create
- name: /IntegrationRuntimes/put/IntegrationRuntimes_Create
- name: /IntegrationRuntimes/get/IntegrationRuntimes_Get
- name: /IntegrationRuntimes/get/IntegrationRuntimes_ListByFactory
- name: /IntegrationRuntimes/post/IntegrationRuntimes_CreateLinkedIntegrationRuntime

Просмотреть файл

@ -196,24 +196,12 @@ bNameList\\":[\\"exampleoutput.csv\\"]},\\"pipelineReference\\":{\\"type\\":\\"P
:\\"examplePipeline\\"}}],\\"typeProperties\\":{\\"recurrence\\":{\\"endTime\\":\\"2018-06-16T00:55:13.8441801Z\\",\\"f\
requency\\":\\"Minute\\",\\"interval\\":4,\\"startTime\\":\\"2018-06-16T00:39:13.8441801Z\\",\\"timeZone\\":\\"UTC\\"}}\
}" --name "exampleTrigger"
- name: Triggers_Update
text: |-
az datafactory trigger create --factory-name "exampleFactoryName" --resource-group \
"exampleResourceGroup" --properties "{\\"type\\":\\"ScheduleTrigger\\",\\"description\\":\\"Example \
description\\",\\"pipelines\\":[{\\"parameters\\":{\\"OutputBlobNameList\\":[\\"exampleoutput.csv\\"]},\\"pipelineRefer\
ence\\":{\\"type\\":\\"PipelineReference\\",\\"referenceName\\":\\"examplePipeline\\"}}],\\"typeProperties\\":{\\"recur\
rence\\":{\\"endTime\\":\\"2018-06-16T00:55:14.905167Z\\",\\"frequency\\":\\"Minute\\",\\"interval\\":4,\\"startTime\\"\
:\\"2018-06-16T00:39:14.905167Z\\",\\"timeZone\\":\\"UTC\\"}}}" --name "exampleTrigger"
"""
helps['datafactory trigger update'] = """
type: command
short-summary: Creates or updates a trigger.
examples:
- name: Triggers_Create
text: |-
az datafactory trigger update --factory-name "exampleFactoryName" --resource-group \
"exampleResourceGroup" --name "exampleTrigger"
- name: Triggers_Update
text: |-
az datafactory trigger update --factory-name "exampleFactoryName" --resource-group \
@ -386,11 +374,6 @@ collaboration-branch=XX root-folder=XX last-commit-id=XX
name: Required. ..
zones-inside: sample of simple array
examples:
- name: IntegrationRuntimes_Create
text: |-
az datafactory integration-runtime managed create --factory-name "exampleFactoryName" --description "A \
selfhosted integration runtime" --name "exampleIntegrationRuntime" --resource-group "exampleResourceGroup"
"""
helps['datafactory integration-runtime self-hosted'] = """

Просмотреть файл

@ -108,18 +108,7 @@ def step__factories_patch_factories_update(test, rg):
# EXAMPLE: /IntegrationRuntimes/put/IntegrationRuntimes_Create
@try_manual
def step__integrationruntimes_put_integrationruntimes_create(test, rg):
test.cmd('az datafactory integration-runtime managed create '
'--factory-name "{exampleFactoryName}" '
'--description "A selfhosted integration runtime" '
'--name "{exampleIntegrationRuntime}" '
'--resource-group "{rg}"',
checks=[])
# EXAMPLE: /IntegrationRuntimes/put/IntegrationRuntimes_Create
@try_manual
def step__integrationruntimes_put_integrationruntimes_create(test, rg):
test.cmd('az datafactory integration-runtime managed create '
test.cmd('az datafactory integration-runtime self-hosted create '
'--factory-name "{exampleFactoryName}" '
'--description "A selfhosted integration runtime" '
'--name "{exampleIntegrationRuntime}" '
@ -293,15 +282,10 @@ def step__triggers_put_triggers_create(test, rg):
# EXAMPLE: /Triggers/put/Triggers_Update
@try_manual
def step__triggers_put_triggers_update(test, rg):
test.cmd('az datafactory trigger create '
test.cmd('az datafactory trigger update '
'--factory-name "{exampleFactoryName}" '
'--resource-group "{rg}" '
'--properties "{{\\"type\\":\\"ScheduleTrigger\\",\\"description\\":\\"Example '
'description\\",\\"pipelines\\":[{{\\"parameters\\":{{\\"OutputBlobNameList\\":[\\"exampleoutput.csv\\"]}}'
',\\"pipelineReference\\":{{\\"type\\":\\"PipelineReference\\",\\"referenceName\\":\\"examplePipeline\\"}}'
'}}],\\"typeProperties\\":{{\\"recurrence\\":{{\\"endTime\\":\\"2018-06-16T00:55:14.905167Z\\",\\"frequenc'
'y\\":\\"Minute\\",\\"interval\\":4,\\"startTime\\":\\"2018-06-16T00:39:14.905167Z\\",\\"timeZone\\":\\"UT'
'C\\"}}}}}}" '
'--description "Example description" '
'--name "{exampleTrigger}"',
checks=[])
@ -431,7 +415,6 @@ def call_scenario(test, rg):
step__factories_post_factories_getgithubaccesstoken(test, rg)
step__factories_patch_factories_update(test, rg)
step__integrationruntimes_put_integrationruntimes_create(test, rg)
step__integrationruntimes_put_integrationruntimes_create(test, rg)
step__integrationruntimes_get_integrationruntimes_get(test, rg)
step__integrationruntimes_get_integrationruntimes_listbyfactory(test, rg)
step__integrationruntimes_post_integrationruntimes_createlinkedintegrationruntime(test, rg)

Просмотреть файл

@ -363,14 +363,6 @@ Policy
id: Resource Id
Multiple actions can be specified by using more than one --mesh argument.
examples:
- name: Create/Update Managed Network Peering Policy
text: |-
az managed-network managed-network-peering-policy mesh-topology create --managed-network-name \
"myManagedNetwork" --policy-name "myHubAndSpoke" --hub id="/subscriptions/subscriptionB/resourceGroups/myResourceGroup/\
providers/Microsoft.Network/virtualNetworks/myHubVnet" --spokes id="/subscriptions/subscriptionB/resourceGroups/myResou\
rceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork/managedNetworkGroups/myManagedNetworkGroup\
1" --resource-group "myResourceGroup"
"""
helps['managed-network managed-network-peering-policy hub-and-spoke-topology update'] = """
@ -437,14 +429,6 @@ Policy
id: Resource Id
Multiple actions can be specified by using more than one --mesh argument.
examples:
- name: Create/Update Managed Network Peering Policy
text: |-
az managed-network managed-network-peering-policy mesh-topology update --managed-network-name \
"myManagedNetwork" --policy-name "myHubAndSpoke" --hub id="/subscriptions/subscriptionB/resourceGroups/myResourceGroup/\
providers/Microsoft.Network/virtualNetworks/myHubVnet" --spokes id="/subscriptions/subscriptionB/resourceGroups/myResou\
rceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork/managedNetworkGroups/myManagedNetworkGroup\
1" --resource-group "myResourceGroup"
"""
helps['managed-network managed-network-peering-policy delete'] = """