From a5940d9b1050ee56082e1daee0326f416c3e3f0e Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 14:53:54 +0800 Subject: [PATCH 01/44] add buildpacks binding in commands.py --- src/spring-cloud/azext_spring_cloud/commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/spring-cloud/azext_spring_cloud/commands.py b/src/spring-cloud/azext_spring_cloud/commands.py index db5bc5bdb78..33e244bd3d1 100644 --- a/src/spring-cloud/azext_spring_cloud/commands.py +++ b/src/spring-cloud/azext_spring_cloud/commands.py @@ -42,6 +42,11 @@ def load_command_table(self, _): client_factory=cf_spring_cloud_enterprise ) + buildpacks_binding_cmd_group = CliCommandType( + operations_tmpl="azext_spring_cloud.buildpacks_binding#{}", + client_factory=cf_spring_cloud_enterprise + ) + with self.command_group('spring-cloud', client_factory=cf_app_services, exception_handler=handle_asc_exception) as g: g.custom_command('create', 'spring_cloud_create', supports_no_wait=True, client_factory=cf_spring_cloud) @@ -171,5 +176,13 @@ def load_command_table(self, _): g.custom_command('remove', 'application_configuration_service_git_remove') g.custom_command('list', 'application_configuration_service_git_list') + with self.command_group('spring-cloud build-service buildpacks-binding', + custom_command_type=buildpacks_binding_cmd_group, + exception_handler=handle_asc_exception) as g: + g.custom_command('create', 'buildpacks_binding_create') + g.custom_command('set', 'buildpacks_binding_set') + g.custom_command('show', 'buildpacks_binding_show') + g.custom_command('delete', 'buildpacks_binding_delete') + with self.command_group('spring-cloud', exception_handler=handle_asc_exception): pass From 4ca0af267b6de4031ce7e9cbaa03bb8d950066a6 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 15:17:42 +0800 Subject: [PATCH 02/44] add buildpacks binding type enum --- src/spring-cloud/azext_spring_cloud/_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/spring-cloud/azext_spring_cloud/_utils.py b/src/spring-cloud/azext_spring_cloud/_utils.py index dc337b454e8..464daccade1 100644 --- a/src/spring-cloud/azext_spring_cloud/_utils.py +++ b/src/spring-cloud/azext_spring_cloud/_utils.py @@ -242,3 +242,10 @@ def handle_asc_exception(ex): raise CLIError(response_dict["error"]["message"]) else: raise CLIError(ex) + + +class BuildpacksBindingType(Enum): + """Type of Buildpacks Binding + """ + + APPLICATION_INSIGHTS = 'ApplicationInsights' From a177b6105029ae402ebd39323d16d12787da1b93 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 15:42:47 +0800 Subject: [PATCH 03/44] add buildpacks binding parameter helps --- src/spring-cloud/azext_spring_cloud/_params.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index dbde10e4e04..284d479d6d3 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -14,7 +14,7 @@ validate_tracing_parameters, validate_app_insights_parameters, validate_java_agent_parameters, validate_instance_count) from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory) -from ._utils import ApiType +from ._utils import ApiType, BuildpacksBindingType from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType @@ -315,3 +315,18 @@ def prepare_logs_argument(c): 'spring-cloud application-configuration-service git repo remove']: with self.argument_context(scope) as c: c.argument('name', help="Required unique name to label each item of git configs.") + + for scope in ['spring-cloud build-service buildpacks-binding create', + 'spring-cloud build-service buildpacks-binding set']: + with self.argument_context(scope) as c: + c.argument('name', help='Required name for buildpacks binding.'), + c.argument('type', arg_type=get_enum_type(BuildpacksBindingType), help='Required type for buildpacks binding.') + c.argument('properties', help='Non-sensitive properties for launchProperties. ' + + 'Sample \"key1=val1 key2=val2\"') + c.argument('secrets', help='Sensitive properties for launchProperties. ' + + 'Once put,it will be encrypted and never return to user. Sample \"sec1=val1 sec2=val2\"') + + for scope in ['az spring-cloud build-service buildpacks-binding show', + 'az spring-cloud build-service buildpacks-binding delete']: + with self.argument_context(scope) as c: + c.argument('name', help='Reqired name for buildpacks binding.') \ No newline at end of file From 380b9d76196c632c9dd5dc81c59b402824827cda Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 16:10:22 +0800 Subject: [PATCH 04/44] add buildpacks binding command helps --- src/spring-cloud/azext_spring_cloud/_help.py | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/spring-cloud/azext_spring_cloud/_help.py b/src/spring-cloud/azext_spring_cloud/_help.py index 03711b986ae..6d6f2182ac2 100644 --- a/src/spring-cloud/azext_spring_cloud/_help.py +++ b/src/spring-cloud/azext_spring_cloud/_help.py @@ -542,3 +542,41 @@ - name: Unbind an app to Application Configuration Service. text: az spring-cloud application-configuration-service unbind --app MyApp -s MyService -g MyResourceGroup """ + +helps['spring-cloud build-service buildpacks-binding create'] = """ + type: command + short-summary: Create a buildpacks binding. + examples: + - name: Create a buildpacks binding without properties or secrets. + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights + - name: Create a buildpacks binding with only secrets. + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --secrets "k1=v1 k2=v2" + - name: Create a buildpacks binding with only properties. + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --properties "a=b c=d" + - name: Create a buildpacks binding with properties and secrets. + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --properties "a=b c=d" --secrets "k1=v1 k2=v2" +""" + +helps['spring-cloud build-service buildpacks-binding set'] = """ + type: command + short-summary: Set a buildpacks binding. + examples: + - name: Set a buildpacks binding with properties and secrets. + text: az spring-cloud build-service buildpacks-binding set --name first-binding --type ApplicationInsights --properties "a=b c=d" --secrets "k1=v1 k2=v2" +""" + +helps['spring-cloud build-service buildpacks-binding show'] = """ + type: command + short-summary: Show a buildpacks binding, the secrets will be masked. + examples: + - name: Show a buildpacks binding. + text: az spring-cloud build-service buildpacks-binding show --name first-binding +""" + +helps['spring-cloud build-service buildpacks-binding delete'] = """ + type: command + short-summary: Delete a buildpacks binding. + examples: + - name: Delete a buildpacks binding. + text: az spring-cloud build-service buildpacks-binding delete --name first-binding +""" From 8b40ba8be3497e7ad2a164b78015b2512903b944 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 16:51:05 +0800 Subject: [PATCH 05/44] enhance parameter definition --- src/spring-cloud/azext_spring_cloud/_params.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 284d479d6d3..73e288ad3b6 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -319,14 +319,13 @@ def prepare_logs_argument(c): for scope in ['spring-cloud build-service buildpacks-binding create', 'spring-cloud build-service buildpacks-binding set']: with self.argument_context(scope) as c: - c.argument('name', help='Required name for buildpacks binding.'), c.argument('type', arg_type=get_enum_type(BuildpacksBindingType), help='Required type for buildpacks binding.') - c.argument('properties', help='Non-sensitive properties for launchProperties. ' + - 'Sample \"key1=val1 key2=val2\"') - c.argument('secrets', help='Sensitive properties for launchProperties. ' + - 'Once put,it will be encrypted and never return to user. Sample \"sec1=val1 sec2=val2\"') + c.argument('properties', help='Non-sensitive properties for launchProperties. Sample "key1=val1 key2=val2"') + c.argument('secrets', help='Sensitive properties for launchProperties. Once put,it will be encrypted and never return to user. Sample "sec1=val1 sec2=val2"') - for scope in ['az spring-cloud build-service buildpacks-binding show', - 'az spring-cloud build-service buildpacks-binding delete']: + for scope in ['spring-cloud build-service buildpacks-binding create', + 'spring-cloud build-service buildpacks-binding set', + 'spring-cloud build-service buildpacks-binding show', + 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: c.argument('name', help='Reqired name for buildpacks binding.') \ No newline at end of file From 9e7f9a6056ffd26851c91dc1a83eadd3d1a4b2ac Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 16:53:01 +0800 Subject: [PATCH 06/44] add stubs for create/set/show/delete parameters --- .../azext_spring_cloud/buildpacks_binding.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/spring-cloud/azext_spring_cloud/buildpacks_binding.py diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py new file mode 100644 index 00000000000..36d60feb9e6 --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -0,0 +1,11 @@ +def buildpacks_binding_set(cmd, client, service, resource_group): + pass + +def buildpacks_binding_create(cmd, client, service, resource_group): + pass + +def buildpacks_binding_show(cmd, client, service, resource_group): + pass + +def buildpacks_binding_delete(cmd, client, service, resource_group): + pass \ No newline at end of file From c449e3e4397c84574688125b0c16d74c95abed0e Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 17:26:48 +0800 Subject: [PATCH 07/44] add buildpacks binding name validator --- src/spring-cloud/azext_spring_cloud/_params.py | 4 ++-- .../_validators_enterprise.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 73e288ad3b6..6576e1a5a0b 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -13,7 +13,7 @@ validate_vnet, validate_vnet_required_parameters, validate_node_resource_group, validate_tracing_parameters, validate_app_insights_parameters, validate_java_agent_parameters, validate_instance_count) -from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory) +from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_name) from ._utils import ApiType, BuildpacksBindingType from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType @@ -328,4 +328,4 @@ def prepare_logs_argument(c): 'spring-cloud build-service buildpacks-binding show', 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: - c.argument('name', help='Reqired name for buildpacks binding.') \ No newline at end of file + c.argument('name', help='Reqired name for buildpacks binding.', validator=validate_buildpacks_binding_name) \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 87ba5e85f13..7cc40d4e647 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -7,6 +7,7 @@ from re import match from azure.cli.core.util import CLIError +from azure.cli.core.azclierror import InvalidArgumentValueError from knack.log import get_logger from ._resource_quantity import ( validate_cpu as validate_and_normalize_cpu, @@ -15,6 +16,8 @@ is_enterprise_tier ) +BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"^[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]$" +BUILDPACKS_BINDING_NAME_MAX_LENGTH=19 logger = get_logger(__name__) @@ -61,3 +64,17 @@ def _is_valid_profile_name(profile): def _is_valid_app_and_profile_name(pattern): parts = pattern.split('/') return len(parts) == 2 and _is_valid_app_name(parts[0]) and _is_valid_profile_name(parts[1]) + +def validate_buildpacks_binding_name(namespace): + if not _is_valid_buildpacks_binding_name_pattern(namespace.name): + raise InvalidArgumentValueError("Buildpacks Binding name should follow pattern {}".format( + BUILDPACKS_BINDING_NAME_REGEX_PATTTERN)) + if not _is_valid_buildpacks_binding_name_length(namespace.name): + raise InvalidArgumentValueError("Buildpacks Binding name character number should not exceed {}".format( + BUILDPACKS_BINDING_NAME_MAX_LENGTH)) + +def _is_valid_buildpacks_binding_name_pattern(name): + return match(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN, name) is not None + +def _is_valid_buildpacks_binding_name_length(name): + return len(name) <= BUILDPACKS_BINDING_NAME_MAX_LENGTH From cb223f6546eda6b5012d1be12f3d4a5787ef0e7d Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 17:46:33 +0800 Subject: [PATCH 08/44] add parameter to sub command stud --- .../azext_spring_cloud/buildpacks_binding.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 36d60feb9e6..7ed96e60fd7 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -1,11 +1,13 @@ -def buildpacks_binding_set(cmd, client, service, resource_group): +def buildpacks_binding_create(cmd, client, service, resource_group, + name, type, properties=None, secrets=None): pass -def buildpacks_binding_create(cmd, client, service, resource_group): +def buildpacks_binding_set(cmd, client, service, resource_group, + name, type, properties=None, secrets=None): pass -def buildpacks_binding_show(cmd, client, service, resource_group): +def buildpacks_binding_show(cmd, client, service, resource_group, name): pass -def buildpacks_binding_delete(cmd, client, service, resource_group): +def buildpacks_binding_delete(cmd, client, service, resource_group, name): pass \ No newline at end of file From 21f615e9d698bbc50d7c2e9ef27f1dbe34c574de Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 17:54:51 +0800 Subject: [PATCH 09/44] fix for buildpacks binding name regex string --- src/spring-cloud/azext_spring_cloud/_validators_enterprise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 7cc40d4e647..234b78bb7a2 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -16,7 +16,7 @@ is_enterprise_tier ) -BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"^[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]$" +BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]$)" BUILDPACKS_BINDING_NAME_MAX_LENGTH=19 logger = get_logger(__name__) From 653ea95a8aecde11ddaa0386429959b8f912a0c8 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 18:09:45 +0800 Subject: [PATCH 10/44] add empty lines --- src/spring-cloud/azext_spring_cloud/_validators_enterprise.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 234b78bb7a2..d7909e49826 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -65,6 +65,7 @@ def _is_valid_app_and_profile_name(pattern): parts = pattern.split('/') return len(parts) == 2 and _is_valid_app_name(parts[0]) and _is_valid_profile_name(parts[1]) + def validate_buildpacks_binding_name(namespace): if not _is_valid_buildpacks_binding_name_pattern(namespace.name): raise InvalidArgumentValueError("Buildpacks Binding name should follow pattern {}".format( @@ -73,8 +74,10 @@ def validate_buildpacks_binding_name(namespace): raise InvalidArgumentValueError("Buildpacks Binding name character number should not exceed {}".format( BUILDPACKS_BINDING_NAME_MAX_LENGTH)) + def _is_valid_buildpacks_binding_name_pattern(name): return match(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN, name) is not None + def _is_valid_buildpacks_binding_name_length(name): return len(name) <= BUILDPACKS_BINDING_NAME_MAX_LENGTH From 21dba447389615d3c2876851ba05092bd9268cf1 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 18:47:38 +0800 Subject: [PATCH 11/44] add properties and secrets validator --- .../azext_spring_cloud/_params.py | 12 ++++-- .../_validators_enterprise.py | 38 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 6576e1a5a0b..a805a399658 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -13,7 +13,9 @@ validate_vnet, validate_vnet_required_parameters, validate_node_resource_group, validate_tracing_parameters, validate_app_insights_parameters, validate_java_agent_parameters, validate_instance_count) -from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_name) +from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, + validate_buildpacks_binding_name, validate_buildpacks_binding_properties, + validate_buildpacks_binding_secrets) from ._utils import ApiType, BuildpacksBindingType from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType @@ -320,8 +322,12 @@ def prepare_logs_argument(c): 'spring-cloud build-service buildpacks-binding set']: with self.argument_context(scope) as c: c.argument('type', arg_type=get_enum_type(BuildpacksBindingType), help='Required type for buildpacks binding.') - c.argument('properties', help='Non-sensitive properties for launchProperties. Sample "key1=val1 key2=val2"') - c.argument('secrets', help='Sensitive properties for launchProperties. Once put,it will be encrypted and never return to user. Sample "sec1=val1 sec2=val2"') + c.argument('properties', + help='Non-sensitive properties for launchProperties. Sample "key1=val1 key2=val2"', + validator=validate_buildpacks_binding_properties) + c.argument('secrets', + help='Sensitive properties for launchProperties. Once put,it will be encrypted and never return to user. Sample "sec1=val1 sec2=val2"', + validator=validate_buildpacks_binding_secrets) for scope in ['spring-cloud build-service buildpacks-binding create', 'spring-cloud build-service buildpacks-binding set', diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index d7909e49826..6a19e3c3fa2 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -81,3 +81,41 @@ def _is_valid_buildpacks_binding_name_pattern(name): def _is_valid_buildpacks_binding_name_length(name): return len(name) <= BUILDPACKS_BINDING_NAME_MAX_LENGTH + + +def validate_buildpacks_binding_properties(namespace): + if namespace.properties is not None: + key_value_pairs = namespace.properties.split(' ') + keys = set() + for pair in key_value_pairs: + if not _is_valid_pair(pair): + raise InvalidArgumentValueError( + 'Invalid pair "{}" Each pair of Buildpacks Binding properties should follow format key=value'.format(pair)) + key = pair[0:pair.find('=')] + if key in keys: + raise InvalidArgumentValueError('Duplicated key "{}" found for buildpacks binding properties'.format(key)) + keys.add(key) + + +def validate_buildpacks_binding_secrets(namespace): + if namespace.secrets is not None: + key_value_pairs = namespace.secrets.split(' ') + keys = set() + for pair in key_value_pairs: + if not _is_valid_pair(pair): + raise InvalidArgumentValueError( + 'Invalid pair "{}", each pair of Buildpacks Binding properties should follow format key=value'.format(pair)) + key = pair[0:pair.find('=')] + if key in keys: + raise InvalidArgumentValueError('Duplicated key "{}" found for buildpacks binding secrets'.format(key)) + keys.add(key) + + +def _is_valid_pair(pair): + if pair.count("=") != 1: + return False; + if pair.find("=") == 0: + return False; + if pair.find("=") == len(pair) - 1: + return False; + return True From d85f884f4f5061c36afcf82e02d829e33a40506d Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 20:43:19 +0800 Subject: [PATCH 12/44] add help info for command group --- src/spring-cloud/azext_spring_cloud/_help.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/spring-cloud/azext_spring_cloud/_help.py b/src/spring-cloud/azext_spring_cloud/_help.py index 6d6f2182ac2..e519f25685f 100644 --- a/src/spring-cloud/azext_spring_cloud/_help.py +++ b/src/spring-cloud/azext_spring_cloud/_help.py @@ -543,6 +543,11 @@ text: az spring-cloud application-configuration-service unbind --app MyApp -s MyService -g MyResourceGroup """ +helps['spring-cloud build-service buildpacks-binding'] = """ + type: group + short-summary: (Enterprise Tier Only) Commands to manage Buildpacks Binding +""" + helps['spring-cloud build-service buildpacks-binding create'] = """ type: command short-summary: Create a buildpacks binding. From 7674782b83e7a19ecd54a588b686991bc821d9e5 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Thu, 12 Aug 2021 23:19:20 +0800 Subject: [PATCH 13/44] fix for buildpacks binding properties and secrets validator --- .../_validators_enterprise.py | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 6a19e3c3fa2..6bc4ab8a288 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -6,6 +6,7 @@ # pylint: disable=too-few-public-methods, unused-argument, redefined-builtin from re import match +import shlex from azure.cli.core.util import CLIError from azure.cli.core.azclierror import InvalidArgumentValueError from knack.log import get_logger @@ -85,37 +86,34 @@ def _is_valid_buildpacks_binding_name_length(name): def validate_buildpacks_binding_properties(namespace): if namespace.properties is not None: - key_value_pairs = namespace.properties.split(' ') - keys = set() - for pair in key_value_pairs: - if not _is_valid_pair(pair): - raise InvalidArgumentValueError( - 'Invalid pair "{}" Each pair of Buildpacks Binding properties should follow format key=value'.format(pair)) - key = pair[0:pair.find('=')] - if key in keys: - raise InvalidArgumentValueError('Duplicated key "{}" found for buildpacks binding properties'.format(key)) - keys.add(key) + if not _is_valid_pair_list(namespace.properties): + raise InvalidArgumentValueError( + 'Invalid pair "{}", each pair of Buildpacks Binding properties should follow ' \ + 'format key=value or key="value also include = symbol"' \ + .format(namespace.secrets)) def validate_buildpacks_binding_secrets(namespace): if namespace.secrets is not None: - key_value_pairs = namespace.secrets.split(' ') - keys = set() - for pair in key_value_pairs: - if not _is_valid_pair(pair): - raise InvalidArgumentValueError( - 'Invalid pair "{}", each pair of Buildpacks Binding properties should follow format key=value'.format(pair)) - key = pair[0:pair.find('=')] + if not _is_valid_pair_list(namespace.secrets): + raise InvalidArgumentValueError( + 'Invalid pair "{}", each pair of Buildpacks Binding secrets should follow ' \ + 'format key=value or key="value also include = symbol"' \ + .format(namespace.secrets)) + + +def _is_valid_pair_list(pair_list): + keys = set() + try: + for token in shlex.split(pair_list): + key, value = token.split('=', 1) + print("key {}, value {}".format(key, value)) + if len(key) == 0 or len(value) == 0: + raise InvalidArgumentValueError('Buildpacks Binding key or value should not be blank for pair "{}"' \ + .format(token)) if key in keys: - raise InvalidArgumentValueError('Duplicated key "{}" found for buildpacks binding secrets'.format(key)) + raise InvalidArgumentValueError('Buildpacks Binding duplicated key "{}" found'.format(key)) keys.add(key) - - -def _is_valid_pair(pair): - if pair.count("=") != 1: - return False; - if pair.find("=") == 0: - return False; - if pair.find("=") == len(pair) - 1: - return False; + except ValueError: + return False return True From 5f40a4001cf7d84a8580f7203f884014bfce1692 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 00:03:46 +0800 Subject: [PATCH 14/44] make buildpacks binding operation concrete --- .../azext_spring_cloud/_enterprise.py | 1 + .../_exception_enterprise.py | 5 ++ .../azext_spring_cloud/buildpacks_binding.py | 84 +++++++++++++++++-- 3 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 src/spring-cloud/azext_spring_cloud/_exception_enterprise.py diff --git a/src/spring-cloud/azext_spring_cloud/_enterprise.py b/src/spring-cloud/azext_spring_cloud/_enterprise.py index bb877556507..50c5e271dc2 100644 --- a/src/spring-cloud/azext_spring_cloud/_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_enterprise.py @@ -22,6 +22,7 @@ DELETE_PRODUCTION_DEPLOYMENT_WARNING = "You are going to delete production deployment, the app will be inaccessible after this operation." LOG_RUNNING_PROMPT = "This command usually takes minutes to run. Add '--verbose' parameter if needed." +DEFAULT_BUILD_SERVICE_NAME = "default" def app_get_enterprise(cmd, client, resource_group, service, name): app = client.apps.get(resource_group, service, name) diff --git a/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py b/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py new file mode 100644 index 00000000000..2f8682d3c84 --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py @@ -0,0 +1,5 @@ +from azure.cli.core.azclierror import UserFault + +class BuildpacksBindingOperationError(UserFault): + """ Describes the buildpacks binding operation error""" + pass \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 7ed96e60fd7..34c59d63c98 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -1,13 +1,81 @@ -def buildpacks_binding_create(cmd, client, service, resource_group, +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=wrong-import-order +import shlex +from ._enterprise import DEFAULT_BUILD_SERVICE_NAME +from ._exception_enterprise import BuildpacksBindingOperationError +from ._util_enterprise import is_enterprise_tier +from .vendored_sdks.appplatform.v2022_05_01_preview import models +from knack.log import get_logger + + +def buildpacks_binding_create(cmd, client, resource_group, service, name, type, properties=None, secrets=None): - pass + _assert_binding_not_exists(client, resource_group, service, name) + binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) + return _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource) -def buildpacks_binding_set(cmd, client, service, resource_group, + +def buildpacks_binding_set(cmd, client, resource_group, service, name, type, properties=None, secrets=None): - pass + _assert_binding_exists(client, resource_group, service, name) + binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) + return _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource) + + +def buildpacks_binding_show(cmd, client, resource_group, service, name): + binding_resource = _get_buildpacks_binding(client, resource_group, service, name) + if binding_resource is None: + raise BuildpacksBindingOperationError("Not exist") + + +def buildpacks_binding_delete(cmd, client, resource_group, service, name): + return _delete_buildpacks_binding(client, resource_group, service, name) + + +def _build_buildpacks_binding_resource(binding_type, launch_props_properties_str, launch_props_secrets_str): + launch_props_properties = _kv_pair_list_to_dict(launch_props_properties_str) + launch_props_secrets = _kv_pair_list_to_dict(launch_props_secrets_str) + launch_properties = models.BuildpacksBindingLaunchProperties(properties=launch_props_properties, + secrets=launch_props_secrets) + binding_properties = models.BuildpacksBindingProperties(binding_type=binding_type, + launch_properties=launch_properties) + return models.BuildpacksBindingResource(properties=binding_properties) + + +def _kv_pair_list_to_dict(kv_pairs_seprated_by_space): + return dict(token.split('=', 1) for token in shlex.split(kv_pairs_seprated_by_space)) + + +def _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource): + return client.buildpacks_binding.create_or_update(resource_group, + service, + DEFAULT_BUILD_SERVICE_NAME, + name, + binding_resource) + + +def _get_buildpacks_binding(client, resource_group, service, binding_name): + return client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) + + +def _delete_buildpacks_binding(client, resource_group, service, binding_name): + client.buildpacks_binding.delete(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) + +def _assert_binding_not_exists(client, resource_group, service, binding_name): + binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) + if binding_resource is not None: + raise BuildpacksBindingOperationError('Buildpacks Binding {} already exists ' \ + 'in resource group {}, service {}' \ + .format(binding_name, resource_group, service)) -def buildpacks_binding_show(cmd, client, service, resource_group, name): - pass -def buildpacks_binding_delete(cmd, client, service, resource_group, name): - pass \ No newline at end of file +def _assert_binding_exists(client, resource_group, service, binding_name): + binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) + if binding_resource is None: + raise BuildpacksBindingOperationError('Buildpacks Binding {} does not exist ' \ + 'in resource group {}, service {}' \ + .format(binding_name, resource_group, service)) From ff465a3a837f640e111e4fee06bfe47c13399715 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 00:24:34 +0800 Subject: [PATCH 15/44] remove print --- src/spring-cloud/azext_spring_cloud/_validators_enterprise.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 6bc4ab8a288..0e47300fb59 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -107,7 +107,6 @@ def _is_valid_pair_list(pair_list): try: for token in shlex.split(pair_list): key, value = token.split('=', 1) - print("key {}, value {}".format(key, value)) if len(key) == 0 or len(value) == 0: raise InvalidArgumentValueError('Buildpacks Binding key or value should not be blank for pair "{}"' \ .format(token)) From 367e7aa4004bdc60b4cdfd35d22a6d573a3d21e6 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 11:39:28 +0800 Subject: [PATCH 16/44] add only support enterprise validator --- src/spring-cloud/azext_spring_cloud/_params.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index a805a399658..8c22fdcd25c 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -15,7 +15,7 @@ validate_instance_count) from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_name, validate_buildpacks_binding_properties, - validate_buildpacks_binding_secrets) + validate_buildpacks_binding_secrets, only_support_enterprise) from ._utils import ApiType, BuildpacksBindingType from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType @@ -334,4 +334,5 @@ def prepare_logs_argument(c): 'spring-cloud build-service buildpacks-binding show', 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: - c.argument('name', help='Reqired name for buildpacks binding.', validator=validate_buildpacks_binding_name) \ No newline at end of file + c.argument('service', service_name_type, validator=only_support_enterprise) + c.argument('name', help='Reqired name for buildpacks binding.', validator=validate_buildpacks_binding_name) From eacd28bc3566d5f7725a452acd237d686c961772 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 11:43:18 +0800 Subject: [PATCH 17/44] and newline at end of file for exception enterprise --- src/spring-cloud/azext_spring_cloud/_exception_enterprise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py b/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py index 2f8682d3c84..62709663e67 100644 --- a/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py @@ -2,4 +2,4 @@ class BuildpacksBindingOperationError(UserFault): """ Describes the buildpacks binding operation error""" - pass \ No newline at end of file + pass From d27d9de429936b7329639e7120dd31325aba40e4 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 11:43:42 +0800 Subject: [PATCH 18/44] add newline for following methods in _enterprise --- src/spring-cloud/azext_spring_cloud/_enterprise.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/spring-cloud/azext_spring_cloud/_enterprise.py b/src/spring-cloud/azext_spring_cloud/_enterprise.py index 50c5e271dc2..8c6dc3d7721 100644 --- a/src/spring-cloud/azext_spring_cloud/_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_enterprise.py @@ -24,6 +24,7 @@ DEFAULT_BUILD_SERVICE_NAME = "default" + def app_get_enterprise(cmd, client, resource_group, service, name): app = client.apps.get(resource_group, service, name) app.properties.activeDeployment = _get_active_deployment(client, resource_group, service, name) From 6a6693a5b839a818d69824d9e3a7b46833e73493 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 11:44:08 +0800 Subject: [PATCH 19/44] fix style check error --- .../azext_spring_cloud/buildpacks_binding.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 34c59d63c98..5d2b2d3c8e1 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -65,17 +65,18 @@ def _get_buildpacks_binding(client, resource_group, service, binding_name): def _delete_buildpacks_binding(client, resource_group, service, binding_name): client.buildpacks_binding.delete(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) + def _assert_binding_not_exists(client, resource_group, service, binding_name): binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) if binding_resource is not None: - raise BuildpacksBindingOperationError('Buildpacks Binding {} already exists ' \ - 'in resource group {}, service {}' \ + raise BuildpacksBindingOperationError('Buildpacks Binding {} already exists ' + 'in resource group {}, service {}' .format(binding_name, resource_group, service)) def _assert_binding_exists(client, resource_group, service, binding_name): binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) if binding_resource is None: - raise BuildpacksBindingOperationError('Buildpacks Binding {} does not exist ' \ - 'in resource group {}, service {}' \ + raise BuildpacksBindingOperationError('Buildpacks Binding {} does not exist ' + 'in resource group {}, service {}' .format(binding_name, resource_group, service)) From 7493e28292de74e38ddf546e46ebc253e2daa57e Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 11:46:37 +0800 Subject: [PATCH 20/44] stylecheck fix: remove redundant backslash --- .../azext_spring_cloud/_validators_enterprise.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 0e47300fb59..e9645b55392 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -88,8 +88,8 @@ def validate_buildpacks_binding_properties(namespace): if namespace.properties is not None: if not _is_valid_pair_list(namespace.properties): raise InvalidArgumentValueError( - 'Invalid pair "{}", each pair of Buildpacks Binding properties should follow ' \ - 'format key=value or key="value also include = symbol"' \ + 'Invalid pair "{}", each pair of Buildpacks Binding properties should follow ' + 'format key=value or key="value also include = symbol"' .format(namespace.secrets)) @@ -97,8 +97,8 @@ def validate_buildpacks_binding_secrets(namespace): if namespace.secrets is not None: if not _is_valid_pair_list(namespace.secrets): raise InvalidArgumentValueError( - 'Invalid pair "{}", each pair of Buildpacks Binding secrets should follow ' \ - 'format key=value or key="value also include = symbol"' \ + 'Invalid pair "{}", each pair of Buildpacks Binding secrets should follow ' + 'format key=value or key="value also include = symbol"' .format(namespace.secrets)) @@ -108,7 +108,7 @@ def _is_valid_pair_list(pair_list): for token in shlex.split(pair_list): key, value = token.split('=', 1) if len(key) == 0 or len(value) == 0: - raise InvalidArgumentValueError('Buildpacks Binding key or value should not be blank for pair "{}"' \ + raise InvalidArgumentValueError('Buildpacks Binding key or value should not be blank for pair "{}"' .format(token)) if key in keys: raise InvalidArgumentValueError('Buildpacks Binding duplicated key "{}" found'.format(key)) From 43eef1f46c16b42a236984fdc72df51d78812d77 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 11:50:21 +0800 Subject: [PATCH 21/44] remove unused imports --- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 5d2b2d3c8e1..f8e035b1713 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -7,9 +7,7 @@ import shlex from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from ._exception_enterprise import BuildpacksBindingOperationError -from ._util_enterprise import is_enterprise_tier from .vendored_sdks.appplatform.v2022_05_01_preview import models -from knack.log import get_logger def buildpacks_binding_create(cmd, client, resource_group, service, From 8dce3b04513afaf71d17c139f5d8e97e1e8ef512 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 14:02:57 +0800 Subject: [PATCH 22/44] add parenthesis --- src/spring-cloud/azext_spring_cloud/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 8c22fdcd25c..8137031188a 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -16,7 +16,7 @@ from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_name, validate_buildpacks_binding_properties, validate_buildpacks_binding_secrets, only_support_enterprise) -from ._utils import ApiType, BuildpacksBindingType +from ._utils import (ApiType, BuildpacksBindingType) from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType From 8532ec5a96fe8a1c505f76e543817e20f514db60 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 14:47:51 +0800 Subject: [PATCH 23/44] replace with CLIError --- .../azext_spring_cloud/_exception_enterprise.py | 5 ----- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 8 ++++---- 2 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 src/spring-cloud/azext_spring_cloud/_exception_enterprise.py diff --git a/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py b/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py deleted file mode 100644 index 62709663e67..00000000000 --- a/src/spring-cloud/azext_spring_cloud/_exception_enterprise.py +++ /dev/null @@ -1,5 +0,0 @@ -from azure.cli.core.azclierror import UserFault - -class BuildpacksBindingOperationError(UserFault): - """ Describes the buildpacks binding operation error""" - pass diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index f8e035b1713..0189f08b873 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -6,8 +6,8 @@ # pylint: disable=wrong-import-order import shlex from ._enterprise import DEFAULT_BUILD_SERVICE_NAME -from ._exception_enterprise import BuildpacksBindingOperationError from .vendored_sdks.appplatform.v2022_05_01_preview import models +from knack.util import CLIError def buildpacks_binding_create(cmd, client, resource_group, service, @@ -27,7 +27,7 @@ def buildpacks_binding_set(cmd, client, resource_group, service, def buildpacks_binding_show(cmd, client, resource_group, service, name): binding_resource = _get_buildpacks_binding(client, resource_group, service, name) if binding_resource is None: - raise BuildpacksBindingOperationError("Not exist") + raise CLIError("Not exist") def buildpacks_binding_delete(cmd, client, resource_group, service, name): @@ -67,7 +67,7 @@ def _delete_buildpacks_binding(client, resource_group, service, binding_name): def _assert_binding_not_exists(client, resource_group, service, binding_name): binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) if binding_resource is not None: - raise BuildpacksBindingOperationError('Buildpacks Binding {} already exists ' + raise CLIError('Buildpacks Binding {} already exists ' 'in resource group {}, service {}' .format(binding_name, resource_group, service)) @@ -75,6 +75,6 @@ def _assert_binding_not_exists(client, resource_group, service, binding_name): def _assert_binding_exists(client, resource_group, service, binding_name): binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) if binding_resource is None: - raise BuildpacksBindingOperationError('Buildpacks Binding {} does not exist ' + raise CLIError('Buildpacks Binding {} does not exist ' 'in resource group {}, service {}' .format(binding_name, resource_group, service)) From 8ab593668bef86b8c0a17ea17ccdb514fe34661d Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 15:10:55 +0800 Subject: [PATCH 24/44] remove un-necessary exception --- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 0189f08b873..77e802a6a2e 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -25,10 +25,7 @@ def buildpacks_binding_set(cmd, client, resource_group, service, def buildpacks_binding_show(cmd, client, resource_group, service, name): - binding_resource = _get_buildpacks_binding(client, resource_group, service, name) - if binding_resource is None: - raise CLIError("Not exist") - + return _get_buildpacks_binding(client, resource_group, service, name) def buildpacks_binding_delete(cmd, client, resource_group, service, name): return _delete_buildpacks_binding(client, resource_group, service, name) From 6ac0f1a103f8422055ed8c4401c44a29571712c4 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 15:11:18 +0800 Subject: [PATCH 25/44] use buildpacks binding type from SDK --- src/spring-cloud/azext_spring_cloud/_params.py | 9 +++++++-- src/spring-cloud/azext_spring_cloud/_utils.py | 7 ------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 8137031188a..a484f7fed1b 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -16,9 +16,12 @@ from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_name, validate_buildpacks_binding_properties, validate_buildpacks_binding_secrets, only_support_enterprise) -from ._utils import (ApiType, BuildpacksBindingType) +from ._utils import ApiType from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType +from .vendored_sdks.appplatform.v2022_05_01_preview.models \ + import _app_platform_management_client_enums as v20220501_preview_AppPlatformEnums + name_type = CLIArgumentType(options_list=[ '--name', '-n'], help='The primary resource name', validator=validate_name) @@ -321,7 +324,9 @@ def prepare_logs_argument(c): for scope in ['spring-cloud build-service buildpacks-binding create', 'spring-cloud build-service buildpacks-binding set']: with self.argument_context(scope) as c: - c.argument('type', arg_type=get_enum_type(BuildpacksBindingType), help='Required type for buildpacks binding.') + c.argument('type', + arg_type=get_enum_type(v20220501_preview_AppPlatformEnums.BindingType), + help='Required type for buildpacks binding.') c.argument('properties', help='Non-sensitive properties for launchProperties. Sample "key1=val1 key2=val2"', validator=validate_buildpacks_binding_properties) diff --git a/src/spring-cloud/azext_spring_cloud/_utils.py b/src/spring-cloud/azext_spring_cloud/_utils.py index 464daccade1..dc337b454e8 100644 --- a/src/spring-cloud/azext_spring_cloud/_utils.py +++ b/src/spring-cloud/azext_spring_cloud/_utils.py @@ -242,10 +242,3 @@ def handle_asc_exception(ex): raise CLIError(response_dict["error"]["message"]) else: raise CLIError(ex) - - -class BuildpacksBindingType(Enum): - """Type of Buildpacks Binding - """ - - APPLICATION_INSIGHTS = 'ApplicationInsights' From 037c9cfe599667bcff70de648e7d6d95ee5f554b Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 15:56:34 +0800 Subject: [PATCH 26/44] enhance buildpacks binding properties and secrets parameter, its validator and help message. --- src/spring-cloud/azext_spring_cloud/_help.py | 8 ++-- .../azext_spring_cloud/_params.py | 15 +++++-- .../_validators_enterprise.py | 42 ++++++------------- .../azext_spring_cloud/buildpacks_binding.py | 13 ++---- 4 files changed, 31 insertions(+), 47 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_help.py b/src/spring-cloud/azext_spring_cloud/_help.py index e519f25685f..21c3b5a7d24 100644 --- a/src/spring-cloud/azext_spring_cloud/_help.py +++ b/src/spring-cloud/azext_spring_cloud/_help.py @@ -555,11 +555,11 @@ - name: Create a buildpacks binding without properties or secrets. text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights - name: Create a buildpacks binding with only secrets. - text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --secrets "k1=v1 k2=v2" + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --secrets k1=v1 k2=v2 - name: Create a buildpacks binding with only properties. - text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --properties "a=b c=d" + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --properties a=b c=d - name: Create a buildpacks binding with properties and secrets. - text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --properties "a=b c=d" --secrets "k1=v1 k2=v2" + text: az spring-cloud build-service buildpacks-binding create --name first-binding --type ApplicationInsights --properties a=b c=d --secrets k1=v1 k2=v2 """ helps['spring-cloud build-service buildpacks-binding set'] = """ @@ -567,7 +567,7 @@ short-summary: Set a buildpacks binding. examples: - name: Set a buildpacks binding with properties and secrets. - text: az spring-cloud build-service buildpacks-binding set --name first-binding --type ApplicationInsights --properties "a=b c=d" --secrets "k1=v1 k2=v2" + text: az spring-cloud build-service buildpacks-binding set --name first-binding --type ApplicationInsights --properties a=b c=d --secrets k1=v1 k2=v2 """ helps['spring-cloud build-service buildpacks-binding show'] = """ diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index a484f7fed1b..cd89326b9d9 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -29,6 +29,15 @@ validator=validate_env, help="Space-separated environment variables in 'key[=value]' format.", nargs='*') service_name_type = CLIArgumentType(options_list=['--service', '-s'], help='Name of Azure Spring Cloud, you can configure the default service using az configure --defaults spring-cloud=.', configured_default='spring-cloud') app_name_type = CLIArgumentType(help='App name, you can configure the default app using az configure --defaults spring-cloud-app=.', validator=validate_app_name, configured_default='spring-cloud-app') +buildpacks_binding_properties_type = CLIArgumentType(help='Non-sensitive properties for launchProperties. ' + 'Format "key[=value]".', + nargs='*', + validator=validate_buildpacks_binding_properties) +buildpacks_binding_secrets_type = CLIArgumentType(help='Sensitive properties for launchProperties. ' + 'Once put,it will be encrypted and never return to user. ' + 'Format "key[=value]".', + nargs="*", + validator=validate_buildpacks_binding_secrets) # pylint: disable=too-many-statements @@ -328,11 +337,9 @@ def prepare_logs_argument(c): arg_type=get_enum_type(v20220501_preview_AppPlatformEnums.BindingType), help='Required type for buildpacks binding.') c.argument('properties', - help='Non-sensitive properties for launchProperties. Sample "key1=val1 key2=val2"', - validator=validate_buildpacks_binding_properties) + buildpacks_binding_properties_type) c.argument('secrets', - help='Sensitive properties for launchProperties. Once put,it will be encrypted and never return to user. Sample "sec1=val1 sec2=val2"', - validator=validate_buildpacks_binding_secrets) + buildpacks_binding_secrets_type) for scope in ['spring-cloud build-service buildpacks-binding create', 'spring-cloud build-service buildpacks-binding set', diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index e9645b55392..1acf2bbd4cd 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -6,9 +6,9 @@ # pylint: disable=too-few-public-methods, unused-argument, redefined-builtin from re import match -import shlex from azure.cli.core.util import CLIError from azure.cli.core.azclierror import InvalidArgumentValueError +from azure.cli.core.commands.validators import validate_tag from knack.log import get_logger from ._resource_quantity import ( validate_cpu as validate_and_normalize_cpu, @@ -85,34 +85,18 @@ def _is_valid_buildpacks_binding_name_length(name): def validate_buildpacks_binding_properties(namespace): - if namespace.properties is not None: - if not _is_valid_pair_list(namespace.properties): - raise InvalidArgumentValueError( - 'Invalid pair "{}", each pair of Buildpacks Binding properties should follow ' - 'format key=value or key="value also include = symbol"' - .format(namespace.secrets)) + """ Extracts multiple space-separated properties in key[=value] format """ + if isinstance(namespace.properties, list): + properties_dict = {} + for item in namespace.properties: + properties_dict.update(validate_tag(item)) + namespace.properties = properties_dict def validate_buildpacks_binding_secrets(namespace): - if namespace.secrets is not None: - if not _is_valid_pair_list(namespace.secrets): - raise InvalidArgumentValueError( - 'Invalid pair "{}", each pair of Buildpacks Binding secrets should follow ' - 'format key=value or key="value also include = symbol"' - .format(namespace.secrets)) - - -def _is_valid_pair_list(pair_list): - keys = set() - try: - for token in shlex.split(pair_list): - key, value = token.split('=', 1) - if len(key) == 0 or len(value) == 0: - raise InvalidArgumentValueError('Buildpacks Binding key or value should not be blank for pair "{}"' - .format(token)) - if key in keys: - raise InvalidArgumentValueError('Buildpacks Binding duplicated key "{}" found'.format(key)) - keys.add(key) - except ValueError: - return False - return True + """ Extracts multiple space-separated secrets in key[=value] format """ + if isinstance(namespace.secrets, list): + secrets_dict = {} + for item in namespace.secrets: + secrets_dict.update(validate_tag(item)) + namespace.secrets = secrets_dict diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 77e802a6a2e..71debdcabf4 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -4,7 +4,6 @@ # -------------------------------------------------------------------------------------------- # pylint: disable=wrong-import-order -import shlex from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from .vendored_sdks.appplatform.v2022_05_01_preview import models from knack.util import CLIError @@ -31,20 +30,14 @@ def buildpacks_binding_delete(cmd, client, resource_group, service, name): return _delete_buildpacks_binding(client, resource_group, service, name) -def _build_buildpacks_binding_resource(binding_type, launch_props_properties_str, launch_props_secrets_str): - launch_props_properties = _kv_pair_list_to_dict(launch_props_properties_str) - launch_props_secrets = _kv_pair_list_to_dict(launch_props_secrets_str) - launch_properties = models.BuildpacksBindingLaunchProperties(properties=launch_props_properties, - secrets=launch_props_secrets) +def _build_buildpacks_binding_resource(binding_type, properties_dict, secrets_dict): + launch_properties = models.BuildpacksBindingLaunchProperties(properties=properties_dict, + secrets=secrets_dict) binding_properties = models.BuildpacksBindingProperties(binding_type=binding_type, launch_properties=launch_properties) return models.BuildpacksBindingResource(properties=binding_properties) -def _kv_pair_list_to_dict(kv_pairs_seprated_by_space): - return dict(token.split('=', 1) for token in shlex.split(kv_pairs_seprated_by_space)) - - def _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource): return client.buildpacks_binding.create_or_update(resource_group, service, From 7a42171cf8501f43f0bb212967c5cf29714011c1 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 16:30:37 +0800 Subject: [PATCH 27/44] fix for calling to get before create/set --- .../azext_spring_cloud/buildpacks_binding.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 71debdcabf4..7ff469d7937 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -6,6 +6,7 @@ # pylint: disable=wrong-import-order from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from .vendored_sdks.appplatform.v2022_05_01_preview import models +from azure.core.exceptions import ResourceNotFoundError from knack.util import CLIError @@ -55,16 +56,21 @@ def _delete_buildpacks_binding(client, resource_group, service, binding_name): def _assert_binding_not_exists(client, resource_group, service, binding_name): - binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) - if binding_resource is not None: - raise CLIError('Buildpacks Binding {} already exists ' - 'in resource group {}, service {}' - .format(binding_name, resource_group, service)) + try: + binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) + if binding_resource is not None: + raise CLIError('Buildpacks Binding {} already exists ' + 'in resource group {}, service {}. You can edit it by set command.' + .format(binding_name, resource_group, service)) + except ResourceNotFoundError as e: + # Excepted case + pass def _assert_binding_exists(client, resource_group, service, binding_name): - binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) - if binding_resource is None: + try: + _get_buildpacks_binding(client, resource_group, service, binding_name) + except ResourceNotFoundError as e: raise CLIError('Buildpacks Binding {} does not exist ' - 'in resource group {}, service {}' - .format(binding_name, resource_group, service)) + 'in resource group {}, service {}. Please create before set.' + .format(binding_name, resource_group, service)) From 96173bce35b44670e75586b345c8a83e809272a3 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 16:34:38 +0800 Subject: [PATCH 28/44] remove extra Required for name param --- src/spring-cloud/azext_spring_cloud/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index cd89326b9d9..f8aa959783b 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -347,4 +347,4 @@ def prepare_logs_argument(c): 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: c.argument('service', service_name_type, validator=only_support_enterprise) - c.argument('name', help='Reqired name for buildpacks binding.', validator=validate_buildpacks_binding_name) + c.argument('name', help='Name for buildpacks binding.', validator=validate_buildpacks_binding_name) From bacbe381168d53fea069a4e1f99552ce2a876954 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 16:36:53 +0800 Subject: [PATCH 29/44] replace InvalidArgumentValueError with CLIError in validators --- .../azext_spring_cloud/_validators_enterprise.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 1acf2bbd4cd..3d9f2bdbad9 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -7,7 +7,6 @@ from re import match from azure.cli.core.util import CLIError -from azure.cli.core.azclierror import InvalidArgumentValueError from azure.cli.core.commands.validators import validate_tag from knack.log import get_logger from ._resource_quantity import ( @@ -69,11 +68,11 @@ def _is_valid_app_and_profile_name(pattern): def validate_buildpacks_binding_name(namespace): if not _is_valid_buildpacks_binding_name_pattern(namespace.name): - raise InvalidArgumentValueError("Buildpacks Binding name should follow pattern {}".format( - BUILDPACKS_BINDING_NAME_REGEX_PATTTERN)) + raise CLIError("Buildpacks Binding name should follow pattern {}" + .format(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN)) if not _is_valid_buildpacks_binding_name_length(namespace.name): - raise InvalidArgumentValueError("Buildpacks Binding name character number should not exceed {}".format( - BUILDPACKS_BINDING_NAME_MAX_LENGTH)) + raise CLIError("Buildpacks Binding name character number should not exceed {}" + .format(BUILDPACKS_BINDING_NAME_MAX_LENGTH)) def _is_valid_buildpacks_binding_name_pattern(name): From a17582a06e32643f479b8cd1aab70a0840856e38 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 16:43:18 +0800 Subject: [PATCH 30/44] put length check in regex --- .../azext_spring_cloud/_validators_enterprise.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 3d9f2bdbad9..24ccff3cede 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -16,8 +16,9 @@ is_enterprise_tier ) -BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]$)" -BUILDPACKS_BINDING_NAME_MAX_LENGTH=19 + +# Minimal length 1, max Length 19 +BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]{0,17}[a-zA-Z0-9]$)" logger = get_logger(__name__) @@ -70,19 +71,12 @@ def validate_buildpacks_binding_name(namespace): if not _is_valid_buildpacks_binding_name_pattern(namespace.name): raise CLIError("Buildpacks Binding name should follow pattern {}" .format(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN)) - if not _is_valid_buildpacks_binding_name_length(namespace.name): - raise CLIError("Buildpacks Binding name character number should not exceed {}" - .format(BUILDPACKS_BINDING_NAME_MAX_LENGTH)) def _is_valid_buildpacks_binding_name_pattern(name): return match(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN, name) is not None -def _is_valid_buildpacks_binding_name_length(name): - return len(name) <= BUILDPACKS_BINDING_NAME_MAX_LENGTH - - def validate_buildpacks_binding_properties(namespace): """ Extracts multiple space-separated properties in key[=value] format """ if isinstance(namespace.properties, list): From ea1c78c45a4dbebd4bba5ba0183d79395fbf8ee3 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 17:15:59 +0800 Subject: [PATCH 31/44] merge create and set into one and add different validators for them --- .../azext_spring_cloud/_params.py | 15 +++++- .../_validators_enterprise.py | 48 +++++++++++++++++++ .../azext_spring_cloud/buildpacks_binding.py | 34 +++---------- 3 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index f8aa959783b..e5cda863055 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -15,7 +15,8 @@ validate_instance_count) from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_name, validate_buildpacks_binding_properties, - validate_buildpacks_binding_secrets, only_support_enterprise) + validate_buildpacks_binding_secrets, only_support_enterprise, + enterprise_only_and_binding_not_exist, enterprise_only_and_binding_exist) from ._utils import ApiType from .vendored_sdks.appplatform.v2020_07_01.models import RuntimeVersion, TestKeyType @@ -346,5 +347,15 @@ def prepare_logs_argument(c): 'spring-cloud build-service buildpacks-binding show', 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: - c.argument('service', service_name_type, validator=only_support_enterprise) c.argument('name', help='Name for buildpacks binding.', validator=validate_buildpacks_binding_name) + + for scope in ['spring-cloud build-service buildpacks-binding show', + 'spring-cloud build-service buildpacks-binding delete']: + with self.argument_context(scope) as c: + c.argument('service', service_name_type, validator=only_support_enterprise) + + with self.argument_context('spring-cloud build-service buildpacks-binding create') as c: + c.argument('service', service_name_type, validator=enterprise_only_and_binding_not_exist) + + with self.argument_context('spring-cloud build-service buildpacks-binding set') as c: + c.argument('service', service_name_type, validator=enterprise_only_and_binding_exist) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 24ccff3cede..18217521531 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -8,13 +8,19 @@ from re import match from azure.cli.core.util import CLIError from azure.cli.core.commands.validators import validate_tag +from azure.cli.core.commands.client_factory import get_mgmt_service_client +from azure.core.exceptions import ResourceNotFoundError from knack.log import get_logger +from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from ._resource_quantity import ( validate_cpu as validate_and_normalize_cpu, validate_memory as validate_and_normalize_memory) from ._util_enterprise import ( is_enterprise_tier ) +from .vendored_sdks.appplatform.v2022_05_01_preview import ( + AppPlatformManagementClient as AppPlatformManagementClient_20220501preview +) # Minimal length 1, max Length 19 @@ -93,3 +99,45 @@ def validate_buildpacks_binding_secrets(namespace): for item in namespace.secrets: secrets_dict.update(validate_tag(item)) namespace.secrets = secrets_dict + + +def enterprise_only_and_binding_not_exist(cmd, namespace): + only_support_enterprise(cmd, namespace) + client = get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient_20220501preview) + _validate_binding_not_exists(client, + namespace.resource_group, + namespace.service, + namespace.name) + + +def enterprise_only_and_binding_exist(cmd, namespace): + only_support_enterprise(cmd, namespace) + client = get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient_20220501preview) + _validate_binding_exists(client, + namespace.resource_group, + namespace.service, + namespace.name) + + +def _validate_binding_not_exists(client, resource_group, service, binding_name): + try: + binding_resource = client.buildpacks_binding.get(resource_group, + service, + DEFAULT_BUILD_SERVICE_NAME, + binding_name) + if binding_resource is not None: + raise CLIError('Buildpacks Binding {} already exists ' + 'in resource group {}, service {}. You can edit it by set command.' + .format(binding_name, resource_group, service)) + except ResourceNotFoundError as e: + # Excepted case + pass + + +def _validate_binding_exists(client, resource_group, service, binding_name): + try: + client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) + except ResourceNotFoundError as e: + raise CLIError('Buildpacks Binding {} does not exist ' + 'in resource group {}, service {}. Please create before set.' + .format(binding_name, resource_group, service)) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 7ff469d7937..11c84b390c4 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -6,22 +6,19 @@ # pylint: disable=wrong-import-order from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from .vendored_sdks.appplatform.v2022_05_01_preview import models -from azure.core.exceptions import ResourceNotFoundError from knack.util import CLIError def buildpacks_binding_create(cmd, client, resource_group, service, name, type, properties=None, secrets=None): - _assert_binding_not_exists(client, resource_group, service, name) - binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) - return _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource) + return _create_or_update_buildpacks_binding(client, resource_group, service, name, + type, properties, secrets) def buildpacks_binding_set(cmd, client, resource_group, service, name, type, properties=None, secrets=None): - _assert_binding_exists(client, resource_group, service, name) - binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) - return _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource) + return _create_or_update_buildpacks_binding(client, resource_group, service, name, + type, properties, secrets) def buildpacks_binding_show(cmd, client, resource_group, service, name): @@ -39,7 +36,8 @@ def _build_buildpacks_binding_resource(binding_type, properties_dict, secrets_di return models.BuildpacksBindingResource(properties=binding_properties) -def _create_or_update_buildpacks_binding(client, resource_group, service, name, binding_resource): +def _create_or_update_buildpacks_binding(client, resource_group, service, name, type, properties, secrets): + binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) return client.buildpacks_binding.create_or_update(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, @@ -54,23 +52,3 @@ def _get_buildpacks_binding(client, resource_group, service, binding_name): def _delete_buildpacks_binding(client, resource_group, service, binding_name): client.buildpacks_binding.delete(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) - -def _assert_binding_not_exists(client, resource_group, service, binding_name): - try: - binding_resource = _get_buildpacks_binding(client, resource_group, service, binding_name) - if binding_resource is not None: - raise CLIError('Buildpacks Binding {} already exists ' - 'in resource group {}, service {}. You can edit it by set command.' - .format(binding_name, resource_group, service)) - except ResourceNotFoundError as e: - # Excepted case - pass - - -def _assert_binding_exists(client, resource_group, service, binding_name): - try: - _get_buildpacks_binding(client, resource_group, service, binding_name) - except ResourceNotFoundError as e: - raise CLIError('Buildpacks Binding {} does not exist ' - 'in resource group {}, service {}. Please create before set.' - .format(binding_name, resource_group, service)) From eb2d5ab3ff8af26c78ec2b39d1db300ca8b089d5 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 17:20:53 +0800 Subject: [PATCH 32/44] enhance show command for buildpacks binding --- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 11c84b390c4..27c114d95cd 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -6,6 +6,7 @@ # pylint: disable=wrong-import-order from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from .vendored_sdks.appplatform.v2022_05_01_preview import models +from azure.core.exceptions import ResourceNotFoundError from knack.util import CLIError @@ -22,7 +23,12 @@ def buildpacks_binding_set(cmd, client, resource_group, service, def buildpacks_binding_show(cmd, client, resource_group, service, name): - return _get_buildpacks_binding(client, resource_group, service, name) + try: + return client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, name) + except ResourceNotFoundError as e: + raise CLIError("Buildpacks Binding {} is not existed in resource group {}, service {}" + .format(name, resource_group, service)) + def buildpacks_binding_delete(cmd, client, resource_group, service, name): return _delete_buildpacks_binding(client, resource_group, service, name) From e1f45e8be6da08b416019ced214f6c2a17e02e9d Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 17:21:13 +0800 Subject: [PATCH 33/44] refine for delete for buildpacks binding --- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 27c114d95cd..3ff4698621b 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -31,7 +31,7 @@ def buildpacks_binding_show(cmd, client, resource_group, service, name): def buildpacks_binding_delete(cmd, client, resource_group, service, name): - return _delete_buildpacks_binding(client, resource_group, service, name) + return client.buildpacks_binding.delete(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, name) def _build_buildpacks_binding_resource(binding_type, properties_dict, secrets_dict): @@ -53,8 +53,3 @@ def _create_or_update_buildpacks_binding(client, resource_group, service, name, def _get_buildpacks_binding(client, resource_group, service, binding_name): return client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) - - -def _delete_buildpacks_binding(client, resource_group, service, binding_name): - client.buildpacks_binding.delete(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) - From 31c4b1d6d1b4b95ebebfa4b2c30ebf5c78c11a83 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 17:23:23 +0800 Subject: [PATCH 34/44] add space --- src/spring-cloud/azext_spring_cloud/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index e5cda863055..402b6ef1a2d 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -35,7 +35,7 @@ nargs='*', validator=validate_buildpacks_binding_properties) buildpacks_binding_secrets_type = CLIArgumentType(help='Sensitive properties for launchProperties. ' - 'Once put,it will be encrypted and never return to user. ' + 'Once put, it will be encrypted and never return to user. ' 'Format "key[=value]".', nargs="*", validator=validate_buildpacks_binding_secrets) From e54631de88059e7c7979582a3bf393269f8c03d2 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 17:40:45 +0800 Subject: [PATCH 35/44] add comment to explain buildpacks binding name format --- .../_validators_enterprise.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 18217521531..f2eec9f997e 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -23,8 +23,22 @@ ) -# Minimal length 1, max Length 19 -BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]{0,17}[a-zA-Z0-9]$)" +""" +Define the binding name of buildpacks. The binding name have some restrictions from kpack as below. + +At most 63 chars. +Have one fixed prefix binding-metadata- 17 char, only 46 chars left. +Must consist of alphabetic characters or '-', and must start and end with an alphabetic character + +We need encode build_service_name, buildpacks_binding_name and type. +We need 2 '-' for separator, 44 chars left. +We need 2 int value for type, 42 chars left. +We need 2 prefix number for encoding prefix for build_service_name and buildpacks_binding_name, 38 char left. + +So there are at most 38 chars for build_service_name and buildpacks_binding_name in total. +We leave 19 character each for build_service_name and buildpacks_binding_name +""" +BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]{0,17}[a-zA-Z]$)" logger = get_logger(__name__) From 246e18ba45adfaf9325cec5e33bbfee3715eb0f8 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 17:42:51 +0800 Subject: [PATCH 36/44] add SDK files for buildpacks binding --- .../_app_platform_management_client.py | 39 +++ .../aio/_app_platform_management_client.py | 39 +++ .../vendored_sdks/appplatform/py.typed | 1 - .../v2019_05_01_preview/_metadata.json | 111 ------- .../appplatform/v2019_05_01_preview/py.typed | 1 - .../appplatform/v2020_07_01/_metadata.json | 113 -------- .../appplatform/v2020_07_01/py.typed | 1 - .../v2020_11_01_preview/_metadata.json | 113 -------- .../appplatform/v2020_11_01_preview/py.typed | 1 - .../v2021_06_01_preview/_metadata.json | 113 -------- .../appplatform/v2021_06_01_preview/py.typed | 1 - .../_app_platform_management_client.py | 15 + .../aio/_app_platform_management_client.py | 15 + .../aio/operations/__init__.py | 6 + .../_buildpacks_binding_operations.py | 254 ++++++++++++++++ .../aio/operations/_service_operations.py | 152 ++++++++++ .../_service_registries_operations.py | 224 ++++++++++++++ .../v2022_05_01_preview/models/__init__.py | 25 ++ .../_app_platform_management_client_enums.py | 16 + .../v2022_05_01_preview/models/_models.py | 258 +++++++++++++++-- .../v2022_05_01_preview/models/_models_py3.py | 274 ++++++++++++++++-- .../operations/__init__.py | 6 + .../_buildpacks_binding_operations.py | 261 +++++++++++++++++ .../operations/_service_operations.py | 158 ++++++++++ .../_service_registries_operations.py | 231 +++++++++++++++ 25 files changed, 1927 insertions(+), 501 deletions(-) delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/py.typed delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/_metadata.json delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/py.typed delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/_metadata.json delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/py.typed delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/_metadata.json delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/py.typed delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/_metadata.json delete mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/py.typed create mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_buildpacks_binding_operations.py create mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_operations.py create mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py create mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_buildpacks_binding_operations.py create mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_operations.py create mode 100644 src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/_app_platform_management_client.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/_app_platform_management_client.py index 27a89fd2b94..6300c4bb258 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/_app_platform_management_client.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/_app_platform_management_client.py @@ -178,6 +178,19 @@ def build_service(self): raise ValueError("API version {} does not have operation group 'build_service'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def buildpacks_binding(self): + """Instance depends on the API version: + + * 2022-05-01-preview: :class:`BuildpacksBindingOperations` + """ + api_version = self._get_api_version('buildpacks_binding') + if api_version == '2022-05-01-preview': + from .v2022_05_01_preview.operations import BuildpacksBindingOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'buildpacks_binding'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def certificates(self): """Instance depends on the API version: @@ -360,6 +373,32 @@ def runtime_versions(self): raise ValueError("API version {} does not have operation group 'runtime_versions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def service(self): + """Instance depends on the API version: + + * 2022-05-01-preview: :class:`ServiceOperations` + """ + api_version = self._get_api_version('service') + if api_version == '2022-05-01-preview': + from .v2022_05_01_preview.operations import ServiceOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'service'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def service_registries(self): + """Instance depends on the API version: + + * 2022-05-01-preview: :class:`ServiceRegistriesOperations` + """ + api_version = self._get_api_version('service_registries') + if api_version == '2022-05-01-preview': + from .v2022_05_01_preview.operations import ServiceRegistriesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'service_registries'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def services(self): """Instance depends on the API version: diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/aio/_app_platform_management_client.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/aio/_app_platform_management_client.py index a3e9a834549..58cdc2fd941 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/aio/_app_platform_management_client.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/aio/_app_platform_management_client.py @@ -176,6 +176,19 @@ def build_service(self): raise ValueError("API version {} does not have operation group 'build_service'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def buildpacks_binding(self): + """Instance depends on the API version: + + * 2022-05-01-preview: :class:`BuildpacksBindingOperations` + """ + api_version = self._get_api_version('buildpacks_binding') + if api_version == '2022-05-01-preview': + from ..v2022_05_01_preview.aio.operations import BuildpacksBindingOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'buildpacks_binding'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def certificates(self): """Instance depends on the API version: @@ -358,6 +371,32 @@ def runtime_versions(self): raise ValueError("API version {} does not have operation group 'runtime_versions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def service(self): + """Instance depends on the API version: + + * 2022-05-01-preview: :class:`ServiceOperations` + """ + api_version = self._get_api_version('service') + if api_version == '2022-05-01-preview': + from ..v2022_05_01_preview.aio.operations import ServiceOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'service'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def service_registries(self): + """Instance depends on the API version: + + * 2022-05-01-preview: :class:`ServiceRegistriesOperations` + """ + api_version = self._get_api_version('service_registries') + if api_version == '2022-05-01-preview': + from ..v2022_05_01_preview.aio.operations import ServiceRegistriesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'service_registries'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def services(self): """Instance depends on the API version: diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/py.typed b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/_metadata.json b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/_metadata.json deleted file mode 100644 index ed50cf259b5..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2019-05-01-preview", - "total_api_version_list": ["2019-05-01-preview"], - "client": { - "name": "AppPlatformManagementClient", - "filename": "_app_platform_management_client", - "description": "REST API for Azure Spring Cloud.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "services": "ServicesOperations", - "apps": "AppsOperations", - "bindings": "BindingsOperations", - "certificates": "CertificatesOperations", - "custom_domains": "CustomDomainsOperations", - "deployments": "DeploymentsOperations", - "operations": "Operations", - "runtime_versions": "RuntimeVersionsOperations", - "sku": "SkuOperations" - } -} \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/py.typed b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2019_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/_metadata.json b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/_metadata.json deleted file mode 100644 index 1f417c7fc3f..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2020-07-01", - "total_api_version_list": ["2020-07-01"], - "client": { - "name": "AppPlatformManagementClient", - "filename": "_app_platform_management_client", - "description": "REST API for Azure Spring Cloud.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "services": "ServicesOperations", - "config_servers": "ConfigServersOperations", - "monitoring_settings": "MonitoringSettingsOperations", - "apps": "AppsOperations", - "bindings": "BindingsOperations", - "certificates": "CertificatesOperations", - "custom_domains": "CustomDomainsOperations", - "deployments": "DeploymentsOperations", - "operations": "Operations", - "runtime_versions": "RuntimeVersionsOperations", - "skus": "SkusOperations" - } -} \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/py.typed b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/_metadata.json b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/_metadata.json deleted file mode 100644 index 22c085a41a3..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2020-11-01-preview", - "total_api_version_list": ["2020-11-01-preview"], - "client": { - "name": "AppPlatformManagementClient", - "filename": "_app_platform_management_client", - "description": "REST API for Azure Spring Cloud.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "services": "ServicesOperations", - "config_servers": "ConfigServersOperations", - "monitoring_settings": "MonitoringSettingsOperations", - "apps": "AppsOperations", - "bindings": "BindingsOperations", - "certificates": "CertificatesOperations", - "custom_domains": "CustomDomainsOperations", - "deployments": "DeploymentsOperations", - "operations": "Operations", - "runtime_versions": "RuntimeVersionsOperations", - "skus": "SkusOperations" - } -} \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/py.typed b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2020_11_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/_metadata.json b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/_metadata.json deleted file mode 100644 index c8bb068cd9a..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2021-06-01-preview", - "total_api_version_list": ["2021-06-01-preview"], - "client": { - "name": "AppPlatformManagementClient", - "filename": "_app_platform_management_client", - "description": "REST API for Azure Spring Cloud.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "services": "ServicesOperations", - "config_servers": "ConfigServersOperations", - "monitoring_settings": "MonitoringSettingsOperations", - "apps": "AppsOperations", - "bindings": "BindingsOperations", - "certificates": "CertificatesOperations", - "custom_domains": "CustomDomainsOperations", - "deployments": "DeploymentsOperations", - "operations": "Operations", - "runtime_versions": "RuntimeVersionsOperations", - "skus": "SkusOperations" - } -} \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/py.typed b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2021_06_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/_app_platform_management_client.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/_app_platform_management_client.py index 731fd96b9ca..56650ef8a36 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/_app_platform_management_client.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/_app_platform_management_client.py @@ -22,7 +22,10 @@ from .operations import ServicesOperations from .operations import ConfigServersOperations from .operations import ConfigurationServicesOperations +from .operations import ServiceRegistriesOperations +from .operations import ServiceOperations from .operations import BuildServiceOperations +from .operations import BuildpacksBindingOperations from .operations import MonitoringSettingsOperations from .operations import AppsOperations from .operations import BindingsOperations @@ -44,8 +47,14 @@ class AppPlatformManagementClient(object): :vartype config_servers: azure.mgmt.appplatform.v2022_05_01_preview.operations.ConfigServersOperations :ivar configuration_services: ConfigurationServicesOperations operations :vartype configuration_services: azure.mgmt.appplatform.v2022_05_01_preview.operations.ConfigurationServicesOperations + :ivar service_registries: ServiceRegistriesOperations operations + :vartype service_registries: azure.mgmt.appplatform.v2022_05_01_preview.operations.ServiceRegistriesOperations + :ivar service: ServiceOperations operations + :vartype service: azure.mgmt.appplatform.v2022_05_01_preview.operations.ServiceOperations :ivar build_service: BuildServiceOperations operations :vartype build_service: azure.mgmt.appplatform.v2022_05_01_preview.operations.BuildServiceOperations + :ivar buildpacks_binding: BuildpacksBindingOperations operations + :vartype buildpacks_binding: azure.mgmt.appplatform.v2022_05_01_preview.operations.BuildpacksBindingOperations :ivar monitoring_settings: MonitoringSettingsOperations operations :vartype monitoring_settings: azure.mgmt.appplatform.v2022_05_01_preview.operations.MonitoringSettingsOperations :ivar apps: AppsOperations operations @@ -96,8 +105,14 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.configuration_services = ConfigurationServicesOperations( self._client, self._config, self._serialize, self._deserialize) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.service = ServiceOperations( + self._client, self._config, self._serialize, self._deserialize) self.build_service = BuildServiceOperations( self._client, self._config, self._serialize, self._deserialize) + self.buildpacks_binding = BuildpacksBindingOperations( + self._client, self._config, self._serialize, self._deserialize) self.monitoring_settings = MonitoringSettingsOperations( self._client, self._config, self._serialize, self._deserialize) self.apps = AppsOperations( diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py index 4987a719467..3e1e3034473 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py @@ -20,7 +20,10 @@ from .operations import ServicesOperations from .operations import ConfigServersOperations from .operations import ConfigurationServicesOperations +from .operations import ServiceRegistriesOperations +from .operations import ServiceOperations from .operations import BuildServiceOperations +from .operations import BuildpacksBindingOperations from .operations import MonitoringSettingsOperations from .operations import AppsOperations from .operations import BindingsOperations @@ -42,8 +45,14 @@ class AppPlatformManagementClient(object): :vartype config_servers: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.ConfigServersOperations :ivar configuration_services: ConfigurationServicesOperations operations :vartype configuration_services: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.ConfigurationServicesOperations + :ivar service_registries: ServiceRegistriesOperations operations + :vartype service_registries: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.ServiceRegistriesOperations + :ivar service: ServiceOperations operations + :vartype service: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.ServiceOperations :ivar build_service: BuildServiceOperations operations :vartype build_service: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.BuildServiceOperations + :ivar buildpacks_binding: BuildpacksBindingOperations operations + :vartype buildpacks_binding: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.BuildpacksBindingOperations :ivar monitoring_settings: MonitoringSettingsOperations operations :vartype monitoring_settings: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.MonitoringSettingsOperations :ivar apps: AppsOperations operations @@ -93,8 +102,14 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.configuration_services = ConfigurationServicesOperations( self._client, self._config, self._serialize, self._deserialize) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.service = ServiceOperations( + self._client, self._config, self._serialize, self._deserialize) self.build_service = BuildServiceOperations( self._client, self._config, self._serialize, self._deserialize) + self.buildpacks_binding = BuildpacksBindingOperations( + self._client, self._config, self._serialize, self._deserialize) self.monitoring_settings = MonitoringSettingsOperations( self._client, self._config, self._serialize, self._deserialize) self.apps = AppsOperations( diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/__init__.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/__init__.py index 0089c0e11aa..8858c1d09e8 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/__init__.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/__init__.py @@ -9,7 +9,10 @@ from ._services_operations import ServicesOperations from ._config_servers_operations import ConfigServersOperations from ._configuration_services_operations import ConfigurationServicesOperations +from ._service_registries_operations import ServiceRegistriesOperations +from ._service_operations import ServiceOperations from ._build_service_operations import BuildServiceOperations +from ._buildpacks_binding_operations import BuildpacksBindingOperations from ._monitoring_settings_operations import MonitoringSettingsOperations from ._apps_operations import AppsOperations from ._bindings_operations import BindingsOperations @@ -24,7 +27,10 @@ 'ServicesOperations', 'ConfigServersOperations', 'ConfigurationServicesOperations', + 'ServiceRegistriesOperations', + 'ServiceOperations', 'BuildServiceOperations', + 'BuildpacksBindingOperations', 'MonitoringSettingsOperations', 'AppsOperations', 'BindingsOperations', diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_buildpacks_binding_operations.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_buildpacks_binding_operations.py new file mode 100644 index 00000000000..ad31f079f64 --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_buildpacks_binding_operations.py @@ -0,0 +1,254 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BuildpacksBindingOperations: + """BuildpacksBindingOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + buildpacks_binding_name: str, + **kwargs: Any + ) -> "_models.BuildpacksBindingResource": + """Get a buildpacks binding by name. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :param build_service_name: The name of the build service resource. + :type build_service_name: str + :param buildpacks_binding_name: The name of the Buildpacks Binding Name. + :type buildpacks_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpacksBindingResource, or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpacksBindingResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + 'buildServiceName': self._serialize.url("build_service_name", build_service_name, 'str'), + 'buildpacksBindingName': self._serialize.url("buildpacks_binding_name", buildpacks_binding_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildservices/{buildServiceName}/buildpacksBindings/{buildpacksBindingName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + buildpacks_binding_name: str, + buildpacks_binding: "_models.BuildpacksBindingResource", + **kwargs: Any + ) -> "_models.BuildpacksBindingResource": + """Create or update a buildpacks binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :param build_service_name: The name of the build service resource. + :type build_service_name: str + :param buildpacks_binding_name: The name of the Buildpacks Binding Name. + :type buildpacks_binding_name: str + :param buildpacks_binding: The target buildpacks binding for the create or update operation. + :type buildpacks_binding: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpacksBindingResource, or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpacksBindingResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + 'buildServiceName': self._serialize.url("build_service_name", build_service_name, 'str'), + 'buildpacksBindingName': self._serialize.url("buildpacks_binding_name", buildpacks_binding_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(buildpacks_binding, 'BuildpacksBindingResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildservices/{buildServiceName}/buildpacksBindings/{buildpacksBindingName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + buildpacks_binding_name: str, + **kwargs: Any + ) -> None: + """Operation to delete a Buildpacks Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :param build_service_name: The name of the build service resource. + :type build_service_name: str + :param buildpacks_binding_name: The name of the Buildpacks Binding Name. + :type buildpacks_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + 'buildServiceName': self._serialize.url("build_service_name", build_service_name, 'str'), + 'buildpacksBindingName': self._serialize.url("buildpacks_binding_name", buildpacks_binding_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildservices/{buildServiceName}/buildpacksBindings/{buildpacksBindingName}'} # type: ignore diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_operations.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_operations.py new file mode 100644 index 00000000000..f70922c4384 --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_operations.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServiceOperations: + """ServiceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _registries_delete_initial( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self._registries_delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _registries_delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore + + async def begin_registries_delete( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._registries_delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_registries_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py new file mode 100644 index 00000000000..72013ca2b60 --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py @@ -0,0 +1,224 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServiceRegistriesOperations: + """ServiceRegistriesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> "_models.ServiceRegistryResource": + """Get the Service Registry and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceRegistryResource, or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> "_models.ServiceRegistryResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> AsyncLROPoller["_models.ServiceRegistryResource"]: + """Create the default Service Registry or update the existing Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceRegistryResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/__init__.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/__init__.py index cc326e4723c..7aca37be7fb 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/__init__.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/__init__.py @@ -29,6 +29,9 @@ from ._models_py3 import BuildServiceProperties from ._models_py3 import BuildServicePropertiesRuntimeState from ._models_py3 import BuildStageProperties + from ._models_py3 import BuildpacksBindingLaunchProperties + from ._models_py3 import BuildpacksBindingProperties + from ._models_py3 import BuildpacksBindingResource from ._models_py3 import CertificateProperties from ._models_py3 import CertificateResource from ._models_py3 import CertificateResourceCollection @@ -93,6 +96,10 @@ from ._models_py3 import ResourceSkuRestrictions from ._models_py3 import ResourceSkuZoneDetails from ._models_py3 import ResourceUploadDefinition + from ._models_py3 import ServiceRegistryInstance + from ._models_py3 import ServiceRegistryProperties + from ._models_py3 import ServiceRegistryResource + from ._models_py3 import ServiceRegistryRuntimeState from ._models_py3 import ServiceResource from ._models_py3 import ServiceResourceList from ._models_py3 import ServiceSpecification @@ -131,6 +138,9 @@ from ._models import BuildServiceProperties # type: ignore from ._models import BuildServicePropertiesRuntimeState # type: ignore from ._models import BuildStageProperties # type: ignore + from ._models import BuildpacksBindingLaunchProperties # type: ignore + from ._models import BuildpacksBindingProperties # type: ignore + from ._models import BuildpacksBindingResource # type: ignore from ._models import CertificateProperties # type: ignore from ._models import CertificateResource # type: ignore from ._models import CertificateResourceCollection # type: ignore @@ -195,6 +205,10 @@ from ._models import ResourceSkuRestrictions # type: ignore from ._models import ResourceSkuZoneDetails # type: ignore from ._models import ResourceUploadDefinition # type: ignore + from ._models import ServiceRegistryInstance # type: ignore + from ._models import ServiceRegistryProperties # type: ignore + from ._models import ServiceRegistryResource # type: ignore + from ._models import ServiceRegistryRuntimeState # type: ignore from ._models import ServiceResource # type: ignore from ._models import ServiceResourceList # type: ignore from ._models import ServiceSpecification # type: ignore @@ -213,6 +227,7 @@ from ._app_platform_management_client_enums import ( AppResourceProvisioningState, + BindingType, BuildResultProvisioningState, ConfigServerState, ConfigurationServiceProvisioningState, @@ -225,6 +240,7 @@ ProvisioningState, ResourceSkuRestrictionsReasonCode, ResourceSkuRestrictionsType, + ServiceRegistryProvisioningState, SkuScaleType, SupportedRuntimePlatform, SupportedRuntimeValue, @@ -255,6 +271,9 @@ 'BuildServiceProperties', 'BuildServicePropertiesRuntimeState', 'BuildStageProperties', + 'BuildpacksBindingLaunchProperties', + 'BuildpacksBindingProperties', + 'BuildpacksBindingResource', 'CertificateProperties', 'CertificateResource', 'CertificateResourceCollection', @@ -319,6 +338,10 @@ 'ResourceSkuRestrictions', 'ResourceSkuZoneDetails', 'ResourceUploadDefinition', + 'ServiceRegistryInstance', + 'ServiceRegistryProperties', + 'ServiceRegistryResource', + 'ServiceRegistryRuntimeState', 'ServiceResource', 'ServiceResourceList', 'ServiceSpecification', @@ -335,6 +358,7 @@ 'UserSourceInfo', 'ValidationMessages', 'AppResourceProvisioningState', + 'BindingType', 'BuildResultProvisioningState', 'ConfigServerState', 'ConfigurationServiceProvisioningState', @@ -347,6 +371,7 @@ 'ProvisioningState', 'ResourceSkuRestrictionsReasonCode', 'ResourceSkuRestrictionsType', + 'ServiceRegistryProvisioningState', 'SkuScaleType', 'SupportedRuntimePlatform', 'SupportedRuntimeValue', diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py index c0ec9c216b5..c965e2789a1 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py @@ -36,6 +36,12 @@ class AppResourceProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, UPDATING = "Updating" DELETING = "Deleting" +class BindingType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Buildpacks Binding Type + """ + + APPLICATION_INSIGHTS = "ApplicationInsights" + class BuildResultProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the KPack build result """ @@ -147,6 +153,16 @@ class ResourceSkuRestrictionsType(with_metaclass(_CaseInsensitiveEnumMeta, str, LOCATION = "Location" ZONE = "Zone" +class ServiceRegistryProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """State of the Service Registry. + """ + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + class SkuScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the type of the scale. """ diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models.py index 0a928ee7331..f4423f72677 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models.py @@ -502,6 +502,95 @@ def __init__( self.tag = kwargs.get('tag', None) +class BuildpacksBindingLaunchProperties(msrest.serialization.Model): + """Buildpacks Binding Launch Properties. + + :param properties: Non-sensitive properties for launchProperties. + :type properties: dict[str, str] + :param secrets: Sensitive properties for launchProperties. + :type secrets: dict[str, str] + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': '{str}'}, + 'secrets': {'key': 'secrets', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(BuildpacksBindingLaunchProperties, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + self.secrets = kwargs.get('secrets', None) + + +class BuildpacksBindingProperties(msrest.serialization.Model): + """Properties of a buildpacks binding. + + :param binding_type: Buildpacks Binding Type. Possible values include: "ApplicationInsights". + :type binding_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingType + :param launch_properties: The object describes the buildpacks binding launch properties. + :type launch_properties: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingLaunchProperties + """ + + _attribute_map = { + 'binding_type': {'key': 'bindingType', 'type': 'str'}, + 'launch_properties': {'key': 'launchProperties', 'type': 'BuildpacksBindingLaunchProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(BuildpacksBindingProperties, self).__init__(**kwargs) + self.binding_type = kwargs.get('binding_type', None) + self.launch_properties = kwargs.get('launch_properties', None) + + +class BuildpacksBindingResource(ProxyResource): + """Buildpacks Binding Resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param properties: Properties of a buildpacks binding. + :type properties: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BuildpacksBindingProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + super(BuildpacksBindingResource, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + self.system_data = None + + class BuildProperties(msrest.serialization.Model): """Build resource properties payload. @@ -1436,9 +1525,8 @@ class ConfigurationServiceProperties(msrest.serialization.Model): :ivar runtime_state: Runtime state of the Application Configuration Service. :vartype runtime_state: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceRuntimeState - :param configuration_service_settings: The settings of Application Configuration Service. - :type configuration_service_settings: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings + :param settings: The settings of Application Configuration Service. + :type settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings """ _validation = { @@ -1449,7 +1537,7 @@ class ConfigurationServiceProperties(msrest.serialization.Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'runtime_state': {'key': 'runtimeState', 'type': 'ConfigurationServiceRuntimeState'}, - 'configuration_service_settings': {'key': 'configurationServiceSettings', 'type': 'ConfigurationServiceSettings'}, + 'settings': {'key': 'settings', 'type': 'ConfigurationServiceSettings'}, } def __init__( @@ -1459,7 +1547,7 @@ def __init__( super(ConfigurationServiceProperties, self).__init__(**kwargs) self.provisioning_state = None self.runtime_state = None - self.configuration_service_settings = kwargs.get('configuration_service_settings', None) + self.settings = kwargs.get('settings', None) class ConfigurationServiceResource(ProxyResource): @@ -1543,13 +1631,13 @@ def __init__( class ConfigurationServiceSettings(msrest.serialization.Model): """The settings of Application Configuration Service. - :param git_properties: Property of git environment. - :type git_properties: + :param git_property: Property of git environment. + :type git_property: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceGitProperty """ _attribute_map = { - 'git_properties': {'key': 'gitProperties', 'type': 'ConfigurationServiceGitProperty'}, + 'git_property': {'key': 'gitProperty', 'type': 'ConfigurationServiceGitProperty'}, } def __init__( @@ -1557,7 +1645,7 @@ def __init__( **kwargs ): super(ConfigurationServiceSettings, self).__init__(**kwargs) - self.git_properties = kwargs.get('git_properties', None) + self.git_property = kwargs.get('git_property', None) class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): @@ -1941,14 +2029,6 @@ def __init__( class DeploymentSettings(msrest.serialization.Model): """Deployment settings payload. - :param cpu: Required CPU. This should be 1 for Basic tier, and in range [1, 4] for Standard - tier. This is deprecated starting from API version 2022-05-01-preview. Please use the - resourceRequests field to set the CPU size. - :type cpu: int - :param memory_in_gb: Required Memory size in GB. This should be in range [1, 2] for Basic tier, - and in range [1, 8] for Standard tier. This is deprecated starting from API version - 2022-05-01-preview. Please use the resourceRequests field to set the the memory size. - :type memory_in_gb: int :param resource_requests: The requested resource quantity for required CPU and Memory. It is recommended that using this field to represent the required CPU and Memory, the old field cpu and memoryInGB will be deprecated later. @@ -1960,8 +2040,6 @@ class DeploymentSettings(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'int'}, 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, 'addon_configs': {'key': 'addonConfigs', 'type': '{AddonProfile}'}, @@ -1972,8 +2050,6 @@ def __init__( **kwargs ): super(DeploymentSettings, self).__init__(**kwargs) - self.cpu = kwargs.get('cpu', 1) - self.memory_in_gb = kwargs.get('memory_in_gb', 1) self.resource_requests = kwargs.get('resource_requests', None) self.environment_variables = kwargs.get('environment_variables', None) self.addon_configs = kwargs.get('addon_configs', None) @@ -3044,6 +3120,146 @@ def __init__( self.upload_url = kwargs.get('upload_url', None) +class ServiceRegistryInstance(msrest.serialization.Model): + """Collection of instances belong to the Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Service Registry instance. + :vartype name: str + :ivar status: Status of the Service Registry instance. + :vartype status: str + """ + + _validation = { + 'name': {'readonly': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryInstance, self).__init__(**kwargs) + self.name = None + self.status = None + + +class ServiceRegistryProperties(msrest.serialization.Model): + """Service Registry properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Service Registry. Possible values include: "Creating", + "Updating", "Succeeded", "Failed", "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryProvisioningState + :ivar runtime_state: Runtime state of the Service Registry. + :vartype runtime_state: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryRuntimeState + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'runtime_state': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'runtime_state': {'key': 'runtimeState', 'type': 'ServiceRegistryRuntimeState'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.runtime_state = None + + +class ServiceRegistryResource(ProxyResource): + """Service Registry resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param properties: Service Registry properties payload. + :type properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ServiceRegistryProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryResource, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class ServiceRegistryRuntimeState(msrest.serialization.Model): + """Runtime state of the Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Service Registry instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Service Registry instance. + :vartype memory: str + :ivar instance_count: Instance count of the Service Registry. + :vartype instance_count: int + :ivar instances: Collection of instances belong to the Service Registry. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryInstance] + """ + + _validation = { + 'cpu': {'readonly': True}, + 'memory': {'readonly': True}, + 'instance_count': {'readonly': True}, + 'instances': {'readonly': True}, + } + + _attribute_map = { + 'cpu': {'key': 'cpu', 'type': 'str'}, + 'memory': {'key': 'memory', 'type': 'str'}, + 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + 'instances': {'key': 'instances', 'type': '[ServiceRegistryInstance]'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryRuntimeState, self).__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + self.instances = None + + class TrackedResource(Resource): """The resource model definition for a ARM tracked top level resource. diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models_py3.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models_py3.py index 72da6dd6a41..0724046f270 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models_py3.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/models/_models_py3.py @@ -545,6 +545,103 @@ def __init__( self.tag = tag +class BuildpacksBindingLaunchProperties(msrest.serialization.Model): + """Buildpacks Binding Launch Properties. + + :param properties: Non-sensitive properties for launchProperties. + :type properties: dict[str, str] + :param secrets: Sensitive properties for launchProperties. + :type secrets: dict[str, str] + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': '{str}'}, + 'secrets': {'key': 'secrets', 'type': '{str}'}, + } + + def __init__( + self, + *, + properties: Optional[Dict[str, str]] = None, + secrets: Optional[Dict[str, str]] = None, + **kwargs + ): + super(BuildpacksBindingLaunchProperties, self).__init__(**kwargs) + self.properties = properties + self.secrets = secrets + + +class BuildpacksBindingProperties(msrest.serialization.Model): + """Properties of a buildpacks binding. + + :param binding_type: Buildpacks Binding Type. Possible values include: "ApplicationInsights". + :type binding_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingType + :param launch_properties: The object describes the buildpacks binding launch properties. + :type launch_properties: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingLaunchProperties + """ + + _attribute_map = { + 'binding_type': {'key': 'bindingType', 'type': 'str'}, + 'launch_properties': {'key': 'launchProperties', 'type': 'BuildpacksBindingLaunchProperties'}, + } + + def __init__( + self, + *, + binding_type: Optional[Union[str, "BindingType"]] = None, + launch_properties: Optional["BuildpacksBindingLaunchProperties"] = None, + **kwargs + ): + super(BuildpacksBindingProperties, self).__init__(**kwargs) + self.binding_type = binding_type + self.launch_properties = launch_properties + + +class BuildpacksBindingResource(ProxyResource): + """Buildpacks Binding Resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param properties: Properties of a buildpacks binding. + :type properties: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BuildpacksBindingProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + properties: Optional["BuildpacksBindingProperties"] = None, + **kwargs + ): + super(BuildpacksBindingResource, self).__init__(**kwargs) + self.properties = properties + self.system_data = None + + class BuildProperties(msrest.serialization.Model): """Build resource properties payload. @@ -1562,9 +1659,8 @@ class ConfigurationServiceProperties(msrest.serialization.Model): :ivar runtime_state: Runtime state of the Application Configuration Service. :vartype runtime_state: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceRuntimeState - :param configuration_service_settings: The settings of Application Configuration Service. - :type configuration_service_settings: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings + :param settings: The settings of Application Configuration Service. + :type settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings """ _validation = { @@ -1575,19 +1671,19 @@ class ConfigurationServiceProperties(msrest.serialization.Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'runtime_state': {'key': 'runtimeState', 'type': 'ConfigurationServiceRuntimeState'}, - 'configuration_service_settings': {'key': 'configurationServiceSettings', 'type': 'ConfigurationServiceSettings'}, + 'settings': {'key': 'settings', 'type': 'ConfigurationServiceSettings'}, } def __init__( self, *, - configuration_service_settings: Optional["ConfigurationServiceSettings"] = None, + settings: Optional["ConfigurationServiceSettings"] = None, **kwargs ): super(ConfigurationServiceProperties, self).__init__(**kwargs) self.provisioning_state = None self.runtime_state = None - self.configuration_service_settings = configuration_service_settings + self.settings = settings class ConfigurationServiceResource(ProxyResource): @@ -1673,23 +1769,23 @@ def __init__( class ConfigurationServiceSettings(msrest.serialization.Model): """The settings of Application Configuration Service. - :param git_properties: Property of git environment. - :type git_properties: + :param git_property: Property of git environment. + :type git_property: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceGitProperty """ _attribute_map = { - 'git_properties': {'key': 'gitProperties', 'type': 'ConfigurationServiceGitProperty'}, + 'git_property': {'key': 'gitProperty', 'type': 'ConfigurationServiceGitProperty'}, } def __init__( self, *, - git_properties: Optional["ConfigurationServiceGitProperty"] = None, + git_property: Optional["ConfigurationServiceGitProperty"] = None, **kwargs ): super(ConfigurationServiceSettings, self).__init__(**kwargs) - self.git_properties = git_properties + self.git_property = git_property class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): @@ -2105,14 +2201,6 @@ def __init__( class DeploymentSettings(msrest.serialization.Model): """Deployment settings payload. - :param cpu: Required CPU. This should be 1 for Basic tier, and in range [1, 4] for Standard - tier. This is deprecated starting from API version 2022-05-01-preview. Please use the - resourceRequests field to set the CPU size. - :type cpu: int - :param memory_in_gb: Required Memory size in GB. This should be in range [1, 2] for Basic tier, - and in range [1, 8] for Standard tier. This is deprecated starting from API version - 2022-05-01-preview. Please use the resourceRequests field to set the the memory size. - :type memory_in_gb: int :param resource_requests: The requested resource quantity for required CPU and Memory. It is recommended that using this field to represent the required CPU and Memory, the old field cpu and memoryInGB will be deprecated later. @@ -2124,8 +2212,6 @@ class DeploymentSettings(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'int'}, 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, 'addon_configs': {'key': 'addonConfigs', 'type': '{AddonProfile}'}, @@ -2134,16 +2220,12 @@ class DeploymentSettings(msrest.serialization.Model): def __init__( self, *, - cpu: Optional[int] = 1, - memory_in_gb: Optional[int] = 1, resource_requests: Optional["ResourceRequests"] = None, environment_variables: Optional[Dict[str, str]] = None, addon_configs: Optional[Dict[str, "AddonProfile"]] = None, **kwargs ): super(DeploymentSettings, self).__init__(**kwargs) - self.cpu = cpu - self.memory_in_gb = memory_in_gb self.resource_requests = resource_requests self.environment_variables = environment_variables self.addon_configs = addon_configs @@ -3342,6 +3424,148 @@ def __init__( self.upload_url = upload_url +class ServiceRegistryInstance(msrest.serialization.Model): + """Collection of instances belong to the Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Service Registry instance. + :vartype name: str + :ivar status: Status of the Service Registry instance. + :vartype status: str + """ + + _validation = { + 'name': {'readonly': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryInstance, self).__init__(**kwargs) + self.name = None + self.status = None + + +class ServiceRegistryProperties(msrest.serialization.Model): + """Service Registry properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Service Registry. Possible values include: "Creating", + "Updating", "Succeeded", "Failed", "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryProvisioningState + :ivar runtime_state: Runtime state of the Service Registry. + :vartype runtime_state: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryRuntimeState + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'runtime_state': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'runtime_state': {'key': 'runtimeState', 'type': 'ServiceRegistryRuntimeState'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.runtime_state = None + + +class ServiceRegistryResource(ProxyResource): + """Service Registry resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param properties: Service Registry properties payload. + :type properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ServiceRegistryProperties'}, + } + + def __init__( + self, + *, + properties: Optional["ServiceRegistryProperties"] = None, + **kwargs + ): + super(ServiceRegistryResource, self).__init__(**kwargs) + self.properties = properties + + +class ServiceRegistryRuntimeState(msrest.serialization.Model): + """Runtime state of the Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Service Registry instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Service Registry instance. + :vartype memory: str + :ivar instance_count: Instance count of the Service Registry. + :vartype instance_count: int + :ivar instances: Collection of instances belong to the Service Registry. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryInstance] + """ + + _validation = { + 'cpu': {'readonly': True}, + 'memory': {'readonly': True}, + 'instance_count': {'readonly': True}, + 'instances': {'readonly': True}, + } + + _attribute_map = { + 'cpu': {'key': 'cpu', 'type': 'str'}, + 'memory': {'key': 'memory', 'type': 'str'}, + 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + 'instances': {'key': 'instances', 'type': '[ServiceRegistryInstance]'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceRegistryRuntimeState, self).__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + self.instances = None + + class TrackedResource(Resource): """The resource model definition for a ARM tracked top level resource. diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/__init__.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/__init__.py index 0089c0e11aa..8858c1d09e8 100644 --- a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/__init__.py +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/__init__.py @@ -9,7 +9,10 @@ from ._services_operations import ServicesOperations from ._config_servers_operations import ConfigServersOperations from ._configuration_services_operations import ConfigurationServicesOperations +from ._service_registries_operations import ServiceRegistriesOperations +from ._service_operations import ServiceOperations from ._build_service_operations import BuildServiceOperations +from ._buildpacks_binding_operations import BuildpacksBindingOperations from ._monitoring_settings_operations import MonitoringSettingsOperations from ._apps_operations import AppsOperations from ._bindings_operations import BindingsOperations @@ -24,7 +27,10 @@ 'ServicesOperations', 'ConfigServersOperations', 'ConfigurationServicesOperations', + 'ServiceRegistriesOperations', + 'ServiceOperations', 'BuildServiceOperations', + 'BuildpacksBindingOperations', 'MonitoringSettingsOperations', 'AppsOperations', 'BindingsOperations', diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_buildpacks_binding_operations.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_buildpacks_binding_operations.py new file mode 100644 index 00000000000..c8f01128e8f --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_buildpacks_binding_operations.py @@ -0,0 +1,261 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BuildpacksBindingOperations(object): + """BuildpacksBindingOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + service_name, # type: str + build_service_name, # type: str + buildpacks_binding_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.BuildpacksBindingResource" + """Get a buildpacks binding by name. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :param build_service_name: The name of the build service resource. + :type build_service_name: str + :param buildpacks_binding_name: The name of the Buildpacks Binding Name. + :type buildpacks_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpacksBindingResource, or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpacksBindingResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + 'buildServiceName': self._serialize.url("build_service_name", build_service_name, 'str'), + 'buildpacksBindingName': self._serialize.url("buildpacks_binding_name", buildpacks_binding_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildservices/{buildServiceName}/buildpacksBindings/{buildpacksBindingName}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + build_service_name, # type: str + buildpacks_binding_name, # type: str + buildpacks_binding, # type: "_models.BuildpacksBindingResource" + **kwargs # type: Any + ): + # type: (...) -> "_models.BuildpacksBindingResource" + """Create or update a buildpacks binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :param build_service_name: The name of the build service resource. + :type build_service_name: str + :param buildpacks_binding_name: The name of the Buildpacks Binding Name. + :type buildpacks_binding_name: str + :param buildpacks_binding: The target buildpacks binding for the create or update operation. + :type buildpacks_binding: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpacksBindingResource, or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksBindingResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpacksBindingResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + 'buildServiceName': self._serialize.url("build_service_name", build_service_name, 'str'), + 'buildpacksBindingName': self._serialize.url("buildpacks_binding_name", buildpacks_binding_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(buildpacks_binding, 'BuildpacksBindingResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('BuildpacksBindingResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildservices/{buildServiceName}/buildpacksBindings/{buildpacksBindingName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + service_name, # type: str + build_service_name, # type: str + buildpacks_binding_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Operation to delete a Buildpacks Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :param build_service_name: The name of the build service resource. + :type build_service_name: str + :param buildpacks_binding_name: The name of the Buildpacks Binding Name. + :type buildpacks_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + 'buildServiceName': self._serialize.url("build_service_name", build_service_name, 'str'), + 'buildpacksBindingName': self._serialize.url("buildpacks_binding_name", buildpacks_binding_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildservices/{buildServiceName}/buildpacksBindings/{buildpacksBindingName}'} # type: ignore diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_operations.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_operations.py new file mode 100644 index 00000000000..181f5bd64fd --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_operations.py @@ -0,0 +1,158 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ServiceOperations(object): + """ServiceOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _registries_delete_initial( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self._registries_delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _registries_delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore + + def begin_registries_delete( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Disable the default Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._registries_delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_registries_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore diff --git a/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py new file mode 100644 index 00000000000..91878c6cbe2 --- /dev/null +++ b/src/spring-cloud/azext_spring_cloud/vendored_sdks/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py @@ -0,0 +1,231 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ServiceRegistriesOperations(object): + """ServiceRegistriesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ServiceRegistryResource" + """Get the Service Registry and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceRegistryResource, or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ServiceRegistryResource" + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-05-01-preview" + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ServiceRegistryResource"] + """Create the default Service Registry or update the existing Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param service_name: The name of the Service resource. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceRegistryResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/default'} # type: ignore From 3cf14ef4bf7679e6bfde302c2cb84c36a218ff38 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 21:52:13 +0800 Subject: [PATCH 37/44] use get_client from utils_enterprise to simplify the code --- .../azext_spring_cloud/_validators_enterprise.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index e04f3a60065..839f5b39d38 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -8,7 +8,6 @@ from re import match from azure.cli.core.util import CLIError from azure.cli.core.commands.validators import validate_tag -from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.core.exceptions import ResourceNotFoundError from knack.log import get_logger from ._enterprise import DEFAULT_BUILD_SERVICE_NAME @@ -16,10 +15,7 @@ validate_cpu as validate_and_normalize_cpu, validate_memory as validate_and_normalize_memory) from ._util_enterprise import ( - is_enterprise_tier -) -from .vendored_sdks.appplatform.v2022_05_01_preview import ( - AppPlatformManagementClient as AppPlatformManagementClient_20220501preview + is_enterprise_tier, get_client ) @@ -131,7 +127,7 @@ def validate_buildpacks_binding_secrets(namespace): def enterprise_only_and_binding_not_exist(cmd, namespace): only_support_enterprise(cmd, namespace) - client = get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient_20220501preview) + client = get_client(cmd) _validate_binding_not_exists(client, namespace.resource_group, namespace.service, @@ -140,7 +136,7 @@ def enterprise_only_and_binding_not_exist(cmd, namespace): def enterprise_only_and_binding_exist(cmd, namespace): only_support_enterprise(cmd, namespace) - client = get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient_20220501preview) + client = get_client(cmd) _validate_binding_exists(client, namespace.resource_group, namespace.service, From 0ff695dde69029a304c64c0e2838ffdcbcfb22e7 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 22:10:09 +0800 Subject: [PATCH 38/44] remove customized exception handling --- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 3ff4698621b..2f7a22615a7 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -23,11 +23,7 @@ def buildpacks_binding_set(cmd, client, resource_group, service, def buildpacks_binding_show(cmd, client, resource_group, service, name): - try: - return client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, name) - except ResourceNotFoundError as e: - raise CLIError("Buildpacks Binding {} is not existed in resource group {}, service {}" - .format(name, resource_group, service)) + return client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, name) def buildpacks_binding_delete(cmd, client, resource_group, service, name): From 03f9f2924ddb0c405f2cf89870145710bae4450e Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 22:10:59 +0800 Subject: [PATCH 39/44] remove un-used method --- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index 2f7a22615a7..f88e9820b63 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -45,7 +45,3 @@ def _create_or_update_buildpacks_binding(client, resource_group, service, name, DEFAULT_BUILD_SERVICE_NAME, name, binding_resource) - - -def _get_buildpacks_binding(client, resource_group, service, binding_name): - return client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) From e812bf1ebaade7142547d1309b328411e8971ea9 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 22:18:04 +0800 Subject: [PATCH 40/44] union create and set commands --- .../azext_spring_cloud/buildpacks_binding.py | 27 ++++++------------- .../azext_spring_cloud/commands.py | 5 ++-- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index f88e9820b63..ae001d9e1bf 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -10,16 +10,14 @@ from knack.util import CLIError -def buildpacks_binding_create(cmd, client, resource_group, service, - name, type, properties=None, secrets=None): - return _create_or_update_buildpacks_binding(client, resource_group, service, name, - type, properties, secrets) - - -def buildpacks_binding_set(cmd, client, resource_group, service, - name, type, properties=None, secrets=None): - return _create_or_update_buildpacks_binding(client, resource_group, service, name, - type, properties, secrets) +def create_or_update_buildpacks_binding(cmd, client, resource_group, service, + name, type, properties=None, secrets=None): + binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) + return client.buildpacks_binding.create_or_update(resource_group, + service, + DEFAULT_BUILD_SERVICE_NAME, + name, + binding_resource) def buildpacks_binding_show(cmd, client, resource_group, service, name): @@ -36,12 +34,3 @@ def _build_buildpacks_binding_resource(binding_type, properties_dict, secrets_di binding_properties = models.BuildpacksBindingProperties(binding_type=binding_type, launch_properties=launch_properties) return models.BuildpacksBindingResource(properties=binding_properties) - - -def _create_or_update_buildpacks_binding(client, resource_group, service, name, type, properties, secrets): - binding_resource = _build_buildpacks_binding_resource(type, properties, secrets) - return client.buildpacks_binding.create_or_update(resource_group, - service, - DEFAULT_BUILD_SERVICE_NAME, - name, - binding_resource) diff --git a/src/spring-cloud/azext_spring_cloud/commands.py b/src/spring-cloud/azext_spring_cloud/commands.py index 33e244bd3d1..3c758928f1b 100644 --- a/src/spring-cloud/azext_spring_cloud/commands.py +++ b/src/spring-cloud/azext_spring_cloud/commands.py @@ -179,8 +179,9 @@ def load_command_table(self, _): with self.command_group('spring-cloud build-service buildpacks-binding', custom_command_type=buildpacks_binding_cmd_group, exception_handler=handle_asc_exception) as g: - g.custom_command('create', 'buildpacks_binding_create') - g.custom_command('set', 'buildpacks_binding_set') + # create and set commands are differentiate by their parameter validators + g.custom_command('create', 'create_or_update_buildpacks_binding') + g.custom_command('set', 'create_or_update_buildpacks_binding') g.custom_command('show', 'buildpacks_binding_show') g.custom_command('delete', 'buildpacks_binding_delete') From a4710b5bee249383f70ca7e759137c679837a1e0 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 22:36:02 +0800 Subject: [PATCH 41/44] fix for style check --- .../azext_spring_cloud/_validators_enterprise.py | 6 +++--- src/spring-cloud/azext_spring_cloud/buildpacks_binding.py | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 839f5b39d38..4b2e6000e6f 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -34,7 +34,7 @@ So there are at most 38 chars for build_service_name and buildpacks_binding_name in total. We leave 19 character each for build_service_name and buildpacks_binding_name """ -BUILDPACKS_BINDING_NAME_REGEX_PATTTERN=r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]{0,17}[a-zA-Z]$)" +BUILDPACKS_BINDING_NAME_REGEX_PATTTERN = r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]{0,17}[a-zA-Z]$)" logger = get_logger(__name__) @@ -153,7 +153,7 @@ def _validate_binding_not_exists(client, resource_group, service, binding_name): raise CLIError('Buildpacks Binding {} already exists ' 'in resource group {}, service {}. You can edit it by set command.' .format(binding_name, resource_group, service)) - except ResourceNotFoundError as e: + except ResourceNotFoundError: # Excepted case pass @@ -161,7 +161,7 @@ def _validate_binding_not_exists(client, resource_group, service, binding_name): def _validate_binding_exists(client, resource_group, service, binding_name): try: client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) - except ResourceNotFoundError as e: + except ResourceNotFoundError: raise CLIError('Buildpacks Binding {} does not exist ' 'in resource group {}, service {}. Please create before set.' .format(binding_name, resource_group, service)) diff --git a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py index ae001d9e1bf..3d4987ae849 100644 --- a/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py +++ b/src/spring-cloud/azext_spring_cloud/buildpacks_binding.py @@ -6,8 +6,6 @@ # pylint: disable=wrong-import-order from ._enterprise import DEFAULT_BUILD_SERVICE_NAME from .vendored_sdks.appplatform.v2022_05_01_preview import models -from azure.core.exceptions import ResourceNotFoundError -from knack.util import CLIError def create_or_update_buildpacks_binding(cmd, client, resource_group, service, From 42f450dbaa419f70729a6f2cfb10a2863d80c0e8 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Fri, 13 Aug 2021 22:56:50 +0800 Subject: [PATCH 42/44] remove buildpacks binding name validation and delegate to RP --- .../azext_spring_cloud/_params.py | 4 +-- .../_validators_enterprise.py | 27 ------------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 90a310f88a8..517c9bce8da 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -14,7 +14,7 @@ validate_tracing_parameters, validate_app_insights_parameters, validate_java_agent_parameters, validate_instance_count) from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, - validate_buildpacks_binding_name, validate_buildpacks_binding_properties, + validate_buildpacks_binding_properties, validate_buildpacks_binding_secrets, only_support_enterprise, enterprise_only_and_binding_not_exist, enterprise_only_and_binding_exist, validate_git_uri, validate_acs_patterns) @@ -353,7 +353,7 @@ def prepare_logs_argument(c): 'spring-cloud build-service buildpacks-binding show', 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: - c.argument('name', help='Name for buildpacks binding.', validator=validate_buildpacks_binding_name) + c.argument('name', help='Name for buildpacks binding.') for scope in ['spring-cloud build-service buildpacks-binding show', 'spring-cloud build-service buildpacks-binding delete']: diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index 4b2e6000e6f..c61fe6fc010 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -19,23 +19,6 @@ ) -""" -Define the binding name of buildpacks. The binding name have some restrictions from kpack as below. - -At most 63 chars. -Have one fixed prefix binding-metadata- 17 char, only 46 chars left. -Must consist of alphabetic characters or '-', and must start and end with an alphabetic character - -We need encode build_service_name, buildpacks_binding_name and type. -We need 2 '-' for separator, 44 chars left. -We need 2 int value for type, 42 chars left. -We need 2 prefix number for encoding prefix for build_service_name and buildpacks_binding_name, 38 char left. - -So there are at most 38 chars for build_service_name and buildpacks_binding_name in total. -We leave 19 character each for build_service_name and buildpacks_binding_name -""" -BUILDPACKS_BINDING_NAME_REGEX_PATTTERN = r"(^[a-zA-Z]$|^[a-zA-Z][-a-zA-Z0-9]{0,17}[a-zA-Z]$)" - logger = get_logger(__name__) def only_support_enterprise(cmd, namespace): @@ -97,16 +80,6 @@ def _is_valid_app_and_profile_name(pattern): return len(parts) == 2 and _is_valid_app_name(parts[0]) and _is_valid_profile_name(parts[1]) -def validate_buildpacks_binding_name(namespace): - if not _is_valid_buildpacks_binding_name_pattern(namespace.name): - raise CLIError("Buildpacks Binding name should follow pattern {}" - .format(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN)) - - -def _is_valid_buildpacks_binding_name_pattern(name): - return match(BUILDPACKS_BINDING_NAME_REGEX_PATTTERN, name) is not None - - def validate_buildpacks_binding_properties(namespace): """ Extracts multiple space-separated properties in key[=value] format """ if isinstance(namespace.properties, list): From 93c94ff860025ce448290382adbdadcb3db81c56 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Sun, 15 Aug 2021 21:37:18 +0800 Subject: [PATCH 43/44] simplify argument type --- .../azext_spring_cloud/_params.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 517c9bce8da..fb8ca089be5 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -31,15 +31,6 @@ validator=validate_env, help="Space-separated environment variables in 'key[=value]' format.", nargs='*') service_name_type = CLIArgumentType(options_list=['--service', '-s'], help='Name of Azure Spring Cloud, you can configure the default service using az configure --defaults spring-cloud=.', configured_default='spring-cloud') app_name_type = CLIArgumentType(help='App name, you can configure the default app using az configure --defaults spring-cloud-app=.', validator=validate_app_name, configured_default='spring-cloud-app') -buildpacks_binding_properties_type = CLIArgumentType(help='Non-sensitive properties for launchProperties. ' - 'Format "key[=value]".', - nargs='*', - validator=validate_buildpacks_binding_properties) -buildpacks_binding_secrets_type = CLIArgumentType(help='Sensitive properties for launchProperties. ' - 'Once put, it will be encrypted and never return to user. ' - 'Format "key[=value]".', - nargs="*", - validator=validate_buildpacks_binding_secrets) # pylint: disable=too-many-statements @@ -344,9 +335,15 @@ def prepare_logs_argument(c): arg_type=get_enum_type(v20220501_preview_AppPlatformEnums.BindingType), help='Required type for buildpacks binding.') c.argument('properties', - buildpacks_binding_properties_type) + help='Non-sensitive properties for launchProperties. Format "key[=value]".', + nargs='*', + validator=validate_buildpacks_binding_properties) c.argument('secrets', - buildpacks_binding_secrets_type) + help='Sensitive properties for launchProperties. ' + 'Once put, it will be encrypted and never return to user. ' + 'Format "key[=value]".', + nargs='*', + validator=validate_buildpacks_binding_secrets) for scope in ['spring-cloud build-service buildpacks-binding create', 'spring-cloud build-service buildpacks-binding set', From 516b7a124d6314fb725e3cbf1e6a876fa779af79 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Sun, 15 Aug 2021 22:11:14 +0800 Subject: [PATCH 44/44] enhance validator for create/set --- .../azext_spring_cloud/_params.py | 21 +++++----- .../_validators_enterprise.py | 39 ++++++------------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index fb8ca089be5..5fb668a82a7 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -16,7 +16,7 @@ from ._validators_enterprise import (validate_config_file_patterns, validate_cpu, validate_memory, validate_buildpacks_binding_properties, validate_buildpacks_binding_secrets, only_support_enterprise, - enterprise_only_and_binding_not_exist, enterprise_only_and_binding_exist, + validate_buildpacks_binding_not_exist, validate_buildpacks_binding_exist, validate_git_uri, validate_acs_patterns) from ._utils import ApiType @@ -345,20 +345,17 @@ def prepare_logs_argument(c): nargs='*', validator=validate_buildpacks_binding_secrets) + for scope in ['spring-cloud build-service buildpacks-binding create']: + with self.argument_context(scope) as c: + c.argument('name', help='Name for buildpacks binding.', validator=validate_buildpacks_binding_not_exist) + + for scope in ['spring-cloud build-service buildpacks-binding set']: + with self.argument_context(scope) as c: + c.argument('name', help='Name for buildpacks binding.', validator=validate_buildpacks_binding_exist) + for scope in ['spring-cloud build-service buildpacks-binding create', 'spring-cloud build-service buildpacks-binding set', 'spring-cloud build-service buildpacks-binding show', 'spring-cloud build-service buildpacks-binding delete']: - with self.argument_context(scope) as c: - c.argument('name', help='Name for buildpacks binding.') - - for scope in ['spring-cloud build-service buildpacks-binding show', - 'spring-cloud build-service buildpacks-binding delete']: with self.argument_context(scope) as c: c.argument('service', service_name_type, validator=only_support_enterprise) - - with self.argument_context('spring-cloud build-service buildpacks-binding create') as c: - c.argument('service', service_name_type, validator=enterprise_only_and_binding_not_exist) - - with self.argument_context('spring-cloud build-service buildpacks-binding set') as c: - c.argument('service', service_name_type, validator=enterprise_only_and_binding_exist) diff --git a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py index c61fe6fc010..f7789f7f40e 100644 --- a/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_validators_enterprise.py @@ -98,30 +98,13 @@ def validate_buildpacks_binding_secrets(namespace): namespace.secrets = secrets_dict -def enterprise_only_and_binding_not_exist(cmd, namespace): - only_support_enterprise(cmd, namespace) +def validate_buildpacks_binding_not_exist(cmd, namespace): client = get_client(cmd) - _validate_binding_not_exists(client, - namespace.resource_group, - namespace.service, - namespace.name) - - -def enterprise_only_and_binding_exist(cmd, namespace): - only_support_enterprise(cmd, namespace) - client = get_client(cmd) - _validate_binding_exists(client, - namespace.resource_group, - namespace.service, - namespace.name) - - -def _validate_binding_not_exists(client, resource_group, service, binding_name): try: - binding_resource = client.buildpacks_binding.get(resource_group, - service, + binding_resource = client.buildpacks_binding.get(namespace.resource_group, + namespace.service, DEFAULT_BUILD_SERVICE_NAME, - binding_name) + namespace.name) if binding_resource is not None: raise CLIError('Buildpacks Binding {} already exists ' 'in resource group {}, service {}. You can edit it by set command.' @@ -131,10 +114,10 @@ def _validate_binding_not_exists(client, resource_group, service, binding_name): pass -def _validate_binding_exists(client, resource_group, service, binding_name): - try: - client.buildpacks_binding.get(resource_group, service, DEFAULT_BUILD_SERVICE_NAME, binding_name) - except ResourceNotFoundError: - raise CLIError('Buildpacks Binding {} does not exist ' - 'in resource group {}, service {}. Please create before set.' - .format(binding_name, resource_group, service)) +def validate_buildpacks_binding_exist(cmd, namespace): + client = get_client(cmd) + # If not exists exception will be raised + client.buildpacks_binding.get(namespace.resource_group, + namespace.service, + DEFAULT_BUILD_SERVICE_NAME, + namespace.name)