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

Commit

Permalink
fix-issue-443 (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha authored Jul 9, 2020
1 parent 86c0d66 commit 3aa71d1
Show file tree
Hide file tree
Showing 44 changed files with 1,940 additions and 12 deletions.
27 changes: 19 additions & 8 deletions src/plugins/azgenerator/TemplateAzureCliParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export function GenerateAzureCliParams(model: CodeModelAz, debug: boolean): stri
output_args.push("");
output_args.push("");
output_args.push("def load_arguments(self, _):");

let hasCommandParamContent = false;
let header: HeaderGenerator = new HeaderGenerator();
if (model.SelectFirstCommandGroup()) {
do {
//let methods: string[] = model.CommandGroup_Commands;
Expand All @@ -41,7 +42,10 @@ export function GenerateAzureCliParams(model: CodeModelAz, debug: boolean): stri
let command_output = getCommandBody(model, needGeneric, debug);
if (model.Command_MethodName == "show") {
show_output = command_output
}
}
if (command_output.length > 0) {
hasCommandParamContent = true;
}
output_args = output_args.concat(command_output);

}
Expand All @@ -53,19 +57,25 @@ export function GenerateAzureCliParams(model: CodeModelAz, debug: boolean): stri
}
} while (model.SelectNextCommandGroup());
}
if (!hasCommandParamContent) {
output_args.push(" pass");
header.disableUnusedArgument = true;
} else {
header.disableTooManyLines = true;
header.disableTooManyStatements = true;
}

let header: HeaderGenerator = new HeaderGenerator();
header.disableTooManyLines = true;
header.disableTooManyStatements = true;

let parameterImports: string[] = [];
if (hasTags) parameterImports.push("tags_type");
if (hasBoolean) parameterImports.push("get_three_state_flag");
if (hasEnum) parameterImports.push("get_enum_type");
if (hasResourceGroup) parameterImports.push("resource_group_name_type");
if (hasLocation) parameterImports.push("get_location_type");

header.addFromImport(model.CliCoreLib + ".commands.parameters", parameterImports);
if (parameterImports.length > 0) {
header.addFromImport(model.CliCoreLib + ".commands.parameters", parameterImports);
}

let validatorImports: string[] = [];
if (hasLocationValidator) {
validatorImports.push("get_default_location_from_resource_group");
Expand All @@ -87,6 +97,7 @@ export function GenerateAzureCliParams(model: CodeModelAz, debug: boolean): stri
output = output.concat(output_args);

output.push("");


output.forEach(element => {
if (element.length > 120) header.disableLineTooLong = true;
Expand Down Expand Up @@ -343,7 +354,7 @@ function getCommandBody(model: CodeModelAz, needGeneric: boolean = false, debug:
}

if (!hasParam) {
output_args.push(" pass");
return [];
}


Expand Down
2 changes: 1 addition & 1 deletion src/test/scenario-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require('source-map-support').install();
let msg = "";
let finalResult = true;
for (const each of folders) {
if (each != 'testserver') {
if (each != "testserver") {
console.log(`Processing: ${each}`);
try {
await this.runAz(dir + each, each).then(res => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def load_arguments(self, _):
'within the array does not imply an order of preference among them, although applications of JWK '
'Sets can choose to assign a meaning to the order for their purposes, if desired.')

with self.argument_context('attestation list-operation') as c:
pass

with self.argument_context('attestation attestation-provider provider list') as c:
c.argument('resource_group_name', resource_group_name_type)

Expand Down
16 changes: 16 additions & 0 deletions src/test/scenarios/boolean/configuration/readme.az.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## CLI

These settings apply only when `--az` is specified on the command line.

``` yaml $(az)
az:
extensions: boolean
package-name: azure-mgmt-boolean
namespace: azure.mgmt.boolean
client-subscription-bound: false
client-base-url-bound: false
client-authentication-policy: SansIOHTTPPolicy
az-output-folder: $(azure-cli-extension-folder)/src/boolean
python-sdk-output-folder: "$(az-output-folder)/azext_boolean/vendored_sdks/boolean"

```
9 changes: 9 additions & 0 deletions src/test/scenarios/boolean/configuration/readme.cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CLI

These settings apply only when `--cli` is specified on the command line.

``` yaml $(cli)
#cli:
# test-scenario:
# - name: Factories_CreateOrUpdate
```
60 changes: 60 additions & 0 deletions src/test/scenarios/boolean/configuration/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Managed Network

> see https://aka.ms/autorest
This is the AutoRest configuration file for Managed Network.



---
## Getting Started
To build the SDK for Managed Network, simply [Install AutoRest](https://aka.ms/autorest/install) and in this folder, run:

> `autorest`
To see additional help and options, run:

> `autorest --help`
---

## Configuration



### Basic Information
These are the global settings for the Managed Network API.

``` yaml
openapi-type: arm
tag: testserver-local
override-info:
title: AutoRest Test Service
description: Test Infrastructure for AutoRest.
```
### Tag: testserver-local
These settings apply only when `--tag=testserver-local` is specified on the command line.

``` yaml $(tag) == 'testserver-local'
input-file:
- ../input/body-boolean.json
```

# Code Generation


## Swagger to SDK

This section describes what SDK should be generated by the automatic system.
This is not used by Autorest itself.

``` yaml $(swagger-to-sdk)
swagger-to-sdk:
- repo: azure-sdk-for-python
```


## CLI

See configuration in [readme.cli.md](./readme.cli.md)
26 changes: 26 additions & 0 deletions src/test/scenarios/boolean/configuration/readme.python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Python

These settings apply only when `--python` is specified on the command line.
Please also specify `--python-sdks-folder=<path to the root directory of your azure-sdk-for-python clone>`.
Use `--python-mode=update` if you already have a setup.py and just want to update the code itself.

``` yaml $(python)
python:
azure-arm: true
license-header: MICROSOFT_MIT_NO_VERSION
payload-flattening-threshold: 2
namespace: azure.mgmt.boolean
package-name: azure-mgmt-boolean
package-version: 0.1.0
clear-output-folder: true
```
``` yaml $(python) && $(python-mode) == 'update'
python:
no-namespace-folders: true
output-folder: $(python-sdks-folder)/boolean/azure-mgmt-boolean/azure/mgmt/boolean
```
``` yaml $(python) && $(python-mode) == 'create'
python:
basic-setup-py: true
output-folder: $(python-sdks-folder)/boolean/azure-mgmt-boolean
```
Loading

0 comments on commit 3aa71d1

Please sign in to comment.