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

Commit

Permalink
for #659 (#663)
Browse files Browse the repository at this point in the history
Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com>
  • Loading branch information
changlong-liu and qiaozha authored Dec 2, 2020
1 parent 5869859 commit 5ce3b7a
Show file tree
Hide file tree
Showing 22 changed files with 159 additions and 146 deletions.
1 change: 1 addition & 0 deletions src/plugins/azgenerator/CodeModelAz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum KeyValueType {
Classic,
PositionalKey,
ShorthandSyntax,
SimpleArray,
}

export class ExampleParam {
Expand Down
15 changes: 13 additions & 2 deletions src/plugins/azgenerator/CodeModelAzImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,8 +1467,12 @@ export class CodeModelCliImpl implements CodeModelAz {
}

public get MethodParameter_IsSimpleArray(): boolean {
if (this.MethodParameter_Type == SchemaType.Array) {
let elementType = this.MethodParameter['schema']['elementType'].type;
return this.Parameter_IsSimpleArray(this.MethodParameter);
}

private Parameter_IsSimpleArray(param: Parameter): boolean {
if (this.Parameter_Type(param) == SchemaType.Array) {
let elementType = param['schema']['elementType'].type;
if (!this.isComplexSchema(elementType)) {
return true;
}
Expand Down Expand Up @@ -1987,6 +1991,13 @@ export class CodeModelCliImpl implements CodeModelAz {
}
example_param.push(new ExampleParam(name, ret, false, KeyValueType.ShorthandSyntax, keys, defaultName, realParam, ancestors, value));
}
else if (this.Parameter_IsSimpleArray(realParam.value)) {
for (let i=0; i<value.length; i++) {
ret += ToJsonString(value[i]) + " ";
}
ret = ret.trim();
example_param.push(new ExampleParam(name, ret, false, KeyValueType.SimpleArray, [], defaultName, realParam, ancestors, value));
}
else {
for (let i=0; i<value.length; i++) {
this.AddExampleParameter(methodParam, example_param, value[i], polySubParam, ancestors, rawValue[i]);
Expand Down
23 changes: 23 additions & 0 deletions src/plugins/azgenerator/templates/tests/ScenarioTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,29 @@ export class ResourcePool {
}
return ret;
}
else if (keyValue==KeyValueType.SimpleArray) {
let ret = [];
for (let instanceString of endpoint.split(" ")) {
let p = "";
if (instanceString.length >= 2 && instanceString[0] == '"' && instanceString[instanceString.length - 1] == '"') {
p = this.addEndpointResource(instanceString.substr(1, instanceString.length - 2), isJson, KeyValueType.No, placeholders, resources, exampleParam, isTest);
if (isTest) {
p= `"${this.formatable(p, placeholders)}"`;
}
else {
p= `"${p}"`;
}
}
else {
p = this.addEndpointResource(instanceString, isJson, KeyValueType.No, placeholders, resources, exampleParam, isTest);
if (isTest) {
p = `${this.formatable(p, placeholders)}`;
}
}
ret.push(p);
}
return ret.join(" ");
}
return this.replaceResourceString(endpoint, placeholders, resources, isTest);
}
public replaceResourceString(endpoint: string, placeholders: string[], resources: string[], isTest = true): any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ az extension add --name datafactory
#### datafactory ####
##### Create #####
```
az datafactory create --location "East US" --zones "earth" --zones "moon" --name "myFactory" \
--resource-group "myResourceGroup"
az datafactory create --location "East US" --zones "earth" "moon" --name "myFactory" --resource-group "myResourceGroup"
```
##### Show #####
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
examples:
- name: Factories_CreateOrUpdate
text: |-
az datafactory create --location "East US" --zones "earth" --zones "moon" --name "myFactory" \
--resource-group "myResourceGroup"
az datafactory create --location "East US" --zones "earth" "moon" --name "myFactory" --resource-group \
"myResourceGroup"
"""

helps['datafactory update'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def step_create(test, rg, checks=None):
checks = []
test.cmd('az datafactory create '
'--location "East US" '
'--zones "earth" '
'--zones "moon" '
'--zones "earth" "moon" '
'--name "{myFactory}" '
'--resource-group "{rg}"',
checks=checks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ az datafactory show --name "myFactory" --resource-group "myResourceGroup"

##### <a name="ExamplesFactoriesCreateOrUpdate#Create">Example</a>
```
az datafactory create --location "East US" --zones "earth" --zones "moon" --name "myFactory" --resource-group \
az datafactory create --location "East US" --zones "earth" "moon" --name "myFactory" --resource-group \
"myResourceGroup"
```
##### <a name="ParametersFactoriesCreateOrUpdate#Create">Parameters</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,11 @@
- name: Create or update a database's blob auditing policy with all parameters
text: |-
az synapse sql-pool-blob-auditing-policy create --audit-actions-and-groups "DATABASE_LOGOUT_GROUP" \
--audit-actions-and-groups "DATABASE_ROLE_MEMBER_CHANGE_GROUP" --audit-actions-and-groups "UPDATE on \
database::TestDatabaseName by public" --is-azure-monitor-target-enabled true --is-storage-secondary-key-in-use false \
--retention-days 6 --state "Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdk\
fD2342309432849328476458/3RSD==" --storage-account-subscription-id "00000000-1234-0000-5678-000000000000" \
--storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "blobauditingtest-4799" --sql-pool-name \
"testdb" --workspace-name "blobauditingtest-6440"
"DATABASE_ROLE_MEMBER_CHANGE_GROUP" "UPDATE on database::TestDatabaseName by public" --is-azure-monitor-target-enabled \
true --is-storage-secondary-key-in-use false --retention-days 6 --state "Enabled" --storage-account-access-key \
"sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" --storage-account-subscription-id\
"00000000-1234-0000-5678-000000000000" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group \
"blobauditingtest-4799" --sql-pool-name "testdb" --workspace-name "blobauditingtest-6440"
- name: Create or update a database's blob auditing policy with minimal parameters
text: |-
az synapse sql-pool-blob-auditing-policy create --state "Enabled" --storage-account-access-key \
Expand Down Expand Up @@ -824,11 +823,11 @@
examples:
- name: Create a Sql pool's threat detection policy with all parameters
text: |-
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" --disabled-alerts \
"Usage_Anomaly" --email-account-admins true --email-addresses "test@microsoft.com" --email-addresses \
"user@microsoft.com" --retention-days 6 --state "Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTE\
RLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" --storage-endpoint "https://mystorage.blob.core.windows.net" \
--resource-group "securityalert-4799" --sql-pool-name "testdb" --workspace-name "securityalert-6440"
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" "Usage_Anomaly" \
--email-account-admins true --email-addresses "test@microsoft.com" "user@microsoft.com" --retention-days 6 --state \
"Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3R\
SD==" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "securityalert-4799" \
--sql-pool-name "testdb" --workspace-name "securityalert-6440"
"""

helps['synapse sql-pool-security-alert-policy update'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,12 +1130,11 @@ az synapse sql-pool-blob-auditing-policy show --resource-group "blobauditingtest
##### <a name="ExamplesSqlPoolBlobAuditingPoliciesCreateOrUpdate#Create">Example</a>
```
az synapse sql-pool-blob-auditing-policy create --audit-actions-and-groups "DATABASE_LOGOUT_GROUP" \
--audit-actions-and-groups "DATABASE_ROLE_MEMBER_CHANGE_GROUP" --audit-actions-and-groups "UPDATE on \
database::TestDatabaseName by public" --is-azure-monitor-target-enabled true --is-storage-secondary-key-in-use false \
--retention-days 6 --state "Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdk\
fD2342309432849328476458/3RSD==" --storage-account-subscription-id "00000000-1234-0000-5678-000000000000" \
--storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "blobauditingtest-4799" --sql-pool-name \
"testdb" --workspace-name "blobauditingtest-6440"
"DATABASE_ROLE_MEMBER_CHANGE_GROUP" "UPDATE on database::TestDatabaseName by public" --is-azure-monitor-target-enabled \
true --is-storage-secondary-key-in-use false --retention-days 6 --state "Enabled" --storage-account-access-key \
"sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" --storage-account-subscription-id\
"00000000-1234-0000-5678-000000000000" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group \
"blobauditingtest-4799" --sql-pool-name "testdb" --workspace-name "blobauditingtest-6440"
```
##### <a name="ExamplesSqlPoolBlobAuditingPoliciesCreateOrUpdate#Create">Example</a>
```
Expand Down Expand Up @@ -1361,11 +1360,11 @@ az synapse sql-pool-security-alert-policy show --resource-group "securityalert-6

##### <a name="ExamplesSqlPoolSecurityAlertPoliciesCreateOrUpdate#Create">Example</a>
```
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" --disabled-alerts "Usage_Anomaly" \
--email-account-admins true --email-addresses "test@microsoft.com" --email-addresses "user@microsoft.com" \
--retention-days 6 --state "Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdk\
fD2342309432849328476458/3RSD==" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group \
"securityalert-4799" --sql-pool-name "testdb" --workspace-name "securityalert-6440"
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" "Usage_Anomaly" \
--email-account-admins true --email-addresses "test@microsoft.com" "user@microsoft.com" --retention-days 6 --state \
"Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3R\
SD==" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "securityalert-4799" \
--sql-pool-name "testdb" --workspace-name "securityalert-6440"
```
##### <a name="ParametersSqlPoolSecurityAlertPoliciesCreateOrUpdate#Create">Parameters</a>
|Option|Type|Description|Path (SDK)|Swagger name|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,8 @@ def step_sql_pool_blob_auditing_policy_create(test, rg_5, rg, rg_2, rg_3, rg_4,
if checks is None:
checks = []
test.cmd('az synapse sql-pool-blob-auditing-policy create '
'--audit-actions-and-groups "DATABASE_LOGOUT_GROUP" '
'--audit-actions-and-groups "DATABASE_ROLE_MEMBER_CHANGE_GROUP" '
'--audit-actions-and-groups "UPDATE on database::TestDatabaseName by public" '
'--audit-actions-and-groups "DATABASE_LOGOUT_GROUP" "DATABASE_ROLE_MEMBER_CHANGE_GROUP" "UPDATE on '
'database::TestDatabaseName by public" '
'--is-azure-monitor-target-enabled true '
'--is-storage-secondary-key-in-use false '
'--retention-days 6 '
Expand Down Expand Up @@ -1002,11 +1001,9 @@ def step_sql_pool_security_alert_policy_create(test, rg_5, rg, rg_2, rg_3, rg_4,
if checks is None:
checks = []
test.cmd('az synapse sql-pool-security-alert-policy create '
'--disabled-alerts "Sql_Injection" '
'--disabled-alerts "Usage_Anomaly" '
'--disabled-alerts "Sql_Injection" "Usage_Anomaly" '
'--email-account-admins true '
'--email-addresses "test@microsoft.com" '
'--email-addresses "user@microsoft.com" '
'--email-addresses "test@microsoft.com" "user@microsoft.com" '
'--retention-days 6 '
'--state "Enabled" '
'--storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD234230943284932847645'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ az synapse sql-pool-transparent-data-encryption show --resource-group "sqlcrudte
#### synapse sql-pool-blob-auditing-policy ####
##### Create #####
```
az synapse sql-pool-blob-auditing-policy create --audit-actions-and-groups "DATABASE_LOGOUT_GROUP" \
--audit-actions-and-groups "DATABASE_ROLE_MEMBER_CHANGE_GROUP" \
--audit-actions-and-groups "UPDATE on database::TestDatabaseName by public" --is-azure-monitor-target-enabled true \
--is-storage-secondary-key-in-use false --retention-days 6 --state "Enabled" \
az synapse sql-pool-blob-auditing-policy create \
--audit-actions-and-groups "DATABASE_LOGOUT_GROUP" "DATABASE_ROLE_MEMBER_CHANGE_GROUP" "UPDATE on database::TestDatabaseName by public" \
--is-azure-monitor-target-enabled true --is-storage-secondary-key-in-use false --retention-days 6 \
--state "Enabled" \
--storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" \
--storage-account-subscription-id "00000000-1234-0000-5678-000000000000" \
--storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "blobauditingtest-4799" \
Expand Down Expand Up @@ -334,9 +334,9 @@ az synapse sql-pool-vulnerability-assessment-scan initiate-scan --resource-group
#### synapse sql-pool-security-alert-policy ####
##### Create #####
```
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" --disabled-alerts "Usage_Anomaly" \
--email-account-admins true --email-addresses "test@microsoft.com" --email-addresses "user@microsoft.com" \
--retention-days 6 --state "Enabled" \
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" "Usage_Anomaly" \
--email-account-admins true --email-addresses "test@microsoft.com" "user@microsoft.com" --retention-days 6 \
--state "Enabled" \
--storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" \
--storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "securityalert-4799" \
--sql-pool-name "testdb" --workspace-name "securityalert-6440"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,11 @@
- name: Create or update a database's blob auditing policy with all parameters
text: |-
az synapse sql-pool-blob-auditing-policy create --audit-actions-and-groups "DATABASE_LOGOUT_GROUP" \
--audit-actions-and-groups "DATABASE_ROLE_MEMBER_CHANGE_GROUP" --audit-actions-and-groups "UPDATE on \
database::TestDatabaseName by public" --is-azure-monitor-target-enabled true --is-storage-secondary-key-in-use false \
--retention-days 6 --state "Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdk\
fD2342309432849328476458/3RSD==" --storage-account-subscription-id "00000000-1234-0000-5678-000000000000" \
--storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "blobauditingtest-4799" --sql-pool-name \
"testdb" --workspace-name "blobauditingtest-6440"
"DATABASE_ROLE_MEMBER_CHANGE_GROUP" "UPDATE on database::TestDatabaseName by public" --is-azure-monitor-target-enabled \
true --is-storage-secondary-key-in-use false --retention-days 6 --state "Enabled" --storage-account-access-key \
"sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" --storage-account-subscription-id\
"00000000-1234-0000-5678-000000000000" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group \
"blobauditingtest-4799" --sql-pool-name "testdb" --workspace-name "blobauditingtest-6440"
- name: Create or update a database's blob auditing policy with minimal parameters
text: |-
az synapse sql-pool-blob-auditing-policy create --state "Enabled" --storage-account-access-key \
Expand Down Expand Up @@ -824,11 +823,11 @@
examples:
- name: Create a Sql pool's threat detection policy with all parameters
text: |-
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" --disabled-alerts \
"Usage_Anomaly" --email-account-admins true --email-addresses "test@microsoft.com" --email-addresses \
"user@microsoft.com" --retention-days 6 --state "Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTE\
RLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==" --storage-endpoint "https://mystorage.blob.core.windows.net" \
--resource-group "securityalert-4799" --sql-pool-name "testdb" --workspace-name "securityalert-6440"
az synapse sql-pool-security-alert-policy create --disabled-alerts "Sql_Injection" "Usage_Anomaly" \
--email-account-admins true --email-addresses "test@microsoft.com" "user@microsoft.com" --retention-days 6 --state \
"Enabled" --storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3R\
SD==" --storage-endpoint "https://mystorage.blob.core.windows.net" --resource-group "securityalert-4799" \
--sql-pool-name "testdb" --workspace-name "securityalert-6440"
"""

helps['synapse sql-pool-security-alert-policy update'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,8 @@ def step_sql_pool_blob_auditing_policy_create(test, rg_5, rg, rg_2, rg_3, rg_4,
if checks is None:
checks = []
test.cmd('az synapse sql-pool-blob-auditing-policy create '
'--audit-actions-and-groups "DATABASE_LOGOUT_GROUP" '
'--audit-actions-and-groups "DATABASE_ROLE_MEMBER_CHANGE_GROUP" '
'--audit-actions-and-groups "UPDATE on database::TestDatabaseName by public" '
'--audit-actions-and-groups "DATABASE_LOGOUT_GROUP" "DATABASE_ROLE_MEMBER_CHANGE_GROUP" "UPDATE on '
'database::TestDatabaseName by public" '
'--is-azure-monitor-target-enabled true '
'--is-storage-secondary-key-in-use false '
'--retention-days 6 '
Expand Down Expand Up @@ -1002,11 +1001,9 @@ def step_sql_pool_security_alert_policy_create(test, rg_5, rg, rg_2, rg_3, rg_4,
if checks is None:
checks = []
test.cmd('az synapse sql-pool-security-alert-policy create '
'--disabled-alerts "Sql_Injection" '
'--disabled-alerts "Usage_Anomaly" '
'--disabled-alerts "Sql_Injection" "Usage_Anomaly" '
'--email-account-admins true '
'--email-addresses "test@microsoft.com" '
'--email-addresses "user@microsoft.com" '
'--email-addresses "test@microsoft.com" "user@microsoft.com" '
'--retention-days 6 '
'--state "Enabled" '
'--storage-account-access-key "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD234230943284932847645'
Expand Down
Loading

0 comments on commit 5ce3b7a

Please sign in to comment.