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

Commit

Permalink
change-default-extension-no-flatten (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha authored Dec 3, 2020
1 parent 80218cb commit 878d0bf
Show file tree
Hide file tree
Showing 244 changed files with 4,905 additions and 3,965 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ debug-output-folder: $(az-output-folder)/_az_debug

use-extension:
"@autorest/python": "5.4.0"
"@autorest/clicommon": "0.5.7"
"@autorest/clicommon": "0.5.8"
#"@autorest/python": "latest"

require:
Expand Down Expand Up @@ -55,9 +55,10 @@ modelerfour:
group-parameters: true
flatten-models: true
flatten-payloads: true
# keep-unused-flattened-models: true
```

``` yaml $(target-mode) != 'core' && !$(sdk-no-flatten)
``` yaml $(sdk-flatten) && !$(sdk-no-flatten)
#payload-flattening-threshold: 4
#recursive-payload-flattening: true

Expand Down Expand Up @@ -92,7 +93,7 @@ pipeline:
scope: scope-az
```
``` yaml $(target-mode) == 'core' || $(sdk-no-flatten)
``` yaml !$(sdk-flatten) || $(sdk-no-flatten)

#payload-flattening-threshold: 4
#recursive-payload-flattening: true
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/azgenerator/templates/generated/CliParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ function getCommandBody(model: CodeModelAz, needGeneric: boolean = false, debug:
} else if (parameterName.endsWith('name') && !model.Method['hasName'] && parameterName.replace(/_name$|_/g, '') == model.CommandGroup_DefaultName.toLowerCase()) {
if (isNullOrUndefined(model.MethodParameter.language['az']['alias'])) {
model.MethodParameter.language['az']['alias'] = [];
model.MethodParameter.language['az']['alias'].push('name');
model.MethodParameter.language['az']['alias'].push('n');
model.MethodParameter.language['az']['alias'].push(parameterName);
}
model.MethodParameter.language['az']['alias'].push('name');
model.MethodParameter.language['az']['alias'].push('n');
model.MethodParameter.language['az']['alias'].push(parameterName);
}
if (!isNullOrUndefined(model.MethodParameter.language['az']['alias'])) {
argument = " c.argument('" + parameterName + "'";
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,11 @@ export async function processRequest(host: Host) {
const debug = await host.GetValue('debug') || false;
let targetMode = await host.GetValue(ArgumentConstants.targetMode) || TargetMode.Extension;
const cliCore = targetMode == TargetMode.Core ? true: false;
let sdkNoFlatten = cliCore? true: false;
sdkNoFlatten = await host.GetValue(ArgumentConstants.sdkNoFlatten) || sdkNoFlatten;
// change both core and extension mode into no flattened mode.
let sdkFlatten = false;
sdkFlatten = await host.GetValue(ArgumentConstants.sdkFlatten) != undefined? true: sdkFlatten;
sdkFlatten = await host.GetValue(ArgumentConstants.sdkNoFlatten) != undefined? false: sdkFlatten;
let sdkNoFlatten = await host.GetValue(ArgumentConstants.sdkNoFlatten) != undefined? true: !sdkFlatten;
if (cliCore && !sdkNoFlatten) {
host.Message({Channel: Channel.Fatal, Text:"You have specified the --target-mode=core and --sdk-no-flatten=false at the same time. which is not a valid configuration"});
throw new Error("Wrong configuration detected, please check!");
Expand Down
1 change: 1 addition & 0 deletions src/plugins/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class ArgumentConstants {
public static readonly targetMode: string = "target-mode";
public static readonly compatibleLevel: string = "compatible-level";
public static readonly sdkNoFlatten = "sdk-no-flatten";
public static readonly sdkFlatten = "sdk-flatten";
public static readonly extensionMode = "extension-mode";
public static readonly azureCliFolder = "azure-cli-folder";
public static readonly azureCliExtFolder = "azure-cli-extension-folder";
Expand Down
10 changes: 5 additions & 5 deletions src/test/scenario-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum TestMode {
ExtIncremental = "ext_Incremental",
CoreDefault = "coredefault",
CoreIncremental = "core_Incremental",
Ext_NoFlatten = "extnoflatten",
Ext_Flatten = "extflatten",
Ext_NoSdk = "extnosdk",
Ext_NoSdk_NoFlatten_Track1 = "extnosdknoflattentrack1"
}
Expand All @@ -25,8 +25,8 @@ enum TestMode {
["datafactory", [TestMode.ExtDefault]],
["managed-network", [TestMode.ExtDefault]],
["mixed-reality", [TestMode.ExtIncremental]],
["kusto", [TestMode.CoreDefault, TestMode.Ext_NoFlatten, TestMode.Ext_NoSdk, TestMode.Ext_NoSdk_NoFlatten_Track1]],
["synapse", [TestMode.CoreDefault, TestMode.Ext_NoFlatten, TestMode.Ext_NoSdk, TestMode.Ext_NoSdk_NoFlatten_Track1]],
["kusto", [TestMode.CoreDefault, TestMode.Ext_Flatten, TestMode.Ext_NoSdk, TestMode.Ext_NoSdk_NoFlatten_Track1]],
["synapse", [TestMode.CoreDefault, TestMode.Ext_Flatten, TestMode.Ext_NoSdk, TestMode.Ext_NoSdk_NoFlatten_Track1]],
["compute", [TestMode.CoreIncremental]]
]);

Expand Down Expand Up @@ -78,10 +78,10 @@ enum TestMode {
key = ArgumentConstants.azureCliFolder;
extraOption[key] = outputDir;
return extraOption;
} else if (testMode == TestMode.Ext_NoFlatten) {
} else if (testMode == TestMode.Ext_Flatten) {
let key = ArgumentConstants.azureCliExtFolder
extraOption[key] = outputDir;
key = ArgumentConstants.sdkNoFlatten;
key = ArgumentConstants.sdkFlatten;
extraOption[key] = true;
return extraOption;
} else if (testMode == TestMode.Ext_NoSdk) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def cf_operation(cli_ctx, *_):


def cf_attestation_provider(cli_ctx, *_):
return cf_attestation_cl(cli_ctx).attestation_provider
return cf_attestation_cl(cli_ctx).attestation_providers
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def load_command_table(self, _):

from azext_attestation.generated._client_factory import cf_attestation_provider
attestation_attestation_provider = CliCommandType(
operations_tmpl='azext_attestation.vendored_sdks.attestation.operations._attestation_provider_operations#Attest'
'ationProviderOperations.{}',
operations_tmpl='azext_attestation.vendored_sdks.attestation.operations._attestation_providers_operations#Attes'
'tationProvidersOperations.{}',
client_factory=cf_attestation_provider)
with self.command_group('attestation attestation-provider', attestation_attestation_provider,
client_factory=cf_attestation_provider) as g:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ def attestation_create_provider(client,
tags=None,
attestation_policy=None,
policy_signing_certificates_keys=None):
creation_params = {}
creation_params['location'] = location
creation_params['tags'] = tags
creation_params['properties'] = {}
creation_params['properties']['attestation_policy'] = attestation_policy
creation_params['properties']['policy_signing_certificates'] = {}
creation_params['properties']['policy_signing_certificates']['keys'] = policy_signing_certificates_keys
return client.create(resource_group_name=resource_group_name,
provider_name=provider_name,
location=location,
tags=tags,
attestation_policy=attestation_policy,
keys=policy_signing_certificates_keys)
creation_params=creation_params)


def attestation_list_operation(client):
Expand All @@ -47,9 +51,11 @@ def attestation_attestation_provider_update(client,
resource_group_name,
provider_name,
tags=None):
update_params = {}
update_params['tags'] = tags
return client.update(resource_group_name=resource_group_name,
provider_name=provider_name,
tags=tags)
update_params=update_params)


def attestation_attestation_provider_delete(client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from ._configuration import AttestationManagementClientConfiguration
from .operations import OperationOperations
from .operations import AttestationProviderOperations
from .operations import AttestationProvidersOperations
from . import models


Expand All @@ -28,8 +28,8 @@ class AttestationManagementClient(object):
:ivar operation: OperationOperations operations
:vartype operation: attestation_management_client.operations.OperationOperations
:ivar attestation_provider: AttestationProviderOperations operations
:vartype attestation_provider: attestation_management_client.operations.AttestationProviderOperations
:ivar attestation_providers: AttestationProvidersOperations operations
:vartype attestation_providers: attestation_management_client.operations.AttestationProvidersOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription.
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(

self.operation = OperationOperations(
self._client, self._config, self._serialize, self._deserialize)
self.attestation_provider = AttestationProviderOperations(
self.attestation_providers = AttestationProvidersOperations(
self._client, self._config, self._serialize, self._deserialize)

def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from ._configuration import AttestationManagementClientConfiguration
from .operations import OperationOperations
from .operations import AttestationProviderOperations
from .operations import AttestationProvidersOperations
from .. import models


Expand All @@ -26,8 +26,8 @@ class AttestationManagementClient(object):
:ivar operation: OperationOperations operations
:vartype operation: attestation_management_client.aio.operations.OperationOperations
:ivar attestation_provider: AttestationProviderOperations operations
:vartype attestation_provider: attestation_management_client.aio.operations.AttestationProviderOperations
:ivar attestation_providers: AttestationProvidersOperations operations
:vartype attestation_providers: attestation_management_client.aio.operations.AttestationProvidersOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription.
Expand All @@ -54,7 +54,7 @@ def __init__(

self.operation = OperationOperations(
self._client, self._config, self._serialize, self._deserialize)
self.attestation_provider = AttestationProviderOperations(
self.attestation_providers = AttestationProvidersOperations(
self._client, self._config, self._serialize, self._deserialize)

async def close(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# --------------------------------------------------------------------------

from ._operation_operations import OperationOperations
from ._attestation_provider_operations import AttestationProviderOperations
from ._attestation_providers_operations import AttestationProvidersOperations

__all__ = [
'OperationOperations',
'AttestationProviderOperations',
'AttestationProvidersOperations',
]
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, Callable, Dict, Generic, List, Optional, TypeVar, Union
from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union
import warnings

from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
Expand All @@ -18,8 +18,8 @@
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]

class AttestationProviderOperations:
"""AttestationProviderOperations async operations.
class AttestationProvidersOperations:
"""AttestationProvidersOperations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
Expand Down Expand Up @@ -102,10 +102,7 @@ async def create(
self,
resource_group_name: str,
provider_name: str,
location: str,
tags: Optional[Dict[str, str]] = None,
attestation_policy: Optional[str] = None,
keys: Optional[List["models.JsonWebKey"]] = None,
creation_params: "models.AttestationServiceCreationParams",
**kwargs
) -> "models.AttestationProvider":
"""Creates or updates the Attestation Provider.
Expand All @@ -114,19 +111,8 @@ async def create(
:type resource_group_name: str
:param provider_name: Name of the attestation service.
:type provider_name: str
:param location: The supported Azure location where the attestation service instance should be
created.
:type location: str
:param tags: The tags that will be assigned to the attestation service instance.
:type tags: dict[str, str]
:param attestation_policy: Name of attestation policy.
:type attestation_policy: str
:param keys: The value of the "keys" parameter is an array of JWK values. By
default, the order of the JWK values 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.
:type keys: list[~attestation_management_client.models.JsonWebKey]
:param creation_params: Client supplied parameters.
:type creation_params: ~attestation_management_client.models.AttestationServiceCreationParams
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AttestationProvider, or the result of cls(response)
:rtype: ~attestation_management_client.models.AttestationProvider
Expand All @@ -137,8 +123,6 @@ async def create(
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))

creation_params = models.AttestationServiceCreationParams(location=location, tags=tags, attestation_policy=attestation_policy, keys=keys)
api_version = "2018-09-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
Expand Down Expand Up @@ -188,7 +172,7 @@ async def update(
self,
resource_group_name: str,
provider_name: str,
tags: Optional[Dict[str, str]] = None,
update_params: "models.AttestationServicePatchParams",
**kwargs
) -> "models.AttestationProvider":
"""Updates the Attestation Provider.
Expand All @@ -197,8 +181,8 @@ async def update(
:type resource_group_name: str
:param provider_name: Name of the attestation service.
:type provider_name: str
:param tags: The tags that will be assigned to the attestation service instance.
:type tags: dict[str, str]
:param update_params: Client supplied parameters.
:type update_params: ~attestation_management_client.models.AttestationServicePatchParams
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AttestationProvider, or the result of cls(response)
:rtype: ~attestation_management_client.models.AttestationProvider
Expand All @@ -209,8 +193,6 @@ async def update(
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))

update_params = models.AttestationServicePatchParams(tags=tags)
api_version = "2018-09-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
from ._models_py3 import AttestationProvider
from ._models_py3 import AttestationProviderListResult
from ._models_py3 import AttestationServiceCreationParams
from ._models_py3 import AttestationServiceCreationSpecificParams
from ._models_py3 import AttestationServicePatchParams
from ._models_py3 import CloudErrorBody
from ._models_py3 import JsonWebKey
from ._models_py3 import JsonWebKeySet
from ._models_py3 import OperationList
from ._models_py3 import OperationsDefinition
from ._models_py3 import OperationsDisplayDefinition
Expand All @@ -22,9 +24,11 @@
from ._models import AttestationProvider # type: ignore
from ._models import AttestationProviderListResult # type: ignore
from ._models import AttestationServiceCreationParams # type: ignore
from ._models import AttestationServiceCreationSpecificParams # type: ignore
from ._models import AttestationServicePatchParams # type: ignore
from ._models import CloudErrorBody # type: ignore
from ._models import JsonWebKey # type: ignore
from ._models import JsonWebKeySet # type: ignore
from ._models import OperationList # type: ignore
from ._models import OperationsDefinition # type: ignore
from ._models import OperationsDisplayDefinition # type: ignore
Expand All @@ -39,9 +43,11 @@
'AttestationProvider',
'AttestationProviderListResult',
'AttestationServiceCreationParams',
'AttestationServiceCreationSpecificParams',
'AttestationServicePatchParams',
'CloudErrorBody',
'JsonWebKey',
'JsonWebKeySet',
'OperationList',
'OperationsDefinition',
'OperationsDisplayDefinition',
Expand Down
Loading

0 comments on commit 878d0bf

Please sign in to comment.