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

check simple array #349

Merged
merged 4 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/azgenerator/CodeModelAzImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class CodeModelCliImpl implements CodeModelAz {
if (this.Parameter_IsPolyOfSimple()) {
continue;
}
if (this.MethodParameter_IsList && this.MethodParameter_IsListOfSimple) {
if (this.MethodParameter_IsList && this.MethodParameter_IsListOfSimple && !this.MethodParameter_IsSimpleArray) {
let groupOpParamName: string = "Add" + Capitalize(ToCamelCase(this.Command_FunctionName + "_" + this.MethodParameter_MapsTo));
let groupParamName: string = "Add" + Capitalize(ToCamelCase(this.CommandGroup_Key + "_" + this.MethodParameter_MapsTo));
let actionName: string = "Add" + Capitalize(ToCamelCase(this.MethodParameter_MapsTo));
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/azgenerator/TemplateAzureCliCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function GetSingleCommandBody(model: CodeModelAz, required, originalOperation: O
do {
if (model.SelectFirstMethodParameter()) {
do {
if (model.MethodParameter_IsList && !model.MethodParameter_IsListOfSimple) {
if (model.MethodParameter_IsList && !model.MethodParameter_IsListOfSimple && !model.MethodParameter_IsSimpleArray) {
if (model.Parameter_IsPolyOfSimple(model.MethodParameter)) {
let baseParam = model.MethodParameter;
let baseName = model.MethodParameter_MapsTo;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/azgenerator/TemplateAzureCliParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function getCommandBody(model: CodeModelAz, needUpdate: boolean = false, needGen

if (!needSkip) {
argument += ", help='" + EscapeString(model.MethodParameter_Description).trimRight();
if (model.MethodParameter_IsList) {
if (model.MethodParameter_IsList && !model.MethodParameter_IsSimpleArray) {
let netDescription = model.MethodParameter_Description.trim();
if (netDescription.length>0 && netDescription[netDescription.length-1].match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+[0-9a-z]+$/i)) {
argument += ".";
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CodeModelAz } from "./CodeModelAz"
import { HeaderGenerator } from "./Header";

export function GenerateAzureCliTestPrepare(model: CodeModelAz) : string[] {
export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] {
let header: HeaderGenerator = new HeaderGenerator();
var output: string[] = header.getLines();
output.push("");
Expand Down
18 changes: 18 additions & 0 deletions src/test/scenarios/datafactory/input/datafactory.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,10 @@
"fakeIdentity": {
"$ref": "#/definitions/FakeFactoryIdentity",
"description": "This is only for az test."
},
"zones": {
"$ref": "#/definitions/Zone",
"description": "This is only for az test."
}
}
},
Expand Down Expand Up @@ -831,12 +835,26 @@
"type"
]
},
"Zone": {
"type": "array",
"items": {
"type": "string"
},
"description": "sample of simple array"
},
"FakeFactoryIdentity": {
"description": "This is only for az test.",
"properties": {
"name": {
"type": "string",
"description": ".."
},
"zonesInside": {
"type": "array",
"items": {
"type": "string"
},
"description": "sample of simple array"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def load_arguments(self, _):
'itHub repo information. Expect value: KEY1=VALUE1 KEY2=VALUE2 ... , available KEYs are: host-name, '
'account-name, repository-name, collaboration-branch, root-folder, last-commit-id.', arg_group='Repo'
'Configuration')
c.argument('fake_identity', action=AddFakeIdentity, nargs='+', help='This is only for az test. Expect value: na'
'me=xx.')
c.argument('fake_identity', action=AddFakeIdentity, nargs='+', help='This is only for az test. Expect value: KE'
'Y1=VALUE1 KEY2=VALUE2 ... , available KEYs are: name, zones-inside.')
c.argument('zones', nargs='+', help='This is only for az test.')

with self.argument_context('datafactory update') as c:
c.argument('resource_group_name', resource_group_name_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,6 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
v = properties[k]
if kl == 'name':
d['name'] = v[0]
elif kl == 'zones-inside':
d['zones_inside'] = v
return d
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def datafactory_create(cmd, client,
identity=None,
factory_vsts_configuration=None,
factory_git_hub_configuration=None,
fake_identity=None):
fake_identity=None,
zones=None):
all_repo_configuration = []
if factory_vsts_configuration is not None:
all_repo_configuration.append(factory_vsts_configuration)
Expand All @@ -53,7 +54,8 @@ def datafactory_create(cmd, client,
location=location,
tags=tags,
identity=identity,
repo_configuration=repo_configuration)
repo_configuration=repo_configuration,
zones=zones)


def datafactory_update(cmd, client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar
import warnings

from azure.core.async_paging import AsyncItemPaged, AsyncList
Expand Down Expand Up @@ -247,6 +247,7 @@ async def create_or_update(
identity: Optional["models.FactoryIdentity"] = None,
repo_configuration: Optional["models.FactoryRepoConfiguration"] = None,
fake_identity: Optional["models.FakeFactoryIdentity"] = None,
zones: Optional[List[str]] = None,
**kwargs
) -> "models.Factory":
"""Creates or updates a factory.
Expand All @@ -268,6 +269,8 @@ async def create_or_update(
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
:param zones: This is only for az test.
:type zones: list[str]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Factory or the result of cls(response)
:rtype: ~azure.mgmt.datafactory.models.Factory
Expand All @@ -277,7 +280,7 @@ async def create_or_update(
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop('error_map', {}))

_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity)
_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity, zones=zones)
api_version = "2018-06-01"
content_type = kwargs.pop("content_type", "application/json")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class Factory(Resource):
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
:param zones: This is only for az test.
:type zones: list[str]
"""

_validation = {
Expand All @@ -180,6 +182,7 @@ class Factory(Resource):
'version': {'key': 'properties.version', 'type': 'str'},
'repo_configuration': {'key': 'properties.repoConfiguration', 'type': 'FactoryRepoConfiguration'},
'fake_identity': {'key': 'properties.fakeIdentity', 'type': 'FakeFactoryIdentity'},
'zones': {'key': 'properties.zones', 'type': '[str]'},
}

def __init__(
Expand All @@ -194,6 +197,7 @@ def __init__(
self.version = None
self.repo_configuration = kwargs.get('repo_configuration', None)
self.fake_identity = kwargs.get('fake_identity', None)
self.zones = kwargs.get('zones', None)


class FactoryRepoConfiguration(msrest.serialization.Model):
Expand Down Expand Up @@ -474,6 +478,8 @@ class FakeFactoryIdentity(msrest.serialization.Model):

:param name: Required. ..
:type name: str
:param zones_inside: sample of simple array.
:type zones_inside: list[str]
"""

_validation = {
Expand All @@ -482,6 +488,7 @@ class FakeFactoryIdentity(msrest.serialization.Model):

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'zones_inside': {'key': 'zonesInside', 'type': '[str]'},
}

def __init__(
Expand All @@ -490,6 +497,7 @@ def __init__(
):
super(FakeFactoryIdentity, self).__init__(**kwargs)
self.name = kwargs['name']
self.zones_inside = kwargs.get('zones_inside', None)


class GitHubAccessTokenRequest(msrest.serialization.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class Factory(Resource):
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
:param zones: This is only for az test.
:type zones: list[str]
"""

_validation = {
Expand All @@ -194,6 +196,7 @@ class Factory(Resource):
'version': {'key': 'properties.version', 'type': 'str'},
'repo_configuration': {'key': 'properties.repoConfiguration', 'type': 'FactoryRepoConfiguration'},
'fake_identity': {'key': 'properties.fakeIdentity', 'type': 'FakeFactoryIdentity'},
'zones': {'key': 'properties.zones', 'type': '[str]'},
}

def __init__(
Expand All @@ -205,6 +208,7 @@ def __init__(
identity: Optional["FactoryIdentity"] = None,
repo_configuration: Optional["FactoryRepoConfiguration"] = None,
fake_identity: Optional["FakeFactoryIdentity"] = None,
zones: Optional[List[str]] = None,
**kwargs
):
super(Factory, self).__init__(location=location, tags=tags, **kwargs)
Expand All @@ -215,6 +219,7 @@ def __init__(
self.version = None
self.repo_configuration = repo_configuration
self.fake_identity = fake_identity
self.zones = zones


class FactoryRepoConfiguration(msrest.serialization.Model):
Expand Down Expand Up @@ -525,6 +530,8 @@ class FakeFactoryIdentity(msrest.serialization.Model):

:param name: Required. ..
:type name: str
:param zones_inside: sample of simple array.
:type zones_inside: list[str]
"""

_validation = {
Expand All @@ -533,16 +540,19 @@ class FakeFactoryIdentity(msrest.serialization.Model):

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'zones_inside': {'key': 'zonesInside', 'type': '[str]'},
}

def __init__(
self,
*,
name: str,
zones_inside: Optional[List[str]] = None,
**kwargs
):
super(FakeFactoryIdentity, self).__init__(**kwargs)
self.name = name
self.zones_inside = zones_inside


class GitHubAccessTokenRequest(msrest.serialization.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar

T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
Expand Down Expand Up @@ -254,6 +254,7 @@ def create_or_update(
identity=None, # type: Optional["models.FactoryIdentity"]
repo_configuration=None, # type: Optional["models.FactoryRepoConfiguration"]
fake_identity=None, # type: Optional["models.FakeFactoryIdentity"]
zones=None, # type: Optional[List[str]]
**kwargs # type: Any
):
# type: (...) -> "models.Factory"
Expand All @@ -276,6 +277,8 @@ def create_or_update(
:type repo_configuration: ~azure.mgmt.datafactory.models.FactoryRepoConfiguration
:param fake_identity: This is only for az test.
:type fake_identity: ~azure.mgmt.datafactory.models.FakeFactoryIdentity
:param zones: This is only for az test.
:type zones: list[str]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Factory or the result of cls(response)
:rtype: ~azure.mgmt.datafactory.models.Factory
Expand All @@ -285,7 +288,7 @@ def create_or_update(
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop('error_map', {}))

_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity)
_factory = models.Factory(location=location, tags=tags, identity=identity, repo_configuration=repo_configuration, fake_identity=fake_identity, zones=zones)
api_version = "2018-06-01"
content_type = kwargs.pop("content_type", "application/json")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ create a datafactory.
|**--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.|fake_identity|
|**--zones**|array|This is only for az test.|zones|
### datafactory delete

delete a datafactory.
Expand Down