From 2352cafca8d4b40ef651bd06da3901f3e66d07db Mon Sep 17 00:00:00 2001 From: kai ru <69238381+kairu-ms@users.noreply.github.com> Date: Mon, 9 Aug 2021 10:19:37 +0800 Subject: [PATCH] [Custom] Optimize custom function (#872) * support to remove empty property * update test custom file * add default value for argument which is not in parameter * update tests --- src/generate/renders/generated/CliCustom.ts | 167 +- .../azext_attestation/generated/custom.py | 14 +- .../command_modules/vm/generated/custom.py | 44 +- .../generated/custom.py | 145 +- .../command_modules/kusto/generated/custom.py | 139 +- .../command_modules/kusto/generated/custom.py | 157 +- .../src/kusto/azext_kusto/generated/custom.py | 396 +++-- .../src/kusto/azext_kusto/generated/custom.py | 369 +++-- .../azext_managed_network/generated/custom.py | 61 +- .../azext_mixed_reality/generated/custom.py | 20 +- .../azext_users_v1_0/generated/custom.py | 1355 +++++++++++------ .../synapse/generated/custom.py | 250 ++- .../synapse/azext_synapse/generated/custom.py | 297 ++-- .../synapse/azext_synapse/generated/custom.py | 4 +- .../synapse/azext_synapse/generated/custom.py | 250 ++- 15 files changed, 2456 insertions(+), 1212 deletions(-) diff --git a/src/generate/renders/generated/CliCustom.ts b/src/generate/renders/generated/CliCustom.ts index 52c4ad1f9..c2fff00f6 100644 --- a/src/generate/renders/generated/CliCustom.ts +++ b/src/generate/renders/generated/CliCustom.ts @@ -116,6 +116,7 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r if (model.SelectFirstMethodParameter(true)) { const originalParameterStack: Parameter[] = []; const originalParameterNameStack: string[] = []; + const originalParameterCheckEmpty: boolean[] = []; const prefixIndent = ' '; let skip = false; @@ -146,6 +147,13 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r methodParameterHandler.MethodParameter.language?.['cli']?.cliFlattenTrace ?.length < originalParameterStack.length ) { + if (originalParameterCheckEmpty.pop()) { + const checks = ConstructEmptyCheck( + prefixIndent, + originalParameterNameStack, + ); + outputBody = outputBody.concat(checks); + } originalParameterStack.pop(); originalParameterNameStack.pop(); } @@ -165,6 +173,13 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r methodHandler.Method.extensions?.['cli-split-operation-original-operation'], ) ) { + if (originalParameterCheckEmpty.pop()) { + const checks = ConstructEmptyCheck( + prefixIndent, + originalParameterNameStack, + ); + outputBody = outputBody.concat(checks); + } originalParameterStack.pop(); originalParameterNameStack.pop(); } @@ -173,14 +188,15 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r allParams.indexOf(methodParameterHandler.MethodParameter.schema) === -1 ) { allParams.push(methodParameterHandler.MethodParameter.schema); - originalParameterStack.push(methodParameterHandler.MethodParameter); - originalParameterNameStack.push(methodParameterHandler.MethodParameter_Name); - } else if (originalParameterStack.length > 0) { - originalParameterStack.push(methodParameterHandler.MethodParameter); - originalParameterNameStack.push(methodParameterHandler.MethodParameter_Name); - } else { + } else if (originalParameterStack.length <= 0) { continue; } + originalParameterStack.push(methodParameterHandler.MethodParameter); + originalParameterNameStack.push(methodParameterHandler.MethodParameter_Name); + originalParameterCheckEmpty.push( + !needGeneric && + !parameterHandler.Parameter_IsRequired(originalParameterStack.last), + ); if (!needGeneric) { outputBody = outputBody.concat( ConstructValuation( @@ -229,6 +245,13 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r originalParameterStack.last.language?.['cli']?.cliM4Path, ) === -1 ) { + if (originalParameterCheckEmpty.pop()) { + const checks = ConstructEmptyCheck( + prefixIndent, + originalParameterNameStack, + ); + outputBody = outputBody.concat(checks); + } originalParameterStack.pop(); originalParameterNameStack.pop(); } @@ -244,8 +267,15 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r flattenedFrom, ); newParam.language['cli'] = flattenedFrom.language['cli']; + originalParameterStack.push(newParam); originalParameterNameStack.push(flattenedFrom.language.python.name); + originalParameterCheckEmpty.push( + !needGeneric && + !parameterHandler.Parameter_IsRequired( + originalParameterStack.last, + ), + ); if (!needGeneric) { outputBody = outputBody.concat( ConstructValuation( @@ -292,7 +322,7 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r defaultValue = '{}'; } if (!methodParameterHandler.MethodParameter_IsHidden) { - let needIfClause = true; + let needIfClause = !methodParameterHandler.MethodParameter_RequiredByMethod; if ( methodParameterHandler.MethodParameter_Type === SchemaType.Constant ) { @@ -359,8 +389,16 @@ function ConstructMethodBodyParameter(model: CodeModelAz, needGeneric = false, r } } } else { + if (originalParameterCheckEmpty.pop()) { + const checks = ConstructEmptyCheck( + prefixIndent, + originalParameterNameStack, + ); + outputBody = outputBody.concat(checks); + } originalParameterStack.pop(); originalParameterNameStack.pop(); + // if this parameter was popped out because of last flattened parameter has just finished construction, // then we need to run construction logic for this parameter one more time. if ( @@ -386,43 +424,65 @@ function ConstructValuation( paramName: string, value: string, defaultValue: string = null, - needIfClause = true, + needIfClause = false, ): string[] { const str = []; - let sentence = ''; - if (isGeneric) { - if ( - !(value.startsWith("'") && value.endsWith("'")) && - !(value.startsWith('"') && value.endsWith('"')) - ) { - str.push(prefix + 'if ' + value + ' is not None:'); - prefix += ' '; - } + let property = ''; - sentence = prefix + GetInstancePath(model, required) + '.'; + if (isGeneric) { + property = GetInstancePath(model, required) + '.'; + // sentence = prefix + GetInstancePath(model, required) + '.'; for (let i = 1; i < classNames.length; ++i) { - sentence += classNames[i] + '.'; + property += classNames[i] + '.'; } - sentence += paramName; + property += paramName; } else { - sentence = prefix + classNames[0]; + property += classNames[0]; + // sentence = prefix + classNames[0]; for (let i = 1; i < classNames.length; ++i) { - sentence += "['" + classNames[i] + "']"; + property += "['" + classNames[i] + "']"; } - if (!isNullOrUndefined(paramName)) { - sentence += "['" + paramName + "']"; + property += "['" + paramName + "']"; } } - if (isNullOrUndefined(defaultValue)) { - sentence += ' = ' + value; + if (needIfClause) { + str.push(prefix + 'if ' + value + ' is not None:'); + str.push(prefix + ' ' + property + ' = ' + value); + if (!isGeneric && !isNullOrUndefined(defaultValue)) { + str.push(prefix + 'else:'); + str.push(prefix + ' ' + property + ' = ' + defaultValue); + } } else { - sentence += ' = ' + defaultValue; - if (needIfClause) { - sentence += ' if ' + value + ' is None else ' + value; + if (!isNullOrUndefined(defaultValue)) { + str.push(prefix + property + ' = ' + defaultValue); + } else { + str.push(prefix + property + ' = ' + value); } } + return str; +} + +function ConstructEmptyCheck(prefix: string, classNames: string[]): string[] { + const str = []; + + if (classNames.length <= 1) { + // avoid to delete 'parameter' variable + return str; + } + + let value = classNames[0]; + for (let i = 1; i < classNames.length; ++i) { + value += "['" + classNames[i] + "']"; + } + + let sentence = prefix + 'if len(' + value + ') == 0:'; + + str.push(sentence); + + prefix += ' '; + sentence = prefix + 'del ' + value; str.push(sentence); return str; } @@ -694,23 +754,6 @@ function GetSingleCommandBody(model: CodeModelAz, required: any) { } continue; } - } else if ( - methodParameterHandler.MethodParameter_DefaultValue !== undefined && - methodParameterHandler.MethodParameter_Type !== SchemaType.Constant - ) { - // model is simple type with default value - outputBody.push( - ' if ' + methodParameterHandler.MethodParameter_MapsTo + ' is None:', - ); - outputBody.push( - ' ' + - methodParameterHandler.MethodParameter_MapsTo + - ' = ' + - ToPythonString( - methodParameterHandler.MethodParameter_DefaultValue, - methodParameterHandler.MethodParameter_Type, - ), - ); } } while (skip || model.SelectNextMethodParameter()); } @@ -971,11 +1014,10 @@ function GetSimpleCallItem( const paramNamePython = parameterHandler.Parameter_NamePython(param); const paramDefaultValue = parameterHandler.Parameter_DefaultValue(param); if (parameterHandler.Parameter_IsHidden(param)) { - if (paramDefaultValue) { + if (!isNullOrUndefined(paramDefaultValue)) { if (schemaHandler.Schema_Type(param.schema) === SchemaType.Object) { - parameterPair = - paramNamePython + - '=json.loads(' + + parameterPair = paramNamePython + `1`; + '=json.loads(' + ToPythonString(paramDefaultValue, parameterHandler.Parameter_Type(param)) + ')'; required.json = true; @@ -995,11 +1037,32 @@ function GetSimpleCallItem( parameterPair = paramNamePython + '=None'; } } else { + let valueName; if (!isNullOrUndefined(optionName)) { - parameterPair = paramNamePython + '=' + optionName; + valueName = optionName; + // parameterPair = paramNamePython + '=' + optionName; } else { - parameterPair = paramNamePython + '=' + parameterHandler.Parameter_MapsTo(param); + valueName = parameterHandler.Parameter_MapsTo(param); + // parameterPair = paramNamePython + '=' + parameterHandler.Parameter_MapsTo(param); + } + + parameterPair = paramNamePython + '='; + if (!isNullOrUndefined(paramDefaultValue)) { + if (schemaHandler.Schema_Type(param.schema) === SchemaType.Object) { + parameterPair += + 'json.loads(' + + ToPythonString(paramDefaultValue, parameterHandler.Parameter_Type(param)) + + ')'; + required.json = true; + } else { + parameterPair += ToPythonString( + paramDefaultValue, + parameterHandler.Parameter_Type(param), + ); + } + parameterPair += ' if ' + valueName + ' is None else '; } + parameterPair += valueName; } } return parameterPair; diff --git a/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py b/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py index 1a71e6e9f..d34b480c1 100644 --- a/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py +++ b/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py @@ -19,11 +19,16 @@ def attestation_create_provider(client, keys=None): creation_params = {} creation_params['location'] = location - creation_params['tags'] = tags + if tags is not None: + creation_params['tags'] = tags creation_params['properties'] = {} - creation_params['properties']['attestation_policy'] = attestation_policy + if attestation_policy is not None: + creation_params['properties']['attestation_policy'] = attestation_policy creation_params['properties']['policy_signing_certificates'] = {} - creation_params['properties']['policy_signing_certificates']['keys'] = keys + if keys is not None: + creation_params['properties']['policy_signing_certificates']['keys'] = keys + if len(creation_params['properties']['policy_signing_certificates']) == 0: + del creation_params['properties']['policy_signing_certificates'] return client.create(resource_group_name=resource_group_name, offer_type="virtualmachine", provider_name=provider_name, @@ -54,7 +59,8 @@ def attestation_attestation_provider_update(client, provider_name, tags=None): update_params = {} - update_params['tags'] = tags + if tags is not None: + update_params['tags'] = tags return client.update(resource_group_name=resource_group_name, offer_type="virtualmachine", provider_name=provider_name, diff --git a/test/scenarios/compute/output/core_Incremental/src/azure-cli/azure/cli/command_modules/vm/generated/custom.py b/test/scenarios/compute/output/core_Incremental/src/azure-cli/azure/cli/command_modules/vm/generated/custom.py index 32d283700..a26fba6f6 100644 --- a/test/scenarios/compute/output/core_Incremental/src/azure-cli/azure/cli/command_modules/vm/generated/custom.py +++ b/test/scenarios/compute/output/core_Incremental/src/azure-cli/azure/cli/command_modules/vm/generated/custom.py @@ -70,21 +70,37 @@ def vm_virtual_machine_scale_set_vm_extension_create(client, no_wait=False): extension_parameters = {} extension_parameters['location'] = location - extension_parameters['tags'] = tags - extension_parameters['force_update_tag'] = force_update_tag - extension_parameters['publisher'] = publisher - extension_parameters['type_properties_type'] = type_properties_type - extension_parameters['type_handler_version'] = type_handler_version - extension_parameters['auto_upgrade_minor_version'] = auto_upgrade_minor_version - extension_parameters['enable_automatic_upgrade'] = enable_automatic_upgrade - extension_parameters['settings'] = settings - extension_parameters['protected_settings'] = protected_settings + if tags is not None: + extension_parameters['tags'] = tags + if force_update_tag is not None: + extension_parameters['force_update_tag'] = force_update_tag + if publisher is not None: + extension_parameters['publisher'] = publisher + if type_properties_type is not None: + extension_parameters['type_properties_type'] = type_properties_type + if type_handler_version is not None: + extension_parameters['type_handler_version'] = type_handler_version + if auto_upgrade_minor_version is not None: + extension_parameters['auto_upgrade_minor_version'] = auto_upgrade_minor_version + if enable_automatic_upgrade is not None: + extension_parameters['enable_automatic_upgrade'] = enable_automatic_upgrade + if settings is not None: + extension_parameters['settings'] = settings + if protected_settings is not None: + extension_parameters['protected_settings'] = protected_settings extension_parameters['instance_view'] = {} - extension_parameters['instance_view']['name'] = name - extension_parameters['instance_view']['type'] = type_ - extension_parameters['instance_view']['type_handler_version'] = virtual_machine_extension_instance_view_type_handler_version_type_handler_version - extension_parameters['instance_view']['substatuses'] = substatuses - extension_parameters['instance_view']['statuses'] = statuses + if name is not None: + extension_parameters['instance_view']['name'] = name + if type_ is not None: + extension_parameters['instance_view']['type'] = type_ + if virtual_machine_extension_instance_view_type_handler_version_type_handler_version is not None: + extension_parameters['instance_view']['type_handler_version'] = virtual_machine_extension_instance_view_type_handler_version_type_handler_version + if substatuses is not None: + extension_parameters['instance_view']['substatuses'] = substatuses + if statuses is not None: + extension_parameters['instance_view']['statuses'] = statuses + if len(extension_parameters['instance_view']) == 0: + del extension_parameters['instance_view'] return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, diff --git a/test/scenarios/datafactory/output/src/datafactory-preview/azext_datafactory_preview/generated/custom.py b/test/scenarios/datafactory/output/src/datafactory-preview/azext_datafactory_preview/generated/custom.py index 927ec450c..c72050104 100644 --- a/test/scenarios/datafactory/output/src/datafactory-preview/azext_datafactory_preview/generated/custom.py +++ b/test/scenarios/datafactory/output/src/datafactory-preview/azext_datafactory_preview/generated/custom.py @@ -53,14 +53,22 @@ def datafactory_create(client, 'repo_configuration!') repo_configuration = all_repo_configuration[0] if len(all_repo_configuration) == 1 else None factory = {} - factory['location'] = location - factory['tags'] = tags - factory['test_inherit'] = test_inherit - factory['repo_configuration'] = repo_configuration - factory['fake_identity'] = fake_identity - factory['zones'] = zones + if location is not None: + factory['location'] = location + if tags is not None: + factory['tags'] = tags + if test_inherit is not None: + factory['test_inherit'] = test_inherit + if repo_configuration is not None: + factory['repo_configuration'] = repo_configuration + if fake_identity is not None: + factory['fake_identity'] = fake_identity + if zones is not None: + factory['zones'] = zones factory['identity'] = {} factory['identity']['type'] = "SystemAssigned" + if len(factory['identity']) == 0: + del factory['identity'] return client.create_or_update(resource_group_name=resource_group_name, factory_name=factory_name, if_match=if_match, @@ -72,9 +80,12 @@ def datafactory_update(client, factory_name, tags=None): factory_update_parameters = {} - factory_update_parameters['tags'] = tags + if tags is not None: + factory_update_parameters['tags'] = tags factory_update_parameters['identity'] = {} factory_update_parameters['identity']['type'] = "SystemAssigned" + if len(factory_update_parameters['identity']) == 0: + del factory_update_parameters['identity'] return client.update(resource_group_name=resource_group_name, factory_name=factory_name, factory_update_parameters=factory_update_parameters) @@ -102,8 +113,10 @@ def datafactory_configure_factory_repo(client, 'repo_configuration!') repo_configuration = all_repo_configuration[0] if len(all_repo_configuration) == 1 else None factory_repo_update = {} - factory_repo_update['factory_resource_id'] = factory_resource_id - factory_repo_update['repo_configuration'] = repo_configuration + if factory_resource_id is not None: + factory_repo_update['factory_resource_id'] = factory_resource_id + if repo_configuration is not None: + factory_repo_update['repo_configuration'] = repo_configuration return client.configure_factory_repo(location_id=location_id, factory_repo_update=factory_repo_update) @@ -117,11 +130,16 @@ def datafactory_get_data_plane_access(client, start_time=None, expire_time=None): policy = {} - policy['permissions'] = permissions - policy['access_resource_path'] = access_resource_path - policy['profile_name'] = profile_name - policy['start_time'] = start_time - policy['expire_time'] = expire_time + if permissions is not None: + policy['permissions'] = permissions + if access_resource_path is not None: + policy['access_resource_path'] = access_resource_path + if profile_name is not None: + policy['profile_name'] = profile_name + if start_time is not None: + policy['start_time'] = start_time + if expire_time is not None: + policy['expire_time'] = expire_time return client.get_data_plane_access(resource_group_name=resource_group_name, factory_name=factory_name, policy=policy) @@ -135,7 +153,8 @@ def datafactory_get_git_hub_access_token(client, git_hub_client_id=None): git_hub_access_token_request = {} git_hub_access_token_request['git_hub_access_code'] = git_hub_access_code - git_hub_access_token_request['git_hub_client_id'] = git_hub_client_id + if git_hub_client_id is not None: + git_hub_access_token_request['git_hub_client_id'] = git_hub_client_id git_hub_access_token_request['git_hub_access_token_base_url'] = git_hub_access_token_base_url return client.get_git_hub_access_token(resource_group_name=resource_group_name, factory_name=factory_name, @@ -213,8 +232,10 @@ def datafactory_trigger_query_by_factory(client, continuation_token=None, parent_trigger_name=None): filter_parameters = {} - filter_parameters['continuation_token'] = continuation_token - filter_parameters['parent_trigger_name'] = parent_trigger_name + if continuation_token is not None: + filter_parameters['continuation_token'] = continuation_token + if parent_trigger_name is not None: + filter_parameters['parent_trigger_name'] = parent_trigger_name return client.query_by_factory(resource_group_name=resource_group_name, factory_name=factory_name, filter_parameters=filter_parameters) @@ -310,12 +331,18 @@ def datafactory_integration_runtime_managed_create(client, integration_runtime = {} integration_runtime['properties'] = {} integration_runtime['properties']['type'] = 'Managed' - integration_runtime['properties']['description'] = description - integration_runtime['properties']['repo_configuration'] = repo_configuration - integration_runtime['properties']['fake_identity'] = fake_identity - integration_runtime['properties']['zones'] = zones - integration_runtime['properties']['compute_properties'] = compute_properties - integration_runtime['properties']['ssis_properties'] = ssis_properties + if description is not None: + integration_runtime['properties']['description'] = description + if repo_configuration is not None: + integration_runtime['properties']['repo_configuration'] = repo_configuration + if fake_identity is not None: + integration_runtime['properties']['fake_identity'] = fake_identity + if zones is not None: + integration_runtime['properties']['zones'] = zones + if compute_properties is not None: + integration_runtime['properties']['compute_properties'] = compute_properties + if ssis_properties is not None: + integration_runtime['properties']['ssis_properties'] = ssis_properties return client.create_or_update(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name, @@ -333,8 +360,10 @@ def datafactory_integration_runtime_self_hosted_create(client, integration_runtime = {} integration_runtime['properties'] = {} integration_runtime['properties']['type'] = 'SelfHosted' - integration_runtime['properties']['description'] = description - integration_runtime['properties']['linked_info'] = linked_info + if description is not None: + integration_runtime['properties']['description'] = description + if linked_info is not None: + integration_runtime['properties']['linked_info'] = linked_info return client.create_or_update(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name, @@ -349,8 +378,10 @@ def datafactory_integration_runtime_update(client, auto_update=None, update_delay_offset=None): update_integration_runtime_request = {} - update_integration_runtime_request['auto_update'] = auto_update - update_integration_runtime_request['update_delay_offset'] = update_delay_offset + if auto_update is not None: + update_integration_runtime_request['auto_update'] = auto_update + if update_delay_offset is not None: + update_integration_runtime_request['update_delay_offset'] = update_delay_offset return client.update(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name, @@ -408,7 +439,8 @@ def datafactory_integration_runtime_regenerate_auth_key(client, integration_runtime_name, key_name=None): regenerate_key_parameters = {} - regenerate_key_parameters['key_name'] = key_name + if key_name is not None: + regenerate_key_parameters['key_name'] = key_name return client.regenerate_auth_key(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name, @@ -479,10 +511,14 @@ def datafactory_linked_integration_runtime_create(client, data_factory_name=None, data_factory_location=None): create_linked_integration_runtime_request = {} - create_linked_integration_runtime_request['name'] = name - create_linked_integration_runtime_request['subscription_id'] = subscription_id - create_linked_integration_runtime_request['data_factory_name'] = data_factory_name - create_linked_integration_runtime_request['data_factory_location'] = data_factory_location + if name is not None: + create_linked_integration_runtime_request['name'] = name + if subscription_id is not None: + create_linked_integration_runtime_request['subscription_id'] = subscription_id + if data_factory_name is not None: + create_linked_integration_runtime_request['data_factory_name'] = data_factory_name + if data_factory_location is not None: + create_linked_integration_runtime_request['data_factory_location'] = data_factory_location return client.create_linked_integration_runtime(resource_group_name=resource_group_name, factory_name=factory_name, integration_runtime_name=integration_runtime_name, @@ -500,13 +536,20 @@ def datafactory_domain_service_create(client, sku=None, filtered_sync=None): domain_service = {} - domain_service['location'] = location - domain_service['tags'] = tags - domain_service['domain_name'] = domain_name - domain_service['replica_sets'] = replica_sets - domain_service['domain_configuration_type'] = domain_configuration_type - domain_service['sku'] = sku - domain_service['filtered_sync'] = filtered_sync + if location is not None: + domain_service['location'] = location + if tags is not None: + domain_service['tags'] = tags + if domain_name is not None: + domain_service['domain_name'] = domain_name + if replica_sets is not None: + domain_service['replica_sets'] = replica_sets + if domain_configuration_type is not None: + domain_service['domain_configuration_type'] = domain_configuration_type + if sku is not None: + domain_service['sku'] = sku + if filtered_sync is not None: + domain_service['filtered_sync'] = filtered_sync return client.begin_create_or_update(resource_group_name=resource_group_name, domain_service_name=domain_service_name, domain_service=domain_service) @@ -523,13 +566,20 @@ def datafactory_domain_service_update(client, sku=None, filtered_sync=None): domain_service = {} - domain_service['location'] = location - domain_service['tags'] = tags - domain_service['domain_name'] = domain_name - domain_service['replica_sets'] = replica_sets - domain_service['domain_configuration_type'] = domain_configuration_type - domain_service['sku'] = sku - domain_service['filtered_sync'] = filtered_sync + if location is not None: + domain_service['location'] = location + if tags is not None: + domain_service['tags'] = tags + if domain_name is not None: + domain_service['domain_name'] = domain_name + if replica_sets is not None: + domain_service['replica_sets'] = replica_sets + if domain_configuration_type is not None: + domain_service['domain_configuration_type'] = domain_configuration_type + if sku is not None: + domain_service['sku'] = sku + if filtered_sync is not None: + domain_service['filtered_sync'] = filtered_sync return client.begin_create_or_update(resource_group_name=resource_group_name, domain_service_name=domain_service_name, domain_service=domain_service) @@ -541,7 +591,8 @@ def datafactory_group_create(client, group_name, e_tag=None): group = {} - group['e_tag'] = e_tag + if e_tag is not None: + group['e_tag'] = e_tag group['properties'] = {} return client.create(resource_group_name=resource_group_name, project_name=project_name, diff --git a/test/scenarios/kusto/output/coredefault/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py b/test/scenarios/kusto/output/coredefault/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py index 43d03f1db..7044e9549 100644 --- a/test/scenarios/kusto/output/coredefault/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py +++ b/test/scenarios/kusto/output/coredefault/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py @@ -46,28 +46,42 @@ def kusto_cluster_create(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags + if tags is not None: + parameters['tags'] = tags parameters['location'] = location parameters['sku'] = sku - parameters['zones'] = zones - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if zones is not None: + parameters['zones'] = zones + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -92,27 +106,42 @@ def kusto_cluster_update(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags - parameters['location'] = location - parameters['sku'] = sku - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if tags is not None: + parameters['tags'] = tags + if location is not None: + parameters['location'] = location + if sku is not None: + parameters['sku'] = sku + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -247,10 +276,14 @@ def kusto_cluster_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -433,10 +466,14 @@ def kusto_database_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -507,10 +544,14 @@ def kusto_attached_database_configuration_create(client, default_principals_modification_kind=None, no_wait=False): parameters = {} - parameters['location'] = location - parameters['database_name'] = database_name - parameters['cluster_resource_id'] = cluster_resource_id - parameters['default_principals_modification_kind'] = default_principals_modification_kind + if location is not None: + parameters['location'] = location + if database_name is not None: + parameters['database_name'] = database_name + if cluster_resource_id is not None: + parameters['cluster_resource_id'] = cluster_resource_id + if default_principals_modification_kind is not None: + parameters['default_principals_modification_kind'] = default_principals_modification_kind return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, diff --git a/test/scenarios/kusto/output/coretrack2/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py b/test/scenarios/kusto/output/coretrack2/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py index 1727a037d..afa18c6b4 100644 --- a/test/scenarios/kusto/output/coretrack2/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py +++ b/test/scenarios/kusto/output/coretrack2/src/azure-cli/azure/cli/command_modules/kusto/generated/custom.py @@ -46,28 +46,42 @@ def kusto_cluster_create(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags + if tags is not None: + parameters['tags'] = tags parameters['location'] = location parameters['sku'] = sku - parameters['zones'] = zones - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if zones is not None: + parameters['zones'] = zones + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -92,27 +106,42 @@ def kusto_cluster_update(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags - parameters['location'] = location - parameters['sku'] = sku - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if tags is not None: + parameters['tags'] = tags + if location is not None: + parameters['location'] = location + if sku is not None: + parameters['sku'] = sku + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -136,7 +165,8 @@ def kusto_cluster_add_language_extension(client, value=None, no_wait=False): language_extensions_to_add = {} - language_extensions_to_add['value'] = value + if value is not None: + language_extensions_to_add['value'] = value return sdk_no_wait(no_wait, client.begin_add_language_extensions, resource_group_name=resource_group_name, @@ -199,7 +229,8 @@ def kusto_cluster_remove_language_extension(client, value=None, no_wait=False): language_extensions_to_remove = {} - language_extensions_to_remove['value'] = value + if value is not None: + language_extensions_to_remove['value'] = value return sdk_no_wait(no_wait, client.begin_remove_language_extensions, resource_group_name=resource_group_name, @@ -253,10 +284,14 @@ def kusto_cluster_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -383,7 +418,8 @@ def kusto_database_add_principal(client, database_name, value=None): database_principals_to_add = {} - database_principals_to_add['value'] = value + if value is not None: + database_principals_to_add['value'] = value return client.add_principals(resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -405,7 +441,8 @@ def kusto_database_remove_principal(client, database_name, value=None): database_principals_to_remove = {} - database_principals_to_remove['value'] = value + if value is not None: + database_principals_to_remove['value'] = value return client.remove_principals(resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -443,10 +480,14 @@ def kusto_database_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -517,10 +558,14 @@ def kusto_attached_database_configuration_create(client, default_principals_modification_kind=None, no_wait=False): parameters = {} - parameters['location'] = location - parameters['database_name'] = database_name - parameters['cluster_resource_id'] = cluster_resource_id - parameters['default_principals_modification_kind'] = default_principals_modification_kind + if location is not None: + parameters['location'] = location + if database_name is not None: + parameters['database_name'] = database_name + if cluster_resource_id is not None: + parameters['cluster_resource_id'] = cluster_resource_id + if default_principals_modification_kind is not None: + parameters['default_principals_modification_kind'] = default_principals_modification_kind return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -680,8 +725,10 @@ def kusto_data_connection_data_connection_validation(client, 'is needed for properties!') properties = all_properties[0] if len(all_properties) == 1 else None parameters = {} - parameters['data_connection_name'] = data_connection_name - parameters['properties'] = properties + if data_connection_name is not None: + parameters['data_connection_name'] = data_connection_name + if properties is not None: + parameters['properties'] = properties return sdk_no_wait(no_wait, client.begin_data_connection_validation, resource_group_name=resource_group_name, diff --git a/test/scenarios/kusto/output/ext_default_folder/src/kusto/azext_kusto/generated/custom.py b/test/scenarios/kusto/output/ext_default_folder/src/kusto/azext_kusto/generated/custom.py index b864220cb..6ae0dce06 100644 --- a/test/scenarios/kusto/output/ext_default_folder/src/kusto/azext_kusto/generated/custom.py +++ b/test/scenarios/kusto/output/ext_default_folder/src/kusto/azext_kusto/generated/custom.py @@ -48,31 +48,46 @@ def kusto_cluster_create(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags + if tags is not None: + parameters['tags'] = tags parameters['location'] = location parameters['sku'] = {} parameters['sku']['name'] = name - parameters['sku']['capacity'] = capacity + if capacity is not None: + parameters['sku']['capacity'] = capacity parameters['sku']['tier'] = tier - parameters['zones'] = zones - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if zones is not None: + parameters['zones'] = zones + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -99,30 +114,47 @@ def kusto_cluster_update(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags - parameters['location'] = location + if tags is not None: + parameters['tags'] = tags + if location is not None: + parameters['location'] = location parameters['sku'] = {} parameters['sku']['name'] = name - parameters['sku']['capacity'] = capacity + if capacity is not None: + parameters['sku']['capacity'] = capacity parameters['sku']['tier'] = tier - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if len(parameters['sku']) == 0: + del parameters['sku'] + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -146,7 +178,8 @@ def kusto_cluster_add_language_extension(client, value=None, no_wait=False): language_extensions_to_add = {} - language_extensions_to_add['value'] = value + if value is not None: + language_extensions_to_add['value'] = value return sdk_no_wait(no_wait, client.begin_add_language_extensions, resource_group_name=resource_group_name, @@ -209,7 +242,8 @@ def kusto_cluster_remove_language_extension(client, value=None, no_wait=False): language_extensions_to_remove = {} - language_extensions_to_remove['value'] = value + if value is not None: + language_extensions_to_remove['value'] = value return sdk_no_wait(no_wait, client.begin_remove_language_extensions, resource_group_name=resource_group_name, @@ -263,10 +297,14 @@ def kusto_cluster_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -393,7 +431,8 @@ def kusto_database_add_principal(client, database_name, value=None): database_principals_to_add = {} - database_principals_to_add['value'] = value + if value is not None: + database_principals_to_add['value'] = value return client.add_principals(resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -415,7 +454,8 @@ def kusto_database_remove_principal(client, database_name, value=None): database_principals_to_remove = {} - database_principals_to_remove['value'] = value + if value is not None: + database_principals_to_remove['value'] = value return client.remove_principals(resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -453,10 +493,14 @@ def kusto_database_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -527,10 +571,14 @@ def kusto_attached_database_configuration_create(client, default_principals_modification_kind=None, no_wait=False): parameters = {} - parameters['location'] = location - parameters['database_name'] = database_name - parameters['cluster_resource_id'] = cluster_resource_id - parameters['default_principals_modification_kind'] = default_principals_modification_kind + if location is not None: + parameters['location'] = location + if database_name is not None: + parameters['database_name'] = database_name + if cluster_resource_id is not None: + parameters['cluster_resource_id'] = cluster_resource_id + if default_principals_modification_kind is not None: + parameters['default_principals_modification_kind'] = default_principals_modification_kind return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -607,16 +655,25 @@ def kusto_data_connection_event_grid_create(client, blob_storage_event_type=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventGrid' - parameters['storage_account_resource_id'] = storage_account_resource_id - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['ignore_first_record'] = ignore_first_record - parameters['blob_storage_event_type'] = blob_storage_event_type + if storage_account_resource_id is not None: + parameters['storage_account_resource_id'] = storage_account_resource_id + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if ignore_first_record is not None: + parameters['ignore_first_record'] = ignore_first_record + if blob_storage_event_type is not None: + parameters['blob_storage_event_type'] = blob_storage_event_type return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -641,15 +698,23 @@ def kusto_data_connection_event_hub_create(client, compression=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventHub' - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['compression'] = compression + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if compression is not None: + parameters['compression'] = compression return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -674,15 +739,23 @@ def kusto_data_connection_iot_hub_create(client, shared_access_policy_name=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'IotHub' - parameters['iot_hub_resource_id'] = iot_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['shared_access_policy_name'] = shared_access_policy_name + if iot_hub_resource_id is not None: + parameters['iot_hub_resource_id'] = iot_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if shared_access_policy_name is not None: + parameters['shared_access_policy_name'] = shared_access_policy_name return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -708,16 +781,25 @@ def kusto_data_connection_event_grid_update(client, blob_storage_event_type=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventGrid' - parameters['storage_account_resource_id'] = storage_account_resource_id - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['ignore_first_record'] = ignore_first_record - parameters['blob_storage_event_type'] = blob_storage_event_type + if storage_account_resource_id is not None: + parameters['storage_account_resource_id'] = storage_account_resource_id + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if ignore_first_record is not None: + parameters['ignore_first_record'] = ignore_first_record + if blob_storage_event_type is not None: + parameters['blob_storage_event_type'] = blob_storage_event_type return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -742,15 +824,23 @@ def kusto_data_connection_event_hub_update(client, compression=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventHub' - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['compression'] = compression + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if compression is not None: + parameters['compression'] = compression return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -775,15 +865,23 @@ def kusto_data_connection_iot_hub_update(client, shared_access_policy_name=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'IotHub' - parameters['iot_hub_resource_id'] = iot_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['shared_access_policy_name'] = shared_access_policy_name + if iot_hub_resource_id is not None: + parameters['iot_hub_resource_id'] = iot_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if shared_access_policy_name is not None: + parameters['shared_access_policy_name'] = shared_access_policy_name return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -823,18 +921,30 @@ def kusto_data_connection_event_grid_data_connection_validation(client, blob_storage_event_type=None, no_wait=False): parameters = {} - parameters['data_connection_name'] = data_connection_name + if data_connection_name is not None: + parameters['data_connection_name'] = data_connection_name parameters['properties'] = {} - parameters['properties']['location'] = location + if location is not None: + parameters['properties']['location'] = location parameters['properties']['kind'] = 'EventGrid' - parameters['properties']['storage_account_resource_id'] = storage_account_resource_id - parameters['properties']['event_hub_resource_id'] = event_hub_resource_id - parameters['properties']['consumer_group'] = consumer_group - parameters['properties']['table_name'] = table_name - parameters['properties']['mapping_rule_name'] = mapping_rule_name - parameters['properties']['data_format'] = data_format - parameters['properties']['ignore_first_record'] = ignore_first_record - parameters['properties']['blob_storage_event_type'] = blob_storage_event_type + if storage_account_resource_id is not None: + parameters['properties']['storage_account_resource_id'] = storage_account_resource_id + if event_hub_resource_id is not None: + parameters['properties']['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['properties']['consumer_group'] = consumer_group + if table_name is not None: + parameters['properties']['table_name'] = table_name + if mapping_rule_name is not None: + parameters['properties']['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['properties']['data_format'] = data_format + if ignore_first_record is not None: + parameters['properties']['ignore_first_record'] = ignore_first_record + if blob_storage_event_type is not None: + parameters['properties']['blob_storage_event_type'] = blob_storage_event_type + if len(parameters['properties']) == 0: + del parameters['properties'] return sdk_no_wait(no_wait, client.begin_data_connection_validation, resource_group_name=resource_group_name, @@ -858,17 +968,28 @@ def kusto_data_connection_event_hub_data_connection_validation(client, compression=None, no_wait=False): parameters = {} - parameters['data_connection_name'] = data_connection_name + if data_connection_name is not None: + parameters['data_connection_name'] = data_connection_name parameters['properties'] = {} - parameters['properties']['location'] = location + if location is not None: + parameters['properties']['location'] = location parameters['properties']['kind'] = 'EventHub' - parameters['properties']['event_hub_resource_id'] = event_hub_resource_id - parameters['properties']['consumer_group'] = consumer_group - parameters['properties']['table_name'] = table_name - parameters['properties']['mapping_rule_name'] = mapping_rule_name - parameters['properties']['data_format'] = data_format - parameters['properties']['event_system_properties'] = event_system_properties - parameters['properties']['compression'] = compression + if event_hub_resource_id is not None: + parameters['properties']['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['properties']['consumer_group'] = consumer_group + if table_name is not None: + parameters['properties']['table_name'] = table_name + if mapping_rule_name is not None: + parameters['properties']['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['properties']['data_format'] = data_format + if event_system_properties is not None: + parameters['properties']['event_system_properties'] = event_system_properties + if compression is not None: + parameters['properties']['compression'] = compression + if len(parameters['properties']) == 0: + del parameters['properties'] return sdk_no_wait(no_wait, client.begin_data_connection_validation, resource_group_name=resource_group_name, @@ -892,17 +1013,28 @@ def kusto_data_connection_iot_hub_data_connection_validation(client, shared_access_policy_name=None, no_wait=False): parameters = {} - parameters['data_connection_name'] = data_connection_name + if data_connection_name is not None: + parameters['data_connection_name'] = data_connection_name parameters['properties'] = {} - parameters['properties']['location'] = location + if location is not None: + parameters['properties']['location'] = location parameters['properties']['kind'] = 'IotHub' - parameters['properties']['iot_hub_resource_id'] = iot_hub_resource_id - parameters['properties']['consumer_group'] = consumer_group - parameters['properties']['table_name'] = table_name - parameters['properties']['mapping_rule_name'] = mapping_rule_name - parameters['properties']['data_format'] = data_format - parameters['properties']['event_system_properties'] = event_system_properties - parameters['properties']['shared_access_policy_name'] = shared_access_policy_name + if iot_hub_resource_id is not None: + parameters['properties']['iot_hub_resource_id'] = iot_hub_resource_id + if consumer_group is not None: + parameters['properties']['consumer_group'] = consumer_group + if table_name is not None: + parameters['properties']['table_name'] = table_name + if mapping_rule_name is not None: + parameters['properties']['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['properties']['data_format'] = data_format + if event_system_properties is not None: + parameters['properties']['event_system_properties'] = event_system_properties + if shared_access_policy_name is not None: + parameters['properties']['shared_access_policy_name'] = shared_access_policy_name + if len(parameters['properties']) == 0: + del parameters['properties'] return sdk_no_wait(no_wait, client.begin_data_connection_validation, resource_group_name=resource_group_name, diff --git a/test/scenarios/kusto/output/extnosdknoflattentrack1/src/kusto/azext_kusto/generated/custom.py b/test/scenarios/kusto/output/extnosdknoflattentrack1/src/kusto/azext_kusto/generated/custom.py index 42c578958..b2de03652 100644 --- a/test/scenarios/kusto/output/extnosdknoflattentrack1/src/kusto/azext_kusto/generated/custom.py +++ b/test/scenarios/kusto/output/extnosdknoflattentrack1/src/kusto/azext_kusto/generated/custom.py @@ -48,31 +48,46 @@ def kusto_cluster_create(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags + if tags is not None: + parameters['tags'] = tags parameters['location'] = location parameters['sku'] = {} parameters['sku']['name'] = name - parameters['sku']['capacity'] = capacity + if capacity is not None: + parameters['sku']['capacity'] = capacity parameters['sku']['tier'] = tier - parameters['zones'] = zones - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if zones is not None: + parameters['zones'] = zones + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -99,30 +114,47 @@ def kusto_cluster_update(client, type_=None, user_assigned_identities=None, no_wait=False): - if enable_streaming_ingest is None: - enable_streaming_ingest = False - if enable_purge is None: - enable_purge = False - if enable_double_encryption is None: - enable_double_encryption = False parameters = {} - parameters['tags'] = tags - parameters['location'] = location + if tags is not None: + parameters['tags'] = tags + if location is not None: + parameters['location'] = location parameters['sku'] = {} parameters['sku']['name'] = name - parameters['sku']['capacity'] = capacity + if capacity is not None: + parameters['sku']['capacity'] = capacity parameters['sku']['tier'] = tier - parameters['trusted_external_tenants'] = trusted_external_tenants - parameters['optimized_autoscale'] = optimized_autoscale - parameters['enable_disk_encryption'] = enable_disk_encryption - parameters['enable_streaming_ingest'] = False if enable_streaming_ingest is None else enable_streaming_ingest - parameters['virtual_network_configuration'] = virtual_network_configuration - parameters['key_vault_properties'] = key_vault_properties - parameters['enable_purge'] = False if enable_purge is None else enable_purge - parameters['enable_double_encryption'] = False if enable_double_encryption is None else enable_double_encryption + if len(parameters['sku']) == 0: + del parameters['sku'] + if trusted_external_tenants is not None: + parameters['trusted_external_tenants'] = trusted_external_tenants + if optimized_autoscale is not None: + parameters['optimized_autoscale'] = optimized_autoscale + if enable_disk_encryption is not None: + parameters['enable_disk_encryption'] = enable_disk_encryption + if enable_streaming_ingest is not None: + parameters['enable_streaming_ingest'] = enable_streaming_ingest + else: + parameters['enable_streaming_ingest'] = False + if virtual_network_configuration is not None: + parameters['virtual_network_configuration'] = virtual_network_configuration + if key_vault_properties is not None: + parameters['key_vault_properties'] = key_vault_properties + if enable_purge is not None: + parameters['enable_purge'] = enable_purge + else: + parameters['enable_purge'] = False + if enable_double_encryption is not None: + parameters['enable_double_encryption'] = enable_double_encryption + else: + parameters['enable_double_encryption'] = False parameters['identity'] = {} - parameters['identity']['type'] = type_ - parameters['identity']['user_assigned_identities'] = user_assigned_identities + if type_ is not None: + parameters['identity']['type'] = type_ + if user_assigned_identities is not None: + parameters['identity']['user_assigned_identities'] = user_assigned_identities + if len(parameters['identity']) == 0: + del parameters['identity'] return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -257,10 +289,14 @@ def kusto_cluster_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -443,10 +479,14 @@ def kusto_database_principal_assignment_create(client, principal_type=None, no_wait=False): parameters = {} - parameters['principal_id'] = principal_id - parameters['role'] = role - parameters['tenant_id'] = tenant_id - parameters['principal_type'] = principal_type + if principal_id is not None: + parameters['principal_id'] = principal_id + if role is not None: + parameters['role'] = role + if tenant_id is not None: + parameters['tenant_id'] = tenant_id + if principal_type is not None: + parameters['principal_type'] = principal_type return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -517,10 +557,14 @@ def kusto_attached_database_configuration_create(client, default_principals_modification_kind=None, no_wait=False): parameters = {} - parameters['location'] = location - parameters['database_name'] = database_name - parameters['cluster_resource_id'] = cluster_resource_id - parameters['default_principals_modification_kind'] = default_principals_modification_kind + if location is not None: + parameters['location'] = location + if database_name is not None: + parameters['database_name'] = database_name + if cluster_resource_id is not None: + parameters['cluster_resource_id'] = cluster_resource_id + if default_principals_modification_kind is not None: + parameters['default_principals_modification_kind'] = default_principals_modification_kind return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -597,16 +641,25 @@ def kusto_data_connection_event_grid_create(client, blob_storage_event_type=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventGrid' - parameters['storage_account_resource_id'] = storage_account_resource_id - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['ignore_first_record'] = ignore_first_record - parameters['blob_storage_event_type'] = blob_storage_event_type + if storage_account_resource_id is not None: + parameters['storage_account_resource_id'] = storage_account_resource_id + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if ignore_first_record is not None: + parameters['ignore_first_record'] = ignore_first_record + if blob_storage_event_type is not None: + parameters['blob_storage_event_type'] = blob_storage_event_type return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -631,15 +684,23 @@ def kusto_data_connection_event_hub_create(client, compression=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventHub' - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['compression'] = compression + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if compression is not None: + parameters['compression'] = compression return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -664,15 +725,23 @@ def kusto_data_connection_iot_hub_create(client, shared_access_policy_name=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'IotHub' - parameters['iot_hub_resource_id'] = iot_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['shared_access_policy_name'] = shared_access_policy_name + if iot_hub_resource_id is not None: + parameters['iot_hub_resource_id'] = iot_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if shared_access_policy_name is not None: + parameters['shared_access_policy_name'] = shared_access_policy_name return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -698,16 +767,25 @@ def kusto_data_connection_event_grid_update(client, blob_storage_event_type=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventGrid' - parameters['storage_account_resource_id'] = storage_account_resource_id - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['ignore_first_record'] = ignore_first_record - parameters['blob_storage_event_type'] = blob_storage_event_type + if storage_account_resource_id is not None: + parameters['storage_account_resource_id'] = storage_account_resource_id + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if ignore_first_record is not None: + parameters['ignore_first_record'] = ignore_first_record + if blob_storage_event_type is not None: + parameters['blob_storage_event_type'] = blob_storage_event_type return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -732,15 +810,23 @@ def kusto_data_connection_event_hub_update(client, compression=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'EventHub' - parameters['event_hub_resource_id'] = event_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['compression'] = compression + if event_hub_resource_id is not None: + parameters['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if compression is not None: + parameters['compression'] = compression return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -765,15 +851,23 @@ def kusto_data_connection_iot_hub_update(client, shared_access_policy_name=None, no_wait=False): parameters = {} - parameters['location'] = location + if location is not None: + parameters['location'] = location parameters['kind'] = 'IotHub' - parameters['iot_hub_resource_id'] = iot_hub_resource_id - parameters['consumer_group'] = consumer_group - parameters['table_name'] = table_name - parameters['mapping_rule_name'] = mapping_rule_name - parameters['data_format'] = data_format - parameters['event_system_properties'] = event_system_properties - parameters['shared_access_policy_name'] = shared_access_policy_name + if iot_hub_resource_id is not None: + parameters['iot_hub_resource_id'] = iot_hub_resource_id + if consumer_group is not None: + parameters['consumer_group'] = consumer_group + if table_name is not None: + parameters['table_name'] = table_name + if mapping_rule_name is not None: + parameters['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + parameters['data_format'] = data_format + if event_system_properties is not None: + parameters['event_system_properties'] = event_system_properties + if shared_access_policy_name is not None: + parameters['shared_access_policy_name'] = shared_access_policy_name return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -813,16 +907,25 @@ def kusto_data_connection_event_grid_data_connection_validation(client, blob_storage_event_type=None, no_wait=False): properties = {} - properties['location'] = location + if location is not None: + properties['location'] = location properties['kind'] = 'EventGrid' - properties['storage_account_resource_id'] = storage_account_resource_id - properties['event_hub_resource_id'] = event_hub_resource_id - properties['consumer_group'] = consumer_group - properties['table_name'] = table_name - properties['mapping_rule_name'] = mapping_rule_name - properties['data_format'] = data_format - properties['ignore_first_record'] = ignore_first_record - properties['blob_storage_event_type'] = blob_storage_event_type + if storage_account_resource_id is not None: + properties['storage_account_resource_id'] = storage_account_resource_id + if event_hub_resource_id is not None: + properties['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + properties['consumer_group'] = consumer_group + if table_name is not None: + properties['table_name'] = table_name + if mapping_rule_name is not None: + properties['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + properties['data_format'] = data_format + if ignore_first_record is not None: + properties['ignore_first_record'] = ignore_first_record + if blob_storage_event_type is not None: + properties['blob_storage_event_type'] = blob_storage_event_type return sdk_no_wait(no_wait, client.data_connection_validation, resource_group_name=resource_group_name, @@ -847,15 +950,23 @@ def kusto_data_connection_event_hub_data_connection_validation(client, compression=None, no_wait=False): properties = {} - properties['location'] = location + if location is not None: + properties['location'] = location properties['kind'] = 'EventHub' - properties['event_hub_resource_id'] = event_hub_resource_id - properties['consumer_group'] = consumer_group - properties['table_name'] = table_name - properties['mapping_rule_name'] = mapping_rule_name - properties['data_format'] = data_format - properties['event_system_properties'] = event_system_properties - properties['compression'] = compression + if event_hub_resource_id is not None: + properties['event_hub_resource_id'] = event_hub_resource_id + if consumer_group is not None: + properties['consumer_group'] = consumer_group + if table_name is not None: + properties['table_name'] = table_name + if mapping_rule_name is not None: + properties['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + properties['data_format'] = data_format + if event_system_properties is not None: + properties['event_system_properties'] = event_system_properties + if compression is not None: + properties['compression'] = compression return sdk_no_wait(no_wait, client.data_connection_validation, resource_group_name=resource_group_name, @@ -880,15 +991,23 @@ def kusto_data_connection_iot_hub_data_connection_validation(client, shared_access_policy_name=None, no_wait=False): properties = {} - properties['location'] = location + if location is not None: + properties['location'] = location properties['kind'] = 'IotHub' - properties['iot_hub_resource_id'] = iot_hub_resource_id - properties['consumer_group'] = consumer_group - properties['table_name'] = table_name - properties['mapping_rule_name'] = mapping_rule_name - properties['data_format'] = data_format - properties['event_system_properties'] = event_system_properties - properties['shared_access_policy_name'] = shared_access_policy_name + if iot_hub_resource_id is not None: + properties['iot_hub_resource_id'] = iot_hub_resource_id + if consumer_group is not None: + properties['consumer_group'] = consumer_group + if table_name is not None: + properties['table_name'] = table_name + if mapping_rule_name is not None: + properties['mapping_rule_name'] = mapping_rule_name + if data_format is not None: + properties['data_format'] = data_format + if event_system_properties is not None: + properties['event_system_properties'] = event_system_properties + if shared_access_policy_name is not None: + properties['shared_access_policy_name'] = shared_access_policy_name return sdk_no_wait(no_wait, client.data_connection_validation, resource_group_name=resource_group_name, diff --git a/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py b/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py index 509f56330..31e08defa 100644 --- a/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py +++ b/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py @@ -44,7 +44,8 @@ def managed_network_mn_update(client, managed_network_name, tags=None): parameters = {} - parameters['tags'] = tags + if tags is not None: + parameters['tags'] = tags return client.begin_update(resource_group_name=resource_group_name, managed_network_name=managed_network_name, parameters=parameters) @@ -83,7 +84,8 @@ def managed_network_mn_scope_assignment_create(client, assigned_managed_network=None): parameters = {} parameters['location'] = location - parameters['assigned_managed_network'] = assigned_managed_network + if assigned_managed_network is not None: + parameters['assigned_managed_network'] = assigned_managed_network parameters['scope_assignment_name_fake'] = scope_assignment_name return client.create_or_update(scope=scope, scope_assignment_name=scope_assignment_name, @@ -95,12 +97,10 @@ def managed_network_mn_scope_assignment_update(instance, scope_assignment_name, location, assigned_managed_network=None): - if location is not None: - instance.location = location + instance.location = location if assigned_managed_network is not None: instance.assigned_managed_network = assigned_managed_network - if scope_assignment_name is not None: - instance.scope_assignment_name_fake = scope_assignment_name + instance.scope_assignment_name_fake = scope_assignment_name return instance @@ -144,10 +144,14 @@ def managed_network_mn_group_create(client, managed_network_group = {} managed_network_group['location'] = location managed_network_group['kind'] = "Connectivity" - managed_network_group['management_groups'] = management_groups - managed_network_group['subscriptions'] = subscriptions - managed_network_group['virtual_networks'] = virtual_networks - managed_network_group['subnets'] = subnets + if management_groups is not None: + managed_network_group['management_groups'] = management_groups + if subscriptions is not None: + managed_network_group['subscriptions'] = subscriptions + if virtual_networks is not None: + managed_network_group['virtual_networks'] = virtual_networks + if subnets is not None: + managed_network_group['subnets'] = subnets return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -166,8 +170,7 @@ def managed_network_mn_group_update(instance, virtual_networks=None, subnets=None, no_wait=False): - if location is not None: - instance.location = location + instance.location = location instance.kind = "Connectivity" if management_groups is not None: instance.management_groups = management_groups @@ -226,10 +229,16 @@ def managed_network_managed_network_peering_policy_hub_and_spoke_topology_create managed_network_policy['location'] = location managed_network_policy['properties'] = {} managed_network_policy['properties']['type'] = 'HubAndSpokeTopology' - managed_network_policy['properties']['hub'] = hub - managed_network_policy['properties']['spokes'] = spokes - managed_network_policy['properties']['mesh'] = mesh - managed_network_policy['managed_network_policy'] = managed_network_policy_ + if hub is not None: + managed_network_policy['properties']['hub'] = hub + if spokes is not None: + managed_network_policy['properties']['spokes'] = spokes + if mesh is not None: + managed_network_policy['properties']['mesh'] = mesh + if len(managed_network_policy['properties']) == 0: + del managed_network_policy['properties'] + if managed_network_policy_ is not None: + managed_network_policy['managed_network_policy'] = managed_network_policy_ return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -252,10 +261,16 @@ def managed_network_managed_network_peering_policy_mesh_topology_create(client, managed_network_policy['location'] = location managed_network_policy['properties'] = {} managed_network_policy['properties']['type'] = 'MeshTopology' - managed_network_policy['properties']['hub'] = hub - managed_network_policy['properties']['spokes'] = spokes - managed_network_policy['properties']['mesh'] = mesh - managed_network_policy['managed_network_policy'] = managed_network_policy_ + if hub is not None: + managed_network_policy['properties']['hub'] = hub + if spokes is not None: + managed_network_policy['properties']['spokes'] = spokes + if mesh is not None: + managed_network_policy['properties']['mesh'] = mesh + if len(managed_network_policy['properties']) == 0: + del managed_network_policy['properties'] + if managed_network_policy_ is not None: + managed_network_policy['managed_network_policy'] = managed_network_policy_ return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -274,8 +289,7 @@ def managed_network_managed_network_peering_policy_hub_and_spoke_topology_update mesh=None, managed_network_policy_=None, no_wait=False): - if location is not None: - instance.location = location + instance.location = location if hub is not None: instance.properties.hub = hub if spokes is not None: @@ -297,8 +311,7 @@ def managed_network_managed_network_peering_policy_mesh_topology_update(instance mesh=None, managed_network_policy_=None, no_wait=False): - if location is not None: - instance.location = location + instance.location = location if hub is not None: instance.properties.hub = hub if spokes is not None: diff --git a/test/scenarios/mixed-reality/output/ext_Incremental/src/mixed-reality/azext_mixed_reality/generated/custom.py b/test/scenarios/mixed-reality/output/ext_Incremental/src/mixed-reality/azext_mixed_reality/generated/custom.py index beb25b0fb..7293a2ba2 100644 --- a/test/scenarios/mixed-reality/output/ext_Incremental/src/mixed-reality/azext_mixed_reality/generated/custom.py +++ b/test/scenarios/mixed-reality/output/ext_Incremental/src/mixed-reality/azext_mixed_reality/generated/custom.py @@ -16,10 +16,11 @@ def spatial_anchors_account_regenerate_key(client, resource_group_name, account_name, serial=None): - if serial is None: - serial = 1 regenerate = {} - regenerate['serial'] = 1 if serial is None else serial + if serial is not None: + regenerate['serial'] = serial + else: + regenerate['serial'] = 1 return client.regenerate_keys(resource_group_name=resource_group_name, account_name=account_name, regenerate=regenerate) @@ -45,7 +46,8 @@ def remote_rendering_account_create(client, location, tags=None): remote_rendering_account = {} - remote_rendering_account['tags'] = tags + if tags is not None: + remote_rendering_account['tags'] = tags remote_rendering_account['location'] = location remote_rendering_account['identity'] = json.loads("{\"type\": \"SystemAssigned\"}") return client.create(resource_group_name=resource_group_name, @@ -59,7 +61,8 @@ def remote_rendering_account_update(client, location, tags=None): remote_rendering_account = {} - remote_rendering_account['tags'] = tags + if tags is not None: + remote_rendering_account['tags'] = tags remote_rendering_account['location'] = location remote_rendering_account['identity'] = json.loads("{\"type\": \"SystemAssigned\"}") return client.update(resource_group_name=resource_group_name, @@ -85,10 +88,11 @@ def remote_rendering_account_regenerate_key(client, resource_group_name, account_name, serial=None): - if serial is None: - serial = 1 regenerate = {} - regenerate['serial'] = 1 if serial is None else serial + if serial is not None: + regenerate['serial'] = serial + else: + regenerate['serial'] = 1 return client.regenerate_keys(resource_group_name=resource_group_name, account_name=account_name, regenerate=regenerate) diff --git a/test/scenarios/msgraphuser/output/users_v1_0/azext_users_v1_0/generated/custom.py b/test/scenarios/msgraphuser/output/users_v1_0/azext_users_v1_0/generated/custom.py index 05f2631c5..8c573ea09 100644 --- a/test/scenarios/msgraphuser/output/users_v1_0/azext_users_v1_0/generated/custom.py +++ b/test/scenarios/msgraphuser/output/users_v1_0/azext_users_v1_0/generated/custom.py @@ -228,214 +228,433 @@ def users_user_create(client, time_zone=None, working_hours=None): body = {} - body['id'] = id_ - body['deleted_date_time'] = deleted_date_time - body['account_enabled'] = account_enabled - body['age_group'] = age_group - body['assigned_licenses'] = assigned_licenses - body['assigned_plans'] = assigned_plans - body['business_phones'] = business_phones - body['city'] = city - body['company_name'] = company_name - body['consent_provided_for_minor'] = consent_provided_for_minor - body['country'] = country - body['created_date_time'] = created_date_time - body['creation_type'] = creation_type - body['department'] = department - body['display_name'] = display_name - body['employee_id'] = employee_id - body['external_user_state'] = external_user_state - body['external_user_state_change_date_time'] = external_user_state_change_date_time - body['fax_number'] = fax_number - body['given_name'] = given_name - body['identities'] = identities - body['im_addresses'] = im_addresses - body['is_resource_account'] = is_resource_account - body['job_title'] = job_title - body['last_password_change_date_time'] = last_password_change_date_time - body['legal_age_group_classification'] = legal_age_group_classification - body['license_assignment_states'] = license_assignment_states - body['mail'] = mail - body['mail_nickname'] = mail_nickname - body['mobile_phone'] = mobile_phone - body['office_location'] = office_location - body['on_premises_distinguished_name'] = on_premises_distinguished_name - body['on_premises_domain_name'] = on_premises_domain_name - body['on_premises_extension_attributes'] = on_premises_extension_attributes - body['on_premises_immutable_id'] = on_premises_immutable_id - body['on_premises_last_sync_date_time'] = on_premises_last_sync_date_time - body['on_premises_provisioning_errors'] = on_premises_provisioning_errors - body['on_premises_sam_account_name'] = on_premises_sam_account_name - body['on_premises_security_identifier'] = on_premises_security_identifier - body['on_premises_sync_enabled'] = on_premises_sync_enabled - body['on_premises_user_principal_name'] = on_premises_user_principal_name - body['other_mails'] = other_mails - body['password_policies'] = password_policies - body['password_profile'] = password_profile - body['postal_code'] = postal_code - body['preferred_language'] = preferred_language - body['provisioned_plans'] = provisioned_plans - body['proxy_addresses'] = proxy_addresses - body['show_in_address_list'] = show_in_address_list - body['sign_in_sessions_valid_from_date_time'] = sign_in_sessions_valid_from_date_time - body['state'] = state - body['street_address'] = street_address - body['surname'] = surname - body['usage_location'] = usage_location - body['user_principal_name'] = user_principal_name - body['user_type'] = user_type - body['device_enrollment_limit'] = device_enrollment_limit - body['about_me'] = about_me - body['birthday'] = birthday - body['hire_date'] = hire_date - body['interests'] = interests - body['my_site'] = my_site - body['past_projects'] = past_projects - body['preferred_name'] = preferred_name - body['responsibilities'] = responsibilities - body['schools'] = schools - body['skills'] = skills - body['app_role_assignments'] = app_role_assignments - body['created_objects'] = created_objects - body['direct_reports'] = direct_reports - body['license_details'] = license_details - body['manager'] = manager - body['member_of'] = member_of - body['oauth2_permission_grants'] = oauth2_permission_grants - body['owned_devices'] = owned_devices - body['owned_objects'] = owned_objects - body['registered_devices'] = registered_devices - body['scoped_role_member_of'] = scoped_role_member_of - body['transitive_member_of'] = transitive_member_of - body['calendar'] = calendar - body['calendar_groups'] = calendar_groups - body['calendars'] = calendars - body['calendar_view'] = calendar_view - body['contact_folders'] = contact_folders - body['contacts'] = contacts - body['events'] = events - body['mail_folders'] = mail_folders - body['messages'] = messages - body['people'] = people - body['photo'] = photo - body['photos'] = photos - body['drive'] = drive - body['drives'] = drives - body['followed_sites'] = followed_sites - body['extensions'] = extensions - body['managed_devices'] = managed_devices - body['managed_app_registrations'] = managed_app_registrations - body['device_management_troubleshooting_events'] = device_management_troubleshooting_events - body['activities'] = activities - body['online_meetings'] = online_meetings - body['joined_teams'] = joined_teams + if id_ is not None: + body['id'] = id_ + if deleted_date_time is not None: + body['deleted_date_time'] = deleted_date_time + if account_enabled is not None: + body['account_enabled'] = account_enabled + if age_group is not None: + body['age_group'] = age_group + if assigned_licenses is not None: + body['assigned_licenses'] = assigned_licenses + if assigned_plans is not None: + body['assigned_plans'] = assigned_plans + if business_phones is not None: + body['business_phones'] = business_phones + if city is not None: + body['city'] = city + if company_name is not None: + body['company_name'] = company_name + if consent_provided_for_minor is not None: + body['consent_provided_for_minor'] = consent_provided_for_minor + if country is not None: + body['country'] = country + if created_date_time is not None: + body['created_date_time'] = created_date_time + if creation_type is not None: + body['creation_type'] = creation_type + if department is not None: + body['department'] = department + if display_name is not None: + body['display_name'] = display_name + if employee_id is not None: + body['employee_id'] = employee_id + if external_user_state is not None: + body['external_user_state'] = external_user_state + if external_user_state_change_date_time is not None: + body['external_user_state_change_date_time'] = external_user_state_change_date_time + if fax_number is not None: + body['fax_number'] = fax_number + if given_name is not None: + body['given_name'] = given_name + if identities is not None: + body['identities'] = identities + if im_addresses is not None: + body['im_addresses'] = im_addresses + if is_resource_account is not None: + body['is_resource_account'] = is_resource_account + if job_title is not None: + body['job_title'] = job_title + if last_password_change_date_time is not None: + body['last_password_change_date_time'] = last_password_change_date_time + if legal_age_group_classification is not None: + body['legal_age_group_classification'] = legal_age_group_classification + if license_assignment_states is not None: + body['license_assignment_states'] = license_assignment_states + if mail is not None: + body['mail'] = mail + if mail_nickname is not None: + body['mail_nickname'] = mail_nickname + if mobile_phone is not None: + body['mobile_phone'] = mobile_phone + if office_location is not None: + body['office_location'] = office_location + if on_premises_distinguished_name is not None: + body['on_premises_distinguished_name'] = on_premises_distinguished_name + if on_premises_domain_name is not None: + body['on_premises_domain_name'] = on_premises_domain_name + if on_premises_extension_attributes is not None: + body['on_premises_extension_attributes'] = on_premises_extension_attributes + if on_premises_immutable_id is not None: + body['on_premises_immutable_id'] = on_premises_immutable_id + if on_premises_last_sync_date_time is not None: + body['on_premises_last_sync_date_time'] = on_premises_last_sync_date_time + if on_premises_provisioning_errors is not None: + body['on_premises_provisioning_errors'] = on_premises_provisioning_errors + if on_premises_sam_account_name is not None: + body['on_premises_sam_account_name'] = on_premises_sam_account_name + if on_premises_security_identifier is not None: + body['on_premises_security_identifier'] = on_premises_security_identifier + if on_premises_sync_enabled is not None: + body['on_premises_sync_enabled'] = on_premises_sync_enabled + if on_premises_user_principal_name is not None: + body['on_premises_user_principal_name'] = on_premises_user_principal_name + if other_mails is not None: + body['other_mails'] = other_mails + if password_policies is not None: + body['password_policies'] = password_policies + if password_profile is not None: + body['password_profile'] = password_profile + if postal_code is not None: + body['postal_code'] = postal_code + if preferred_language is not None: + body['preferred_language'] = preferred_language + if provisioned_plans is not None: + body['provisioned_plans'] = provisioned_plans + if proxy_addresses is not None: + body['proxy_addresses'] = proxy_addresses + if show_in_address_list is not None: + body['show_in_address_list'] = show_in_address_list + if sign_in_sessions_valid_from_date_time is not None: + body['sign_in_sessions_valid_from_date_time'] = sign_in_sessions_valid_from_date_time + if state is not None: + body['state'] = state + if street_address is not None: + body['street_address'] = street_address + if surname is not None: + body['surname'] = surname + if usage_location is not None: + body['usage_location'] = usage_location + if user_principal_name is not None: + body['user_principal_name'] = user_principal_name + if user_type is not None: + body['user_type'] = user_type + if device_enrollment_limit is not None: + body['device_enrollment_limit'] = device_enrollment_limit + if about_me is not None: + body['about_me'] = about_me + if birthday is not None: + body['birthday'] = birthday + if hire_date is not None: + body['hire_date'] = hire_date + if interests is not None: + body['interests'] = interests + if my_site is not None: + body['my_site'] = my_site + if past_projects is not None: + body['past_projects'] = past_projects + if preferred_name is not None: + body['preferred_name'] = preferred_name + if responsibilities is not None: + body['responsibilities'] = responsibilities + if schools is not None: + body['schools'] = schools + if skills is not None: + body['skills'] = skills + if app_role_assignments is not None: + body['app_role_assignments'] = app_role_assignments + if created_objects is not None: + body['created_objects'] = created_objects + if direct_reports is not None: + body['direct_reports'] = direct_reports + if license_details is not None: + body['license_details'] = license_details + if manager is not None: + body['manager'] = manager + if member_of is not None: + body['member_of'] = member_of + if oauth2_permission_grants is not None: + body['oauth2_permission_grants'] = oauth2_permission_grants + if owned_devices is not None: + body['owned_devices'] = owned_devices + if owned_objects is not None: + body['owned_objects'] = owned_objects + if registered_devices is not None: + body['registered_devices'] = registered_devices + if scoped_role_member_of is not None: + body['scoped_role_member_of'] = scoped_role_member_of + if transitive_member_of is not None: + body['transitive_member_of'] = transitive_member_of + if calendar is not None: + body['calendar'] = calendar + if calendar_groups is not None: + body['calendar_groups'] = calendar_groups + if calendars is not None: + body['calendars'] = calendars + if calendar_view is not None: + body['calendar_view'] = calendar_view + if contact_folders is not None: + body['contact_folders'] = contact_folders + if contacts is not None: + body['contacts'] = contacts + if events is not None: + body['events'] = events + if mail_folders is not None: + body['mail_folders'] = mail_folders + if messages is not None: + body['messages'] = messages + if people is not None: + body['people'] = people + if photo is not None: + body['photo'] = photo + if photos is not None: + body['photos'] = photos + if drive is not None: + body['drive'] = drive + if drives is not None: + body['drives'] = drives + if followed_sites is not None: + body['followed_sites'] = followed_sites + if extensions is not None: + body['extensions'] = extensions + if managed_devices is not None: + body['managed_devices'] = managed_devices + if managed_app_registrations is not None: + body['managed_app_registrations'] = managed_app_registrations + if device_management_troubleshooting_events is not None: + body['device_management_troubleshooting_events'] = device_management_troubleshooting_events + if activities is not None: + body['activities'] = activities + if online_meetings is not None: + body['online_meetings'] = online_meetings + if joined_teams is not None: + body['joined_teams'] = joined_teams body['exceptions'] = {} - body['exceptions']['body_contains'] = body_contains - body['exceptions']['body_or_subject_contains'] = body_or_subject_contains - body['exceptions']['categories'] = categories - body['exceptions']['from_addresses'] = from_addresses - body['exceptions']['has_attachments'] = has_attachments - body['exceptions']['header_contains'] = header_contains - body['exceptions']['importance'] = importance - body['exceptions']['is_approval_request'] = exceptions_is_approval_request - body['exceptions']['is_automatic_forward'] = exceptions_is_automatic_forward - body['exceptions']['is_automatic_reply'] = exceptions_is_automatic_reply - body['exceptions']['is_encrypted'] = exceptions_is_encrypted - body['exceptions']['is_meeting_request'] = exceptions_is_meeting_request - body['exceptions']['is_meeting_response'] = exceptions_is_meeting_response - body['exceptions']['is_non_delivery_report'] = exceptions_is_non_delivery_report - body['exceptions']['is_permission_controlled'] = exceptions_is_permission_controlled - body['exceptions']['is_read_receipt'] = exceptions_is_read_receipt - body['exceptions']['is_signed'] = exceptions_is_signed - body['exceptions']['is_voicemail'] = exceptions_is_voicemail - body['exceptions']['message_action_flag'] = message_action_flag - body['exceptions']['not_sent_to_me'] = not_sent_to_me - body['exceptions']['recipient_contains'] = recipient_contains - body['exceptions']['sender_contains'] = sender_contains - body['exceptions']['sensitivity'] = sensitivity - body['exceptions']['sent_cc_me'] = sent_cc_me - body['exceptions']['sent_only_to_me'] = sent_only_to_me - body['exceptions']['sent_to_addresses'] = sent_to_addresses - body['exceptions']['sent_to_me'] = sent_to_me - body['exceptions']['sent_to_or_cc_me'] = sent_to_or_cc_me - body['exceptions']['subject_contains'] = subject_contains - body['exceptions']['within_size_range'] = within_size_range + if body_contains is not None: + body['exceptions']['body_contains'] = body_contains + if body_or_subject_contains is not None: + body['exceptions']['body_or_subject_contains'] = body_or_subject_contains + if categories is not None: + body['exceptions']['categories'] = categories + if from_addresses is not None: + body['exceptions']['from_addresses'] = from_addresses + if has_attachments is not None: + body['exceptions']['has_attachments'] = has_attachments + if header_contains is not None: + body['exceptions']['header_contains'] = header_contains + if importance is not None: + body['exceptions']['importance'] = importance + if exceptions_is_approval_request is not None: + body['exceptions']['is_approval_request'] = exceptions_is_approval_request + if exceptions_is_automatic_forward is not None: + body['exceptions']['is_automatic_forward'] = exceptions_is_automatic_forward + if exceptions_is_automatic_reply is not None: + body['exceptions']['is_automatic_reply'] = exceptions_is_automatic_reply + if exceptions_is_encrypted is not None: + body['exceptions']['is_encrypted'] = exceptions_is_encrypted + if exceptions_is_meeting_request is not None: + body['exceptions']['is_meeting_request'] = exceptions_is_meeting_request + if exceptions_is_meeting_response is not None: + body['exceptions']['is_meeting_response'] = exceptions_is_meeting_response + if exceptions_is_non_delivery_report is not None: + body['exceptions']['is_non_delivery_report'] = exceptions_is_non_delivery_report + if exceptions_is_permission_controlled is not None: + body['exceptions']['is_permission_controlled'] = exceptions_is_permission_controlled + if exceptions_is_read_receipt is not None: + body['exceptions']['is_read_receipt'] = exceptions_is_read_receipt + if exceptions_is_signed is not None: + body['exceptions']['is_signed'] = exceptions_is_signed + if exceptions_is_voicemail is not None: + body['exceptions']['is_voicemail'] = exceptions_is_voicemail + if message_action_flag is not None: + body['exceptions']['message_action_flag'] = message_action_flag + if not_sent_to_me is not None: + body['exceptions']['not_sent_to_me'] = not_sent_to_me + if recipient_contains is not None: + body['exceptions']['recipient_contains'] = recipient_contains + if sender_contains is not None: + body['exceptions']['sender_contains'] = sender_contains + if sensitivity is not None: + body['exceptions']['sensitivity'] = sensitivity + if sent_cc_me is not None: + body['exceptions']['sent_cc_me'] = sent_cc_me + if sent_only_to_me is not None: + body['exceptions']['sent_only_to_me'] = sent_only_to_me + if sent_to_addresses is not None: + body['exceptions']['sent_to_addresses'] = sent_to_addresses + if sent_to_me is not None: + body['exceptions']['sent_to_me'] = sent_to_me + if sent_to_or_cc_me is not None: + body['exceptions']['sent_to_or_cc_me'] = sent_to_or_cc_me + if subject_contains is not None: + body['exceptions']['subject_contains'] = subject_contains + if within_size_range is not None: + body['exceptions']['within_size_range'] = within_size_range + if len(body['exceptions']) == 0: + del body['exceptions'] body['conditions'] = {} - body['conditions']['body_contains'] = microsoft_graph_message_rule_predicates_body_contains - body['conditions']['body_or_subject_contains'] = microsoft_graph_message_rule_predicates_body_or_subject_contains_body_or_subject_contains - body['conditions']['categories'] = microsoft_graph_message_rule_predicates_categories - body['conditions']['from_addresses'] = microsoft_graph_message_rule_predicates_from_addresses - body['conditions']['has_attachments'] = boolean_has_attachments - body['conditions']['header_contains'] = microsoft_graph_message_rule_predicates_header_contains - body['conditions']['importance'] = microsoft_graph_importance - body['conditions']['is_approval_request'] = is_approval_request - body['conditions']['is_automatic_forward'] = is_automatic_forward - body['conditions']['is_automatic_reply'] = is_automatic_reply - body['conditions']['is_encrypted'] = is_encrypted - body['conditions']['is_meeting_request'] = is_meeting_request - body['conditions']['is_meeting_response'] = is_meeting_response - body['conditions']['is_non_delivery_report'] = is_non_delivery_report - body['conditions']['is_permission_controlled'] = is_permission_controlled - body['conditions']['is_read_receipt'] = is_read_receipt - body['conditions']['is_signed'] = is_signed - body['conditions']['is_voicemail'] = is_voicemail - body['conditions']['message_action_flag'] = microsoft_graph_message_action_flag_message_action_flag - body['conditions']['not_sent_to_me'] = boolean_not_sent_to_me - body['conditions']['recipient_contains'] = microsoft_graph_message_rule_predicates_recipient_contains - body['conditions']['sender_contains'] = microsoft_graph_message_rule_predicates_sender_contains - body['conditions']['sensitivity'] = microsoft_graph_sensitivity - body['conditions']['sent_cc_me'] = boolean_sent_cc_me - body['conditions']['sent_only_to_me'] = boolean_sent_only_to_me - body['conditions']['sent_to_addresses'] = microsoft_graph_message_rule_predicates_sent_to_addresses_sent_to_addresses - body['conditions']['sent_to_me'] = boolean_sent_to_me - body['conditions']['sent_to_or_cc_me'] = boolean_sent_to_or_cc_me - body['conditions']['subject_contains'] = microsoft_graph_message_rule_predicates_subject_contains - body['conditions']['within_size_range'] = microsoft_graph_size_range_within_size_range + if microsoft_graph_message_rule_predicates_body_contains is not None: + body['conditions']['body_contains'] = microsoft_graph_message_rule_predicates_body_contains + if microsoft_graph_message_rule_predicates_body_or_subject_contains_body_or_subject_contains is not None: + body['conditions']['body_or_subject_contains'] = microsoft_graph_message_rule_predicates_body_or_subject_contains_body_or_subject_contains + if microsoft_graph_message_rule_predicates_categories is not None: + body['conditions']['categories'] = microsoft_graph_message_rule_predicates_categories + if microsoft_graph_message_rule_predicates_from_addresses is not None: + body['conditions']['from_addresses'] = microsoft_graph_message_rule_predicates_from_addresses + if boolean_has_attachments is not None: + body['conditions']['has_attachments'] = boolean_has_attachments + if microsoft_graph_message_rule_predicates_header_contains is not None: + body['conditions']['header_contains'] = microsoft_graph_message_rule_predicates_header_contains + if microsoft_graph_importance is not None: + body['conditions']['importance'] = microsoft_graph_importance + if is_approval_request is not None: + body['conditions']['is_approval_request'] = is_approval_request + if is_automatic_forward is not None: + body['conditions']['is_automatic_forward'] = is_automatic_forward + if is_automatic_reply is not None: + body['conditions']['is_automatic_reply'] = is_automatic_reply + if is_encrypted is not None: + body['conditions']['is_encrypted'] = is_encrypted + if is_meeting_request is not None: + body['conditions']['is_meeting_request'] = is_meeting_request + if is_meeting_response is not None: + body['conditions']['is_meeting_response'] = is_meeting_response + if is_non_delivery_report is not None: + body['conditions']['is_non_delivery_report'] = is_non_delivery_report + if is_permission_controlled is not None: + body['conditions']['is_permission_controlled'] = is_permission_controlled + if is_read_receipt is not None: + body['conditions']['is_read_receipt'] = is_read_receipt + if is_signed is not None: + body['conditions']['is_signed'] = is_signed + if is_voicemail is not None: + body['conditions']['is_voicemail'] = is_voicemail + if microsoft_graph_message_action_flag_message_action_flag is not None: + body['conditions']['message_action_flag'] = microsoft_graph_message_action_flag_message_action_flag + if boolean_not_sent_to_me is not None: + body['conditions']['not_sent_to_me'] = boolean_not_sent_to_me + if microsoft_graph_message_rule_predicates_recipient_contains is not None: + body['conditions']['recipient_contains'] = microsoft_graph_message_rule_predicates_recipient_contains + if microsoft_graph_message_rule_predicates_sender_contains is not None: + body['conditions']['sender_contains'] = microsoft_graph_message_rule_predicates_sender_contains + if microsoft_graph_sensitivity is not None: + body['conditions']['sensitivity'] = microsoft_graph_sensitivity + if boolean_sent_cc_me is not None: + body['conditions']['sent_cc_me'] = boolean_sent_cc_me + if boolean_sent_only_to_me is not None: + body['conditions']['sent_only_to_me'] = boolean_sent_only_to_me + if microsoft_graph_message_rule_predicates_sent_to_addresses_sent_to_addresses is not None: + body['conditions']['sent_to_addresses'] = microsoft_graph_message_rule_predicates_sent_to_addresses_sent_to_addresses + if boolean_sent_to_me is not None: + body['conditions']['sent_to_me'] = boolean_sent_to_me + if boolean_sent_to_or_cc_me is not None: + body['conditions']['sent_to_or_cc_me'] = boolean_sent_to_or_cc_me + if microsoft_graph_message_rule_predicates_subject_contains is not None: + body['conditions']['subject_contains'] = microsoft_graph_message_rule_predicates_subject_contains + if microsoft_graph_size_range_within_size_range is not None: + body['conditions']['within_size_range'] = microsoft_graph_size_range_within_size_range + if len(body['conditions']) == 0: + del body['conditions'] body['onenote'] = {} - body['onenote']['id'] = microsoft_graph_entity_id - body['onenote']['notebooks'] = notebooks - body['onenote']['operations'] = operations - body['onenote']['pages'] = pages - body['onenote']['resources'] = resources - body['onenote']['section_groups'] = section_groups - body['onenote']['sections'] = sections + if microsoft_graph_entity_id is not None: + body['onenote']['id'] = microsoft_graph_entity_id + if notebooks is not None: + body['onenote']['notebooks'] = notebooks + if operations is not None: + body['onenote']['operations'] = operations + if pages is not None: + body['onenote']['pages'] = pages + if resources is not None: + body['onenote']['resources'] = resources + if section_groups is not None: + body['onenote']['section_groups'] = section_groups + if sections is not None: + body['onenote']['sections'] = sections + if len(body['onenote']) == 0: + del body['onenote'] body['settings'] = {} - body['settings']['id'] = id1 - body['settings']['contribution_to_content_discovery_as_organization_disabled'] = contribution_to_content_discovery_as_organization_disabled - body['settings']['contribution_to_content_discovery_disabled'] = contribution_to_content_discovery_disabled + if id1 is not None: + body['settings']['id'] = id1 + if contribution_to_content_discovery_as_organization_disabled is not None: + body['settings']['contribution_to_content_discovery_as_organization_disabled'] = contribution_to_content_discovery_as_organization_disabled + if contribution_to_content_discovery_disabled is not None: + body['settings']['contribution_to_content_discovery_disabled'] = contribution_to_content_discovery_disabled body['settings']['shift_preferences'] = {} - body['settings']['shift_preferences']['id'] = id2 - body['settings']['shift_preferences']['created_date_time'] = microsoft_graph_change_tracked_entity_created_date_time_created_date_time - body['settings']['shift_preferences']['last_modified_date_time'] = last_modified_date_time + if id2 is not None: + body['settings']['shift_preferences']['id'] = id2 + if microsoft_graph_change_tracked_entity_created_date_time_created_date_time is not None: + body['settings']['shift_preferences']['created_date_time'] = microsoft_graph_change_tracked_entity_created_date_time_created_date_time + if last_modified_date_time is not None: + body['settings']['shift_preferences']['last_modified_date_time'] = last_modified_date_time body['settings']['shift_preferences']['last_modified_by'] = {} - body['settings']['shift_preferences']['last_modified_by']['application'] = application - body['settings']['shift_preferences']['last_modified_by']['device'] = device - body['settings']['shift_preferences']['last_modified_by']['user'] = user - body['settings']['shift_preferences']['availability'] = availability + if application is not None: + body['settings']['shift_preferences']['last_modified_by']['application'] = application + if device is not None: + body['settings']['shift_preferences']['last_modified_by']['device'] = device + if user is not None: + body['settings']['shift_preferences']['last_modified_by']['user'] = user + if len(body['settings']['shift_preferences']['last_modified_by']) == 0: + del body['settings']['shift_preferences']['last_modified_by'] + if availability is not None: + body['settings']['shift_preferences']['availability'] = availability + if len(body['settings']['shift_preferences']) == 0: + del body['settings']['shift_preferences'] + if len(body['settings']) == 0: + del body['settings'] body['insights'] = {} - body['insights']['id'] = id3 - body['insights']['shared'] = shared - body['insights']['trending'] = trending - body['insights']['used'] = used + if id3 is not None: + body['insights']['id'] = id3 + if shared is not None: + body['insights']['shared'] = shared + if trending is not None: + body['insights']['trending'] = trending + if used is not None: + body['insights']['used'] = used + if len(body['insights']) == 0: + del body['insights'] body['planner'] = {} - body['planner']['id'] = id4 - body['planner']['plans'] = plans - body['planner']['tasks'] = tasks + if id4 is not None: + body['planner']['id'] = id4 + if plans is not None: + body['planner']['plans'] = plans + if tasks is not None: + body['planner']['tasks'] = tasks + if len(body['planner']) == 0: + del body['planner'] body['outlook'] = {} - body['outlook']['id'] = id5 - body['outlook']['master_categories'] = master_categories + if id5 is not None: + body['outlook']['id'] = id5 + if master_categories is not None: + body['outlook']['master_categories'] = master_categories + if len(body['outlook']) == 0: + del body['outlook'] body['inference_classification'] = {} - body['inference_classification']['id'] = id6 - body['inference_classification']['overrides'] = overrides + if id6 is not None: + body['inference_classification']['id'] = id6 + if overrides is not None: + body['inference_classification']['overrides'] = overrides + if len(body['inference_classification']) == 0: + del body['inference_classification'] body['mailbox_settings'] = {} - body['mailbox_settings']['archive_folder'] = archive_folder - body['mailbox_settings']['automatic_replies_setting'] = automatic_replies_setting - body['mailbox_settings']['date_format'] = date_format - body['mailbox_settings']['delegate_meeting_message_delivery_options'] = delegate_meeting_message_delivery_options - body['mailbox_settings']['language'] = language - body['mailbox_settings']['time_format'] = time_format - body['mailbox_settings']['time_zone'] = time_zone - body['mailbox_settings']['working_hours'] = working_hours + if archive_folder is not None: + body['mailbox_settings']['archive_folder'] = archive_folder + if automatic_replies_setting is not None: + body['mailbox_settings']['automatic_replies_setting'] = automatic_replies_setting + if date_format is not None: + body['mailbox_settings']['date_format'] = date_format + if delegate_meeting_message_delivery_options is not None: + body['mailbox_settings']['delegate_meeting_message_delivery_options'] = delegate_meeting_message_delivery_options + if language is not None: + body['mailbox_settings']['language'] = language + if time_format is not None: + body['mailbox_settings']['time_format'] = time_format + if time_zone is not None: + body['mailbox_settings']['time_zone'] = time_zone + if working_hours is not None: + body['mailbox_settings']['working_hours'] = working_hours + if len(body['mailbox_settings']) == 0: + del body['mailbox_settings'] return client.create_user(body=body) @@ -639,214 +858,433 @@ def users_user_update(client, time_zone=None, working_hours=None): body = {} - body['id'] = id_ - body['deleted_date_time'] = deleted_date_time - body['account_enabled'] = account_enabled - body['age_group'] = age_group - body['assigned_licenses'] = assigned_licenses - body['assigned_plans'] = assigned_plans - body['business_phones'] = business_phones - body['city'] = city - body['company_name'] = company_name - body['consent_provided_for_minor'] = consent_provided_for_minor - body['country'] = country - body['created_date_time'] = created_date_time - body['creation_type'] = creation_type - body['department'] = department - body['display_name'] = display_name - body['employee_id'] = employee_id - body['external_user_state'] = external_user_state - body['external_user_state_change_date_time'] = external_user_state_change_date_time - body['fax_number'] = fax_number - body['given_name'] = given_name - body['identities'] = identities - body['im_addresses'] = im_addresses - body['is_resource_account'] = is_resource_account - body['job_title'] = job_title - body['last_password_change_date_time'] = last_password_change_date_time - body['legal_age_group_classification'] = legal_age_group_classification - body['license_assignment_states'] = license_assignment_states - body['mail'] = mail - body['mail_nickname'] = mail_nickname - body['mobile_phone'] = mobile_phone - body['office_location'] = office_location - body['on_premises_distinguished_name'] = on_premises_distinguished_name - body['on_premises_domain_name'] = on_premises_domain_name - body['on_premises_extension_attributes'] = on_premises_extension_attributes - body['on_premises_immutable_id'] = on_premises_immutable_id - body['on_premises_last_sync_date_time'] = on_premises_last_sync_date_time - body['on_premises_provisioning_errors'] = on_premises_provisioning_errors - body['on_premises_sam_account_name'] = on_premises_sam_account_name - body['on_premises_security_identifier'] = on_premises_security_identifier - body['on_premises_sync_enabled'] = on_premises_sync_enabled - body['on_premises_user_principal_name'] = on_premises_user_principal_name - body['other_mails'] = other_mails - body['password_policies'] = password_policies - body['password_profile'] = password_profile - body['postal_code'] = postal_code - body['preferred_language'] = preferred_language - body['provisioned_plans'] = provisioned_plans - body['proxy_addresses'] = proxy_addresses - body['show_in_address_list'] = show_in_address_list - body['sign_in_sessions_valid_from_date_time'] = sign_in_sessions_valid_from_date_time - body['state'] = state - body['street_address'] = street_address - body['surname'] = surname - body['usage_location'] = usage_location - body['user_principal_name'] = user_principal_name - body['user_type'] = user_type - body['device_enrollment_limit'] = device_enrollment_limit - body['about_me'] = about_me - body['birthday'] = birthday - body['hire_date'] = hire_date - body['interests'] = interests - body['my_site'] = my_site - body['past_projects'] = past_projects - body['preferred_name'] = preferred_name - body['responsibilities'] = responsibilities - body['schools'] = schools - body['skills'] = skills - body['app_role_assignments'] = app_role_assignments - body['created_objects'] = created_objects - body['direct_reports'] = direct_reports - body['license_details'] = license_details - body['manager'] = manager - body['member_of'] = member_of - body['oauth2_permission_grants'] = oauth2_permission_grants - body['owned_devices'] = owned_devices - body['owned_objects'] = owned_objects - body['registered_devices'] = registered_devices - body['scoped_role_member_of'] = scoped_role_member_of - body['transitive_member_of'] = transitive_member_of - body['calendar'] = calendar - body['calendar_groups'] = calendar_groups - body['calendars'] = calendars - body['calendar_view'] = calendar_view - body['contact_folders'] = contact_folders - body['contacts'] = contacts - body['events'] = events - body['mail_folders'] = mail_folders - body['messages'] = messages - body['people'] = people - body['photo'] = photo - body['photos'] = photos - body['drive'] = drive - body['drives'] = drives - body['followed_sites'] = followed_sites - body['extensions'] = extensions - body['managed_devices'] = managed_devices - body['managed_app_registrations'] = managed_app_registrations - body['device_management_troubleshooting_events'] = device_management_troubleshooting_events - body['activities'] = activities - body['online_meetings'] = online_meetings - body['joined_teams'] = joined_teams + if id_ is not None: + body['id'] = id_ + if deleted_date_time is not None: + body['deleted_date_time'] = deleted_date_time + if account_enabled is not None: + body['account_enabled'] = account_enabled + if age_group is not None: + body['age_group'] = age_group + if assigned_licenses is not None: + body['assigned_licenses'] = assigned_licenses + if assigned_plans is not None: + body['assigned_plans'] = assigned_plans + if business_phones is not None: + body['business_phones'] = business_phones + if city is not None: + body['city'] = city + if company_name is not None: + body['company_name'] = company_name + if consent_provided_for_minor is not None: + body['consent_provided_for_minor'] = consent_provided_for_minor + if country is not None: + body['country'] = country + if created_date_time is not None: + body['created_date_time'] = created_date_time + if creation_type is not None: + body['creation_type'] = creation_type + if department is not None: + body['department'] = department + if display_name is not None: + body['display_name'] = display_name + if employee_id is not None: + body['employee_id'] = employee_id + if external_user_state is not None: + body['external_user_state'] = external_user_state + if external_user_state_change_date_time is not None: + body['external_user_state_change_date_time'] = external_user_state_change_date_time + if fax_number is not None: + body['fax_number'] = fax_number + if given_name is not None: + body['given_name'] = given_name + if identities is not None: + body['identities'] = identities + if im_addresses is not None: + body['im_addresses'] = im_addresses + if is_resource_account is not None: + body['is_resource_account'] = is_resource_account + if job_title is not None: + body['job_title'] = job_title + if last_password_change_date_time is not None: + body['last_password_change_date_time'] = last_password_change_date_time + if legal_age_group_classification is not None: + body['legal_age_group_classification'] = legal_age_group_classification + if license_assignment_states is not None: + body['license_assignment_states'] = license_assignment_states + if mail is not None: + body['mail'] = mail + if mail_nickname is not None: + body['mail_nickname'] = mail_nickname + if mobile_phone is not None: + body['mobile_phone'] = mobile_phone + if office_location is not None: + body['office_location'] = office_location + if on_premises_distinguished_name is not None: + body['on_premises_distinguished_name'] = on_premises_distinguished_name + if on_premises_domain_name is not None: + body['on_premises_domain_name'] = on_premises_domain_name + if on_premises_extension_attributes is not None: + body['on_premises_extension_attributes'] = on_premises_extension_attributes + if on_premises_immutable_id is not None: + body['on_premises_immutable_id'] = on_premises_immutable_id + if on_premises_last_sync_date_time is not None: + body['on_premises_last_sync_date_time'] = on_premises_last_sync_date_time + if on_premises_provisioning_errors is not None: + body['on_premises_provisioning_errors'] = on_premises_provisioning_errors + if on_premises_sam_account_name is not None: + body['on_premises_sam_account_name'] = on_premises_sam_account_name + if on_premises_security_identifier is not None: + body['on_premises_security_identifier'] = on_premises_security_identifier + if on_premises_sync_enabled is not None: + body['on_premises_sync_enabled'] = on_premises_sync_enabled + if on_premises_user_principal_name is not None: + body['on_premises_user_principal_name'] = on_premises_user_principal_name + if other_mails is not None: + body['other_mails'] = other_mails + if password_policies is not None: + body['password_policies'] = password_policies + if password_profile is not None: + body['password_profile'] = password_profile + if postal_code is not None: + body['postal_code'] = postal_code + if preferred_language is not None: + body['preferred_language'] = preferred_language + if provisioned_plans is not None: + body['provisioned_plans'] = provisioned_plans + if proxy_addresses is not None: + body['proxy_addresses'] = proxy_addresses + if show_in_address_list is not None: + body['show_in_address_list'] = show_in_address_list + if sign_in_sessions_valid_from_date_time is not None: + body['sign_in_sessions_valid_from_date_time'] = sign_in_sessions_valid_from_date_time + if state is not None: + body['state'] = state + if street_address is not None: + body['street_address'] = street_address + if surname is not None: + body['surname'] = surname + if usage_location is not None: + body['usage_location'] = usage_location + if user_principal_name is not None: + body['user_principal_name'] = user_principal_name + if user_type is not None: + body['user_type'] = user_type + if device_enrollment_limit is not None: + body['device_enrollment_limit'] = device_enrollment_limit + if about_me is not None: + body['about_me'] = about_me + if birthday is not None: + body['birthday'] = birthday + if hire_date is not None: + body['hire_date'] = hire_date + if interests is not None: + body['interests'] = interests + if my_site is not None: + body['my_site'] = my_site + if past_projects is not None: + body['past_projects'] = past_projects + if preferred_name is not None: + body['preferred_name'] = preferred_name + if responsibilities is not None: + body['responsibilities'] = responsibilities + if schools is not None: + body['schools'] = schools + if skills is not None: + body['skills'] = skills + if app_role_assignments is not None: + body['app_role_assignments'] = app_role_assignments + if created_objects is not None: + body['created_objects'] = created_objects + if direct_reports is not None: + body['direct_reports'] = direct_reports + if license_details is not None: + body['license_details'] = license_details + if manager is not None: + body['manager'] = manager + if member_of is not None: + body['member_of'] = member_of + if oauth2_permission_grants is not None: + body['oauth2_permission_grants'] = oauth2_permission_grants + if owned_devices is not None: + body['owned_devices'] = owned_devices + if owned_objects is not None: + body['owned_objects'] = owned_objects + if registered_devices is not None: + body['registered_devices'] = registered_devices + if scoped_role_member_of is not None: + body['scoped_role_member_of'] = scoped_role_member_of + if transitive_member_of is not None: + body['transitive_member_of'] = transitive_member_of + if calendar is not None: + body['calendar'] = calendar + if calendar_groups is not None: + body['calendar_groups'] = calendar_groups + if calendars is not None: + body['calendars'] = calendars + if calendar_view is not None: + body['calendar_view'] = calendar_view + if contact_folders is not None: + body['contact_folders'] = contact_folders + if contacts is not None: + body['contacts'] = contacts + if events is not None: + body['events'] = events + if mail_folders is not None: + body['mail_folders'] = mail_folders + if messages is not None: + body['messages'] = messages + if people is not None: + body['people'] = people + if photo is not None: + body['photo'] = photo + if photos is not None: + body['photos'] = photos + if drive is not None: + body['drive'] = drive + if drives is not None: + body['drives'] = drives + if followed_sites is not None: + body['followed_sites'] = followed_sites + if extensions is not None: + body['extensions'] = extensions + if managed_devices is not None: + body['managed_devices'] = managed_devices + if managed_app_registrations is not None: + body['managed_app_registrations'] = managed_app_registrations + if device_management_troubleshooting_events is not None: + body['device_management_troubleshooting_events'] = device_management_troubleshooting_events + if activities is not None: + body['activities'] = activities + if online_meetings is not None: + body['online_meetings'] = online_meetings + if joined_teams is not None: + body['joined_teams'] = joined_teams body['exceptions'] = {} - body['exceptions']['body_contains'] = body_contains - body['exceptions']['body_or_subject_contains'] = body_or_subject_contains - body['exceptions']['categories'] = categories - body['exceptions']['from_addresses'] = from_addresses - body['exceptions']['has_attachments'] = has_attachments - body['exceptions']['header_contains'] = header_contains - body['exceptions']['importance'] = importance - body['exceptions']['is_approval_request'] = exceptions_is_approval_request - body['exceptions']['is_automatic_forward'] = exceptions_is_automatic_forward - body['exceptions']['is_automatic_reply'] = exceptions_is_automatic_reply - body['exceptions']['is_encrypted'] = exceptions_is_encrypted - body['exceptions']['is_meeting_request'] = exceptions_is_meeting_request - body['exceptions']['is_meeting_response'] = exceptions_is_meeting_response - body['exceptions']['is_non_delivery_report'] = exceptions_is_non_delivery_report - body['exceptions']['is_permission_controlled'] = exceptions_is_permission_controlled - body['exceptions']['is_read_receipt'] = exceptions_is_read_receipt - body['exceptions']['is_signed'] = exceptions_is_signed - body['exceptions']['is_voicemail'] = exceptions_is_voicemail - body['exceptions']['message_action_flag'] = message_action_flag - body['exceptions']['not_sent_to_me'] = not_sent_to_me - body['exceptions']['recipient_contains'] = recipient_contains - body['exceptions']['sender_contains'] = sender_contains - body['exceptions']['sensitivity'] = sensitivity - body['exceptions']['sent_cc_me'] = sent_cc_me - body['exceptions']['sent_only_to_me'] = sent_only_to_me - body['exceptions']['sent_to_addresses'] = sent_to_addresses - body['exceptions']['sent_to_me'] = sent_to_me - body['exceptions']['sent_to_or_cc_me'] = sent_to_or_cc_me - body['exceptions']['subject_contains'] = subject_contains - body['exceptions']['within_size_range'] = within_size_range + if body_contains is not None: + body['exceptions']['body_contains'] = body_contains + if body_or_subject_contains is not None: + body['exceptions']['body_or_subject_contains'] = body_or_subject_contains + if categories is not None: + body['exceptions']['categories'] = categories + if from_addresses is not None: + body['exceptions']['from_addresses'] = from_addresses + if has_attachments is not None: + body['exceptions']['has_attachments'] = has_attachments + if header_contains is not None: + body['exceptions']['header_contains'] = header_contains + if importance is not None: + body['exceptions']['importance'] = importance + if exceptions_is_approval_request is not None: + body['exceptions']['is_approval_request'] = exceptions_is_approval_request + if exceptions_is_automatic_forward is not None: + body['exceptions']['is_automatic_forward'] = exceptions_is_automatic_forward + if exceptions_is_automatic_reply is not None: + body['exceptions']['is_automatic_reply'] = exceptions_is_automatic_reply + if exceptions_is_encrypted is not None: + body['exceptions']['is_encrypted'] = exceptions_is_encrypted + if exceptions_is_meeting_request is not None: + body['exceptions']['is_meeting_request'] = exceptions_is_meeting_request + if exceptions_is_meeting_response is not None: + body['exceptions']['is_meeting_response'] = exceptions_is_meeting_response + if exceptions_is_non_delivery_report is not None: + body['exceptions']['is_non_delivery_report'] = exceptions_is_non_delivery_report + if exceptions_is_permission_controlled is not None: + body['exceptions']['is_permission_controlled'] = exceptions_is_permission_controlled + if exceptions_is_read_receipt is not None: + body['exceptions']['is_read_receipt'] = exceptions_is_read_receipt + if exceptions_is_signed is not None: + body['exceptions']['is_signed'] = exceptions_is_signed + if exceptions_is_voicemail is not None: + body['exceptions']['is_voicemail'] = exceptions_is_voicemail + if message_action_flag is not None: + body['exceptions']['message_action_flag'] = message_action_flag + if not_sent_to_me is not None: + body['exceptions']['not_sent_to_me'] = not_sent_to_me + if recipient_contains is not None: + body['exceptions']['recipient_contains'] = recipient_contains + if sender_contains is not None: + body['exceptions']['sender_contains'] = sender_contains + if sensitivity is not None: + body['exceptions']['sensitivity'] = sensitivity + if sent_cc_me is not None: + body['exceptions']['sent_cc_me'] = sent_cc_me + if sent_only_to_me is not None: + body['exceptions']['sent_only_to_me'] = sent_only_to_me + if sent_to_addresses is not None: + body['exceptions']['sent_to_addresses'] = sent_to_addresses + if sent_to_me is not None: + body['exceptions']['sent_to_me'] = sent_to_me + if sent_to_or_cc_me is not None: + body['exceptions']['sent_to_or_cc_me'] = sent_to_or_cc_me + if subject_contains is not None: + body['exceptions']['subject_contains'] = subject_contains + if within_size_range is not None: + body['exceptions']['within_size_range'] = within_size_range + if len(body['exceptions']) == 0: + del body['exceptions'] body['conditions'] = {} - body['conditions']['body_contains'] = microsoft_graph_message_rule_predicates_body_contains - body['conditions']['body_or_subject_contains'] = microsoft_graph_message_rule_predicates_body_or_subject_contains_body_or_subject_contains - body['conditions']['categories'] = microsoft_graph_message_rule_predicates_categories - body['conditions']['from_addresses'] = microsoft_graph_message_rule_predicates_from_addresses - body['conditions']['has_attachments'] = boolean_has_attachments - body['conditions']['header_contains'] = microsoft_graph_message_rule_predicates_header_contains - body['conditions']['importance'] = microsoft_graph_importance - body['conditions']['is_approval_request'] = is_approval_request - body['conditions']['is_automatic_forward'] = is_automatic_forward - body['conditions']['is_automatic_reply'] = is_automatic_reply - body['conditions']['is_encrypted'] = is_encrypted - body['conditions']['is_meeting_request'] = is_meeting_request - body['conditions']['is_meeting_response'] = is_meeting_response - body['conditions']['is_non_delivery_report'] = is_non_delivery_report - body['conditions']['is_permission_controlled'] = is_permission_controlled - body['conditions']['is_read_receipt'] = is_read_receipt - body['conditions']['is_signed'] = is_signed - body['conditions']['is_voicemail'] = is_voicemail - body['conditions']['message_action_flag'] = microsoft_graph_message_action_flag_message_action_flag - body['conditions']['not_sent_to_me'] = boolean_not_sent_to_me - body['conditions']['recipient_contains'] = microsoft_graph_message_rule_predicates_recipient_contains - body['conditions']['sender_contains'] = microsoft_graph_message_rule_predicates_sender_contains - body['conditions']['sensitivity'] = microsoft_graph_sensitivity - body['conditions']['sent_cc_me'] = boolean_sent_cc_me - body['conditions']['sent_only_to_me'] = boolean_sent_only_to_me - body['conditions']['sent_to_addresses'] = microsoft_graph_message_rule_predicates_sent_to_addresses_sent_to_addresses - body['conditions']['sent_to_me'] = boolean_sent_to_me - body['conditions']['sent_to_or_cc_me'] = boolean_sent_to_or_cc_me - body['conditions']['subject_contains'] = microsoft_graph_message_rule_predicates_subject_contains - body['conditions']['within_size_range'] = microsoft_graph_size_range_within_size_range + if microsoft_graph_message_rule_predicates_body_contains is not None: + body['conditions']['body_contains'] = microsoft_graph_message_rule_predicates_body_contains + if microsoft_graph_message_rule_predicates_body_or_subject_contains_body_or_subject_contains is not None: + body['conditions']['body_or_subject_contains'] = microsoft_graph_message_rule_predicates_body_or_subject_contains_body_or_subject_contains + if microsoft_graph_message_rule_predicates_categories is not None: + body['conditions']['categories'] = microsoft_graph_message_rule_predicates_categories + if microsoft_graph_message_rule_predicates_from_addresses is not None: + body['conditions']['from_addresses'] = microsoft_graph_message_rule_predicates_from_addresses + if boolean_has_attachments is not None: + body['conditions']['has_attachments'] = boolean_has_attachments + if microsoft_graph_message_rule_predicates_header_contains is not None: + body['conditions']['header_contains'] = microsoft_graph_message_rule_predicates_header_contains + if microsoft_graph_importance is not None: + body['conditions']['importance'] = microsoft_graph_importance + if is_approval_request is not None: + body['conditions']['is_approval_request'] = is_approval_request + if is_automatic_forward is not None: + body['conditions']['is_automatic_forward'] = is_automatic_forward + if is_automatic_reply is not None: + body['conditions']['is_automatic_reply'] = is_automatic_reply + if is_encrypted is not None: + body['conditions']['is_encrypted'] = is_encrypted + if is_meeting_request is not None: + body['conditions']['is_meeting_request'] = is_meeting_request + if is_meeting_response is not None: + body['conditions']['is_meeting_response'] = is_meeting_response + if is_non_delivery_report is not None: + body['conditions']['is_non_delivery_report'] = is_non_delivery_report + if is_permission_controlled is not None: + body['conditions']['is_permission_controlled'] = is_permission_controlled + if is_read_receipt is not None: + body['conditions']['is_read_receipt'] = is_read_receipt + if is_signed is not None: + body['conditions']['is_signed'] = is_signed + if is_voicemail is not None: + body['conditions']['is_voicemail'] = is_voicemail + if microsoft_graph_message_action_flag_message_action_flag is not None: + body['conditions']['message_action_flag'] = microsoft_graph_message_action_flag_message_action_flag + if boolean_not_sent_to_me is not None: + body['conditions']['not_sent_to_me'] = boolean_not_sent_to_me + if microsoft_graph_message_rule_predicates_recipient_contains is not None: + body['conditions']['recipient_contains'] = microsoft_graph_message_rule_predicates_recipient_contains + if microsoft_graph_message_rule_predicates_sender_contains is not None: + body['conditions']['sender_contains'] = microsoft_graph_message_rule_predicates_sender_contains + if microsoft_graph_sensitivity is not None: + body['conditions']['sensitivity'] = microsoft_graph_sensitivity + if boolean_sent_cc_me is not None: + body['conditions']['sent_cc_me'] = boolean_sent_cc_me + if boolean_sent_only_to_me is not None: + body['conditions']['sent_only_to_me'] = boolean_sent_only_to_me + if microsoft_graph_message_rule_predicates_sent_to_addresses_sent_to_addresses is not None: + body['conditions']['sent_to_addresses'] = microsoft_graph_message_rule_predicates_sent_to_addresses_sent_to_addresses + if boolean_sent_to_me is not None: + body['conditions']['sent_to_me'] = boolean_sent_to_me + if boolean_sent_to_or_cc_me is not None: + body['conditions']['sent_to_or_cc_me'] = boolean_sent_to_or_cc_me + if microsoft_graph_message_rule_predicates_subject_contains is not None: + body['conditions']['subject_contains'] = microsoft_graph_message_rule_predicates_subject_contains + if microsoft_graph_size_range_within_size_range is not None: + body['conditions']['within_size_range'] = microsoft_graph_size_range_within_size_range + if len(body['conditions']) == 0: + del body['conditions'] body['onenote'] = {} - body['onenote']['id'] = microsoft_graph_entity_id - body['onenote']['notebooks'] = notebooks - body['onenote']['operations'] = operations - body['onenote']['pages'] = pages - body['onenote']['resources'] = resources - body['onenote']['section_groups'] = section_groups - body['onenote']['sections'] = sections + if microsoft_graph_entity_id is not None: + body['onenote']['id'] = microsoft_graph_entity_id + if notebooks is not None: + body['onenote']['notebooks'] = notebooks + if operations is not None: + body['onenote']['operations'] = operations + if pages is not None: + body['onenote']['pages'] = pages + if resources is not None: + body['onenote']['resources'] = resources + if section_groups is not None: + body['onenote']['section_groups'] = section_groups + if sections is not None: + body['onenote']['sections'] = sections + if len(body['onenote']) == 0: + del body['onenote'] body['settings'] = {} - body['settings']['id'] = id1 - body['settings']['contribution_to_content_discovery_as_organization_disabled'] = contribution_to_content_discovery_as_organization_disabled - body['settings']['contribution_to_content_discovery_disabled'] = contribution_to_content_discovery_disabled + if id1 is not None: + body['settings']['id'] = id1 + if contribution_to_content_discovery_as_organization_disabled is not None: + body['settings']['contribution_to_content_discovery_as_organization_disabled'] = contribution_to_content_discovery_as_organization_disabled + if contribution_to_content_discovery_disabled is not None: + body['settings']['contribution_to_content_discovery_disabled'] = contribution_to_content_discovery_disabled body['settings']['shift_preferences'] = {} - body['settings']['shift_preferences']['id'] = id2 - body['settings']['shift_preferences']['created_date_time'] = microsoft_graph_change_tracked_entity_created_date_time_created_date_time - body['settings']['shift_preferences']['last_modified_date_time'] = last_modified_date_time + if id2 is not None: + body['settings']['shift_preferences']['id'] = id2 + if microsoft_graph_change_tracked_entity_created_date_time_created_date_time is not None: + body['settings']['shift_preferences']['created_date_time'] = microsoft_graph_change_tracked_entity_created_date_time_created_date_time + if last_modified_date_time is not None: + body['settings']['shift_preferences']['last_modified_date_time'] = last_modified_date_time body['settings']['shift_preferences']['last_modified_by'] = {} - body['settings']['shift_preferences']['last_modified_by']['application'] = application - body['settings']['shift_preferences']['last_modified_by']['device'] = device - body['settings']['shift_preferences']['last_modified_by']['user'] = user - body['settings']['shift_preferences']['availability'] = availability + if application is not None: + body['settings']['shift_preferences']['last_modified_by']['application'] = application + if device is not None: + body['settings']['shift_preferences']['last_modified_by']['device'] = device + if user is not None: + body['settings']['shift_preferences']['last_modified_by']['user'] = user + if len(body['settings']['shift_preferences']['last_modified_by']) == 0: + del body['settings']['shift_preferences']['last_modified_by'] + if availability is not None: + body['settings']['shift_preferences']['availability'] = availability + if len(body['settings']['shift_preferences']) == 0: + del body['settings']['shift_preferences'] + if len(body['settings']) == 0: + del body['settings'] body['insights'] = {} - body['insights']['id'] = id3 - body['insights']['shared'] = shared - body['insights']['trending'] = trending - body['insights']['used'] = used + if id3 is not None: + body['insights']['id'] = id3 + if shared is not None: + body['insights']['shared'] = shared + if trending is not None: + body['insights']['trending'] = trending + if used is not None: + body['insights']['used'] = used + if len(body['insights']) == 0: + del body['insights'] body['planner'] = {} - body['planner']['id'] = id4 - body['planner']['plans'] = plans - body['planner']['tasks'] = tasks + if id4 is not None: + body['planner']['id'] = id4 + if plans is not None: + body['planner']['plans'] = plans + if tasks is not None: + body['planner']['tasks'] = tasks + if len(body['planner']) == 0: + del body['planner'] body['outlook'] = {} - body['outlook']['id'] = id5 - body['outlook']['master_categories'] = master_categories + if id5 is not None: + body['outlook']['id'] = id5 + if master_categories is not None: + body['outlook']['master_categories'] = master_categories + if len(body['outlook']) == 0: + del body['outlook'] body['inference_classification'] = {} - body['inference_classification']['id'] = id6 - body['inference_classification']['overrides'] = overrides + if id6 is not None: + body['inference_classification']['id'] = id6 + if overrides is not None: + body['inference_classification']['overrides'] = overrides + if len(body['inference_classification']) == 0: + del body['inference_classification'] body['mailbox_settings'] = {} - body['mailbox_settings']['archive_folder'] = archive_folder - body['mailbox_settings']['automatic_replies_setting'] = automatic_replies_setting - body['mailbox_settings']['date_format'] = date_format - body['mailbox_settings']['delegate_meeting_message_delivery_options'] = delegate_meeting_message_delivery_options - body['mailbox_settings']['language'] = language - body['mailbox_settings']['time_format'] = time_format - body['mailbox_settings']['time_zone'] = time_zone - body['mailbox_settings']['working_hours'] = working_hours + if archive_folder is not None: + body['mailbox_settings']['archive_folder'] = archive_folder + if automatic_replies_setting is not None: + body['mailbox_settings']['automatic_replies_setting'] = automatic_replies_setting + if date_format is not None: + body['mailbox_settings']['date_format'] = date_format + if delegate_meeting_message_delivery_options is not None: + body['mailbox_settings']['delegate_meeting_message_delivery_options'] = delegate_meeting_message_delivery_options + if language is not None: + body['mailbox_settings']['language'] = language + if time_format is not None: + body['mailbox_settings']['time_format'] = time_format + if time_zone is not None: + body['mailbox_settings']['time_zone'] = time_zone + if working_hours is not None: + body['mailbox_settings']['working_hours'] = working_hours + if len(body['mailbox_settings']) == 0: + del body['mailbox_settings'] return client.update_user(user_id=user_id, body=body) @@ -862,7 +1300,8 @@ def users_user_create_extension(client, user_id, id_=None): body = {} - body['id'] = id_ + if id_ is not None: + body['id'] = id_ return client.create_extensions(user_id=user_id, body=body) @@ -874,10 +1313,14 @@ def users_user_create_license_detail(client, sku_id=None, sku_part_number=None): body = {} - body['id'] = id_ - body['service_plans'] = service_plans - body['sku_id'] = sku_id - body['sku_part_number'] = sku_part_number + if id_ is not None: + body['id'] = id_ + if service_plans is not None: + body['service_plans'] = service_plans + if sku_id is not None: + body['sku_id'] = sku_id + if sku_part_number is not None: + body['sku_part_number'] = sku_part_number return client.create_license_details(user_id=user_id, body=body) @@ -888,9 +1331,12 @@ def users_user_create_photo(client, height=None, width=None): body = {} - body['id'] = id_ - body['height'] = height - body['width'] = width + if id_ is not None: + body['id'] = id_ + if height is not None: + body['height'] = height + if width is not None: + body['width'] = width return client.create_photos(user_id=user_id, body=body) @@ -1260,7 +1706,8 @@ def users_user_update_extension(client, extension_id, id_=None): body = {} - body['id'] = id_ + if id_ is not None: + body['id'] = id_ return client.update_extensions(user_id=user_id, extension_id=extension_id, body=body) @@ -1274,10 +1721,14 @@ def users_user_update_license_detail(client, sku_id=None, sku_part_number=None): body = {} - body['id'] = id_ - body['service_plans'] = service_plans - body['sku_id'] = sku_id - body['sku_part_number'] = sku_part_number + if id_ is not None: + body['id'] = id_ + if service_plans is not None: + body['service_plans'] = service_plans + if sku_id is not None: + body['sku_id'] = sku_id + if sku_part_number is not None: + body['sku_part_number'] = sku_part_number return client.update_license_details(user_id=user_id, license_details_id=license_details_id, body=body) @@ -1288,8 +1739,10 @@ def users_user_update_outlook(client, id_=None, master_categories=None): body = {} - body['id'] = id_ - body['master_categories'] = master_categories + if id_ is not None: + body['id'] = id_ + if master_categories is not None: + body['master_categories'] = master_categories return client.update_outlook(user_id=user_id, body=body) @@ -1301,9 +1754,12 @@ def users_user_update_photo(client, height=None, width=None): body = {} - body['id'] = id_ - body['height'] = height - body['width'] = width + if id_ is not None: + body['id'] = id_ + if height is not None: + body['height'] = height + if width is not None: + body['width'] = width if user_id is not None and profile_photo_id is not None: return client.update_photos(user_id=user_id, profile_photo_id=profile_photo_id, @@ -1325,18 +1781,32 @@ def users_user_update_setting(client, user=None, availability=None): body = {} - body['id'] = id_ - body['contribution_to_content_discovery_as_organization_disabled'] = contribution_to_content_discovery_as_organization_disabled - body['contribution_to_content_discovery_disabled'] = contribution_to_content_discovery_disabled + if id_ is not None: + body['id'] = id_ + if contribution_to_content_discovery_as_organization_disabled is not None: + body['contribution_to_content_discovery_as_organization_disabled'] = contribution_to_content_discovery_as_organization_disabled + if contribution_to_content_discovery_disabled is not None: + body['contribution_to_content_discovery_disabled'] = contribution_to_content_discovery_disabled body['shift_preferences'] = {} - body['shift_preferences']['id'] = microsoft_graph_entity_id - body['shift_preferences']['created_date_time'] = created_date_time - body['shift_preferences']['last_modified_date_time'] = last_modified_date_time + if microsoft_graph_entity_id is not None: + body['shift_preferences']['id'] = microsoft_graph_entity_id + if created_date_time is not None: + body['shift_preferences']['created_date_time'] = created_date_time + if last_modified_date_time is not None: + body['shift_preferences']['last_modified_date_time'] = last_modified_date_time body['shift_preferences']['last_modified_by'] = {} - body['shift_preferences']['last_modified_by']['application'] = application - body['shift_preferences']['last_modified_by']['device'] = device - body['shift_preferences']['last_modified_by']['user'] = user - body['shift_preferences']['availability'] = availability + if application is not None: + body['shift_preferences']['last_modified_by']['application'] = application + if device is not None: + body['shift_preferences']['last_modified_by']['device'] = device + if user is not None: + body['shift_preferences']['last_modified_by']['user'] = user + if len(body['shift_preferences']['last_modified_by']) == 0: + del body['shift_preferences']['last_modified_by'] + if availability is not None: + body['shift_preferences']['availability'] = availability + if len(body['shift_preferences']) == 0: + del body['shift_preferences'] return client.update_settings(user_id=user_id, body=body) @@ -1347,9 +1817,12 @@ def users_user_outlook_create_master_category(client, color=None, display_name=None): body = {} - body['id'] = id_ - body['color'] = color - body['display_name'] = display_name + if id_ is not None: + body['id'] = id_ + if color is not None: + body['color'] = color + if display_name is not None: + body['display_name'] = display_name return client.create_master_categories(user_id=user_id, body=body) @@ -1392,9 +1865,12 @@ def users_user_outlook_update_master_category(client, color=None, display_name=None): body = {} - body['id'] = id_ - body['color'] = color - body['display_name'] = display_name + if id_ is not None: + body['id'] = id_ + if color is not None: + body['color'] = color + if display_name is not None: + body['display_name'] = display_name return client.update_master_categories(user_id=user_id, outlook_category_id=outlook_category_id, body=body) @@ -1426,13 +1902,22 @@ def users_user_setting_update_shift_preference(client, user=None, availability=None): body = {} - body['id'] = id_ - body['created_date_time'] = created_date_time - body['last_modified_date_time'] = last_modified_date_time + if id_ is not None: + body['id'] = id_ + if created_date_time is not None: + body['created_date_time'] = created_date_time + if last_modified_date_time is not None: + body['last_modified_date_time'] = last_modified_date_time body['last_modified_by'] = {} - body['last_modified_by']['application'] = application - body['last_modified_by']['device'] = device - body['last_modified_by']['user'] = user - body['availability'] = availability + if application is not None: + body['last_modified_by']['application'] = application + if device is not None: + body['last_modified_by']['device'] = device + if user is not None: + body['last_modified_by']['user'] = user + if len(body['last_modified_by']) == 0: + del body['last_modified_by'] + if availability is not None: + body['availability'] = availability return client.update_shift_preferences(user_id=user_id, body=body) diff --git a/test/scenarios/synapse/output/coredefault/src/azure-cli/azure/cli/command_modules/synapse/generated/custom.py b/test/scenarios/synapse/output/coredefault/src/azure-cli/azure/cli/command_modules/synapse/generated/custom.py index 4af2a1142..24bdb2458 100644 --- a/test/scenarios/synapse/output/coredefault/src/azure-cli/azure/cli/command_modules/synapse/generated/custom.py +++ b/test/scenarios/synapse/output/coredefault/src/azure-cli/azure/cli/command_modules/synapse/generated/custom.py @@ -48,28 +48,38 @@ def synapse_big_data_pool_create(client, node_size=None, node_size_family=None, no_wait=False): - if force is None: - force = False big_data_pool_info = {} - big_data_pool_info['tags'] = tags + if tags is not None: + big_data_pool_info['tags'] = tags big_data_pool_info['location'] = location - big_data_pool_info['provisioning_state'] = provisioning_state - big_data_pool_info['auto_scale'] = auto_scale - big_data_pool_info['creation_date'] = creation_date - big_data_pool_info['auto_pause'] = auto_pause - big_data_pool_info['spark_events_folder'] = spark_events_folder - big_data_pool_info['node_count'] = node_count - big_data_pool_info['library_requirements'] = library_requirements - big_data_pool_info['spark_version'] = spark_version - big_data_pool_info['default_spark_log_folder'] = default_spark_log_folder - big_data_pool_info['node_size'] = node_size - big_data_pool_info['node_size_family'] = node_size_family + if provisioning_state is not None: + big_data_pool_info['provisioning_state'] = provisioning_state + if auto_scale is not None: + big_data_pool_info['auto_scale'] = auto_scale + if creation_date is not None: + big_data_pool_info['creation_date'] = creation_date + if auto_pause is not None: + big_data_pool_info['auto_pause'] = auto_pause + if spark_events_folder is not None: + big_data_pool_info['spark_events_folder'] = spark_events_folder + if node_count is not None: + big_data_pool_info['node_count'] = node_count + if library_requirements is not None: + big_data_pool_info['library_requirements'] = library_requirements + if spark_version is not None: + big_data_pool_info['spark_version'] = spark_version + if default_spark_log_folder is not None: + big_data_pool_info['default_spark_log_folder'] = default_spark_log_folder + if node_size is not None: + big_data_pool_info['node_size'] = node_size + if node_size_family is not None: + big_data_pool_info['node_size_family'] = node_size_family return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, - force=force, + force=False if force is None else force, big_data_pool_info=big_data_pool_info) @@ -220,18 +230,29 @@ def synapse_sql_pool_create(client, creation_date=None, no_wait=False): sql_pool_info = {} - sql_pool_info['tags'] = tags + if tags is not None: + sql_pool_info['tags'] = tags sql_pool_info['location'] = location - sql_pool_info['sku'] = sku - sql_pool_info['max_size_bytes'] = max_size_bytes - sql_pool_info['collation'] = collation - sql_pool_info['source_database_id'] = source_database_id - sql_pool_info['recoverable_database_id'] = recoverable_database_id - sql_pool_info['provisioning_state'] = provisioning_state - sql_pool_info['status'] = status - sql_pool_info['restore_point_in_time'] = restore_point_in_time - sql_pool_info['create_mode'] = create_mode - sql_pool_info['creation_date'] = creation_date + if sku is not None: + sql_pool_info['sku'] = sku + if max_size_bytes is not None: + sql_pool_info['max_size_bytes'] = max_size_bytes + if collation is not None: + sql_pool_info['collation'] = collation + if source_database_id is not None: + sql_pool_info['source_database_id'] = source_database_id + if recoverable_database_id is not None: + sql_pool_info['recoverable_database_id'] = recoverable_database_id + if provisioning_state is not None: + sql_pool_info['provisioning_state'] = provisioning_state + if status is not None: + sql_pool_info['status'] = status + if restore_point_in_time is not None: + sql_pool_info['restore_point_in_time'] = restore_point_in_time + if create_mode is not None: + sql_pool_info['create_mode'] = create_mode + if creation_date is not None: + sql_pool_info['creation_date'] = creation_date return sdk_no_wait(no_wait, client.create, resource_group_name=resource_group_name, @@ -257,18 +278,30 @@ def synapse_sql_pool_update(client, create_mode=None, creation_date=None): sql_pool_info = {} - sql_pool_info['tags'] = tags - sql_pool_info['location'] = location - sql_pool_info['sku'] = sku - sql_pool_info['max_size_bytes'] = max_size_bytes - sql_pool_info['collation'] = collation - sql_pool_info['source_database_id'] = source_database_id - sql_pool_info['recoverable_database_id'] = recoverable_database_id - sql_pool_info['provisioning_state'] = provisioning_state - sql_pool_info['status'] = status - sql_pool_info['restore_point_in_time'] = restore_point_in_time - sql_pool_info['create_mode'] = create_mode - sql_pool_info['creation_date'] = creation_date + if tags is not None: + sql_pool_info['tags'] = tags + if location is not None: + sql_pool_info['location'] = location + if sku is not None: + sql_pool_info['sku'] = sku + if max_size_bytes is not None: + sql_pool_info['max_size_bytes'] = max_size_bytes + if collation is not None: + sql_pool_info['collation'] = collation + if source_database_id is not None: + sql_pool_info['source_database_id'] = source_database_id + if recoverable_database_id is not None: + sql_pool_info['recoverable_database_id'] = recoverable_database_id + if provisioning_state is not None: + sql_pool_info['provisioning_state'] = provisioning_state + if status is not None: + sql_pool_info['status'] = status + if restore_point_in_time is not None: + sql_pool_info['restore_point_in_time'] = restore_point_in_time + if create_mode is not None: + sql_pool_info['create_mode'] = create_mode + if creation_date is not None: + sql_pool_info['creation_date'] = creation_date return client.update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -458,14 +491,22 @@ def synapse_sql_pool_blob_auditing_policy_create(client, is_storage_secondary_key_in_use=None, is_azure_monitor_target_enabled=None): parameters = {} - parameters['state'] = state - parameters['storage_endpoint'] = storage_endpoint - parameters['storage_account_access_key'] = storage_account_access_key - parameters['retention_days'] = retention_days - parameters['audit_actions_and_groups'] = audit_actions_and_groups - parameters['storage_account_subscription_id'] = storage_account_subscription_id - parameters['is_storage_secondary_key_in_use'] = is_storage_secondary_key_in_use - parameters['is_azure_monitor_target_enabled'] = is_azure_monitor_target_enabled + if state is not None: + parameters['state'] = state + if storage_endpoint is not None: + parameters['storage_endpoint'] = storage_endpoint + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if retention_days is not None: + parameters['retention_days'] = retention_days + if audit_actions_and_groups is not None: + parameters['audit_actions_and_groups'] = audit_actions_and_groups + if storage_account_subscription_id is not None: + parameters['storage_account_subscription_id'] = storage_account_subscription_id + if is_storage_secondary_key_in_use is not None: + parameters['is_storage_secondary_key_in_use'] = is_storage_secondary_key_in_use + if is_azure_monitor_target_enabled is not None: + parameters['is_azure_monitor_target_enabled'] = is_azure_monitor_target_enabled return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -533,10 +574,14 @@ def synapse_sql_pool_sensitivity_label_create(client, information_type=None, information_type_id=None): parameters = {} - parameters['label_name'] = label_name - parameters['label_id'] = label_id - parameters['information_type'] = information_type - parameters['information_type_id'] = information_type_id + if label_name is not None: + parameters['label_name'] = label_name + if label_id is not None: + parameters['label_id'] = label_id + if information_type is not None: + parameters['information_type'] = information_type + if information_type_id is not None: + parameters['information_type_id'] = information_type_id return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -558,10 +603,14 @@ def synapse_sql_pool_sensitivity_label_update(client, information_type=None, information_type_id=None): parameters = {} - parameters['label_name'] = label_name - parameters['label_id'] = label_id - parameters['information_type'] = information_type - parameters['information_type_id'] = information_type_id + if label_name is not None: + parameters['label_name'] = label_name + if label_id is not None: + parameters['label_id'] = label_id + if information_type is not None: + parameters['information_type'] = information_type + if information_type_id is not None: + parameters['information_type_id'] = information_type_id return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -719,10 +768,14 @@ def synapse_sql_pool_vulnerability_assessment_create(client, storage_account_access_key=None, recurring_scans=None): parameters = {} - parameters['storage_container_path'] = storage_container_path - parameters['storage_container_sas_key'] = storage_container_sas_key - parameters['storage_account_access_key'] = storage_account_access_key - parameters['recurring_scans'] = recurring_scans + if storage_container_path is not None: + parameters['storage_container_path'] = storage_container_path + if storage_container_sas_key is not None: + parameters['storage_container_sas_key'] = storage_container_sas_key + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if recurring_scans is not None: + parameters['recurring_scans'] = recurring_scans return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -815,13 +868,20 @@ def synapse_sql_pool_security_alert_policy_create(client, storage_account_access_key=None, retention_days=None): parameters = {} - parameters['state'] = state - parameters['disabled_alerts'] = disabled_alerts - parameters['email_addresses'] = email_addresses - parameters['email_account_admins'] = email_account_admins - parameters['storage_endpoint'] = storage_endpoint - parameters['storage_account_access_key'] = storage_account_access_key - parameters['retention_days'] = retention_days + if state is not None: + parameters['state'] = state + if disabled_alerts is not None: + parameters['disabled_alerts'] = disabled_alerts + if email_addresses is not None: + parameters['email_addresses'] = email_addresses + if email_account_admins is not None: + parameters['email_account_admins'] = email_account_admins + if storage_endpoint is not None: + parameters['storage_endpoint'] = storage_endpoint + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if retention_days is not None: + parameters['retention_days'] = retention_days return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -933,19 +993,33 @@ def synapse_workspace_create(client, type_=None, no_wait=False): workspace_info = {} - workspace_info['tags'] = tags + if tags is not None: + workspace_info['tags'] = tags workspace_info['location'] = location - workspace_info['default_data_lake_storage'] = default_data_lake_storage - workspace_info['sql_administrator_login_password'] = sql_administrator_login_password - workspace_info['managed_resource_group_name'] = managed_resource_group_name - workspace_info['sql_administrator_login'] = sql_administrator_login - workspace_info['connectivity_endpoints'] = connectivity_endpoints - workspace_info['managed_virtual_network'] = managed_virtual_network - workspace_info['private_endpoint_connections'] = private_endpoint_connections + if default_data_lake_storage is not None: + workspace_info['default_data_lake_storage'] = default_data_lake_storage + if sql_administrator_login_password is not None: + workspace_info['sql_administrator_login_password'] = sql_administrator_login_password + if managed_resource_group_name is not None: + workspace_info['managed_resource_group_name'] = managed_resource_group_name + if sql_administrator_login is not None: + workspace_info['sql_administrator_login'] = sql_administrator_login + if connectivity_endpoints is not None: + workspace_info['connectivity_endpoints'] = connectivity_endpoints + if managed_virtual_network is not None: + workspace_info['managed_virtual_network'] = managed_virtual_network + if private_endpoint_connections is not None: + workspace_info['private_endpoint_connections'] = private_endpoint_connections workspace_info['virtual_network_profile'] = {} - workspace_info['virtual_network_profile']['compute_subnet_id'] = compute_subnet_id + if compute_subnet_id is not None: + workspace_info['virtual_network_profile']['compute_subnet_id'] = compute_subnet_id + if len(workspace_info['virtual_network_profile']) == 0: + del workspace_info['virtual_network_profile'] workspace_info['identity'] = {} - workspace_info['identity']['type'] = type_ + if type_ is not None: + workspace_info['identity']['type'] = type_ + if len(workspace_info['identity']) == 0: + del workspace_info['identity'] return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -961,10 +1035,15 @@ def synapse_workspace_update(client, type_=None, no_wait=False): workspace_patch_info = {} - workspace_patch_info['tags'] = tags - workspace_patch_info['sql_administrator_login_password'] = sql_administrator_login_password + if tags is not None: + workspace_patch_info['tags'] = tags + if sql_administrator_login_password is not None: + workspace_patch_info['sql_administrator_login_password'] = sql_administrator_login_password workspace_patch_info['identity'] = {} - workspace_patch_info['identity']['type'] = type_ + if type_ is not None: + workspace_patch_info['identity']['type'] = type_ + if len(workspace_patch_info['identity']) == 0: + del workspace_patch_info['identity'] return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -998,10 +1077,14 @@ def synapse_workspace_aad_admin_create(client, sid=None, no_wait=False): aad_admin_info = {} - aad_admin_info['tenant_id'] = tenant_id - aad_admin_info['login'] = login - aad_admin_info['administrator_type'] = administrator_type - aad_admin_info['sid'] = sid + if tenant_id is not None: + aad_admin_info['tenant_id'] = tenant_id + if login is not None: + aad_admin_info['login'] = login + if administrator_type is not None: + aad_admin_info['administrator_type'] = administrator_type + if sid is not None: + aad_admin_info['sid'] = sid return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -1050,7 +1133,8 @@ def synapse_workspace_managed_identity_sql_control_setting_create(client, workspace_name, desired_state=None): grant_sql_control_to_managed_identity = {} - grant_sql_control_to_managed_identity['desired_state'] = desired_state + if desired_state is not None: + grant_sql_control_to_managed_identity['desired_state'] = desired_state return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, grant_sql_control_to_managed_identity=grant_sql_control_to_managed_identity) diff --git a/test/scenarios/synapse/output/ext_default_folder/src/synapse/azext_synapse/generated/custom.py b/test/scenarios/synapse/output/ext_default_folder/src/synapse/azext_synapse/generated/custom.py index 162411cab..478c7d4c8 100644 --- a/test/scenarios/synapse/output/ext_default_folder/src/synapse/azext_synapse/generated/custom.py +++ b/test/scenarios/synapse/output/ext_default_folder/src/synapse/azext_synapse/generated/custom.py @@ -48,28 +48,38 @@ def synapse_big_data_pool_create(client, node_size=None, node_size_family=None, no_wait=False): - if force is None: - force = False big_data_pool_info = {} - big_data_pool_info['tags'] = tags + if tags is not None: + big_data_pool_info['tags'] = tags big_data_pool_info['location'] = location - big_data_pool_info['provisioning_state'] = provisioning_state - big_data_pool_info['auto_scale'] = auto_scale - big_data_pool_info['creation_date'] = creation_date - big_data_pool_info['auto_pause'] = auto_pause - big_data_pool_info['spark_events_folder'] = spark_events_folder - big_data_pool_info['node_count'] = node_count - big_data_pool_info['library_requirements'] = library_requirements - big_data_pool_info['spark_version'] = spark_version - big_data_pool_info['default_spark_log_folder'] = default_spark_log_folder - big_data_pool_info['node_size'] = node_size - big_data_pool_info['node_size_family'] = node_size_family + if provisioning_state is not None: + big_data_pool_info['provisioning_state'] = provisioning_state + if auto_scale is not None: + big_data_pool_info['auto_scale'] = auto_scale + if creation_date is not None: + big_data_pool_info['creation_date'] = creation_date + if auto_pause is not None: + big_data_pool_info['auto_pause'] = auto_pause + if spark_events_folder is not None: + big_data_pool_info['spark_events_folder'] = spark_events_folder + if node_count is not None: + big_data_pool_info['node_count'] = node_count + if library_requirements is not None: + big_data_pool_info['library_requirements'] = library_requirements + if spark_version is not None: + big_data_pool_info['spark_version'] = spark_version + if default_spark_log_folder is not None: + big_data_pool_info['default_spark_log_folder'] = default_spark_log_folder + if node_size is not None: + big_data_pool_info['node_size'] = node_size + if node_size_family is not None: + big_data_pool_info['node_size_family'] = node_size_family return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, - force=force, + force=False if force is None else force, big_data_pool_info=big_data_pool_info) @@ -79,7 +89,8 @@ def synapse_big_data_pool_update(client, big_data_pool_name, tags=None): big_data_pool_patch_info = {} - big_data_pool_patch_info['tags'] = tags + if tags is not None: + big_data_pool_patch_info['tags'] = tags return client.update(resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -140,8 +151,10 @@ def synapse_ip_firewall_rule_create(client, start_ip_address=None, no_wait=False): ip_firewall_rule_info = {} - ip_firewall_rule_info['end_ip_address'] = end_ip_address - ip_firewall_rule_info['start_ip_address'] = start_ip_address + if end_ip_address is not None: + ip_firewall_rule_info['end_ip_address'] = end_ip_address + if start_ip_address is not None: + ip_firewall_rule_info['start_ip_address'] = start_ip_address return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -182,7 +195,8 @@ def synapse_ip_firewall_rule_replace_all(client, ip_firewall_rules=None, no_wait=False): request = {} - request['ip_firewall_rules'] = ip_firewall_rules + if ip_firewall_rules is not None: + request['ip_firewall_rules'] = ip_firewall_rules return sdk_no_wait(no_wait, client.begin_replace_all, resource_group_name=resource_group_name, @@ -224,18 +238,29 @@ def synapse_sql_pool_create(client, creation_date=None, no_wait=False): sql_pool_info = {} - sql_pool_info['tags'] = tags + if tags is not None: + sql_pool_info['tags'] = tags sql_pool_info['location'] = location - sql_pool_info['sku'] = sku - sql_pool_info['max_size_bytes'] = max_size_bytes - sql_pool_info['collation'] = collation - sql_pool_info['source_database_id'] = source_database_id - sql_pool_info['recoverable_database_id'] = recoverable_database_id - sql_pool_info['provisioning_state'] = provisioning_state - sql_pool_info['status'] = status - sql_pool_info['restore_point_in_time'] = restore_point_in_time - sql_pool_info['create_mode'] = create_mode - sql_pool_info['creation_date'] = creation_date + if sku is not None: + sql_pool_info['sku'] = sku + if max_size_bytes is not None: + sql_pool_info['max_size_bytes'] = max_size_bytes + if collation is not None: + sql_pool_info['collation'] = collation + if source_database_id is not None: + sql_pool_info['source_database_id'] = source_database_id + if recoverable_database_id is not None: + sql_pool_info['recoverable_database_id'] = recoverable_database_id + if provisioning_state is not None: + sql_pool_info['provisioning_state'] = provisioning_state + if status is not None: + sql_pool_info['status'] = status + if restore_point_in_time is not None: + sql_pool_info['restore_point_in_time'] = restore_point_in_time + if create_mode is not None: + sql_pool_info['create_mode'] = create_mode + if creation_date is not None: + sql_pool_info['creation_date'] = creation_date return sdk_no_wait(no_wait, client.begin_create, resource_group_name=resource_group_name, @@ -261,18 +286,30 @@ def synapse_sql_pool_update(client, create_mode=None, creation_date=None): sql_pool_info = {} - sql_pool_info['tags'] = tags - sql_pool_info['location'] = location - sql_pool_info['sku'] = sku - sql_pool_info['max_size_bytes'] = max_size_bytes - sql_pool_info['collation'] = collation - sql_pool_info['source_database_id'] = source_database_id - sql_pool_info['recoverable_database_id'] = recoverable_database_id - sql_pool_info['provisioning_state'] = provisioning_state - sql_pool_info['status'] = status - sql_pool_info['restore_point_in_time'] = restore_point_in_time - sql_pool_info['create_mode'] = create_mode - sql_pool_info['creation_date'] = creation_date + if tags is not None: + sql_pool_info['tags'] = tags + if location is not None: + sql_pool_info['location'] = location + if sku is not None: + sql_pool_info['sku'] = sku + if max_size_bytes is not None: + sql_pool_info['max_size_bytes'] = max_size_bytes + if collation is not None: + sql_pool_info['collation'] = collation + if source_database_id is not None: + sql_pool_info['source_database_id'] = source_database_id + if recoverable_database_id is not None: + sql_pool_info['recoverable_database_id'] = recoverable_database_id + if provisioning_state is not None: + sql_pool_info['provisioning_state'] = provisioning_state + if status is not None: + sql_pool_info['status'] = status + if restore_point_in_time is not None: + sql_pool_info['restore_point_in_time'] = restore_point_in_time + if create_mode is not None: + sql_pool_info['create_mode'] = create_mode + if creation_date is not None: + sql_pool_info['creation_date'] = creation_date return client.update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -343,7 +380,8 @@ def synapse_sql_pool_metadata_sync_config_create(client, sql_pool_name, enabled=None): metadata_sync_configuration = {} - metadata_sync_configuration['enabled'] = enabled + if enabled is not None: + metadata_sync_configuration['enabled'] = enabled return client.create(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -428,7 +466,8 @@ def synapse_sql_pool_transparent_data_encryption_create(client, sql_pool_name, status=None): parameters = {} - parameters['status'] = status + if status is not None: + parameters['status'] = status return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -468,14 +507,22 @@ def synapse_sql_pool_blob_auditing_policy_create(client, is_storage_secondary_key_in_use=None, is_azure_monitor_target_enabled=None): parameters = {} - parameters['state'] = state - parameters['storage_endpoint'] = storage_endpoint - parameters['storage_account_access_key'] = storage_account_access_key - parameters['retention_days'] = retention_days - parameters['audit_actions_and_groups'] = audit_actions_and_groups - parameters['storage_account_subscription_id'] = storage_account_subscription_id - parameters['is_storage_secondary_key_in_use'] = is_storage_secondary_key_in_use - parameters['is_azure_monitor_target_enabled'] = is_azure_monitor_target_enabled + if state is not None: + parameters['state'] = state + if storage_endpoint is not None: + parameters['storage_endpoint'] = storage_endpoint + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if retention_days is not None: + parameters['retention_days'] = retention_days + if audit_actions_and_groups is not None: + parameters['audit_actions_and_groups'] = audit_actions_and_groups + if storage_account_subscription_id is not None: + parameters['storage_account_subscription_id'] = storage_account_subscription_id + if is_storage_secondary_key_in_use is not None: + parameters['is_storage_secondary_key_in_use'] = is_storage_secondary_key_in_use + if is_azure_monitor_target_enabled is not None: + parameters['is_azure_monitor_target_enabled'] = is_azure_monitor_target_enabled return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -543,10 +590,14 @@ def synapse_sql_pool_sensitivity_label_create(client, information_type=None, information_type_id=None): parameters = {} - parameters['label_name'] = label_name - parameters['label_id'] = label_id - parameters['information_type'] = information_type - parameters['information_type_id'] = information_type_id + if label_name is not None: + parameters['label_name'] = label_name + if label_id is not None: + parameters['label_id'] = label_id + if information_type is not None: + parameters['information_type'] = information_type + if information_type_id is not None: + parameters['information_type_id'] = information_type_id return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -568,10 +619,14 @@ def synapse_sql_pool_sensitivity_label_update(client, information_type=None, information_type_id=None): parameters = {} - parameters['label_name'] = label_name - parameters['label_id'] = label_id - parameters['information_type'] = information_type - parameters['information_type_id'] = information_type_id + if label_name is not None: + parameters['label_name'] = label_name + if label_id is not None: + parameters['label_id'] = label_id + if information_type is not None: + parameters['information_type'] = information_type + if information_type_id is not None: + parameters['information_type_id'] = information_type_id return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -729,10 +784,14 @@ def synapse_sql_pool_vulnerability_assessment_create(client, storage_account_access_key=None, recurring_scans=None): parameters = {} - parameters['storage_container_path'] = storage_container_path - parameters['storage_container_sas_key'] = storage_container_sas_key - parameters['storage_account_access_key'] = storage_account_access_key - parameters['recurring_scans'] = recurring_scans + if storage_container_path is not None: + parameters['storage_container_path'] = storage_container_path + if storage_container_sas_key is not None: + parameters['storage_container_sas_key'] = storage_container_sas_key + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if recurring_scans is not None: + parameters['recurring_scans'] = recurring_scans return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -825,13 +884,20 @@ def synapse_sql_pool_security_alert_policy_create(client, storage_account_access_key=None, retention_days=None): parameters = {} - parameters['state'] = state - parameters['disabled_alerts'] = disabled_alerts - parameters['email_addresses'] = email_addresses - parameters['email_account_admins'] = email_account_admins - parameters['storage_endpoint'] = storage_endpoint - parameters['storage_account_access_key'] = storage_account_access_key - parameters['retention_days'] = retention_days + if state is not None: + parameters['state'] = state + if disabled_alerts is not None: + parameters['disabled_alerts'] = disabled_alerts + if email_addresses is not None: + parameters['email_addresses'] = email_addresses + if email_account_admins is not None: + parameters['email_account_admins'] = email_account_admins + if storage_endpoint is not None: + parameters['storage_endpoint'] = storage_endpoint + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if retention_days is not None: + parameters['retention_days'] = retention_days return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -875,7 +941,8 @@ def synapse_sql_pool_vulnerability_assessment_rule_baseline_create(client, baseline_name, baseline_results=None): parameters = {} - parameters['baseline_results'] = baseline_results + if baseline_results is not None: + parameters['baseline_results'] = baseline_results return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -893,7 +960,8 @@ def synapse_sql_pool_vulnerability_assessment_rule_baseline_update(client, baseline_name, baseline_results=None): parameters = {} - parameters['baseline_results'] = baseline_results + if baseline_results is not None: + parameters['baseline_results'] = baseline_results return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -947,19 +1015,33 @@ def synapse_workspace_create(client, type_=None, no_wait=False): workspace_info = {} - workspace_info['tags'] = tags + if tags is not None: + workspace_info['tags'] = tags workspace_info['location'] = location - workspace_info['default_data_lake_storage'] = default_data_lake_storage - workspace_info['sql_administrator_login_password'] = sql_administrator_login_password - workspace_info['managed_resource_group_name'] = managed_resource_group_name - workspace_info['sql_administrator_login'] = sql_administrator_login - workspace_info['connectivity_endpoints'] = connectivity_endpoints - workspace_info['managed_virtual_network'] = managed_virtual_network - workspace_info['private_endpoint_connections'] = private_endpoint_connections + if default_data_lake_storage is not None: + workspace_info['default_data_lake_storage'] = default_data_lake_storage + if sql_administrator_login_password is not None: + workspace_info['sql_administrator_login_password'] = sql_administrator_login_password + if managed_resource_group_name is not None: + workspace_info['managed_resource_group_name'] = managed_resource_group_name + if sql_administrator_login is not None: + workspace_info['sql_administrator_login'] = sql_administrator_login + if connectivity_endpoints is not None: + workspace_info['connectivity_endpoints'] = connectivity_endpoints + if managed_virtual_network is not None: + workspace_info['managed_virtual_network'] = managed_virtual_network + if private_endpoint_connections is not None: + workspace_info['private_endpoint_connections'] = private_endpoint_connections workspace_info['virtual_network_profile'] = {} - workspace_info['virtual_network_profile']['compute_subnet_id'] = compute_subnet_id + if compute_subnet_id is not None: + workspace_info['virtual_network_profile']['compute_subnet_id'] = compute_subnet_id + if len(workspace_info['virtual_network_profile']) == 0: + del workspace_info['virtual_network_profile'] workspace_info['identity'] = {} - workspace_info['identity']['type'] = type_ + if type_ is not None: + workspace_info['identity']['type'] = type_ + if len(workspace_info['identity']) == 0: + del workspace_info['identity'] return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -975,10 +1057,15 @@ def synapse_workspace_update(client, type_=None, no_wait=False): workspace_patch_info = {} - workspace_patch_info['tags'] = tags - workspace_patch_info['sql_administrator_login_password'] = sql_administrator_login_password + if tags is not None: + workspace_patch_info['tags'] = tags + if sql_administrator_login_password is not None: + workspace_patch_info['sql_administrator_login_password'] = sql_administrator_login_password workspace_patch_info['identity'] = {} - workspace_patch_info['identity']['type'] = type_ + if type_ is not None: + workspace_patch_info['identity']['type'] = type_ + if len(workspace_patch_info['identity']) == 0: + del workspace_patch_info['identity'] return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -1012,10 +1099,14 @@ def synapse_workspace_aad_admin_create(client, sid=None, no_wait=False): aad_admin_info = {} - aad_admin_info['tenant_id'] = tenant_id - aad_admin_info['login'] = login - aad_admin_info['administrator_type'] = administrator_type - aad_admin_info['sid'] = sid + if tenant_id is not None: + aad_admin_info['tenant_id'] = tenant_id + if login is not None: + aad_admin_info['login'] = login + if administrator_type is not None: + aad_admin_info['administrator_type'] = administrator_type + if sid is not None: + aad_admin_info['sid'] = sid return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -1065,7 +1156,10 @@ def synapse_workspace_managed_identity_sql_control_setting_create(client, desired_state=None): managed_identity_sql_control_settings = {} managed_identity_sql_control_settings['grant_sql_control_to_managed_identity'] = {} - managed_identity_sql_control_settings['grant_sql_control_to_managed_identity']['desired_state'] = desired_state + if desired_state is not None: + managed_identity_sql_control_settings['grant_sql_control_to_managed_identity']['desired_state'] = desired_state + if len(managed_identity_sql_control_settings['grant_sql_control_to_managed_identity']) == 0: + del managed_identity_sql_control_settings['grant_sql_control_to_managed_identity'] return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, managed_identity_sql_control_settings=managed_identity_sql_control_settings) @@ -1123,8 +1217,10 @@ def synapse_integration_runtime_update(client, auto_update=None, update_delay_offset=None): update_integration_runtime_request = {} - update_integration_runtime_request['auto_update'] = auto_update - update_integration_runtime_request['update_delay_offset'] = update_delay_offset + if auto_update is not None: + update_integration_runtime_request['auto_update'] = auto_update + if update_delay_offset is not None: + update_integration_runtime_request['update_delay_offset'] = update_delay_offset return client.update(resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1187,7 +1283,8 @@ def synapse_integration_runtime_object_metadata_get(client, integration_runtime_name, metadata_path=None): get_metadata_request = {} - get_metadata_request['metadata_path'] = metadata_path + if metadata_path is not None: + get_metadata_request['metadata_path'] = metadata_path return client.get(resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1221,7 +1318,8 @@ def synapse_integration_runtime_node_update(client, node_name, concurrent_jobs_limit=None): update_integration_runtime_node_request = {} - update_integration_runtime_node_request['concurrent_jobs_limit'] = concurrent_jobs_limit + if concurrent_jobs_limit is not None: + update_integration_runtime_node_request['concurrent_jobs_limit'] = concurrent_jobs_limit return client.update(resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1273,7 +1371,8 @@ def synapse_integration_runtime_auth_key_regenerate(client, integration_runtime_name, key_name=None): regenerate_key_parameters = {} - regenerate_key_parameters['key_name'] = key_name + if key_name is not None: + regenerate_key_parameters['key_name'] = key_name return client.regenerate(resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1374,7 +1473,8 @@ def synapse_private_link_hub_create(client, location, tags=None): private_link_hub_info = {} - private_link_hub_info['tags'] = tags + if tags is not None: + private_link_hub_info['tags'] = tags private_link_hub_info['location'] = location return client.create_or_update(resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, @@ -1386,7 +1486,8 @@ def synapse_private_link_hub_update(client, private_link_hub_name, tags=None): private_link_hub_patch_info = {} - private_link_hub_patch_info['tags'] = tags + if tags is not None: + private_link_hub_patch_info['tags'] = tags return client.update(resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, private_link_hub_patch_info=private_link_hub_patch_info) diff --git a/test/scenarios/synapse/output/extflatten/src/synapse/azext_synapse/generated/custom.py b/test/scenarios/synapse/output/extflatten/src/synapse/azext_synapse/generated/custom.py index 58f04e4fa..8529cbce1 100644 --- a/test/scenarios/synapse/output/extflatten/src/synapse/azext_synapse/generated/custom.py +++ b/test/scenarios/synapse/output/extflatten/src/synapse/azext_synapse/generated/custom.py @@ -47,14 +47,12 @@ def synapse_big_data_pool_create(client, node_size=None, node_size_family=None, no_wait=False): - if force is None: - force = False return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, - force=force, + force=False if force is None else force, tags=tags, location=location, provisioning_state=provisioning_state, diff --git a/test/scenarios/synapse/output/extnosdknoflattentrack1/src/synapse/azext_synapse/generated/custom.py b/test/scenarios/synapse/output/extnosdknoflattentrack1/src/synapse/azext_synapse/generated/custom.py index 4af2a1142..24bdb2458 100644 --- a/test/scenarios/synapse/output/extnosdknoflattentrack1/src/synapse/azext_synapse/generated/custom.py +++ b/test/scenarios/synapse/output/extnosdknoflattentrack1/src/synapse/azext_synapse/generated/custom.py @@ -48,28 +48,38 @@ def synapse_big_data_pool_create(client, node_size=None, node_size_family=None, no_wait=False): - if force is None: - force = False big_data_pool_info = {} - big_data_pool_info['tags'] = tags + if tags is not None: + big_data_pool_info['tags'] = tags big_data_pool_info['location'] = location - big_data_pool_info['provisioning_state'] = provisioning_state - big_data_pool_info['auto_scale'] = auto_scale - big_data_pool_info['creation_date'] = creation_date - big_data_pool_info['auto_pause'] = auto_pause - big_data_pool_info['spark_events_folder'] = spark_events_folder - big_data_pool_info['node_count'] = node_count - big_data_pool_info['library_requirements'] = library_requirements - big_data_pool_info['spark_version'] = spark_version - big_data_pool_info['default_spark_log_folder'] = default_spark_log_folder - big_data_pool_info['node_size'] = node_size - big_data_pool_info['node_size_family'] = node_size_family + if provisioning_state is not None: + big_data_pool_info['provisioning_state'] = provisioning_state + if auto_scale is not None: + big_data_pool_info['auto_scale'] = auto_scale + if creation_date is not None: + big_data_pool_info['creation_date'] = creation_date + if auto_pause is not None: + big_data_pool_info['auto_pause'] = auto_pause + if spark_events_folder is not None: + big_data_pool_info['spark_events_folder'] = spark_events_folder + if node_count is not None: + big_data_pool_info['node_count'] = node_count + if library_requirements is not None: + big_data_pool_info['library_requirements'] = library_requirements + if spark_version is not None: + big_data_pool_info['spark_version'] = spark_version + if default_spark_log_folder is not None: + big_data_pool_info['default_spark_log_folder'] = default_spark_log_folder + if node_size is not None: + big_data_pool_info['node_size'] = node_size + if node_size_family is not None: + big_data_pool_info['node_size_family'] = node_size_family return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, - force=force, + force=False if force is None else force, big_data_pool_info=big_data_pool_info) @@ -220,18 +230,29 @@ def synapse_sql_pool_create(client, creation_date=None, no_wait=False): sql_pool_info = {} - sql_pool_info['tags'] = tags + if tags is not None: + sql_pool_info['tags'] = tags sql_pool_info['location'] = location - sql_pool_info['sku'] = sku - sql_pool_info['max_size_bytes'] = max_size_bytes - sql_pool_info['collation'] = collation - sql_pool_info['source_database_id'] = source_database_id - sql_pool_info['recoverable_database_id'] = recoverable_database_id - sql_pool_info['provisioning_state'] = provisioning_state - sql_pool_info['status'] = status - sql_pool_info['restore_point_in_time'] = restore_point_in_time - sql_pool_info['create_mode'] = create_mode - sql_pool_info['creation_date'] = creation_date + if sku is not None: + sql_pool_info['sku'] = sku + if max_size_bytes is not None: + sql_pool_info['max_size_bytes'] = max_size_bytes + if collation is not None: + sql_pool_info['collation'] = collation + if source_database_id is not None: + sql_pool_info['source_database_id'] = source_database_id + if recoverable_database_id is not None: + sql_pool_info['recoverable_database_id'] = recoverable_database_id + if provisioning_state is not None: + sql_pool_info['provisioning_state'] = provisioning_state + if status is not None: + sql_pool_info['status'] = status + if restore_point_in_time is not None: + sql_pool_info['restore_point_in_time'] = restore_point_in_time + if create_mode is not None: + sql_pool_info['create_mode'] = create_mode + if creation_date is not None: + sql_pool_info['creation_date'] = creation_date return sdk_no_wait(no_wait, client.create, resource_group_name=resource_group_name, @@ -257,18 +278,30 @@ def synapse_sql_pool_update(client, create_mode=None, creation_date=None): sql_pool_info = {} - sql_pool_info['tags'] = tags - sql_pool_info['location'] = location - sql_pool_info['sku'] = sku - sql_pool_info['max_size_bytes'] = max_size_bytes - sql_pool_info['collation'] = collation - sql_pool_info['source_database_id'] = source_database_id - sql_pool_info['recoverable_database_id'] = recoverable_database_id - sql_pool_info['provisioning_state'] = provisioning_state - sql_pool_info['status'] = status - sql_pool_info['restore_point_in_time'] = restore_point_in_time - sql_pool_info['create_mode'] = create_mode - sql_pool_info['creation_date'] = creation_date + if tags is not None: + sql_pool_info['tags'] = tags + if location is not None: + sql_pool_info['location'] = location + if sku is not None: + sql_pool_info['sku'] = sku + if max_size_bytes is not None: + sql_pool_info['max_size_bytes'] = max_size_bytes + if collation is not None: + sql_pool_info['collation'] = collation + if source_database_id is not None: + sql_pool_info['source_database_id'] = source_database_id + if recoverable_database_id is not None: + sql_pool_info['recoverable_database_id'] = recoverable_database_id + if provisioning_state is not None: + sql_pool_info['provisioning_state'] = provisioning_state + if status is not None: + sql_pool_info['status'] = status + if restore_point_in_time is not None: + sql_pool_info['restore_point_in_time'] = restore_point_in_time + if create_mode is not None: + sql_pool_info['create_mode'] = create_mode + if creation_date is not None: + sql_pool_info['creation_date'] = creation_date return client.update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -458,14 +491,22 @@ def synapse_sql_pool_blob_auditing_policy_create(client, is_storage_secondary_key_in_use=None, is_azure_monitor_target_enabled=None): parameters = {} - parameters['state'] = state - parameters['storage_endpoint'] = storage_endpoint - parameters['storage_account_access_key'] = storage_account_access_key - parameters['retention_days'] = retention_days - parameters['audit_actions_and_groups'] = audit_actions_and_groups - parameters['storage_account_subscription_id'] = storage_account_subscription_id - parameters['is_storage_secondary_key_in_use'] = is_storage_secondary_key_in_use - parameters['is_azure_monitor_target_enabled'] = is_azure_monitor_target_enabled + if state is not None: + parameters['state'] = state + if storage_endpoint is not None: + parameters['storage_endpoint'] = storage_endpoint + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if retention_days is not None: + parameters['retention_days'] = retention_days + if audit_actions_and_groups is not None: + parameters['audit_actions_and_groups'] = audit_actions_and_groups + if storage_account_subscription_id is not None: + parameters['storage_account_subscription_id'] = storage_account_subscription_id + if is_storage_secondary_key_in_use is not None: + parameters['is_storage_secondary_key_in_use'] = is_storage_secondary_key_in_use + if is_azure_monitor_target_enabled is not None: + parameters['is_azure_monitor_target_enabled'] = is_azure_monitor_target_enabled return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -533,10 +574,14 @@ def synapse_sql_pool_sensitivity_label_create(client, information_type=None, information_type_id=None): parameters = {} - parameters['label_name'] = label_name - parameters['label_id'] = label_id - parameters['information_type'] = information_type - parameters['information_type_id'] = information_type_id + if label_name is not None: + parameters['label_name'] = label_name + if label_id is not None: + parameters['label_id'] = label_id + if information_type is not None: + parameters['information_type'] = information_type + if information_type_id is not None: + parameters['information_type_id'] = information_type_id return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -558,10 +603,14 @@ def synapse_sql_pool_sensitivity_label_update(client, information_type=None, information_type_id=None): parameters = {} - parameters['label_name'] = label_name - parameters['label_id'] = label_id - parameters['information_type'] = information_type - parameters['information_type_id'] = information_type_id + if label_name is not None: + parameters['label_name'] = label_name + if label_id is not None: + parameters['label_id'] = label_id + if information_type is not None: + parameters['information_type'] = information_type + if information_type_id is not None: + parameters['information_type_id'] = information_type_id return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -719,10 +768,14 @@ def synapse_sql_pool_vulnerability_assessment_create(client, storage_account_access_key=None, recurring_scans=None): parameters = {} - parameters['storage_container_path'] = storage_container_path - parameters['storage_container_sas_key'] = storage_container_sas_key - parameters['storage_account_access_key'] = storage_account_access_key - parameters['recurring_scans'] = recurring_scans + if storage_container_path is not None: + parameters['storage_container_path'] = storage_container_path + if storage_container_sas_key is not None: + parameters['storage_container_sas_key'] = storage_container_sas_key + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if recurring_scans is not None: + parameters['recurring_scans'] = recurring_scans return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -815,13 +868,20 @@ def synapse_sql_pool_security_alert_policy_create(client, storage_account_access_key=None, retention_days=None): parameters = {} - parameters['state'] = state - parameters['disabled_alerts'] = disabled_alerts - parameters['email_addresses'] = email_addresses - parameters['email_account_admins'] = email_account_admins - parameters['storage_endpoint'] = storage_endpoint - parameters['storage_account_access_key'] = storage_account_access_key - parameters['retention_days'] = retention_days + if state is not None: + parameters['state'] = state + if disabled_alerts is not None: + parameters['disabled_alerts'] = disabled_alerts + if email_addresses is not None: + parameters['email_addresses'] = email_addresses + if email_account_admins is not None: + parameters['email_account_admins'] = email_account_admins + if storage_endpoint is not None: + parameters['storage_endpoint'] = storage_endpoint + if storage_account_access_key is not None: + parameters['storage_account_access_key'] = storage_account_access_key + if retention_days is not None: + parameters['retention_days'] = retention_days return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -933,19 +993,33 @@ def synapse_workspace_create(client, type_=None, no_wait=False): workspace_info = {} - workspace_info['tags'] = tags + if tags is not None: + workspace_info['tags'] = tags workspace_info['location'] = location - workspace_info['default_data_lake_storage'] = default_data_lake_storage - workspace_info['sql_administrator_login_password'] = sql_administrator_login_password - workspace_info['managed_resource_group_name'] = managed_resource_group_name - workspace_info['sql_administrator_login'] = sql_administrator_login - workspace_info['connectivity_endpoints'] = connectivity_endpoints - workspace_info['managed_virtual_network'] = managed_virtual_network - workspace_info['private_endpoint_connections'] = private_endpoint_connections + if default_data_lake_storage is not None: + workspace_info['default_data_lake_storage'] = default_data_lake_storage + if sql_administrator_login_password is not None: + workspace_info['sql_administrator_login_password'] = sql_administrator_login_password + if managed_resource_group_name is not None: + workspace_info['managed_resource_group_name'] = managed_resource_group_name + if sql_administrator_login is not None: + workspace_info['sql_administrator_login'] = sql_administrator_login + if connectivity_endpoints is not None: + workspace_info['connectivity_endpoints'] = connectivity_endpoints + if managed_virtual_network is not None: + workspace_info['managed_virtual_network'] = managed_virtual_network + if private_endpoint_connections is not None: + workspace_info['private_endpoint_connections'] = private_endpoint_connections workspace_info['virtual_network_profile'] = {} - workspace_info['virtual_network_profile']['compute_subnet_id'] = compute_subnet_id + if compute_subnet_id is not None: + workspace_info['virtual_network_profile']['compute_subnet_id'] = compute_subnet_id + if len(workspace_info['virtual_network_profile']) == 0: + del workspace_info['virtual_network_profile'] workspace_info['identity'] = {} - workspace_info['identity']['type'] = type_ + if type_ is not None: + workspace_info['identity']['type'] = type_ + if len(workspace_info['identity']) == 0: + del workspace_info['identity'] return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -961,10 +1035,15 @@ def synapse_workspace_update(client, type_=None, no_wait=False): workspace_patch_info = {} - workspace_patch_info['tags'] = tags - workspace_patch_info['sql_administrator_login_password'] = sql_administrator_login_password + if tags is not None: + workspace_patch_info['tags'] = tags + if sql_administrator_login_password is not None: + workspace_patch_info['sql_administrator_login_password'] = sql_administrator_login_password workspace_patch_info['identity'] = {} - workspace_patch_info['identity']['type'] = type_ + if type_ is not None: + workspace_patch_info['identity']['type'] = type_ + if len(workspace_patch_info['identity']) == 0: + del workspace_patch_info['identity'] return sdk_no_wait(no_wait, client.update, resource_group_name=resource_group_name, @@ -998,10 +1077,14 @@ def synapse_workspace_aad_admin_create(client, sid=None, no_wait=False): aad_admin_info = {} - aad_admin_info['tenant_id'] = tenant_id - aad_admin_info['login'] = login - aad_admin_info['administrator_type'] = administrator_type - aad_admin_info['sid'] = sid + if tenant_id is not None: + aad_admin_info['tenant_id'] = tenant_id + if login is not None: + aad_admin_info['login'] = login + if administrator_type is not None: + aad_admin_info['administrator_type'] = administrator_type + if sid is not None: + aad_admin_info['sid'] = sid return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, @@ -1050,7 +1133,8 @@ def synapse_workspace_managed_identity_sql_control_setting_create(client, workspace_name, desired_state=None): grant_sql_control_to_managed_identity = {} - grant_sql_control_to_managed_identity['desired_state'] = desired_state + if desired_state is not None: + grant_sql_control_to_managed_identity['desired_state'] = desired_state return client.create_or_update(resource_group_name=resource_group_name, workspace_name=workspace_name, grant_sql_control_to_managed_identity=grant_sql_control_to_managed_identity)