From 8aedb4ee9633de9a1e4d5e4a6efa594a72ecb8e7 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Wed, 8 Dec 2021 16:48:25 -0800 Subject: [PATCH] Enable Bucket Support in the CLI (#92) * Update vendored_sdks * Enable source kind generation factories and use kwargs to pass to provider * Add better validation logic to source generator * Move away from classes in the provider directory * Fix style issues using black auto-formatter * Fix linter failures * Update identity with api version and rp in same function --- .flake8 | 1 + .../azext_k8s_configuration/__init__.py | 12 +- .../_client_factory.py | 32 +- .../azext_k8s_configuration/_help.py | 8 + .../azext_k8s_configuration/_params.py | 496 ++-- .../azext_k8s_configuration/action.py | 31 +- .../azext_k8s_configuration/commands.py | 120 +- .../azext_k8s_configuration/confirm.py | 6 +- .../azext_k8s_configuration/consts.py | 175 +- .../azext_k8s_configuration/custom.py | 141 -- .../azext_k8s_configuration/format.py | 2 +- .../providers/FluxConfigurationProvider.py | 1408 ++++++++---- .../SourceControlConfigurationProvider.py | 265 ++- .../azext_k8s_configuration/utils.py | 73 +- .../azext_k8s_configuration/validators.py | 146 +- .../_source_control_configuration_client.py | 34 + .../_source_control_configuration_client.py | 34 + .../v2021_11_01_preview/models/_models.py | 8 +- .../v2021_11_01_preview/models/_models_py3.py | 14 +- .../v2022_01_01_preview/__init__.py | 19 + .../v2022_01_01_preview/_configuration.py | 71 + .../_source_control_configuration_client.py | 134 ++ .../v2022_01_01_preview/_version.py | 9 + .../v2022_01_01_preview/aio/__init__.py | 10 + .../v2022_01_01_preview/aio/_configuration.py | 67 + .../_source_control_configuration_client.py | 127 ++ .../aio/operations/__init__.py | 31 + .../_cluster_extension_type_operations.py | 114 + .../_cluster_extension_types_operations.py | 127 ++ .../_extension_type_versions_operations.py | 117 + .../aio/operations/_extensions_operations.py | 643 ++++++ ...flux_config_operation_status_operations.py | 118 + .../_flux_configurations_operations.py | 643 ++++++ .../_location_extension_types_operations.py | 113 + .../_operation_status_operations.py | 204 ++ .../aio/operations/_operations.py | 105 + ...ource_control_configurations_operations.py | 420 ++++ .../v2022_01_01_preview/models/__init__.py | 181 ++ .../v2022_01_01_preview/models/_models.py | 1836 +++++++++++++++ .../v2022_01_01_preview/models/_models_py3.py | 2028 +++++++++++++++++ ...urce_control_configuration_client_enums.py | 146 ++ .../operations/__init__.py | 31 + .../_cluster_extension_type_operations.py | 119 + .../_cluster_extension_types_operations.py | 132 ++ .../_extension_type_versions_operations.py | 122 + .../operations/_extensions_operations.py | 655 ++++++ ...flux_config_operation_status_operations.py | 123 + .../_flux_configurations_operations.py | 655 ++++++ .../_location_extension_types_operations.py | 118 + .../_operation_status_operations.py | 210 ++ .../operations/_operations.py | 110 + ...ource_control_configurations_operations.py | 429 ++++ 52 files changed, 11898 insertions(+), 1075 deletions(-) delete mode 100644 src/k8s-configuration/azext_k8s_configuration/custom.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/__init__.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_configuration.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_source_control_configuration_client.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_version.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/__init__.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_configuration.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_source_control_configuration_client.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/__init__.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extensions_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operation_status_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/__init__.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models_py3.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_source_control_configuration_client_enums.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/__init__.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_type_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_types_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extension_type_versions_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extensions_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_configurations_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_location_extension_types_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operation_status_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operations.py create mode 100644 src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_source_control_configurations_operations.py diff --git a/.flake8 b/.flake8 index 0295f1c0277..5d2b0466e0e 100644 --- a/.flake8 +++ b/.flake8 @@ -7,6 +7,7 @@ ignore = F401, # imported but unused, too many violations, to be removed in the future F811, # redefinition of unused, to be removed in the future C901 # code flow is too complex, too many violations, to be removed in the future + W503 # line break before binary operator effect on readability is subjective W504 # line break after binary operator effect on readability is subjective exclude = */vendored_sdks diff --git a/src/k8s-configuration/azext_k8s_configuration/__init__.py b/src/k8s-configuration/azext_k8s_configuration/__init__.py index ea33c66418f..0951f5c1594 100644 --- a/src/k8s-configuration/azext_k8s_configuration/__init__.py +++ b/src/k8s-configuration/azext_k8s_configuration/__init__.py @@ -9,23 +9,25 @@ class K8sConfigurationCommandsLoader(AzCommandsLoader): - def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType from azext_k8s_configuration._client_factory import k8s_configuration_client + k8s_configuration_custom = CliCommandType( - operations_tmpl='azext_k8s_configuration.custom#{}', - client_factory=k8s_configuration_client) - super().__init__(cli_ctx=cli_ctx, - custom_command_type=k8s_configuration_custom) + operations_tmpl="azext_k8s_configuration.custom#{}", + client_factory=k8s_configuration_client, + ) + super().__init__(cli_ctx=cli_ctx, custom_command_type=k8s_configuration_custom) def load_command_table(self, args): from azext_k8s_configuration.commands import load_command_table + load_command_table(self, args) return self.command_table def load_arguments(self, command): from azext_k8s_configuration._params import load_arguments + load_arguments(self, command) diff --git a/src/k8s-configuration/azext_k8s_configuration/_client_factory.py b/src/k8s-configuration/azext_k8s_configuration/_client_factory.py index 372adc3f1fd..31575613e5f 100644 --- a/src/k8s-configuration/azext_k8s_configuration/_client_factory.py +++ b/src/k8s-configuration/azext_k8s_configuration/_client_factory.py @@ -10,39 +10,51 @@ def k8s_configuration_client(cli_ctx, **kwargs): from azext_k8s_configuration.vendored_sdks import SourceControlConfigurationClient + return get_mgmt_service_client(cli_ctx, SourceControlConfigurationClient, **kwargs) def k8s_configuration_fluxconfig_client(cli_ctx, *_): - return k8s_configuration_client(cli_ctx, api_version=consts.FLUXCONFIG_API_VERSION).flux_configurations + return k8s_configuration_client( + cli_ctx, api_version=consts.FLUXCONFIG_API_VERSION + ).flux_configurations def k8s_configuration_sourcecontrol_client(cli_ctx, *_): return k8s_configuration_client( - cli_ctx, - api_version=consts.SOURCE_CONTROL_API_VERSION + cli_ctx, api_version=consts.SOURCE_CONTROL_API_VERSION ).source_control_configurations def k8s_configuration_extension_client(cli_ctx, *_): - return k8s_configuration_client(cli_ctx, api_version=consts.EXTENSION_API_VERSION).extensions + return k8s_configuration_client( + cli_ctx, api_version=consts.EXTENSION_API_VERSION + ).extensions def resource_providers_client(cli_ctx): from azure.mgmt.resource import ResourceManagementClient + return get_mgmt_service_client(cli_ctx, ResourceManagementClient).providers def cf_resource_groups(cli_ctx, subscription_id=None): - return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, - subscription_id=subscription_id).resource_groups + return get_mgmt_service_client( + cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id + ).resource_groups def cf_resources(cli_ctx, subscription_id=None): - return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, - subscription_id=subscription_id).resources + return get_mgmt_service_client( + cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id + ).resources def cf_log_analytics(cli_ctx, subscription_id=None): - from azure.mgmt.loganalytics import LogAnalyticsManagementClient # pylint: disable=no-name-in-module - return get_mgmt_service_client(cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id) + from azure.mgmt.loganalytics import ( + LogAnalyticsManagementClient, + ) # pylint: disable=no-name-in-module + + return get_mgmt_service_client( + cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id + ) diff --git a/src/k8s-configuration/azext_k8s_configuration/_help.py b/src/k8s-configuration/azext_k8s_configuration/_help.py index 062309ce3b1..31e14bffda4 100644 --- a/src/k8s-configuration/azext_k8s_configuration/_help.py +++ b/src/k8s-configuration/azext_k8s_configuration/_help.py @@ -86,6 +86,14 @@ --name myconfig --scope cluster --namespace my-namespace \\ --kind git --url https://github.com/Azure/arc-k8s-demo \\ --branch main --kustomization name=my-kustomization + - name: Create a Kubernetes v2 Flux Configuration with Bucket Source Kind + text: |- + az k8s-configuration flux create --resource-group my-resource-group \\ + --cluster-name mycluster --cluster-type connectedClusters \\ + --name myconfig --scope cluster --namespace my-namespace \\ + --kind bucket --url https://bucket-provider.minio.io \\ + --bucket-name my-bucket --kustomization name=my-kustomization \\ + --access-key my-access-key --secret-key my-secret-key """ helps[ diff --git a/src/k8s-configuration/azext_k8s_configuration/_params.py b/src/k8s-configuration/azext_k8s_configuration/_params.py index 6695f58f441..bed4994c216 100644 --- a/src/k8s-configuration/azext_k8s_configuration/_params.py +++ b/src/k8s-configuration/azext_k8s_configuration/_params.py @@ -9,14 +9,14 @@ from azure.cli.core.commands.parameters import ( get_enum_type, get_three_state_flag, - tags_type + tags_type, ) from .validators import ( validate_configuration_name, validate_fluxconfig_name, validate_namespace, validate_operator_instance_name, - validate_operator_namespace + validate_operator_namespace, ) from .action import ( @@ -26,190 +26,322 @@ def load_arguments(self, _): - with self.argument_context('k8s-configuration') as c: - c.argument('tags', tags_type) - c.argument('location', validator=get_default_location_from_resource_group) - c.argument('cluster_name', - options_list=['--cluster-name', '-c'], - help='Name of the Kubernetes cluster') - c.argument('cluster_type', - options_list=['--cluster-type', '-t'], - arg_type=get_enum_type(['connectedClusters', 'managedClusters']), - help='Specify Arc connected clusters or AKS managed clusters.') + with self.argument_context("k8s-configuration") as c: + c.argument("tags", tags_type) + c.argument("location", validator=get_default_location_from_resource_group) + c.argument( + "cluster_name", + options_list=["--cluster-name", "-c"], + help="Name of the Kubernetes cluster", + ) + c.argument( + "cluster_type", + options_list=["--cluster-type", "-t"], + arg_type=get_enum_type(["connectedClusters", "managedClusters"]), + help="Specify Arc connected clusters or AKS managed clusters.", + ) - with self.argument_context('k8s-configuration flux') as c: - c.argument('name', - options_list=['--name', '-n'], - help='Name of the flux configuration', - validator=validate_fluxconfig_name) - c.argument('scope', - options_list=['--scope', '-s'], - arg_type=get_enum_type(['namespace', 'cluster']), - help="Specify scope of the operator to be 'namespace' or 'cluster'") - c.argument('namespace', - help='Namespace to deploy the configuration', - options_list=['--namespace', '--ns'], - validator=validate_namespace) - c.argument('kind', - arg_type=get_enum_type([consts.GIT]), - help='Source kind to reconcile') - c.argument('url', - options_list=['--url', '-u'], - help='URL of the git repo source to reconcile') - c.argument('timeout', - help='Maximum time to reconcile the source before timing out') - c.argument('sync_interval', - options_list=['--interval', '--sync-interval'], - help='Time between reconciliations of the source on the cluster') - c.argument('branch', - arg_group="Git Repo Ref", - help='Branch within the git source to reconcile with the cluster') - c.argument('tag', - arg_group="Git Repo Ref", - help='Tag within the git source to reconcile with the cluster') - c.argument('semver', - arg_group="Git Repo Ref", - help='Semver range within the git source to reconcile with the cluster') - c.argument('commit', - arg_group="Git Repo Ref", - help='Commit within the git source to reconcile with the cluster') - c.argument('ssh_private_key', - arg_group="Auth", - help='Base64-encoded private ssh key for private repository sync') - c.argument('ssh_private_key_file', - arg_group="Auth", - help='File path to private ssh key for private repository sync') - c.argument('https_user', - arg_group="Auth", - help='HTTPS username for private repository sync') - c.argument('https_key', - arg_group="Auth", - help='HTTPS token/password for private repository sync') - c.argument('https_ca_cert', - arg_group="Auth", - help='Base64-encoded HTTPS CA certificate for TLS communication with private repository sync') - c.argument('https_ca_cert_file', - arg_group="Auth", - help='File path to HTTPS CA certificate file for TLS communication with private repository sync') - c.argument('known_hosts', - arg_group="Auth", - help='Base64-encoded known_hosts data containing public SSH keys required to access private Git instances') - c.argument('known_hosts_file', - arg_group="Auth", - help='File path to known_hosts contents containing public SSH keys required to access private Git instances') - c.argument('local_auth_ref', - options_list=['--local-auth-ref', '--local-ref'], - arg_group="Auth", - help='Local reference to a kubernetes secret in the configuration namespace to use for communication to the source') - c.argument('suspend', - arg_type=get_three_state_flag(), - help='Suspend the reconciliation of the source and kustomizations associated with this configuration') - c.argument('kustomization', - action=KustomizationAddAction, - options_list=['--kustomization', '-k'], - help="Define kustomizations to sync sources with parameters ['name', 'path', 'depends_on', 'timeout', 'sync_interval', 'retry_interval', 'prune', 'force']", - nargs='+') + with self.argument_context("k8s-configuration flux") as c: + c.argument( + "name", + options_list=["--name", "-n"], + help="Name of the flux configuration", + validator=validate_fluxconfig_name, + ) + c.argument( + "scope", + options_list=["--scope", "-s"], + arg_type=get_enum_type(["namespace", "cluster"]), + help="Specify scope of the operator to be 'namespace' or 'cluster'", + ) + c.argument( + "namespace", + help="Namespace to deploy the configuration", + options_list=["--namespace", "--ns"], + validator=validate_namespace, + ) + c.argument( + "kind", + arg_type=get_enum_type([consts.GIT, consts.BUCKET]), + help="Source kind to reconcile", + ) + c.argument( + "url", options_list=["--url", "-u"], help="URL of the source to reconcile" + ) + c.argument( + "timeout", help="Maximum time to reconcile the source before timing out" + ) + c.argument( + "sync_interval", + options_list=["--interval", "--sync-interval"], + help="Time between reconciliations of the source on the cluster", + ) + c.argument( + "branch", + arg_group="Git Repo Ref", + help="Branch within the git source to reconcile with the cluster", + ) + c.argument( + "tag", + arg_group="Git Repo Ref", + help="Tag within the git source to reconcile with the cluster", + ) + c.argument( + "semver", + arg_group="Git Repo Ref", + help="Semver range within the git source to reconcile with the cluster", + ) + c.argument( + "commit", + arg_group="Git Repo Ref", + help="Commit within the git source to reconcile with the cluster", + ) + c.argument( + "ssh_private_key", + arg_group="Git Auth", + help="Base64-encoded private ssh key for private repository sync", + ) + c.argument( + "ssh_private_key_file", + arg_group="Git Auth", + help="File path to private ssh key for private repository sync", + ) + c.argument( + "https_user", + arg_group="Git Auth", + help="HTTPS username for private repository sync", + ) + c.argument( + "https_key", + arg_group="Git Auth", + help="HTTPS token/password for private repository sync", + ) + c.argument( + "https_ca_cert", + arg_group="Git Auth", + help="Base64-encoded HTTPS CA certificate for TLS communication with private repository sync", + ) + c.argument( + "https_ca_cert_file", + arg_group="Git Auth", + help="File path to HTTPS CA certificate file for TLS communication with private repository sync", + ) + c.argument( + "known_hosts", + arg_group="Git Auth", + help="Base64-encoded known_hosts data containing public SSH keys required to access private Git instances", + ) + c.argument( + "known_hosts_file", + arg_group="Git Auth", + help="File path to known_hosts contents containing public SSH keys required to access private Git instances", + ) + c.argument( + "access_key", + arg_group="Bucket Auth", + help="Access Key Id used to authenticate with the bucket url", + ) + c.argument( + "secret_key", + arg_group="Bucket Auth", + help="Secret Key used to authenticate with the bucket url", + ) + c.argument( + "bucket_name", + help="Name of the S3 bucket at the given url to connect to", + ) + c.argument( + "insecure", + arg_type=get_three_state_flag(), + help="Communicate with a bucket without TLS", + ) + c.argument( + "local_auth_ref", + arg_group="Auth", + options_list=["--local-auth-ref", "--local-ref"], + help="Local reference to a kubernetes secret in the configuration namespace to use for communication to the source", + ) + c.argument( + "suspend", + arg_type=get_three_state_flag(), + help="Suspend the reconciliation of the source and kustomizations associated with this configuration", + ) + c.argument( + "kustomization", + action=KustomizationAddAction, + options_list=["--kustomization", "-k"], + help="Define kustomizations to sync sources with parameters ['name', 'path', 'depends_on', 'timeout', 'sync_interval', 'retry_interval', 'prune', 'force']", + nargs="+", + ) - with self.argument_context('k8s-configuration flux delete') as c: - c.argument('force', - arg_type=get_three_state_flag(), - help='Force delete the flux configuration from the cluster.') - c.argument('yes', - options_list=['--yes', '-y'], - help='Do not prompt for confirmation') + with self.argument_context("k8s-configuration flux update") as c: + c.argument( + "yes", options_list=["--yes", "-y"], help="Do not prompt for confirmation" + ) - with self.argument_context('k8s-configuration flux deployed-object show') as c: - c.argument('object_name', - help='Name of the object deployed by the configuration on the cluster.') - c.argument('object_namespace', - help='Namespace of the object deployed by the configuration on the cluster.') - c.argument('object_kind', - arg_type=get_enum_type(['GitRepository', 'Bucket', 'HelmRepository', 'HelmChart', 'HelmRelease', 'Kustomization']), - help='Kind of the object deployed by the configuration on the cluster.') + with self.argument_context("k8s-configuration flux delete") as c: + c.argument( + "force", + arg_type=get_three_state_flag(), + help="Force delete the flux configuration from the cluster.", + ) + c.argument( + "yes", options_list=["--yes", "-y"], help="Do not prompt for confirmation" + ) - with self.argument_context('k8s-configuration') as c: - c.argument('name', - options_list=['--name', '-n'], - help='Name of the configuration', - validator=validate_configuration_name) + with self.argument_context("k8s-configuration flux deployed-object show") as c: + c.argument( + "object_name", + help="Name of the object deployed by the configuration on the cluster.", + ) + c.argument( + "object_namespace", + help="Namespace of the object deployed by the configuration on the cluster.", + ) + c.argument( + "object_kind", + arg_type=get_enum_type( + [ + "GitRepository", + "Bucket", + "HelmRepository", + "HelmChart", + "HelmRelease", + "Kustomization", + ] + ), + help="Kind of the object deployed by the configuration on the cluster.", + ) - with self.argument_context('k8s-configuration create') as c: - c.argument('repository_url', - options_list=['--repository-url', '-u'], - help='Url of the source control repository') - c.argument('scope', - arg_type=get_enum_type(['namespace', 'cluster']), - help='''Specify scope of the operator to be 'namespace' or 'cluster' ''') - c.argument('enable_helm_operator', - arg_group="Helm Operator", - arg_type=get_three_state_flag(), - options_list=['--enable-helm-operator', '--enable-hop'], - help='Enable support for Helm chart deployments') - c.argument('helm_operator_params', - arg_group="Helm Operator", - options_list=['--helm-operator-params', '--hop-params'], - help='Chart values for the Helm Operator (if enabled)') - c.argument('helm_operator_chart_version', - arg_group="Helm Operator", - options_list=['--helm-operator-chart-version', '--hop-chart-version'], - help='Chart version of the Helm Operator (if enabled)') - c.argument('operator_params', - arg_group="Operator", - help='Parameters for the Operator') - c.argument('operator_instance_name', - arg_group="Operator", - help='Instance name of the Operator', - validator=validate_operator_instance_name) - c.argument('operator_namespace', - arg_group="Operator", - help='Namespace in which to install the Operator', - validator=validate_operator_namespace) - c.argument('operator_type', - arg_group="Operator", - help='''Type of the operator. Valid value is 'flux' ''') - c.argument('ssh_private_key', - arg_group="Auth", - help='Specify Base64-encoded private ssh key for private repository sync') - c.argument('ssh_private_key_file', - arg_group="Auth", - help='Specify file path to private ssh key for private repository sync') - c.argument('https_user', - arg_group="Auth", - help='Specify HTTPS username for private repository sync') - c.argument('https_key', - arg_group="Auth", - help='Specify HTTPS token/password for private repository sync') - c.argument('ssh_known_hosts', - arg_group="Auth", - help='Specify Base64-encoded known_hosts contents containing public SSH keys required to access private Git instances') - c.argument('ssh_known_hosts_file', - arg_group="Auth", - help='Specify file path to known_hosts contents containing public SSH keys required to access private Git instances') + with self.argument_context("k8s-configuration") as c: + c.argument( + "name", + options_list=["--name", "-n"], + help="Name of the configuration", + validator=validate_configuration_name, + ) - with self.argument_context('k8s-configuration flux kustomization') as c: - c.argument('kustomization_name', - options_list=['--kustomization-name', '-k'], - help='Specify the name of the kustomization to target') - c.argument('path', - help='Specify the path in the source that the kustomization should apply') - c.argument('dependencies', - options_list=['--depends', '--dependencies', "--depends-on"], - help='Comma-separated list of kustomization dependencies') - c.argument('timeout', - help='Maximum time to reconcile the kustomization before timing out') - c.argument('sync_interval', - options_list=['--interval', '--sync-interval'], - help='Time between reconciliations of the kustomization on the cluster') - c.argument('retry_interval', - help='Time between reconciliations of the kustomization on the cluster on failures, defaults to --sync-interval') - c.argument('prune', - arg_type=get_three_state_flag(), - help='Garbage collect resources deployed by the kustomization on the cluster') - c.argument('force', - arg_type=get_three_state_flag(), - help='Re-create resources that cannot be updated on the cluster (i.e. jobs)') + with self.argument_context("k8s-configuration create") as c: + c.argument( + "repository_url", + options_list=["--repository-url", "-u"], + help="Url of the source control repository", + ) + c.argument( + "scope", + arg_type=get_enum_type(["namespace", "cluster"]), + help="""Specify scope of the operator to be 'namespace' or 'cluster' """, + ) + c.argument( + "enable_helm_operator", + arg_group="Helm Operator", + arg_type=get_three_state_flag(), + options_list=["--enable-helm-operator", "--enable-hop"], + help="Enable support for Helm chart deployments", + ) + c.argument( + "helm_operator_params", + arg_group="Helm Operator", + options_list=["--helm-operator-params", "--hop-params"], + help="Chart values for the Helm Operator (if enabled)", + ) + c.argument( + "helm_operator_chart_version", + arg_group="Helm Operator", + options_list=["--helm-operator-chart-version", "--hop-chart-version"], + help="Chart version of the Helm Operator (if enabled)", + ) + c.argument( + "operator_params", arg_group="Operator", help="Parameters for the Operator" + ) + c.argument( + "operator_instance_name", + arg_group="Operator", + help="Instance name of the Operator", + validator=validate_operator_instance_name, + ) + c.argument( + "operator_namespace", + arg_group="Operator", + help="Namespace in which to install the Operator", + validator=validate_operator_namespace, + ) + c.argument( + "operator_type", + arg_group="Operator", + help="""Type of the operator. Valid value is 'flux' """, + ) + c.argument( + "ssh_private_key", + arg_group="Auth", + help="Specify Base64-encoded private ssh key for private repository sync", + ) + c.argument( + "ssh_private_key_file", + arg_group="Auth", + help="Specify file path to private ssh key for private repository sync", + ) + c.argument( + "https_user", + arg_group="Auth", + help="Specify HTTPS username for private repository sync", + ) + c.argument( + "https_key", + arg_group="Auth", + help="Specify HTTPS token/password for private repository sync", + ) + c.argument( + "ssh_known_hosts", + arg_group="Auth", + help="Specify Base64-encoded known_hosts contents containing public SSH keys required to access private Git instances", + ) + c.argument( + "ssh_known_hosts_file", + arg_group="Auth", + help="Specify file path to known_hosts contents containing public SSH keys required to access private Git instances", + ) - with self.argument_context('k8s-configuration flux kustomization delete') as c: - c.argument('yes', - options_list=['--yes', '-y'], - help='Do not prompt for confirmation') + with self.argument_context("k8s-configuration flux kustomization") as c: + c.argument( + "kustomization_name", + options_list=["--kustomization-name", "-k"], + help="Specify the name of the kustomization to target", + ) + c.argument( + "path", + help="Specify the path in the source that the kustomization should apply", + ) + c.argument( + "dependencies", + options_list=["--depends", "--dependencies", "--depends-on"], + help="Comma-separated list of kustomization dependencies", + ) + c.argument( + "timeout", + help="Maximum time to reconcile the kustomization before timing out", + ) + c.argument( + "sync_interval", + options_list=["--interval", "--sync-interval"], + help="Time between reconciliations of the kustomization on the cluster", + ) + c.argument( + "retry_interval", + help="Time between reconciliations of the kustomization on the cluster on failures, defaults to --sync-interval", + ) + c.argument( + "prune", + arg_type=get_three_state_flag(), + help="Garbage collect resources deployed by the kustomization on the cluster", + ) + c.argument( + "force", + arg_type=get_three_state_flag(), + help="Re-create resources that cannot be updated on the cluster (i.e. jobs)", + ) + + with self.argument_context("k8s-configuration flux kustomization delete") as c: + c.argument( + "yes", options_list=["--yes", "-y"], help="Do not prompt for confirmation" + ) diff --git a/src/k8s-configuration/azext_k8s_configuration/action.py b/src/k8s-configuration/azext_k8s_configuration/action.py index 5ad965b6114..7bc2d460742 100644 --- a/src/k8s-configuration/azext_k8s_configuration/action.py +++ b/src/k8s-configuration/azext_k8s_configuration/action.py @@ -6,7 +6,11 @@ import argparse from azure.cli.core.azclierror import InvalidArgumentValueError -from .vendored_sdks.v2021_11_01_preview.models import KustomizationDefinition, DependsOnDefinition +from .vendored_sdks.v2022_01_01_preview.models import ( + KustomizationDefinition, + KustomizationPatchDefinition, + DependsOnDefinition, +) from .validators import validate_kustomization from . import consts from .utils import parse_dependencies, parse_duration @@ -14,15 +18,21 @@ class InternalKustomizationDefinition(KustomizationDefinition): def __init__(self, **kwargs): - self.name = kwargs.get('name', "") + self.name = kwargs.get("name", "") super().__init__(**kwargs) def to_KustomizationDefinition(self): k_dict = dict(self.__dict__) - del k_dict['name'] - del k_dict['additional_properties'] + del k_dict["name"] + del k_dict["additional_properties"] return KustomizationDefinition(**k_dict) + def to_KustomizationPatchDefinition(self): + k_dict = dict(self.__dict__) + del k_dict["name"] + del k_dict["additional_properties"] + return KustomizationPatchDefinition(**k_dict) + class KustomizationAddAction(argparse._AppendAction): def __call__(self, parser, namespace, values, option_string=None): @@ -34,14 +44,12 @@ def __call__(self, parser, namespace, values, option_string=None): kwargs = {} for item in values: try: - key, value = item.split('=', 1) + key, value = item.split("=", 1) if key in consts.DEPENDENCY_KEYS: dependencies = parse_dependencies(value) for dep in dependencies: model_dependency.append( - DependsOnDefinition( - kustomization_name=dep - ) + DependsOnDefinition(kustomization_name=dep) ) elif key in consts.SYNC_INTERVAL_KEYS: sync_interval = value @@ -52,8 +60,9 @@ def __call__(self, parser, namespace, values, option_string=None): else: kwargs[key] = value except ValueError as ex: - raise InvalidArgumentValueError('usage error: {} KEY=VALUE [KEY=VALUE ...]' - .format(option_string)) from ex + raise InvalidArgumentValueError( + "usage error: {} KEY=VALUE [KEY=VALUE ...]".format(option_string) + ) from ex super().__call__( parser, namespace, @@ -64,5 +73,5 @@ def __call__(self, parser, namespace, values, option_string=None): timeout_in_seconds=parse_duration(timeout), **kwargs ), - option_string + option_string, ) diff --git a/src/k8s-configuration/azext_k8s_configuration/commands.py b/src/k8s-configuration/azext_k8s_configuration/commands.py index c14e162c4bd..e42cc830b7b 100644 --- a/src/k8s-configuration/azext_k8s_configuration/commands.py +++ b/src/k8s-configuration/azext_k8s_configuration/commands.py @@ -7,7 +7,7 @@ from azure.cli.core.commands import CliCommandType from azext_k8s_configuration._client_factory import ( k8s_configuration_fluxconfig_client, - k8s_configuration_sourcecontrol_client + k8s_configuration_sourcecontrol_client, ) from .format import ( fluxconfig_deployed_object_list_table_format, @@ -17,41 +17,99 @@ fluxconfig_kustomization_list_table_format, fluxconfig_kustomization_show_table_format, sourcecontrol_list_table_format, - sourcecontrol_show_table_format + sourcecontrol_show_table_format, ) def load_command_table(self, _): - k8s_configuration_fluxconfig_sdk = CliCommandType( - operations_tmpl='azext_k8s_configuration.vendored_sdks.operations#FluxConfigurationsOperations.{}', - client_factory=k8s_configuration_fluxconfig_client + flux_configuration_custom_type = CliCommandType( + operations_tmpl="azext_k8s_configuration.providers.FluxConfigurationProvider#{}", + client_factory=k8s_configuration_fluxconfig_client, ) - k8s_configuration_sourcecontrol_sdk = CliCommandType( - operations_tmpl='azext_k8s_configuration.vendored_sdks.operations#SourceControlConfigurationsOperations.{}', - client_factory=k8s_configuration_sourcecontrol_client + source_control_configuration_custom_type = CliCommandType( + operations_tmpl="azext_k8s_configuration.providers.SourceControlConfigurationProvider#{}", + client_factory=k8s_configuration_sourcecontrol_client, ) - with self.command_group('k8s-configuration flux', k8s_configuration_fluxconfig_sdk, client_factory=k8s_configuration_fluxconfig_client, is_preview=True) as g: - g.custom_command('create', 'flux_config_create', supports_no_wait=True) - g.custom_command('update', 'flux_config_update', supports_no_wait=True) - g.custom_command('list', "flux_config_list", table_transformer=fluxconfig_list_table_format) - g.custom_show_command('show', 'flux_config_show', table_transformer=fluxconfig_show_table_format) - g.custom_command('delete', 'flux_config_delete', supports_no_wait=True) - - with self.command_group('k8s-configuration flux kustomization', k8s_configuration_fluxconfig_sdk, client_factory=k8s_configuration_fluxconfig_client, is_preview=True) as g: - g.custom_command('create', 'flux_config_create_kustomization', supports_no_wait=True) - g.custom_command('update', 'flux_config_update_kustomization', supports_no_wait=True) - g.custom_command('delete', 'flux_config_delete_kustomization', supports_no_wait=True) - g.custom_command('list', 'flux_config_list_kustomization', table_transformer=fluxconfig_kustomization_list_table_format) - g.custom_show_command('show', 'flux_config_show_kustomization', table_transformer=fluxconfig_kustomization_show_table_format) - - with self.command_group('k8s-configuration flux deployed-object', k8s_configuration_fluxconfig_sdk, client_factory=k8s_configuration_fluxconfig_client, is_preview=True) as g: - g.custom_command('list', 'flux_config_list_deployed_object', table_transformer=fluxconfig_deployed_object_list_table_format) - g.custom_show_command('show', 'flux_config_show_deployed_object', table_transformer=fluxconfig_deployed_object_show_table_format) - - with self.command_group('k8s-configuration', k8s_configuration_sourcecontrol_sdk, client_factory=k8s_configuration_sourcecontrol_client) as g: - g.custom_command('create', 'sourcecontrol_create', deprecate_info=self.deprecate(redirect='k8s-configuration flux create')) - g.custom_command('list', 'sourcecontrol_list', table_transformer=sourcecontrol_list_table_format, deprecate_info=self.deprecate(redirect='k8s-configuration flux list')) - g.custom_show_command('show', 'sourcecontrol_show', table_transformer=sourcecontrol_show_table_format, deprecate_info=self.deprecate(redirect='k8s-configuration flux show')) - g.custom_command('delete', 'sourcecontrol_delete', confirmation=True, deprecate_info=self.deprecate(redirect='k8s-configuration flux delete')) + with self.command_group( + "k8s-configuration flux", + k8s_configuration_fluxconfig_client, + custom_command_type=flux_configuration_custom_type, + is_preview=True, + ) as g: + g.custom_command("create", "create_config", supports_no_wait=True) + g.custom_command("update", "update_config", supports_no_wait=True) + g.custom_command( + "list", "list_configs", table_transformer=fluxconfig_list_table_format + ) + g.custom_show_command( + "show", "show_config", table_transformer=fluxconfig_show_table_format + ) + g.custom_command("delete", "delete_config", supports_no_wait=True) + + with self.command_group( + "k8s-configuration flux kustomization", + k8s_configuration_fluxconfig_client, + custom_command_type=flux_configuration_custom_type, + is_preview=True, + ) as g: + g.custom_command("create", "create_kustomization", supports_no_wait=True) + g.custom_command("update", "update_kustomization", supports_no_wait=True) + g.custom_command("delete", "delete_kustomization", supports_no_wait=True) + g.custom_command( + "list", + "list_kustomization", + table_transformer=fluxconfig_kustomization_list_table_format, + ) + g.custom_show_command( + "show", + "show_kustomization", + table_transformer=fluxconfig_kustomization_show_table_format, + ) + + with self.command_group( + "k8s-configuration flux deployed-object", + k8s_configuration_fluxconfig_client, + custom_command_type=flux_configuration_custom_type, + is_preview=True, + ) as g: + g.custom_command( + "list", + "list_deployed_object", + table_transformer=fluxconfig_deployed_object_list_table_format, + ) + g.custom_show_command( + "show", + "show_deployed_object", + table_transformer=fluxconfig_deployed_object_show_table_format, + ) + + with self.command_group( + "k8s-configuration", + k8s_configuration_sourcecontrol_client, + custom_command_type=source_control_configuration_custom_type, + ) as g: + g.custom_command( + "create", + "create_config", + deprecate_info=self.deprecate(redirect="k8s-configuration flux create"), + ) + g.custom_command( + "list", + "list_configs", + table_transformer=sourcecontrol_list_table_format, + deprecate_info=self.deprecate(redirect="k8s-configuration flux list"), + ) + g.custom_show_command( + "show", + "show_config", + table_transformer=sourcecontrol_show_table_format, + deprecate_info=self.deprecate(redirect="k8s-configuration flux show"), + ) + g.custom_command( + "delete", + "delete_config", + confirmation=True, + deprecate_info=self.deprecate(redirect="k8s-configuration flux delete"), + ) diff --git a/src/k8s-configuration/azext_k8s_configuration/confirm.py b/src/k8s-configuration/azext_k8s_configuration/confirm.py index 2f8d3a6bdd6..3f24dd14dd4 100644 --- a/src/k8s-configuration/azext_k8s_configuration/confirm.py +++ b/src/k8s-configuration/azext_k8s_configuration/confirm.py @@ -6,7 +6,9 @@ from azure.cli.core.util import user_confirmation -def user_confirmation_factory(cmd, yes, message="Are you sure you want to perform this operation?"): - if cmd.cli_ctx.config.getboolean('core', 'disable_confirm_prompt', fallback=False): +def user_confirmation_factory( + cmd, yes, message="Are you sure you want to perform this operation?" +): + if cmd.cli_ctx.config.getboolean("core", "disable_confirm_prompt", fallback=False): return user_confirmation(message, yes=yes) diff --git a/src/k8s-configuration/azext_k8s_configuration/consts.py b/src/k8s-configuration/azext_k8s_configuration/consts.py index 606e766a5a2..7db604b9c33 100644 --- a/src/k8s-configuration/azext_k8s_configuration/consts.py +++ b/src/k8s-configuration/azext_k8s_configuration/consts.py @@ -7,29 +7,53 @@ # API VERSIONS ----------------------------------------- -SOURCE_CONTROL_API_VERSION = '2021-03-01' -FLUXCONFIG_API_VERSION = '2021-11-01-preview' +SOURCE_CONTROL_API_VERSION = "2021-03-01" +FLUXCONFIG_API_VERSION = "2022-01-01-preview" EXTENSION_API_VERSION = "2021-09-01" # ERROR/HELP TEXT DEFINITIONS ----------------------------------------- -KUSTOMIZATION_REQUIRED_VALUES_MISSING_ERROR = "Error! Kustomization definition is invalid, required values {} not found" -KUSTOMIZATION_REQUIRED_VALUES_MISSING_HELP = "Add the required values to the Kustomization object and try again" +KUSTOMIZATION_REQUIRED_VALUES_MISSING_ERROR = ( + "Error! Kustomization definition is invalid, required values {} not found" +) +KUSTOMIZATION_REQUIRED_VALUES_MISSING_HELP = ( + "Add the required values to the Kustomization object and try again" +) REPOSITORY_REF_REQUIRED_VALUES_MISSING_ERROR = "Error! Repository reference is invalid" -REPOSITORY_REF_REQUIRED_VALUES_MISSING_HELP = "Specifying one of [--branch, --tag, --semver, --commit] is required" +REPOSITORY_REF_REQUIRED_VALUES_MISSING_HELP = ( + "Specifying one of [--branch, --tag, --semver, --commit] is required" +) REPOSITORY_REF_TOO_MANY_VALUES_ERROR = "Error! Repository reference is invalid" -REPOSITORY_REF_TOO_MANY_VALUES_HELP = "Specifying more than one repository ref argument is invalid" - -GIT_REPOSITORY_REQUIRED_VALUES_MISSING_ERROR = "Error! Required property '{}' was not specified for kind 'GitRepository'" -GIT_REPOSITORY_REQUIRED_VALUES_MISSING_HELP = "Add missing required property and try again" +REPOSITORY_REF_TOO_MANY_VALUES_HELP = ( + "Specifying more than one repository ref argument is invalid" +) + +REQUIRED_VALUES_MISSING_ERROR = ( + "Error! Required properties [{}] were not specified for kind '{}'" +) +REQUIRED_VALUES_MISSING_HELP = "Add the missing required properties and try again" + +REQUIRED_BUCKET_VALUES_MISSING_ERROR = ( + "Error! Auth properties must be specified for kind 'bucket'" +) +REQUIRED_BUCKET_VALUES_MISSING_HELP = ( + "Provide either both of '--secret-key' and '--access-key' or '--local-auth-ref'" +) + +EXTRA_VALUES_PROVIDED_ERROR = ( + "Error! Invalid properties [{}] were specified for kind '{}'" +) +EXTRA_VALUES_PROVIDED_HELP = "Valid properties for kind '{}' include [{}]" INVALID_DURATION_ERROR = "Error! Invalid {0}." -INVALID_DURATION_HELP = "Specify a valid ISO8601 duration and try again" +INVALID_DURATION_HELP = "Specify a valid Go duration and try again (i.e. 1h2m5s)" INVALID_URL_ERROR = "Error! Invalid --url." -INVALID_URL_HELP = "Url must beginwith one of ['http://', 'https://', 'git@', 'ssh://']" +INVALID_URL_HELP = ( + "Url must begin with one of ['http://', 'https://', 'git@', 'ssh://']" +) INVALID_KUBERNETES_NAME_LENGTH_ERROR = "Error! Invalid {0}" INVALID_KUBERNETES_NAME_LENGTH_HELP = "Parameter {0} can be a maximum of {1} characters. Specify a shorter name and try again." @@ -41,16 +65,22 @@ INVALID_KUBERNETES_NAME_PERIOD_HELP = "Parameter {0} cannot begin or end with a period." INVALID_KUBERNETES_DNS_NAME_ERROR = "Error! Invalid {0}" -INVALID_KUBERNETES_DNS_NAME_HELP = "Parameter {0} can only contain lowercase alphanumeric characters and hyphens" +INVALID_KUBERNETES_DNS_NAME_HELP = ( + "Parameter {0} can only contain lowercase alphanumeric characters and hyphens" +) INVALID_KUBERNETES_DNS_SUBDOMAIN_NAME_ERROR = "Error! Invalid {0}" INVALID_KUBERNETES_DNS_SUBDOMAIN_NAME_HELP = "Parameter {0} can only contain lowercase alphanumeric characters, hyphens, and periods" DUPLICATE_KUSTOMIZATION_NAME_ERROR = "Error! Invalid kustomization list. Kustomization name '{0}' duplicated in multiple Kustomization objects" -DUPLICATE_KUSTOMIZATION_NAME_HELP = "Ensure that all Kustomization names are unique and try again" +DUPLICATE_KUSTOMIZATION_NAME_HELP = ( + "Ensure that all Kustomization names are unique and try again" +) KUSTOMIZATION_NAME_TOO_LONG_ERROR = "Error! Invalid Kustomization list. Flux configuration name '{0}' combined with kustomization name '{1}' cannot be greater than 62 characters" -KUSTOMIZATION_NAME_TOO_LONG_HELP = "Shorten the flux configuration or the kustomization name and try again" +KUSTOMIZATION_NAME_TOO_LONG_HELP = ( + "Shorten the flux configuration or the kustomization name and try again" +) CREATE_KUSTOMIZATION_EXIST_ERROR = "Error! Cannot create a kustomization that already exists. Kustomization name '{0}' already exists on configuration '{1}'" CREATE_KUSTOMIZATION_EXIST_HELP = "You can update an already created kustomization with 'az k8s-configuration flux kustomization update'" @@ -58,26 +88,44 @@ UPDATE_KUSTOMIZATION_NO_EXIST_ERROR = "Error! Cannot update a kustomization that doesn't exist. Kustomization name '{0}' does not exist on configuration '{1}'" UPDATE_KUSTOMIZATION_NO_EXIST_HELP = "You can add the kustomization to the configuration with 'az k8s-configuration flux kustomization create'" -DELETE_KUSTOMIZATION_NO_EXIST_ERROR = "Error! Cannot delete a kustomization that doesn't exist." +DELETE_KUSTOMIZATION_NO_EXIST_ERROR = ( + "Error! Cannot delete a kustomization that doesn't exist." +) DELETE_KUSTOMIZATION_NO_EXIST_HELP = "You can view all kustomizations on a configuration with 'az k8s-configuration flux kustomization list'" -SHOW_KUSTOMIZATION_NO_EXIST_ERROR = "Error! Kustomization with name '{0}' does not exist on configuration '{1}'." +SHOW_KUSTOMIZATION_NO_EXIST_ERROR = ( + "Error! Kustomization with name '{0}' does not exist on configuration '{1}'." +) SHOW_KUSTOMIZATION_NO_EXIST_HELP = "You can view all kustomizations on a configuration with 'az k8s-configuration flux kustomization list'" SHOW_DEPLOYED_OBJECT_NO_EXIST_ERROR = "Error! Deployed object with name '{0}', namespace '{1}', and kind '{2}' does not exist on configuration '{3}'." SHOW_DEPLOYED_OBJECT_NO_EXIST_HELP = "You can view all deployed objects on a configuration with 'az k8s-configuration flux deployed-object list'" -SSH_PRIVATE_KEY_WITH_HTTP_URL_ERROR = "Error! An --ssh-private-key cannot be used with an http(s) url" -SSH_PRIVATE_KEY_WITH_HTTP_URL_HELP = "Verify the url provided is a valid ssh url and not an http(s) url" +SSH_PRIVATE_KEY_WITH_HTTP_URL_ERROR = ( + "Error! An --ssh-private-key cannot be used with an http(s) url" +) +SSH_PRIVATE_KEY_WITH_HTTP_URL_HELP = ( + "Verify the url provided is a valid ssh url and not an http(s) url" +) -KNOWN_HOSTS_WITH_HTTP_URL_ERROR = "Error! --ssh-known-hosts cannot be used with an http(s) url" -KNOWN_HOSTS_WITH_HTTP_URL_HELP = "Verify the url provided is a valid ssh url and not an http(s) url" +KNOWN_HOSTS_WITH_HTTP_URL_ERROR = ( + "Error! --ssh-known-hosts cannot be used with an http(s) url" +) +KNOWN_HOSTS_WITH_HTTP_URL_HELP = ( + "Verify the url provided is a valid ssh url and not an http(s) url" +) HTTPS_AUTH_WITH_SSH_URL_ERROR = "Error! https auth (--https-user and --https-key) cannot be used with a non-http(s) url" -HTTPS_AUTH_WITH_SSH_URL_HELP = "Verify the url provided is a valid http(s) url and not an ssh url" +HTTPS_AUTH_WITH_SSH_URL_HELP = ( + "Verify the url provided is a valid http(s) url and not an ssh url" +) -KNOWN_HOSTS_BASE64_ENCODING_ERROR = "Error! ssh known_hosts is not a valid utf-8 base64 encoded string" -KNOWN_HOSTS_BASE64_ENCODING_HELP = "Verify that the string provided safely decodes into a valid utf-8 format" +KNOWN_HOSTS_BASE64_ENCODING_ERROR = ( + "Error! ssh known_hosts is not a valid utf-8 base64 encoded string" +) +KNOWN_HOSTS_BASE64_ENCODING_HELP = ( + "Verify that the string provided safely decodes into a valid utf-8 format" +) KNOWN_HOSTS_FORMAT_ERROR = "Error! ssh known_hosts provided in wrong format" KNOWN_HOSTS_FORMAT_HELP = "Verify that all lines in the known_hosts contents are provided in a valid sshd(8) format" @@ -85,16 +133,26 @@ SSH_PRIVATE_KEY_ERROR = "Error! --ssh-private-key provided in invalid format" SSH_PRIVATE_KEY_HELP = "Verify the key provided is a valid PEM-formatted key of type RSA, ECC, DSA, or Ed25519" -HTTPS_USER_KEY_MATCH_ERROR = "Error! --https-user and --https-key cannot be used separately" +HTTPS_USER_KEY_MATCH_ERROR = ( + "Error! --https-user and --https-key cannot be used separately" +) HTTPS_USER_KEY_MATCH_HELP = "Try providing both --https-user and --https-key together" KEY_FILE_READ_ERROR = "Error! Unable to read key file specified with: {0}" -KEY_FILE_READ_HELP = "Verify that the filepath specified exists and contains valid utf-8 data" - -KEY_AND_FILE_TOGETHER_ERROR = "Error! Both textual key and key filepath cannot be provided" -KEY_AND_FILE_TOGETHER_HELP = "Try providing the file parameter without providing the plaintext parameter" - -SCC_EXISTS_ON_CLUSTER_ERROR = "Error! Flux v1 configurations already exist on the cluster" +KEY_FILE_READ_HELP = ( + "Verify that the filepath specified exists and contains valid utf-8 data" +) + +KEY_AND_FILE_TOGETHER_ERROR = ( + "Error! Both textual key and key filepath cannot be provided" +) +KEY_AND_FILE_TOGETHER_HELP = ( + "Try providing the file parameter without providing the plaintext parameter" +) + +SCC_EXISTS_ON_CLUSTER_ERROR = ( + "Error! Flux v1 configurations already exist on the cluster" +) SCC_EXISTS_ON_CLUSTER_HELP = "Try removing all Flux v1 configurations from the cluster before attempting to add Flux v2 configurations" FLUX_EXTENSION_NOT_SUCCEEDED_OR_CREATING_ERROR = "Error! 'Microsoft.Flux' extension is installed but not in a succeeded state on the cluster. Unable to proceed with Flux v2 configuration install." @@ -113,7 +171,7 @@ CC_REGISTRATION_WARNING = "'Flux Configuration' cannot be used because '%s' provider has not been registered. More details for registering this provider can be found here - %s" CC_REGISTRATION_LINK = "https://aka.ms/RegisterKubernetesConfigurationProvider" CC_REGISTRATION_ERROR = "Unable to fetch registration state of '{0}' provider. Failed to enable 'flux configuration' feature..." -CC_PROVIDER_NAMESPACE = 'Microsoft.KubernetesConfiguration' +CC_PROVIDER_NAMESPACE = "Microsoft.KubernetesConfiguration" REGISTERED = "Registered" CREATING = "Creating" SUCCEEDED = "Succeeded" @@ -123,6 +181,39 @@ SSH_PRIVATE_KEY_KEY = "sshPrivateKey" HTTPS_USER_KEY = "httpsUser" HTTPS_KEY_KEY = "httpsKey" +BUCKET_SECRET_KEY_KEY = "bucketSecretKey" + +GIT_REPO_REQUIRED_PARAMS = {"url"} +GIT_REPO_VALID_PARAMS = { + "url", + "branch", + "tag", + "semver", + "commit", + "sync_interval", + "timeout", + "ssh_private_key", + "ssh_private_key_file", + "https_user", + "https_key", + "https_ca_cert", + "https_ca_cert_file", + "known_hosts", + "known_hosts_file", + "local_auth_ref", +} + +BUCKET_REQUIRED_PARAMS = {"url", "bucket_name"} +BUCKET_VALID_PARAMS = { + "url", + "bucket_name", + "sync_interval", + "timeout", + "access_key", + "secret_key", + "insecure", + "local_auth_ref", +} DEPENDENCY_KEYS = ["dependencies", "depends_on", "dependsOn", "depends"] SYNC_INTERVAL_KEYS = ["interval", "sync_interval", "syncInterval"] @@ -131,25 +222,31 @@ REQUIRED_KUSTOMIZATION_KEYS = {"name"} VALID_DURATION_REGEX = r"((?P\d+?)h)?((?P\d+?)m)?((?P\d+?)s)?" -VALID_URL_REGEX = r"^(((http|https|ssh)://)|(git@))" +VALID_GIT_URL_REGEX = r"^(((http|https|ssh)://)|(git@))" +VALID_BUCKET_URL_REGEX = r"^(((http|https)://))" VALID_KUBERNETES_DNS_SUBDOMAIN_NAME_REGEX = r"^[a-z0-9]([\.\-a-z0-9]*[a-z0-9])?$" VALID_KUBERNETES_DNS_NAME_REGEX = r"^[a-z0-9]([\-a-z0-9]*[a-z0-9])?$" GIT = "git" +BUCKET = "bucket" GIT_REPOSITORY = "GitRepository" -CONNECTED_CLUSTERS = "connectedclusters" -MANAGED_CLUSTERS = "managedclusters" -APPLIANCES = "appliances" +CONNECTED_CLUSTER_TYPE = "connectedclusters" +MANAGED_CLUSTER_TYPE = "managedclusters" +APPLIANCE_TYPE = "appliances" + +MANAGED_CLUSTER_RP = "Microsoft.ContainerService" +CONNECTED_CLUSTER_RP = "Microsoft.Kubernetes" +APPLIANCE_RP = "Microsoft.ResourceConnector" -MANAGED_RP_NAMESPACE = "Microsoft.ContainerService" -CONNECTED_RP_NAMESPACE = "Microsoft.Kubernetes" -APPLIANCE_RP_NAMESPACE = "Microsoft.ResourceConnector" +CONNECTED_CLUSTER_API_VERSION = "2021-10-01" +MANAGED_CLUSTER_API_VERSION = "2021-10-01" +APPLIANCE_API_VERSION = "2021-10-31-preview" KUBERNETES_MAX_NAME_SIZE = 63 -DF_RM_ENDPOINT = 'https://api-dogfood.resources.windows-int.net/' +DF_RM_ENDPOINT = "https://api-dogfood.resources.windows-int.net/" FLUX_EXTENSION_RELEASETRAIN = "FLUX_EXTENSION_RELEASETRAIN" FLUX_EXTENSION_VERSION = "FLUX_EXTENSION_VERSION" diff --git a/src/k8s-configuration/azext_k8s_configuration/custom.py b/src/k8s-configuration/azext_k8s_configuration/custom.py deleted file mode 100644 index d14836fc077..00000000000 --- a/src/k8s-configuration/azext_k8s_configuration/custom.py +++ /dev/null @@ -1,141 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=unused-argument - -from .providers.FluxConfigurationProvider import FluxConfigurationProvider -from .providers.SourceControlConfigurationProvider import SourceControlConfigurationProvider -from . import consts - - -# Source Control Configuration Methods - -def sourcecontrol_create(cmd, client, resource_group_name, cluster_name, name, repository_url, scope, cluster_type, - operator_instance_name=None, operator_namespace='default', - helm_operator_chart_version='1.4.0', operator_type='flux', operator_params='', - ssh_private_key='', ssh_private_key_file='', https_user='', https_key='', - ssh_known_hosts='', ssh_known_hosts_file='', enable_helm_operator=None, - helm_operator_params=''): - provider = SourceControlConfigurationProvider(cmd) - return provider.create(resource_group_name, cluster_name, name, repository_url, scope, cluster_type, - operator_instance_name, operator_namespace, helm_operator_chart_version, operator_type, - operator_params, ssh_private_key, ssh_private_key_file, https_user, https_key, - ssh_known_hosts, ssh_known_hosts_file, enable_helm_operator, helm_operator_params) - - -def sourcecontrol_show(cmd, client, resource_group_name, cluster_type, cluster_name, name): - provider = SourceControlConfigurationProvider(cmd) - return provider.show(resource_group_name, cluster_type, cluster_name, name) - - -def sourcecontrol_list(cmd, client, resource_group_name, cluster_type, cluster_name): - provider = SourceControlConfigurationProvider(cmd) - return provider.list(resource_group_name, cluster_type, cluster_name) - - -def sourcecontrol_delete(cmd, client, resource_group_name, cluster_type, cluster_name, name): - provider = SourceControlConfigurationProvider(cmd) - return provider.delete(resource_group_name, cluster_type, cluster_name, name) - - -# Flux Configuration Methods -def flux_config_show(cmd, client, resource_group_name, cluster_type, cluster_name, name): - provider = FluxConfigurationProvider(cmd) - return provider.show(resource_group_name, cluster_type, cluster_name, name) - - -def flux_config_list(cmd, client, resource_group_name, cluster_type, cluster_name): - provider = FluxConfigurationProvider(cmd) - return provider.list(resource_group_name, cluster_type, cluster_name) - - -# pylint: disable=too-many-locals -def flux_config_create(cmd, client, resource_group_name, cluster_type, cluster_name, name, url=None, - scope='cluster', namespace='default', kind=consts.GIT, timeout=None, sync_interval=None, - branch=None, tag=None, semver=None, commit=None, local_auth_ref=None, ssh_private_key=None, - ssh_private_key_file=None, https_user=None, https_key=None, https_ca_cert=None, - https_ca_cert_file=None, known_hosts=None, known_hosts_file=None, suspend=False, - kustomization=None, no_wait=False): - - provider = FluxConfigurationProvider(cmd) - return provider.create(resource_group_name, cluster_type, cluster_name, name, url, scope, namespace, kind, - timeout, sync_interval, branch, tag, semver, commit, local_auth_ref, ssh_private_key, - ssh_private_key_file, https_user, https_key, https_ca_cert, https_ca_cert_file, known_hosts, - known_hosts_file, suspend, kustomization, no_wait) - - -# pylint: disable=too-many-locals -def flux_config_update(cmd, client, resource_group_name, cluster_type, cluster_name, name, url=None, - timeout=None, sync_interval=None, branch=None, tag=None, semver=None, commit=None, - local_auth_ref=None, ssh_private_key=None, ssh_private_key_file=None, https_user=None, - https_key=None, https_ca_cert=None, https_ca_cert_file=None, known_hosts=None, - known_hosts_file=None, suspend=None, kustomization=None, no_wait=False): - - provider = FluxConfigurationProvider(cmd) - return provider.update(resource_group_name, cluster_type, cluster_name, name, url, timeout, sync_interval, - branch, tag, semver, commit, local_auth_ref, ssh_private_key, ssh_private_key_file, - https_user, https_key, https_ca_cert, https_ca_cert_file, known_hosts, - known_hosts_file, suspend, kustomization, no_wait) - - -def flux_config_create_kustomization(cmd, client, resource_group_name, cluster_type, cluster_name, name, - kustomization_name, dependencies=None, timeout=None, sync_interval=None, - retry_interval=None, path='', prune=None, force=None, no_wait=False): - - provider = FluxConfigurationProvider(cmd) - return provider.create_kustomization(resource_group_name, cluster_type, cluster_name, name, kustomization_name, - dependencies, timeout, sync_interval, retry_interval, path, prune, - force, no_wait) - - -def flux_config_update_kustomization(cmd, client, resource_group_name, cluster_type, cluster_name, name, - kustomization_name, dependencies=None, timeout=None, sync_interval=None, - retry_interval=None, path=None, prune=None, force=None, no_wait=False): - - provider = FluxConfigurationProvider(cmd) - return provider.update_kustomization(resource_group_name, cluster_type, cluster_name, name, kustomization_name, - dependencies, timeout, sync_interval, retry_interval, path, prune, - force, no_wait) - - -def flux_config_delete_kustomization(cmd, client, resource_group_name, cluster_type, cluster_name, name, - kustomization_name, no_wait=False, yes=False): - - provider = FluxConfigurationProvider(cmd) - return provider.delete_kustomization(resource_group_name, cluster_type, cluster_name, - name, kustomization_name, no_wait, yes) - - -def flux_config_list_kustomization(cmd, client, resource_group_name, cluster_type, cluster_name, name): - - provider = FluxConfigurationProvider(cmd) - return provider.list_kustomization(resource_group_name, cluster_type, cluster_name, name) - - -def flux_config_show_kustomization(cmd, client, resource_group_name, cluster_type, cluster_name, name, - kustomization_name): - - provider = FluxConfigurationProvider(cmd) - return provider.show_kustomization(resource_group_name, cluster_type, cluster_name, name, kustomization_name) - - -def flux_config_list_deployed_object(cmd, client, resource_group_name, cluster_type, cluster_name, name): - - provider = FluxConfigurationProvider(cmd) - return provider.list_deployed_object(resource_group_name, cluster_type, cluster_name, name) - - -def flux_config_show_deployed_object(cmd, client, resource_group_name, cluster_type, cluster_name, name, - object_name, object_namespace, object_kind): - - provider = FluxConfigurationProvider(cmd) - return provider.show_deployed_object(resource_group_name, cluster_type, cluster_name, name, - object_name, object_namespace, object_kind) - - -def flux_config_delete(cmd, client, resource_group_name, cluster_type, - cluster_name, name, force=False, no_wait=False, yes=False): - provider = FluxConfigurationProvider(cmd) - return provider.delete(resource_group_name, cluster_type, cluster_name, name, force, no_wait, yes) diff --git a/src/k8s-configuration/azext_k8s_configuration/format.py b/src/k8s-configuration/azext_k8s_configuration/format.py index 954a661b5fd..01d729e7244 100644 --- a/src/k8s-configuration/azext_k8s_configuration/format.py +++ b/src/k8s-configuration/azext_k8s_configuration/format.py @@ -44,7 +44,7 @@ def __get_fluxconfig_table_row(result): ("scope", result["scope"]), ("provisioningState", result["provisioningState"]), ("complianceState", result["complianceState"]), - ("lastSourceSyncedAt", result["lastSourceSyncedAt"]), + ("lastSourceUpdatedAt", result["lastSourceUpdatedAt"]), ] ) diff --git a/src/k8s-configuration/azext_k8s_configuration/providers/FluxConfigurationProvider.py b/src/k8s-configuration/azext_k8s_configuration/providers/FluxConfigurationProvider.py index 9bc3404c7fa..1faaea717e1 100644 --- a/src/k8s-configuration/azext_k8s_configuration/providers/FluxConfigurationProvider.py +++ b/src/k8s-configuration/azext_k8s_configuration/providers/FluxConfigurationProvider.py @@ -7,7 +7,13 @@ import os -from azure.cli.core.azclierror import DeploymentError, ResourceNotFoundError, ValidationError +from azure.cli.core.azclierror import ( + DeploymentError, + ResourceNotFoundError, + ValidationError, + UnrecognizedArgumentError, + RequiredArgumentMissingError, +) from azure.cli.core.util import sdk_no_wait from azure.cli.core.commands.client_factory import get_subscription_id @@ -17,515 +23,1031 @@ from ..confirm import user_confirmation_factory from .._client_factory import ( cf_resources, - k8s_configuration_fluxconfig_client, - k8s_configuration_extension_client + k8s_configuration_extension_client, + k8s_configuration_sourcecontrol_client, ) from ..utils import ( - get_parent_api_version, - get_cluster_rp, + get_cluster_rp_api_version, get_data_from_key_or_file, parse_dependencies, parse_duration, has_prune_enabled, to_base64, - is_dogfood_cluster + is_dogfood_cluster, ) from ..validators import ( + validate_bucket_url, validate_cc_registration, + validate_git_url, validate_known_hosts, validate_repository_ref, validate_duration, - validate_git_repository, validate_private_key, - validate_url_with_params + validate_url_with_params, ) from .. import consts -from ..vendored_sdks.v2021_11_01_preview.models import ( +from ..vendored_sdks.v2022_01_01_preview.models import ( FluxConfiguration, FluxConfigurationPatch, GitRepositoryDefinition, + GitRepositoryPatchDefinition, + BucketDefinition, RepositoryRefDefinition, KustomizationDefinition, - DependsOnDefinition -) -from ..vendored_sdks.v2021_05_01_preview.models import ( - Extension, - Identity + KustomizationPatchDefinition, + DependsOnDefinition, + SourceKindType, ) -from .SourceControlConfigurationProvider import SourceControlConfigurationProvider +from ..vendored_sdks.v2021_09_01.models import Extension, Identity logger = get_logger(__name__) -class FluxConfigurationProvider: - def __init__(self, cmd): - self.extension_client = k8s_configuration_extension_client(cmd.cli_ctx) - self.source_control_configuration_provider = SourceControlConfigurationProvider(cmd) - self.cmd = cmd - self.client = k8s_configuration_fluxconfig_client(cmd.cli_ctx) +def show_config(cmd, client, resource_group_name, cluster_type, cluster_name, name): + """Get an existing Kubernetes Source Control Configuration.""" - def show(self, resource_group_name, cluster_type, cluster_name, name): - """Get an existing Kubernetes Source Control Configuration. - - """ - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - try: - config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - return config - except HttpResponseError as ex: - # Customize the error message for resources not found - if ex.response.status_code == 404: - # If Cluster not found - if ex.message.__contains__("(ResourceNotFound)"): - message = ex.message - recommendation = 'Verify that the --cluster-type is correct and the Resource ' \ - '{0}/{1}/{2} exists'.format(cluster_rp, cluster_type, cluster_name) - # If Configuration not found - elif ex.message.__contains__("Operation returned an invalid status code 'Not Found'"): - message = '(FluxConfigurationNotFound) The Resource {0}/{1}/{2}/' \ - 'Microsoft.KubernetesConfiguration/fluxConfigurations/{3} ' \ - 'could not be found!' \ - .format(cluster_rp, cluster_type, cluster_name, name) - recommendation = 'Verify that the Resource {0}/{1}/{2}/Microsoft.KubernetesConfiguration' \ - '/fluxConfigurations/{3} exists'.format(cluster_rp, cluster_type, - cluster_name, name) - else: - message = ex.message - recommendation = '' - raise ResourceNotFoundError(message, recommendation) from ex - raise ex - - def list(self, resource_group_name, cluster_type, cluster_name): - cluster_rp = get_cluster_rp(cluster_type) - return self.client.list(resource_group_name, cluster_rp, cluster_type, cluster_name) - - # pylint: disable=too-many-locals - def create(self, resource_group_name, cluster_type, cluster_name, name, url=None, scope='cluster', - namespace='default', kind=consts.GIT, timeout=None, sync_interval=None, branch=None, - tag=None, semver=None, commit=None, local_auth_ref=None, ssh_private_key=None, - ssh_private_key_file=None, https_user=None, https_key=None, https_ca_cert=None, - https_ca_cert_file=None, known_hosts=None, known_hosts_file=None, suspend=False, - kustomization=None, no_wait=False): - - # Determine the cluster RP - cluster_rp = get_cluster_rp(cluster_type) - dp_source_kind = "" - git_repository = None - - # Validate and Create the Data before checking the cluster compataibility - if kind == consts.GIT: - dp_source_kind = consts.GIT_REPOSITORY - git_repository = self._validate_and_get_gitrepository(url, branch, tag, semver, commit, timeout, - sync_interval, ssh_private_key, - ssh_private_key_file, https_user, - https_key, https_ca_cert, https_ca_cert_file, - known_hosts, known_hosts_file, local_auth_ref, True) - - if kustomization: - # Convert the Internal List Representation of Kustomization to Dictionary - kustomization = {k.name: k.to_KustomizationDefinition() for k in kustomization} - else: - logger.warning(consts.NO_KUSTOMIZATIONS_WARNING) - kustomization = { - consts.DEFAULT_KUSTOMIZATION_NAME: KustomizationDefinition() - } - - # Get the protected settings and validate the private key value - protected_settings = get_protected_settings( - ssh_private_key, ssh_private_key_file, https_user, https_key + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + try: + config = client.get( + resource_group_name, cluster_rp, cluster_type, cluster_name, name ) - if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings: - validate_private_key(protected_settings['sshPrivateKey']) - - flux_configuration = FluxConfiguration( - scope=scope, - namespace=namespace, - source_kind=dp_source_kind, - git_repository=git_repository, - suspend=suspend, - kustomizations=kustomization, - configuration_protected_settings=protected_settings, + return config + except HttpResponseError as ex: + # Customize the error message for resources not found + if ex.response.status_code == 404: + # If Cluster not found + if ex.message.__contains__("(ResourceNotFound)"): + message = ex.message + recommendation = ( + "Verify that the --cluster-type is correct and the Resource " + "{0}/{1}/{2} exists".format(cluster_rp, cluster_type, cluster_name) + ) + # If Configuration not found + elif ex.message.__contains__( + "Operation returned an invalid status code 'Not Found'" + ): + message = ( + "(FluxConfigurationNotFound) The Resource {0}/{1}/{2}/" + "Microsoft.KubernetesConfiguration/fluxConfigurations/{3} " + "could not be found!".format( + cluster_rp, cluster_type, cluster_name, name + ) + ) + recommendation = ( + "Verify that the Resource {0}/{1}/{2}/Microsoft.KubernetesConfiguration" + "/fluxConfigurations/{3} exists".format( + cluster_rp, cluster_type, cluster_name, name + ) + ) + else: + message = ex.message + recommendation = "" + raise ResourceNotFoundError(message, recommendation) from ex + raise ex + + +def list_configs(cmd, client, resource_group_name, cluster_type, cluster_name): + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + return client.list(resource_group_name, cluster_rp, cluster_type, cluster_name) + + +# pylint: disable=too-many-locals +def create_config( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + url, + bucket_name=None, + scope="cluster", + namespace="default", + kind=consts.GIT, + timeout=None, + sync_interval=None, + branch=None, + tag=None, + semver=None, + commit=None, + local_auth_ref=None, + ssh_private_key=None, + ssh_private_key_file=None, + https_user=None, + https_key=None, + https_ca_cert=None, + https_ca_cert_file=None, + known_hosts=None, + known_hosts_file=None, + access_key=None, + secret_key=None, + insecure=False, + suspend=False, + kustomization=None, + no_wait=False, +): + + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + factory = source_kind_generator_factory( + kind, + url=url, + bucket_name=bucket_name, + timeout=timeout, + sync_interval=sync_interval, + branch=branch, + tag=tag, + semver=semver, + commit=commit, + local_auth_ref=local_auth_ref, + ssh_private_key=ssh_private_key, + ssh_private_key_file=ssh_private_key_file, + https_user=https_user, + https_key=https_key, + https_ca_cert=https_ca_cert, + https_ca_cert_file=https_ca_cert_file, + known_hosts=known_hosts, + known_hosts_file=known_hosts_file, + access_key=access_key, + secret_key=secret_key, + insecure=insecure, + ) + + # This update func is a generated update function that modifies + # the FluxConfiguration object with the appropriate source kind + update_func = factory.generate_update_func() + + if kustomization: + # Convert the Internal List Representation of Kustomization to Dictionary + kustomization = {k.name: k.to_KustomizationDefinition() for k in kustomization} + else: + logger.warning(consts.NO_KUSTOMIZATIONS_WARNING) + kustomization = {consts.DEFAULT_KUSTOMIZATION_NAME: KustomizationDefinition()} + + # Get the protected settings and validate the private key value + protected_settings = get_protected_settings( + ssh_private_key, ssh_private_key_file, https_key, secret_key + ) + if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings: + validate_private_key(protected_settings["sshPrivateKey"]) + + flux_configuration = FluxConfiguration( + scope=scope, + namespace=namespace, + suspend=suspend, + kustomizations=kustomization, + configuration_protected_settings=protected_settings, + ) + flux_configuration = update_func(flux_configuration) + + _validate_source_control_config_not_installed( + cmd, resource_group_name, cluster_rp, cluster_type, cluster_name + ) + _validate_extension_install( + cmd, resource_group_name, cluster_rp, cluster_type, cluster_name, no_wait + ) + + logger.warning( + "Creating the flux configuration '%s' in the cluster. This may take a few minutes...", + name, + ) + + return sdk_no_wait( + no_wait, + client.begin_create_or_update, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + flux_configuration, + ) + + +def update_config( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + kind=None, + url=None, + bucket_name=None, + timeout=None, + sync_interval=None, + branch=None, + tag=None, + semver=None, + commit=None, + local_auth_ref=None, + ssh_private_key=None, + ssh_private_key_file=None, + https_user=None, + https_key=None, + https_ca_cert=None, + https_ca_cert_file=None, + known_hosts=None, + known_hosts_file=None, + access_key=None, + secret_key=None, + insecure=None, + suspend=None, + kustomization=None, + no_wait=False, + yes=False, +): + + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + if not kind: + kind = convert_to_cli_source_kind(config.source_kind) + factory = source_kind_generator_factory( + kind, + url=url, + bucket_name=bucket_name, + timeout=timeout, + sync_interval=sync_interval, + branch=branch, + tag=tag, + semver=semver, + commit=commit, + local_auth_ref=local_auth_ref, + ssh_private_key=ssh_private_key, + ssh_private_key_file=ssh_private_key_file, + https_user=https_user, + https_key=https_key, + https_ca_cert=https_ca_cert, + https_ca_cert_file=https_ca_cert_file, + known_hosts=known_hosts, + known_hosts_file=known_hosts_file, + access_key=access_key, + secret_key=secret_key, + insecure=insecure, + ) + + # This update func is a generated update function that modifies + # the FluxConfiguration object with the appropriate source kind + # If we update the source kind, we will also null out the other + # kind type + changed_source_kind = ( + kind.lower() != convert_to_cli_source_kind(config.source_kind).lower() + ) + update_func = factory.generate_patch_update_func(changed_source_kind) + + if changed_source_kind: + user_confirmation_factory( + cmd, + yes, + f"You are choosing to migrate from source kind '{convert_to_cli_source_kind(config.source_kind).lower()}' " + + f"to source kind '{kind.lower()}'. Changing your source repository may also require you to change your " + + "kustomizations. Are you sure you want to change kinds?", ) - self._validate_source_control_config_not_installed(resource_group_name, cluster_type, cluster_name) - self._validate_extension_install(resource_group_name, cluster_rp, cluster_type, cluster_name, no_wait) - - logger.warning("Creating the flux configuration '%s' in the cluster. This may take a few minutes...", name) - - return sdk_no_wait(no_wait, self.client.begin_create_or_update, resource_group_name, cluster_rp, - cluster_type, cluster_name, name, flux_configuration) - - def update(self, resource_group_name, cluster_type, cluster_name, name, url=None, - timeout=None, sync_interval=None, branch=None, tag=None, semver=None, - commit=None, local_auth_ref=None, ssh_private_key=None, ssh_private_key_file=None, - https_user=None, https_key=None, https_ca_cert=None, https_ca_cert_file=None, known_hosts=None, - known_hosts_file=None, suspend=None, kustomization=None, no_wait=False): - # Determine the cluster RP - cluster_rp = get_cluster_rp(cluster_type) - - git_repository = None - if any([url, branch, tag, semver, commit, - timeout, sync_interval, - ssh_private_key, ssh_private_key_file, - https_user, https_key, https_ca_cert, - https_ca_cert_file, known_hosts, - known_hosts_file, local_auth_ref]): - git_repository = self._validate_and_get_gitrepository(url, branch, tag, semver, commit, - timeout, sync_interval, - ssh_private_key, ssh_private_key_file, - https_user, https_key, https_ca_cert, - https_ca_cert_file, known_hosts, - known_hosts_file, local_auth_ref, False) - - if kustomization: - # Convert the Internal List Representation of Kustomization to Dictionary - kustomization = {k.name: k.to_KustomizationDefinition() for k in kustomization} - - # Get the protected settings and validate the private key value - protected_settings = get_protected_settings( - ssh_private_key, ssh_private_key_file, https_user, https_key + if kustomization: + # Convert the Internal List Representation of Kustomization to Dictionary + kustomization = { + k.name: k.to_KustomizationPatchDefinition() for k in kustomization + } + + # Get the protected settings and validate the private key value + protected_settings = get_protected_settings( + ssh_private_key, ssh_private_key_file, https_key, secret_key + ) + if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings: + validate_private_key(protected_settings["sshPrivateKey"]) + + flux_configuration = FluxConfigurationPatch( + suspend=suspend, + kustomizations=kustomization, + configuration_protected_settings=protected_settings, + ) + flux_configuration = update_func(flux_configuration) + + return sdk_no_wait( + no_wait, + client.begin_update, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + flux_configuration, + ) + + +def create_kustomization( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + kustomization_name, + dependencies=None, + timeout=None, + sync_interval=None, + retry_interval=None, + path="", + prune=None, + force=None, + no_wait=False, +): + + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + # Pre-Validation + validate_duration("--timeout", timeout) + validate_duration("--sync-interval", sync_interval) + validate_duration("--retry-interval", retry_interval) + + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + if kustomization_name in current_config.kustomizations: + raise ValidationError( + consts.CREATE_KUSTOMIZATION_EXIST_ERROR.format(kustomization_name, name), + consts.CREATE_KUSTOMIZATION_EXIST_HELP, + ) + + # Add the dependencies in their model to the kustomization + model_dependencies = None + if dependencies: + model_dependencies = [] + for dep in parse_dependencies(dependencies): + model_dependencies.append(DependsOnDefinition(kustomization_name=dep)) + + kustomization = { + kustomization_name: KustomizationPatchDefinition( + path=path, + depends_on=model_dependencies, + timeout_in_seconds=parse_duration(timeout), + sync_interval_in_seconds=parse_duration(sync_interval), + retry_interval_in_seconds=parse_duration(retry_interval), + prune=prune, + force=force, ) - if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings: - validate_private_key(protected_settings['sshPrivateKey']) - - flux_configuration = FluxConfigurationPatch( - git_repository=git_repository, - suspend=suspend, - kustomizations=kustomization, - configuration_protected_settings=protected_settings, + } + flux_configuration_patch = FluxConfigurationPatch(kustomizations=kustomization) + return sdk_no_wait( + no_wait, + client.begin_update, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + flux_configuration_patch, + ) + + +def update_kustomization( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + kustomization_name, + dependencies=None, + timeout=None, + sync_interval=None, + retry_interval=None, + path=None, + prune=None, + force=None, + no_wait=False, +): + + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + # Pre-Validation + validate_duration("--timeout", timeout) + validate_duration("--sync-interval", sync_interval) + validate_duration("--retry-interval", retry_interval) + + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + if kustomization_name not in current_config.kustomizations: + raise ValidationError( + consts.UPDATE_KUSTOMIZATION_NO_EXIST_ERROR.format(kustomization_name, name), + consts.UPDATE_KUSTOMIZATION_NO_EXIST_HELP, ) - return sdk_no_wait(no_wait, self.client.begin_update, resource_group_name, cluster_rp, - cluster_type, cluster_name, name, flux_configuration) + # Add the dependencies in their model to the kustomization + model_dependencies = None + if dependencies: + model_dependencies = [] + for dep in parse_dependencies(dependencies): + model_dependencies.append(DependsOnDefinition(kustomization_name=dep)) + + kustomization = { + kustomization_name: KustomizationPatchDefinition( + path=path, + depends_on=model_dependencies, + timeout_in_seconds=parse_duration(timeout), + sync_interval_in_seconds=parse_duration(sync_interval), + retry_interval_in_seconds=parse_duration(retry_interval), + prune=prune, + force=force, + ) + } + flux_configuration_patch = FluxConfigurationPatch(kustomizations=kustomization) + return sdk_no_wait( + no_wait, + client.begin_update, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + flux_configuration_patch, + ) + + +def delete_kustomization( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + kustomization_name, + no_wait=False, + yes=False, +): + + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + # Confirmation message for deletes + user_confirmation_factory(cmd, yes) + + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + if kustomization_name not in current_config.kustomizations: + raise ValidationError( + consts.DELETE_KUSTOMIZATION_NO_EXIST_ERROR.format(kustomization_name, name), + consts.DELETE_KUSTOMIZATION_NO_EXIST_HELP, + ) - def create_kustomization(self, resource_group_name, cluster_type, cluster_name, name, - kustomization_name, dependencies=None, timeout=None, sync_interval=None, - retry_interval=None, path='', prune=False, force=False, no_wait=False): - # Pre-Validation - validate_duration("--timeout", timeout) - validate_duration("--sync-interval", sync_interval) - validate_duration("--retry-interval", retry_interval) - - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - if kustomization_name in current_config.kustomizations: - raise ValidationError( - consts.CREATE_KUSTOMIZATION_EXIST_ERROR.format(kustomization_name, name), - consts.CREATE_KUSTOMIZATION_EXIST_HELP - ) + if current_config.kustomizations[kustomization_name].prune: + logger.warning( + "Prune is enabled on this kustomization. Deleting a kustomization " + "with prune enabled will also delete the Kubernetes objects " + "deployed by the kustomization." + ) + user_confirmation_factory(cmd, yes, "Do you want to continue?") + + kustomization = {kustomization_name: None} + flux_configuration_patch = FluxConfigurationPatch(kustomizations=kustomization) + return sdk_no_wait( + no_wait, + client.begin_update, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + flux_configuration_patch, + ) + + +def list_kustomization( + cmd, client, resource_group_name, cluster_type, cluster_name, name +): + # Get Resource Provider to call + validate_cc_registration(cmd) + + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + return current_config.kustomizations + + +def show_kustomization( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + kustomization_name, +): + + validate_cc_registration(cmd) + + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + if kustomization_name not in current_config.kustomizations: + raise ValidationError( + consts.SHOW_KUSTOMIZATION_NO_EXIST_ERROR.format(kustomization_name), + consts.SHOW_KUSTOMIZATION_NO_EXIST_HELP, + ) + return {kustomization_name: current_config.kustomizations[kustomization_name]} + + +def list_deployed_object( + cmd, client, resource_group_name, cluster_type, cluster_name, name +): + validate_cc_registration(cmd) + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + return current_config.statuses + + +def show_deployed_object( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + object_name, + object_namespace, + object_kind, +): + validate_cc_registration(cmd) + current_config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + + for status in current_config.statuses: + if ( + status.name == object_name + and status.namespace == object_namespace + and status.kind == object_kind + ): + return status + raise ValidationError( + consts.SHOW_DEPLOYED_OBJECT_NO_EXIST_ERROR.format( + object_name, object_namespace, object_kind, name + ), + consts.SHOW_DEPLOYED_OBJECT_NO_EXIST_HELP, + ) + + +def delete_config( + cmd, + client, + resource_group_name, + cluster_type, + cluster_name, + name, + force=False, + no_wait=False, + yes=False, +): + + # Confirmation message for deletes + user_confirmation_factory(cmd, yes) + + # Get Resource Provider to call + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + validate_cc_registration(cmd) + + config = None + try: + config = show_config( + cmd, client, resource_group_name, cluster_type, cluster_name, name + ) + except HttpResponseError: + logger.warning( + "No flux configuration with name '%s' found on cluster '%s', so nothing to delete", + name, + cluster_name, + ) + return None - # Add the dependencies in their model to the kustomization - model_dependencies = None - if dependencies: - model_dependencies = [] - for dep in parse_dependencies(dependencies): - model_dependencies.append( - DependsOnDefinition( - kustomization_name=dep - ) - ) + if has_prune_enabled(config): + logger.warning( + "Prune is enabled on one or more of your kustomizations. Deleting a Flux " + "configuration with prune enabled will also delete the Kubernetes objects " + "deployed by the kustomization(s)." + ) + user_confirmation_factory(cmd, yes, "Do you want to continue?") - kustomization = { - kustomization_name: KustomizationDefinition( - path=path, - depends_on=model_dependencies, - timeout_in_seconds=parse_duration(timeout), - sync_interval_in_seconds=parse_duration(sync_interval), - retry_interval_in_seconds=parse_duration(retry_interval), - prune=prune, - force=force - ) - } - flux_configuration_patch = FluxConfigurationPatch( - kustomizations=kustomization + if not force: + logger.info( + "Deleting the flux configuration from the cluster. This may take a few minutes..." + ) + return sdk_no_wait( + no_wait, + client.begin_delete, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + force_delete=force, + ) + + +def _validate_source_control_config_not_installed( + cmd, resource_group_name, cluster_rp, cluster_type, cluster_name +): + # Validate if we are able to install the flux configuration + source_control_client = k8s_configuration_sourcecontrol_client(cmd.cli_ctx) + configs = source_control_client.list( + resource_group_name, cluster_rp, cluster_type, cluster_name + ) + # configs is an iterable, no len() so we have to iterate to check for configs + for _ in configs: + raise DeploymentError( + consts.SCC_EXISTS_ON_CLUSTER_ERROR, consts.SCC_EXISTS_ON_CLUSTER_HELP ) - return sdk_no_wait(no_wait, self.client.begin_update, resource_group_name, cluster_rp, - cluster_type, cluster_name, name, flux_configuration_patch) - def update_kustomization(self, resource_group_name, cluster_type, cluster_name, name, - kustomization_name, dependencies=None, timeout=None, sync_interval=None, - retry_interval=None, path=None, prune=False, force=False, no_wait=False): - # Pre-Validation - validate_duration("--timeout", timeout) - validate_duration("--sync-interval", sync_interval) - validate_duration("--retry-interval", retry_interval) - - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - if kustomization_name not in current_config.kustomizations: - raise ValidationError( - consts.UPDATE_KUSTOMIZATION_NO_EXIST_ERROR.format(kustomization_name, name), - consts.UPDATE_KUSTOMIZATION_NO_EXIST_HELP - ) - # Add the dependencies in their model to the kustomization - model_dependencies = None - if dependencies: - model_dependencies = [] - for dep in parse_dependencies(dependencies): - model_dependencies.append( - DependsOnDefinition( - kustomization_name=dep - ) - ) +def _validate_extension_install( + cmd, resource_group_name, cluster_rp, cluster_type, cluster_name, no_wait +): + # Validate if the extension is installed, if not, install it + extension_client = k8s_configuration_extension_client(cmd.cli_ctx) + extensions = extension_client.list( + resource_group_name, cluster_rp, cluster_type, cluster_name + ) + flux_extension = None + for extension in extensions: + if extension.extension_type.lower() == consts.FLUX_EXTENSION_TYPE: + flux_extension = extension + break + if not flux_extension: + logger.warning( + "'Microsoft.Flux' extension not found on the cluster, installing it now." + " This may take a few minutes..." + ) - kustomization = { - kustomization_name: KustomizationDefinition( - path=path, - depends_on=model_dependencies, - timeout_in_seconds=parse_duration(timeout), - sync_interval_in_seconds=parse_duration(sync_interval), - retry_interval_in_seconds=parse_duration(retry_interval), - prune=prune, - force=force - ) - } - flux_configuration_patch = FluxConfigurationPatch( - kustomizations=kustomization + extension = Extension( + extension_type="microsoft.flux", + auto_upgrade_minor_version=True, + release_train=os.getenv(consts.FLUX_EXTENSION_RELEASETRAIN), + version=os.getenv(consts.FLUX_EXTENSION_VERSION), ) - return sdk_no_wait(no_wait, self.client.begin_update, resource_group_name, cluster_rp, - cluster_type, cluster_name, name, flux_configuration_patch) - - def delete_kustomization(self, resource_group_name, cluster_type, cluster_name, name, - kustomization_name, no_wait=False, yes=False): - # Confirmation message for deletes - user_confirmation_factory(self.cmd, yes) - - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - if kustomization_name not in current_config.kustomizations: - raise ValidationError( - consts.DELETE_KUSTOMIZATION_NO_EXIST_ERROR.format(kustomization_name, name), - consts.DELETE_KUSTOMIZATION_NO_EXIST_HELP + if not is_dogfood_cluster(cmd): + extension = __add_identity( + cmd, + extension, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, ) - if current_config.kustomizations[kustomization_name].prune: - logger.warning("Prune is enabled on this kustomization. Deleting a kustomization " - "with prune enabled will also delete the Kubernetes objects " - "deployed by the kustomization.") - user_confirmation_factory(self.cmd, yes, "Do you want to continue?") - - kustomization = { - kustomization_name: None - } - flux_configuration_patch = FluxConfigurationPatch( - kustomizations=kustomization + logger.info( + "Starting extension creation on the cluster. This might take a few minutes..." ) - return sdk_no_wait(no_wait, self.client.begin_update, resource_group_name, cluster_rp, - cluster_type, cluster_name, name, flux_configuration_patch) - - def list_kustomization(self, resource_group_name, cluster_type, cluster_name, name): - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - return current_config.kustomizations - - def show_kustomization(self, resource_group_name, cluster_type, cluster_name, name, kustomization_name): - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - if kustomization_name not in current_config.kustomizations: - raise ValidationError( - consts.SHOW_KUSTOMIZATION_NO_EXIST_ERROR.format(kustomization_name, name), - consts.SHOW_KUSTOMIZATION_NO_EXIST_HELP + sdk_no_wait( + no_wait, + extension_client.begin_create, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + "flux", + extension, + ).result() + # Only show that we have received a success when we have --no-wait + if not no_wait: + logger.warning( + "'Microsoft.Flux' extension was successfully installed on the cluster" ) - return {kustomization_name: current_config.kustomizations[kustomization_name]} - - def list_deployed_object(self, resource_group_name, cluster_type, cluster_name, name): - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - return current_config.statuses - - def show_deployed_object(self, resource_group_name, cluster_type, cluster_name, name, - object_name, object_namespace, object_kind): - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - current_config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - - for status in current_config.statuses: - if status.name == object_name and status.namespace == object_namespace and status.kind == object_kind: - return status - raise ValidationError( - consts.SHOW_DEPLOYED_OBJECT_NO_EXIST_ERROR.format(object_name, object_namespace, object_kind, name), - consts.SHOW_DEPLOYED_OBJECT_NO_EXIST_HELP + elif flux_extension.provisioning_state == consts.CREATING: + raise DeploymentError( + consts.FLUX_EXTENSION_CREATING_ERROR, consts.FLUX_EXTENSION_CREATING_HELP + ) + elif flux_extension.provisioning_state != consts.SUCCEEDED: + raise DeploymentError( + consts.FLUX_EXTENSION_NOT_SUCCEEDED_OR_CREATING_ERROR, + consts.FLUX_EXTENSION_NOT_SUCCEEDED_OR_CREATING_HELP, ) - def delete(self, resource_group_name, cluster_type, cluster_name, name, force, no_wait, yes): - # Confirmation message for deletes - user_confirmation_factory(self.cmd, yes) - - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - - config = None - try: - config = self.client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - except HttpResponseError: - logger.warning("No flux configuration with name '%s' found on cluster '%s', so nothing to delete", - name, cluster_name) - return None - - if has_prune_enabled(config): - logger.warning("Prune is enabled on one or more of your kustomizations. Deleting a Flux " - "configuration with prune enabled will also delete the Kubernetes objects " - "deployed by the kustomization(s).") - user_confirmation_factory(self.cmd, yes, "Do you want to continue?") - - if not force: - logger.info("Deleting the flux configuration from the cluster. This may take a few minutes...") - return sdk_no_wait(no_wait, self.client.begin_delete, resource_group_name, cluster_rp, cluster_type, - cluster_name, name, force_delete=force) - - def _is_deferred(self): - if '--defer' in self.cmd.cli_ctx.data.get('safe_params'): - return True - return False - - def _validate_source_control_config_not_installed(self, resource_group_name, cluster_type, cluster_name): - # Validate if we are able to install the flux configuration - configs = self.source_control_configuration_provider.list(resource_group_name, cluster_type, cluster_name) - # configs is an iterable, no len() so we have to iterate to check for configs - for _ in configs: - raise DeploymentError( - consts.SCC_EXISTS_ON_CLUSTER_ERROR, - consts.SCC_EXISTS_ON_CLUSTER_HELP) - - def _validate_extension_install(self, resource_group_name, cluster_rp, cluster_type, cluster_name, no_wait): - # Validate if the extension is installed, if not, install it - extensions = self.extension_client.list(resource_group_name, cluster_rp, cluster_type, cluster_name) - flux_extension = None - for extension in extensions: - if extension.extension_type.lower() == consts.FLUX_EXTENSION_TYPE: - flux_extension = extension - break - if not flux_extension: - logger.warning("'Microsoft.Flux' extension not found on the cluster, installing it now." - " This may take a few minutes...") - - extension = Extension( - extension_type="microsoft.flux", - auto_upgrade_minor_version=True, - release_train=os.getenv(consts.FLUX_EXTENSION_RELEASETRAIN), - version=os.getenv(consts.FLUX_EXTENSION_VERSION) - ) - if not is_dogfood_cluster(self.cmd): - extension = self.__add_identity(extension, - resource_group_name, - cluster_rp, - cluster_type, - cluster_name) - - logger.info("Starting extension creation on the cluster. This might take a few minutes...") - sdk_no_wait(no_wait, self.extension_client.begin_create, resource_group_name, cluster_rp, cluster_type, - cluster_name, "flux", extension).result() - # Only show that we have received a success when we have --no-wait - if not no_wait: - logger.warning("'Microsoft.Flux' extension was successfully installed on the cluster") - elif flux_extension.provisioning_state == consts.CREATING: - raise DeploymentError( - consts.FLUX_EXTENSION_CREATING_ERROR, - consts.FLUX_EXTENSION_CREATING_HELP + +def __add_identity( + cmd, extension_instance, resource_group_name, cluster_rp, cluster_type, cluster_name +): + subscription_id = get_subscription_id(cmd.cli_ctx) + resources = cf_resources(cmd.cli_ctx, subscription_id) + + if cluster_type.lower() == consts.MANAGED_CLUSTER_TYPE: + return extension_instance + + cluster_rp, parent_api_version = get_cluster_rp_api_version(cluster_type) + + cluster_resource_id = ( + "/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}".format( + subscription_id, resource_group_name, cluster_rp, cluster_type, cluster_name + ) + ) + + try: + resource = resources.get_by_id(cluster_resource_id, parent_api_version) + location = str(resource.location.lower()) + except HttpResponseError as ex: + raise ex + identity_type = "SystemAssigned" + + extension_instance.identity = Identity(type=identity_type) + extension_instance.location = location + return extension_instance + + +def source_kind_generator_factory(kind=consts.GIT, **kwargs): + if kind == consts.GIT: + return GitRepositoryGenerator(**kwargs) + return BucketGenerator(**kwargs) + + +def convert_to_cli_source_kind(rp_source_kind): + if rp_source_kind == consts.GIT_REPOSITORY: + return consts.GIT + return consts.BUCKET + + +class SourceKindGenerator: + def __init__(self, kind, required_params, valid_params): + self.kind = kind + self.valid_params = valid_params + self.required_params = required_params + + def validate_required_params(self, **kwargs): + copied_required = self.required_params.copy() + for kwarg, value in kwargs.items(): + if value: + copied_required.discard(kwarg) + if len(copied_required) > 0: + raise RequiredArgumentMissingError( + consts.REQUIRED_VALUES_MISSING_ERROR.format( + ",".join(map(pretty_parameter, copied_required)), self.kind + ), + consts.REQUIRED_VALUES_MISSING_HELP, ) - elif flux_extension.provisioning_state != consts.SUCCEEDED: - # Print the error detail so the user know how to fix it - if flux_extension.error_detail: - logger.error('%s %s', flux_extension.error_detail.code, flux_extension.error_detail.message) - raise DeploymentError( - consts.FLUX_EXTENSION_NOT_SUCCEEDED_OR_CREATING_ERROR, - consts.FLUX_EXTENSION_NOT_SUCCEEDED_OR_CREATING_HELP + + def validate_params(self, **kwargs): + bad_args = [] + for kwarg, value in kwargs.items(): + if value and kwarg not in self.valid_params: + bad_args.append(kwarg) + if len(bad_args) > 0: + raise UnrecognizedArgumentError( + consts.EXTRA_VALUES_PROVIDED_ERROR.format( + ",".join(map(pretty_parameter, bad_args)), self.kind + ), + consts.EXTRA_VALUES_PROVIDED_HELP.format( + self.kind, ",".join(map(pretty_parameter, self.valid_params)) + ), ) - def _validate_and_get_gitrepository(self, url, branch, tag, semver, commit, timeout, sync_interval, - ssh_private_key, ssh_private_key_file, https_user, https_key, - https_ca_cert, https_ca_cert_file, known_hosts, known_hosts_file, - local_auth_ref, is_create): + +def pretty_parameter(parameter): + parameter = parameter.replace("_", "-") + return "'--" + parameter + "'" + + +# pylint: disable=too-many-instance-attributes +class GitRepositoryGenerator(SourceKindGenerator): + def __init__(self, **kwargs): + # Common Pre-Validation + super().__init__( + consts.GIT, consts.GIT_REPO_REQUIRED_PARAMS, consts.GIT_REPO_VALID_PARAMS + ) + super().validate_params(**kwargs) + # Pre-Validation - validate_duration("--timeout", timeout) - validate_duration("--sync-interval", sync_interval) + validate_duration("--timeout", kwargs.get("timeout")) + validate_duration("--sync-interval", kwargs.get("sync_interval")) + + self.kwargs = kwargs + self.url = kwargs.get("url") + self.timeout = kwargs.get("timeout") + self.sync_interval = kwargs.get("sync_interval") + self.local_auth_ref = kwargs.get("local_auth_ref") + self.known_hosts = kwargs.get("known_hosts") + self.known_hosts_file = kwargs.get("known_hosts_file") + self.ssh_private_key = kwargs.get("ssh_private_key") + self.ssh_private_key_file = kwargs.get("ssh_private_key_file") + self.https_user = kwargs.get("https_user") + self.https_key = kwargs.get("https_key") # Get the known hosts data and validate it - knownhost_data = get_data_from_key_or_file(known_hosts, known_hosts_file, strip_newline=True) - if knownhost_data: - validate_known_hosts(knownhost_data) - - https_ca_data = get_data_from_key_or_file(https_ca_cert, https_ca_cert_file, strip_newline=True) - - # Validate registration with the RP endpoint - validate_cc_registration(self.cmd) - - if is_create: - validate_git_repository(url) - validate_url_with_params(url, ssh_private_key, ssh_private_key_file, - known_hosts, known_hosts_file, https_user, https_key) - validate_repository_ref(branch, tag, semver, commit) - - repository_ref = None - if any([branch, tag, semver, commit]): - repository_ref = RepositoryRefDefinition( - branch=branch, - tag=tag, - semver=semver, - commit=commit + self.knownhost_data = get_data_from_key_or_file( + kwargs.get("known_hosts"), + kwargs.get("known_hosts_file"), + strip_newline=True, + ) + if self.knownhost_data: + validate_known_hosts(self.knownhost_data) + + self.https_ca_data = get_data_from_key_or_file( + kwargs.get("https_ca_cert"), + kwargs.get("https_ca_cert_file"), + strip_newline=True, + ) + self.repository_ref = None + if any( + [ + kwargs.get("branch"), + kwargs.get("tag"), + kwargs.get("semver"), + kwargs.get("commit"), + ] + ): + self.repository_ref = RepositoryRefDefinition( + branch=kwargs.get("branch"), + tag=kwargs.get("tag"), + semver=kwargs.get("semver"), + commit=kwargs.get("commit"), ) - # Encode the https username to base64 - if https_user: - https_user = to_base64(https_user) + def validate(self): + super().validate_required_params(**self.kwargs) + validate_git_url(self.url) + validate_url_with_params( + self.url, + self.ssh_private_key, + self.ssh_private_key_file, + self.known_hosts, + self.known_hosts_file, + self.https_user, + self.https_key, + ) + validate_repository_ref(self.repository_ref) - return GitRepositoryDefinition( - url=url, - timeout_in_seconds=parse_duration(timeout), - sync_interval_in_seconds=parse_duration(sync_interval), - repository_ref=repository_ref, - ssh_known_hosts=knownhost_data, - https_user=https_user, - local_auth_ref=local_auth_ref, - https_ca_file=https_ca_data + def generate_update_func(self): + """ + generate_update_func(self) generates a function to add a GitRepository + object to the flux configuration for the PUT case + """ + self.validate() + + def updater(config): + config.git_repository = GitRepositoryDefinition( + url=self.url, + timeout_in_seconds=parse_duration(self.timeout), + sync_interval_in_seconds=parse_duration(self.sync_interval), + repository_ref=self.repository_ref, + ssh_known_hosts=self.knownhost_data, + https_user=self.https_user, + local_auth_ref=self.local_auth_ref, + https_ca_cert=self.https_ca_data, + ) + config.source_kind = SourceKindType.GIT_REPOSITORY + return config + + return updater + + def generate_patch_update_func(self, swapped_kind): + """ + generate_patch_update_func(self) generates a function update the GitRepository + object to the flux configuration for the PATCH case. + If the source kind has been changed, we also set the Bucket to null + """ + + def git_repository_updater(config): + if any(kwarg is not None for kwarg in self.kwargs.values()): + config.git_repository = GitRepositoryPatchDefinition( + url=self.url, + timeout_in_seconds=parse_duration(self.timeout), + sync_interval_in_seconds=parse_duration(self.sync_interval), + repository_ref=self.repository_ref, + ssh_known_hosts=self.knownhost_data, + https_user=self.https_user, + local_auth_ref=self.local_auth_ref, + https_ca_cert=self.https_ca_data, + ) + if swapped_kind: + self.validate() + config.source_kind = SourceKindType.GIT_REPOSITORY + + # Have to set these things to none otherwise the patch will fail + # due to default values + config.bucket = BucketDefinition( + insecure=None, + timeout_in_seconds=None, + sync_interval_in_seconds=None, + ) + return config + + return git_repository_updater + + +class BucketGenerator(SourceKindGenerator): + def __init__(self, **kwargs): + # Common Pre-Validation + super().__init__( + consts.BUCKET, consts.BUCKET_REQUIRED_PARAMS, consts.BUCKET_VALID_PARAMS ) + super().validate_params(**kwargs) + + # Pre-Validations + validate_duration("--timeout", kwargs.get("timeout")) + validate_duration("--sync-interval", kwargs.get("sync_interval")) + + self.kwargs = kwargs + self.url = kwargs.get("url") + self.bucket_name = kwargs.get("bucket_name") + self.timeout = kwargs.get("timeout") + self.sync_interval = kwargs.get("sync_interval") + self.access_key = kwargs.get("access_key") + self.secret_key = kwargs.get("secret_key") + self.local_auth_ref = kwargs.get("local_auth_ref") + self.insecure = kwargs.get("insecure") + + def validate(self): + super().validate_required_params(**self.kwargs) + validate_bucket_url(self.url) + if not ((self.access_key and self.secret_key) or self.local_auth_ref): + raise RequiredArgumentMissingError( + consts.REQUIRED_BUCKET_VALUES_MISSING_ERROR, + consts.REQUIRED_BUCKET_VALUES_MISSING_HELP, + ) - def __add_identity(self, extension_instance, resource_group_name, cluster_rp, cluster_type, cluster_name): - subscription_id = get_subscription_id(self.cmd.cli_ctx) - resources = cf_resources(self.cmd.cli_ctx, subscription_id) - - cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}'.format(subscription_id, - resource_group_name, - cluster_rp, - cluster_type, - cluster_name) - - if cluster_rp == consts.MANAGED_RP_NAMESPACE: - return extension_instance - parent_api_version = get_parent_api_version(cluster_rp) - try: - resource = resources.get_by_id(cluster_resource_id, parent_api_version) - location = str(resource.location.lower()) - except HttpResponseError as ex: - raise ex - identity_type = "SystemAssigned" - - extension_instance.identity = Identity(type=identity_type) - extension_instance.location = location - return extension_instance + def generate_update_func(self): + """ + generate_update_func(self) generates a function to add a Bucket + object to the flux configuration for the PUT case + """ + self.validate() + + def bucket_updater(config): + config.bucket = BucketDefinition( + url=self.url, + bucket_name=self.bucket_name, + timeout_in_seconds=parse_duration(self.timeout), + sync_interval_in_seconds=parse_duration(self.sync_interval), + access_key=self.access_key, + local_auth_ref=self.local_auth_ref, + insecure=self.insecure, + ) + config.source_kind = SourceKindType.BUCKET + return config + + return bucket_updater + + def generate_patch_update_func(self, swapped_kind): + """ + generate_patch_update_func(self) generates a function update the Bucket + object to the flux configuration for the PATCH case. + If the source kind has been changed, we also set the GitRepository to null + """ + + def bucket_patch_updater(config): + if any(kwarg is not None for kwarg in self.kwargs.values()): + config.bucket = BucketDefinition( + url=self.url, + bucket_name=self.bucket_name, + timeout_in_seconds=parse_duration(self.timeout), + sync_interval_in_seconds=parse_duration(self.sync_interval), + access_key=self.access_key, + local_auth_ref=self.local_auth_ref, + insecure=self.insecure, + ) + if swapped_kind: + self.validate() + config.source_kind = SourceKindType.BUCKET + config.git_repository = GitRepositoryPatchDefinition() + return config + + return bucket_patch_updater -def get_protected_settings(ssh_private_key, ssh_private_key_file, https_user, https_key): +def get_protected_settings( + ssh_private_key, ssh_private_key_file, https_key, secret_key +): protected_settings = {} - ssh_private_key_data = get_data_from_key_or_file(ssh_private_key, ssh_private_key_file) + ssh_private_key_data = get_data_from_key_or_file( + ssh_private_key, ssh_private_key_file + ) # Add gitops private key data to protected settings if exists - # Dry-run all key types to determine if the private key is in a valid format if ssh_private_key_data: protected_settings[consts.SSH_PRIVATE_KEY_KEY] = ssh_private_key_data - # Check if both httpsUser and httpsKey exist, then add to protected settings - if https_user and https_key: + if https_key: protected_settings[consts.HTTPS_KEY_KEY] = to_base64(https_key) + if secret_key: + protected_settings[consts.BUCKET_SECRET_KEY_KEY] = to_base64(secret_key) + # Return the protected settings dict if there are any values there return protected_settings if len(protected_settings) > 0 else None diff --git a/src/k8s-configuration/azext_k8s_configuration/providers/SourceControlConfigurationProvider.py b/src/k8s-configuration/azext_k8s_configuration/providers/SourceControlConfigurationProvider.py index d5d497ac514..7209a12730b 100644 --- a/src/k8s-configuration/azext_k8s_configuration/providers/SourceControlConfigurationProvider.py +++ b/src/k8s-configuration/azext_k8s_configuration/providers/SourceControlConfigurationProvider.py @@ -7,124 +7,175 @@ from azure.core.exceptions import HttpResponseError from knack.log import get_logger -from .._client_factory import k8s_configuration_sourcecontrol_client -from ..utils import fix_compliance_state, get_cluster_rp, get_data_from_key_or_file, to_base64 -from ..validators import validate_cc_registration, validate_known_hosts, validate_url_with_params +from ..utils import ( + fix_compliance_state, + get_cluster_rp_api_version, + get_data_from_key_or_file, + to_base64, +) +from ..validators import ( + validate_cc_registration, + validate_known_hosts, + validate_url_with_params, +) from .. import consts from ..vendored_sdks.v2021_03_01.models import ( HelmOperatorProperties, - SourceControlConfiguration + SourceControlConfiguration, ) logger = get_logger(__name__) -class SourceControlConfigurationProvider: - def __init__(self, cmd): - self.cmd = cmd - self.client = k8s_configuration_sourcecontrol_client(cmd.cli_ctx) - - def show(self, resource_group_name, cluster_type, cluster_name, name): - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - try: - extension = self.client.get(resource_group_name, - cluster_rp, cluster_type, - cluster_name, name) - return extension - except HttpResponseError as ex: - # Customize the error message for resources not found - if ex.response.status_code == 404: - # If Cluster not found - if ex.message.__contains__("(ResourceNotFound)"): - message = "{0} Verify that the cluster-type is correct and the resource exists.".format( - ex.message) - # If Configuration not found - elif ex.message.__contains__("Operation returned an invalid status code 'Not Found'"): - message = "(SourceControlConfigurationNotFound) The Resource {0}/{1}/{2}/" \ - "Microsoft.KubernetesConfiguration/sourceControlConfigurations/{3}" \ - "could not be found!".format(cluster_rp, cluster_type, - cluster_name, name) - else: - message = ex.message - raise ResourceNotFoundError(message) from ex - raise ex - - def list(self, resource_group_name, cluster_type, cluster_name): - cluster_rp = get_cluster_rp(cluster_type) - return self.client.list(resource_group_name, cluster_rp, cluster_type, cluster_name) - - def delete(self, resource_group_name, cluster_type, cluster_name, name): - cluster_rp = get_cluster_rp(cluster_type) - return self.client.begin_delete(resource_group_name, cluster_rp, cluster_type, cluster_name, name) - - # pylint: disable=too-many-locals - def create(self, resource_group_name, cluster_name, name, repository_url, scope, cluster_type, - operator_instance_name, operator_namespace, helm_operator_chart_version, operator_type, - operator_params, ssh_private_key, ssh_private_key_file, https_user, https_key, - ssh_known_hosts, ssh_known_hosts_file, enable_helm_operator, helm_operator_params): - - """Create a new Kubernetes Source Control Configuration. - - """ - # Determine ClusterRP - cluster_rp = get_cluster_rp(cluster_type) - - # Determine operatorInstanceName - if operator_instance_name is None: - operator_instance_name = name - - # Create helmOperatorProperties object - helm_operator_properties = None - if enable_helm_operator: - helm_operator_properties = HelmOperatorProperties() - helm_operator_properties.chart_version = helm_operator_chart_version.strip() - helm_operator_properties.chart_values = helm_operator_params.strip() - - validate_url_with_params(repository_url, - ssh_private_key, - ssh_private_key_file, - ssh_known_hosts, - ssh_known_hosts_file, - https_user, - https_key) - - protected_settings = get_protected_settings(ssh_private_key, - ssh_private_key_file, - https_user, - https_key) - knownhost_data = get_data_from_key_or_file(ssh_known_hosts, ssh_known_hosts_file) - if knownhost_data: - validate_known_hosts(knownhost_data) - - # Validate that the subscription is registered to Microsoft.KubernetesConfiguration - validate_cc_registration(self.cmd) - - # Create sourceControlConfiguration object - source_control_configuration = SourceControlConfiguration( - repository_url=repository_url, - operator_namespace=operator_namespace, - operator_instance_name=operator_instance_name, - operator_type=operator_type, - operator_params=operator_params, - configuration_protected_settings=protected_settings, - operator_scope=scope, - ssh_known_hosts_contents=knownhost_data, - enable_helm_operator=enable_helm_operator, - helm_operator_properties=helm_operator_properties - ) - - # Try to create the resource - config = self.client.create_or_update(resource_group_name, cluster_rp, cluster_type, cluster_name, - name, source_control_configuration) +def show_config(cmd, client, resource_group_name, cluster_type, cluster_name, name): + # Validate that the subscription is registered to Microsoft.KubernetesConfiguration + validate_cc_registration(cmd) - return fix_compliance_state(config) - - -def get_protected_settings(ssh_private_key, ssh_private_key_file, https_user, https_key): + # Determine ClusterRP + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + try: + extension = client.get( + resource_group_name, cluster_rp, cluster_type, cluster_name, name + ) + return extension + except HttpResponseError as ex: + # Customize the error message for resources not found + if ex.response.status_code == 404: + # If Cluster not found + if ex.message.__contains__("(ResourceNotFound)"): + message = "{0} Verify that the cluster-type is correct and the resource exists.".format( + ex.message + ) + # If Configuration not found + elif ex.message.__contains__( + "Operation returned an invalid status code 'Not Found'" + ): + message = ( + "(SourceControlConfigurationNotFound) The Resource {0}/{1}/{2}/" + "Microsoft.KubernetesConfiguration/sourceControlConfigurations/{3}" + "could not be found!".format( + cluster_rp, cluster_type, cluster_name, name + ) + ) + else: + message = ex.message + raise ResourceNotFoundError(message) from ex + raise ex + + +def list_configs(cmd, client, resource_group_name, cluster_type, cluster_name): + # Validate that the subscription is registered to Microsoft.KubernetesConfiguration + validate_cc_registration(cmd) + + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + return client.list(resource_group_name, cluster_rp, cluster_type, cluster_name) + + +def delete_config(cmd, client, resource_group_name, cluster_type, cluster_name, name): + # Validate that the subscription is registered to Microsoft.KubernetesConfiguration + validate_cc_registration(cmd) + + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + return client.begin_delete( + resource_group_name, cluster_rp, cluster_type, cluster_name, name + ) + + +# pylint: disable=too-many-locals +def create_config( + cmd, + client, + resource_group_name, + cluster_name, + name, + repository_url, + scope, + cluster_type, + operator_instance_name=None, + operator_namespace="default", + helm_operator_chart_version="1.4.0", + operator_type="flux", + operator_params="", + ssh_private_key="", + ssh_private_key_file="", + https_user="", + https_key="", + ssh_known_hosts="", + ssh_known_hosts_file="", + enable_helm_operator=None, + helm_operator_params="", +): + + """Create a new Kubernetes Source Control Configuration.""" + # Determine ClusterRP + cluster_rp, _ = get_cluster_rp_api_version(cluster_type) + + # Determine operatorInstanceName + if operator_instance_name is None: + operator_instance_name = name + + # Create helmOperatorProperties object + helm_operator_properties = None + if enable_helm_operator: + helm_operator_properties = HelmOperatorProperties() + helm_operator_properties.chart_version = helm_operator_chart_version.strip() + helm_operator_properties.chart_values = helm_operator_params.strip() + + validate_url_with_params( + repository_url, + ssh_private_key, + ssh_private_key_file, + ssh_known_hosts, + ssh_known_hosts_file, + https_user, + https_key, + ) + + protected_settings = get_protected_settings( + ssh_private_key, ssh_private_key_file, https_user, https_key + ) + knownhost_data = get_data_from_key_or_file(ssh_known_hosts, ssh_known_hosts_file) + if knownhost_data: + validate_known_hosts(knownhost_data) + + # Validate that the subscription is registered to Microsoft.KubernetesConfiguration + validate_cc_registration(cmd) + + # Create sourceControlConfiguration object + source_control_configuration = SourceControlConfiguration( + repository_url=repository_url, + operator_namespace=operator_namespace, + operator_instance_name=operator_instance_name, + operator_type=operator_type, + operator_params=operator_params, + configuration_protected_settings=protected_settings, + operator_scope=scope, + ssh_known_hosts_contents=knownhost_data, + enable_helm_operator=enable_helm_operator, + helm_operator_properties=helm_operator_properties, + ) + + # Try to create the resource + config = client.create_or_update( + resource_group_name, + cluster_rp, + cluster_type, + cluster_name, + name, + source_control_configuration, + ) + + return fix_compliance_state(config) + + +def get_protected_settings( + ssh_private_key, ssh_private_key_file, https_user, https_key +): protected_settings = {} - ssh_private_key_data = get_data_from_key_or_file(ssh_private_key, ssh_private_key_file) + ssh_private_key_data = get_data_from_key_or_file( + ssh_private_key, ssh_private_key_file + ) # Add gitops private key data to protected settings if exists # Dry-run all key types to determine if the private key is in a valid format diff --git a/src/k8s-configuration/azext_k8s_configuration/utils.py b/src/k8s-configuration/azext_k8s_configuration/utils.py index b90381aa8e8..d66271b2233 100644 --- a/src/k8s-configuration/azext_k8s_configuration/utils.py +++ b/src/k8s-configuration/azext_k8s_configuration/utils.py @@ -7,28 +7,34 @@ import json import re from datetime import timedelta +from typing import Tuple from azure.cli.core.azclierror import ( MutuallyExclusiveArgumentError, - InvalidArgumentValueError + InvalidArgumentValueError, ) from . import consts -def get_cluster_rp(cluster_type): - if cluster_type.lower() == consts.CONNECTED_CLUSTERS: - return consts.CONNECTED_RP_NAMESPACE - if cluster_type.lower() == consts.APPLIANCES: - return consts.APPLIANCE_RP_NAMESPACE - if cluster_type.lower() == '' or cluster_type.lower() == 'managedclusters': - return consts.MANAGED_RP_NAMESPACE - raise InvalidArgumentValueError("Error! Cluster type '{}' is not supported".format(cluster_type)) +def get_cluster_rp_api_version(cluster_type) -> Tuple[str, str]: + if cluster_type.lower() == consts.CONNECTED_CLUSTER_TYPE: + return consts.CONNECTED_CLUSTER_RP, consts.CONNECTED_CLUSTER_API_VERSION + if cluster_type.lower() == consts.APPLIANCE_TYPE: + return consts.APPLIANCE_RP, consts.APPLIANCE_API_VERSION + if ( + cluster_type.lower() == "" + or cluster_type.lower() == consts.MANAGED_CLUSTER_TYPE + ): + return consts.MANAGED_CLUSTER_RP, consts.MANAGED_CLUSTER_API_VERSION + raise InvalidArgumentValueError( + "Error! Cluster type '{}' is not supported".format(cluster_type) + ) def get_data_from_key_or_file(key, filepath, strip_newline=False): if key and filepath: raise MutuallyExclusiveArgumentError( - consts.KEY_AND_FILE_TOGETHER_ERROR, - consts.KEY_AND_FILE_TOGETHER_HELP) + consts.KEY_AND_FILE_TOGETHER_ERROR, consts.KEY_AND_FILE_TOGETHER_HELP + ) data = None if filepath: data = read_key_file(filepath, strip_newline) @@ -39,7 +45,7 @@ def get_data_from_key_or_file(key, filepath, strip_newline=False): def read_config_settings_file(file_path): try: - with open(file_path, 'r') as f: + with open(file_path, "r") as f: settings = json.load(f) if len(settings) == 0: raise Exception("File {} is empty".format(file_path)) @@ -55,27 +61,27 @@ def read_key_file(path, strip_newline=False): data_list_len = len(data_list) if (data_list_len) <= 0: raise Exception("File provided does not contain any data") - raw_data = ''.join(data_list) + raw_data = "".join(data_list) if strip_newline: raw_data = raw_data.strip() return to_base64(raw_data) except Exception as ex: raise InvalidArgumentValueError( - consts.KEY_FILE_READ_ERROR.format(ex), - consts.KEY_FILE_READ_HELP) from ex + consts.KEY_FILE_READ_ERROR.format(ex), consts.KEY_FILE_READ_HELP + ) from ex def parse_dependencies(depends_on): depends_on = depends_on.strip() - if depends_on[0] == '[': + if depends_on[0] == "[": depends_on = depends_on[1:-1] - return depends_on.split(',') + return depends_on.split(",") def parse_duration(duration): if not duration: return duration - regex = re.compile(r'((?P\d+?)h)?((?P\d+?)m)?((?P\d+?)s)?') + regex = re.compile(r"((?P\d+?)h)?((?P\d+?)m)?((?P\d+?)s)?") parts = regex.match(duration) parts = parts.groupdict() time_params = {} @@ -93,13 +99,13 @@ def format_duration(seconds): seconds -= hours * 3600 minutes = seconds // 60 seconds -= minutes * 60 - res = '' + res = "" if hours > 0: - res += '{}h'.format(hours) + res += "{}h".format(hours) if minutes > 0: - res += '{}m'.format(minutes) + res += "{}m".format(minutes) if seconds > 0: - res += '{}s'.format(seconds) + res += "{}s".format(seconds) return res @@ -108,31 +114,20 @@ def from_base64(base64_str): def to_base64(raw_data): - bytes_data = raw_data.encode('utf-8') - return base64.b64encode(bytes_data).decode('utf-8') + bytes_data = raw_data.encode("utf-8") + return base64.b64encode(bytes_data).decode("utf-8") def fix_compliance_state(config): # If we get Compliant/NonCompliant as compliance_sate, change them before returning - if config.compliance_status.compliance_state.lower() == 'noncompliant': - config.compliance_status.compliance_state = 'Failed' - elif config.compliance_status.compliance_state.lower() == 'compliant': - config.compliance_status.compliance_state = 'Installed' + if config.compliance_status.compliance_state.lower() == "noncompliant": + config.compliance_status.compliance_state = "Failed" + elif config.compliance_status.compliance_state.lower() == "compliant": + config.compliance_status.compliance_state = "Installed" return config -def get_parent_api_version(cluster_rp): - if cluster_rp == 'Microsoft.Kubernetes': - return '2020-01-01-preview' - if cluster_rp == 'Microsoft.ResourceConnector': - return '2020-09-15-privatepreview' - if cluster_rp == 'Microsoft.ContainerService': - return '2017-07-01' - raise InvalidArgumentValueError("Error! Cluster RP '{}' is not supported" - " for extension identity".format(cluster_rp)) - - def is_dogfood_cluster(cmd): return cmd.cli_ctx.cloud.endpoints.resource_manager == consts.DF_RM_ENDPOINT diff --git a/src/k8s-configuration/azext_k8s_configuration/validators.py b/src/k8s-configuration/azext_k8s_configuration/validators.py index 3eb2142663c..acefb4ab14a 100644 --- a/src/k8s-configuration/azext_k8s_configuration/validators.py +++ b/src/k8s-configuration/azext_k8s_configuration/validators.py @@ -10,7 +10,7 @@ from azure.cli.core.azclierror import ( InvalidArgumentValueError, RequiredArgumentMissingError, - MutuallyExclusiveArgumentError + MutuallyExclusiveArgumentError, ) from paramiko.hostkeys import HostKeyEntry from paramiko.ed25519key import Ed25519Key @@ -40,7 +40,9 @@ def validate_fluxconfig_name(namespace): def validate_operator_instance_name(namespace): if namespace.operator_instance_name: - __validate_k8s_name(namespace.operator_instance_name, "--operator-instance-name", 23) + __validate_k8s_name( + namespace.operator_instance_name, "--operator-instance-name", 23 + ) def validate_operator_namespace(namespace): @@ -51,7 +53,7 @@ def validate_operator_namespace(namespace): def validate_kustomization(values): required_keys = consts.REQUIRED_KUSTOMIZATION_KEYS for item in values: - key, value = item.split('=', 1) + key, value = item.split("=", 1) if key == "name": __validate_k8s_cr_name(value, key, 63) elif key in consts.SYNC_INTERVAL_KEYS: @@ -65,50 +67,61 @@ def validate_kustomization(values): if required_keys: raise RequiredArgumentMissingError( consts.KUSTOMIZATION_REQUIRED_VALUES_MISSING_ERROR.format(required_keys), - consts.KUSTOMIZATION_REQUIRED_VALUES_MISSING_HELP + consts.KUSTOMIZATION_REQUIRED_VALUES_MISSING_HELP, ) -def validate_repository_ref(branch: str, tag: str, semver: str, commit: str): +def validate_repository_ref(repository_ref): num_set_args = 0 - for elem in [branch, tag, semver, commit]: - if elem: - num_set_args += 1 + if repository_ref: + for elem in [ + repository_ref.branch, + repository_ref.tag, + repository_ref.semver, + repository_ref.commit, + ]: + if elem: + num_set_args += 1 if num_set_args == 0: raise RequiredArgumentMissingError( consts.REPOSITORY_REF_REQUIRED_VALUES_MISSING_ERROR, - consts.REPOSITORY_REF_REQUIRED_VALUES_MISSING_HELP + consts.REPOSITORY_REF_REQUIRED_VALUES_MISSING_HELP, ) if num_set_args == 1: return raise MutuallyExclusiveArgumentError( consts.REPOSITORY_REF_TOO_MANY_VALUES_ERROR, - consts.REPOSITORY_REF_TOO_MANY_VALUES_HELP + consts.REPOSITORY_REF_TOO_MANY_VALUES_HELP, ) def validate_duration(arg_name: str, duration: str): - if duration and not re.match(consts.VALID_DURATION_REGEX, duration): + if not duration: + return + regex = re.compile(r"((?P\d+?)h)?((?P\d+?)m)?((?P\d+?)s)?") + parts = regex.match(duration) + if duration and not parts: + raise InvalidArgumentValueError( + consts.INVALID_DURATION_ERROR.format(arg_name), consts.INVALID_DURATION_HELP + ) + parts = parts.groupdict() + if not any(parts.values()): raise InvalidArgumentValueError( - consts.INVALID_DURATION_ERROR.format(arg_name), - consts.INVALID_DURATION_HELP + consts.INVALID_DURATION_ERROR.format(arg_name), consts.INVALID_DURATION_HELP ) -def validate_git_repository(url: str): - if not url: - raise RequiredArgumentMissingError( - consts.GIT_REPOSITORY_REQUIRED_VALUES_MISSING_ERROR.format("--url"), - consts.GIT_REPOSITORY_REQUIRED_VALUES_MISSING_HELP +def validate_git_url(url: str): + if not re.match(consts.VALID_GIT_URL_REGEX, url): + raise InvalidArgumentValueError( + consts.INVALID_URL_ERROR, consts.INVALID_URL_HELP ) - validate_git_url(url) -def validate_git_url(url: str): - if not re.match(consts.VALID_URL_REGEX, url): +def validate_bucket_url(url: str): + if not re.match(consts.VALID_BUCKET_URL_REGEX, url): raise InvalidArgumentValueError( - consts.INVALID_URL_ERROR, - consts.INVALID_URL_HELP + consts.INVALID_URL_ERROR, consts.INVALID_URL_HELP ) @@ -117,17 +130,17 @@ def __validate_k8s_name(param_value, param_name, max_len): if len(param_value) > max_len: raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_NAME_LENGTH_ERROR.format(param_name), - consts.INVALID_KUBERNETES_NAME_LENGTH_HELP.format(param_name, max_len) + consts.INVALID_KUBERNETES_NAME_LENGTH_HELP.format(param_name, max_len), ) if not re.match(consts.VALID_KUBERNETES_DNS_NAME_REGEX, param_value): if param_value[0] == "-" or param_value[-1] == "-": raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_NAME_HYPHEN_ERROR.format(param_name), - consts.INVALID_KUBERNETES_NAME_HYPHEN_HELP.format(param_name) + consts.INVALID_KUBERNETES_NAME_HYPHEN_HELP.format(param_name), ) raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_DNS_NAME_ERROR.format(param_name), - consts.INVALID_KUBERNETES_DNS_NAME_HELP.format(param_name) + consts.INVALID_KUBERNETES_DNS_NAME_HELP.format(param_name), ) @@ -135,47 +148,54 @@ def __validate_k8s_cr_name(param_value, param_name, max_len): if len(param_value) > max_len: raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_NAME_LENGTH_ERROR.format(param_name), - consts.INVALID_KUBERNETES_NAME_LENGTH_HELP.format(param_name, max_len) + consts.INVALID_KUBERNETES_NAME_LENGTH_HELP.format(param_name, max_len), ) if not re.match(consts.VALID_KUBERNETES_DNS_SUBDOMAIN_NAME_REGEX, param_value): if param_value[0] == "-" or param_value[-1] == "-": raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_NAME_HYPHEN_ERROR.format(param_name), - consts.INVALID_KUBERNETES_NAME_HYPHEN_HELP.format(param_name) + consts.INVALID_KUBERNETES_NAME_HYPHEN_HELP.format(param_name), ) if param_value[0] == "." or param_value[-1] == ".": raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_NAME_PERIOD_ERROR.format(param_name), - consts.INVALID_KUBERNETES_NAME_PERIOD_HELP.format(param_name) + consts.INVALID_KUBERNETES_NAME_PERIOD_HELP.format(param_name), ) raise InvalidArgumentValueError( consts.INVALID_KUBERNETES_DNS_SUBDOMAIN_NAME_ERROR.format(param_name), - consts.INVALID_KUBERNETES_DNS_SUBDOMAIN_NAME_ERROR.format(param_name) + consts.INVALID_KUBERNETES_DNS_SUBDOMAIN_NAME_ERROR.format(param_name), ) -def validate_url_with_params(url: str, ssh_private_key, ssh_private_key_file, - known_hosts, known_hosts_file, https_user, https_key): +def validate_url_with_params( + url: str, + ssh_private_key, + ssh_private_key_file, + known_hosts, + known_hosts_file, + https_user, + https_key, +): scheme = urlparse(url).scheme - if scheme.lower() in ('http', 'https'): + if scheme.lower() in ("http", "https"): if ssh_private_key or ssh_private_key_file: raise MutuallyExclusiveArgumentError( consts.SSH_PRIVATE_KEY_WITH_HTTP_URL_ERROR, - consts.SSH_PRIVATE_KEY_WITH_HTTP_URL_HELP + consts.SSH_PRIVATE_KEY_WITH_HTTP_URL_HELP, ) if known_hosts or known_hosts_file: raise MutuallyExclusiveArgumentError( consts.KNOWN_HOSTS_WITH_HTTP_URL_ERROR, - consts.KNOWN_HOSTS_WITH_HTTP_URL_HELP + consts.KNOWN_HOSTS_WITH_HTTP_URL_HELP, ) - if not (https_user and https_key) and scheme == 'https': + if not (https_user and https_key) and scheme == "https": logger.warning(consts.HTTP_URL_NO_AUTH_WARNING) else: if https_user or https_key: raise MutuallyExclusiveArgumentError( consts.HTTPS_AUTH_WITH_SSH_URL_ERROR, - consts.HTTPS_AUTH_WITH_SSH_URL_HELP + consts.HTTPS_AUTH_WITH_SSH_URL_HELP, ) if https_user and https_key: @@ -183,31 +203,31 @@ def validate_url_with_params(url: str, ssh_private_key, ssh_private_key_file, # If we just provide one or the other raise an error if https_user or https_key: raise RequiredArgumentMissingError( - consts.HTTPS_USER_KEY_MATCH_ERROR, - consts.HTTPS_USER_KEY_MATCH_HELP) + consts.HTTPS_USER_KEY_MATCH_ERROR, consts.HTTPS_USER_KEY_MATCH_HELP + ) def validate_known_hosts(knownhost_data): try: - knownhost_str = from_base64(knownhost_data).decode('utf-8') + knownhost_str = from_base64(knownhost_data).decode("utf-8") except Exception as ex: raise InvalidArgumentValueError( consts.KNOWN_HOSTS_BASE64_ENCODING_ERROR, - consts.KNOWN_HOSTS_BASE64_ENCODING_HELP) from ex - lines = knownhost_str.split('\n') + consts.KNOWN_HOSTS_BASE64_ENCODING_HELP, + ) from ex + lines = knownhost_str.split("\n") for line in lines: - line = line.strip(' ') + line = line.strip(" ") line_len = len(line) if (line_len == 0) or (line[0] == "#"): continue try: host_key = HostKeyEntry.from_line(line) if not host_key: - raise Exception('not enough fields found in known_hosts line') + raise Exception("not enough fields found in known_hosts line") except Exception as ex: raise InvalidArgumentValueError( - consts.KNOWN_HOSTS_FORMAT_ERROR, - consts.KNOWN_HOSTS_FORMAT_HELP + consts.KNOWN_HOSTS_FORMAT_ERROR, consts.KNOWN_HOSTS_FORMAT_HELP ) from ex @@ -225,13 +245,14 @@ def validate_private_key(ssh_private_key_data): return except ValueError: try: - key_obj = io.StringIO(from_base64(ssh_private_key_data).decode('utf-8')) + key_obj = io.StringIO( + from_base64(ssh_private_key_data).decode("utf-8") + ) Ed25519Key(file_obj=key_obj) return except SSHException as ex: raise InvalidArgumentValueError( - consts.SSH_PRIVATE_KEY_ERROR, - consts.SSH_PRIVATE_KEY_HELP + consts.SSH_PRIVATE_KEY_ERROR, consts.SSH_PRIVATE_KEY_HELP ) from ex @@ -239,30 +260,39 @@ def validate_private_key(ssh_private_key_data): def validate_cc_registration(cmd): try: rp_client = resource_providers_client(cmd.cli_ctx) - registration_state = rp_client.get(consts.CC_PROVIDER_NAMESPACE).registration_state + registration_state = rp_client.get( + consts.CC_PROVIDER_NAMESPACE + ).registration_state if registration_state.lower() != consts.REGISTERED.lower(): - logger.warning(consts.CC_REGISTRATION_WARNING, - consts.CC_PROVIDER_NAMESPACE, - consts.CC_REGISTRATION_LINK) + logger.warning( + consts.CC_REGISTRATION_WARNING, + consts.CC_PROVIDER_NAMESPACE, + consts.CC_REGISTRATION_LINK, + ) except Exception: - logger.warning(consts.CC_REGISTRATION_ERROR, - consts.CC_PROVIDER_NAMESPACE) + logger.warning(consts.CC_REGISTRATION_ERROR, consts.CC_PROVIDER_NAMESPACE) def validate_scope_and_namespace(scope, release_namespace, target_namespace): - if scope == 'cluster': + if scope == "cluster": if target_namespace is not None: message = "When --scope is 'cluster', --target-namespace must not be given." raise MutuallyExclusiveArgumentError(message) else: if release_namespace is not None: - message = "When --scope is 'namespace', --release-namespace must not be given." + message = ( + "When --scope is 'namespace', --release-namespace must not be given." + ) raise MutuallyExclusiveArgumentError(message) def validate_scope_after_customization(scope_obj): - if scope_obj is not None and scope_obj.namespace is not None and scope_obj.namespace.target_namespace is None: + if ( + scope_obj is not None + and scope_obj.namespace is not None + and scope_obj.namespace.target_namespace is None + ): message = "When --scope is 'namespace', --target-namespace must be given." raise RequiredArgumentMissingError(message) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/_source_control_configuration_client.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/_source_control_configuration_client.py index f0749f25ad1..1743fa49f4d 100644 --- a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/_source_control_configuration_client.py +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/_source_control_configuration_client.py @@ -98,6 +98,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` * 2021-09-01: :mod:`v2021_09_01.models` * 2021-11-01-preview: :mod:`v2021_11_01_preview.models` + * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` """ if api_version == '2020-07-01-preview': from .v2020_07_01_preview import models @@ -117,6 +118,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-11-01-preview': from .v2021_11_01_preview import models return models + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -125,12 +129,15 @@ def cluster_extension_type(self): * 2021-05-01-preview: :class:`ClusterExtensionTypeOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypeOperations` + * 2022-01-01-preview: :class:`ClusterExtensionTypeOperations` """ api_version = self._get_api_version('cluster_extension_type') if api_version == '2021-05-01-preview': from .v2021_05_01_preview.operations import ClusterExtensionTypeOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import ClusterExtensionTypeOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import ClusterExtensionTypeOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_type'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -141,12 +148,15 @@ def cluster_extension_types(self): * 2021-05-01-preview: :class:`ClusterExtensionTypesOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypesOperations` + * 2022-01-01-preview: :class:`ClusterExtensionTypesOperations` """ api_version = self._get_api_version('cluster_extension_types') if api_version == '2021-05-01-preview': from .v2021_05_01_preview.operations import ClusterExtensionTypesOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import ClusterExtensionTypesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import ClusterExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_types'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -157,12 +167,15 @@ def extension_type_versions(self): * 2021-05-01-preview: :class:`ExtensionTypeVersionsOperations` * 2021-11-01-preview: :class:`ExtensionTypeVersionsOperations` + * 2022-01-01-preview: :class:`ExtensionTypeVersionsOperations` """ api_version = self._get_api_version('extension_type_versions') if api_version == '2021-05-01-preview': from .v2021_05_01_preview.operations import ExtensionTypeVersionsOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import ExtensionTypeVersionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import ExtensionTypeVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extension_type_versions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -175,6 +188,7 @@ def extensions(self): * 2021-05-01-preview: :class:`ExtensionsOperations` * 2021-09-01: :class:`ExtensionsOperations` * 2021-11-01-preview: :class:`ExtensionsOperations` + * 2022-01-01-preview: :class:`ExtensionsOperations` """ api_version = self._get_api_version('extensions') if api_version == '2020-07-01-preview': @@ -185,6 +199,8 @@ def extensions(self): from .v2021_09_01.operations import ExtensionsOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import ExtensionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extensions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -194,10 +210,13 @@ def flux_config_operation_status(self): """Instance depends on the API version: * 2021-11-01-preview: :class:`FluxConfigOperationStatusOperations` + * 2022-01-01-preview: :class:`FluxConfigOperationStatusOperations` """ api_version = self._get_api_version('flux_config_operation_status') if api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import FluxConfigOperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_config_operation_status'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -207,10 +226,13 @@ def flux_configurations(self): """Instance depends on the API version: * 2021-11-01-preview: :class:`FluxConfigurationsOperations` + * 2022-01-01-preview: :class:`FluxConfigurationsOperations` """ api_version = self._get_api_version('flux_configurations') if api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import FluxConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_configurations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -221,12 +243,15 @@ def location_extension_types(self): * 2021-05-01-preview: :class:`LocationExtensionTypesOperations` * 2021-11-01-preview: :class:`LocationExtensionTypesOperations` + * 2022-01-01-preview: :class:`LocationExtensionTypesOperations` """ api_version = self._get_api_version('location_extension_types') if api_version == '2021-05-01-preview': from .v2021_05_01_preview.operations import LocationExtensionTypesOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import LocationExtensionTypesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import LocationExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'location_extension_types'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -238,6 +263,7 @@ def operation_status(self): * 2021-05-01-preview: :class:`OperationStatusOperations` * 2021-09-01: :class:`OperationStatusOperations` * 2021-11-01-preview: :class:`OperationStatusOperations` + * 2022-01-01-preview: :class:`OperationStatusOperations` """ api_version = self._get_api_version('operation_status') if api_version == '2021-05-01-preview': @@ -246,6 +272,8 @@ def operation_status(self): from .v2021_09_01.operations import OperationStatusOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import OperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'operation_status'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -260,6 +288,7 @@ def operations(self): * 2021-05-01-preview: :class:`Operations` * 2021-09-01: :class:`Operations` * 2021-11-01-preview: :class:`Operations` + * 2022-01-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-07-01-preview': @@ -274,6 +303,8 @@ def operations(self): from .v2021_09_01.operations import Operations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import Operations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -287,6 +318,7 @@ def source_control_configurations(self): * 2021-03-01: :class:`SourceControlConfigurationsOperations` * 2021-05-01-preview: :class:`SourceControlConfigurationsOperations` * 2021-11-01-preview: :class:`SourceControlConfigurationsOperations` + * 2022-01-01-preview: :class:`SourceControlConfigurationsOperations` """ api_version = self._get_api_version('source_control_configurations') if api_version == '2020-07-01-preview': @@ -299,6 +331,8 @@ def source_control_configurations(self): from .v2021_05_01_preview.operations import SourceControlConfigurationsOperations as OperationClass elif api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_01_preview.operations import SourceControlConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'source_control_configurations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/aio/_source_control_configuration_client.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/aio/_source_control_configuration_client.py index 0207133fc2a..97f3e6688eb 100644 --- a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/aio/_source_control_configuration_client.py +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/aio/_source_control_configuration_client.py @@ -96,6 +96,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` * 2021-09-01: :mod:`v2021_09_01.models` * 2021-11-01-preview: :mod:`v2021_11_01_preview.models` + * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` """ if api_version == '2020-07-01-preview': from ..v2020_07_01_preview import models @@ -115,6 +116,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview import models return models + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -123,12 +127,15 @@ def cluster_extension_type(self): * 2021-05-01-preview: :class:`ClusterExtensionTypeOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypeOperations` + * 2022-01-01-preview: :class:`ClusterExtensionTypeOperations` """ api_version = self._get_api_version('cluster_extension_type') if api_version == '2021-05-01-preview': from ..v2021_05_01_preview.aio.operations import ClusterExtensionTypeOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import ClusterExtensionTypeOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import ClusterExtensionTypeOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_type'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -139,12 +146,15 @@ def cluster_extension_types(self): * 2021-05-01-preview: :class:`ClusterExtensionTypesOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypesOperations` + * 2022-01-01-preview: :class:`ClusterExtensionTypesOperations` """ api_version = self._get_api_version('cluster_extension_types') if api_version == '2021-05-01-preview': from ..v2021_05_01_preview.aio.operations import ClusterExtensionTypesOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import ClusterExtensionTypesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import ClusterExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_types'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -155,12 +165,15 @@ def extension_type_versions(self): * 2021-05-01-preview: :class:`ExtensionTypeVersionsOperations` * 2021-11-01-preview: :class:`ExtensionTypeVersionsOperations` + * 2022-01-01-preview: :class:`ExtensionTypeVersionsOperations` """ api_version = self._get_api_version('extension_type_versions') if api_version == '2021-05-01-preview': from ..v2021_05_01_preview.aio.operations import ExtensionTypeVersionsOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import ExtensionTypeVersionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import ExtensionTypeVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extension_type_versions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -173,6 +186,7 @@ def extensions(self): * 2021-05-01-preview: :class:`ExtensionsOperations` * 2021-09-01: :class:`ExtensionsOperations` * 2021-11-01-preview: :class:`ExtensionsOperations` + * 2022-01-01-preview: :class:`ExtensionsOperations` """ api_version = self._get_api_version('extensions') if api_version == '2020-07-01-preview': @@ -183,6 +197,8 @@ def extensions(self): from ..v2021_09_01.aio.operations import ExtensionsOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import ExtensionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extensions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -192,10 +208,13 @@ def flux_config_operation_status(self): """Instance depends on the API version: * 2021-11-01-preview: :class:`FluxConfigOperationStatusOperations` + * 2022-01-01-preview: :class:`FluxConfigOperationStatusOperations` """ api_version = self._get_api_version('flux_config_operation_status') if api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import FluxConfigOperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_config_operation_status'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -205,10 +224,13 @@ def flux_configurations(self): """Instance depends on the API version: * 2021-11-01-preview: :class:`FluxConfigurationsOperations` + * 2022-01-01-preview: :class:`FluxConfigurationsOperations` """ api_version = self._get_api_version('flux_configurations') if api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import FluxConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_configurations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -219,12 +241,15 @@ def location_extension_types(self): * 2021-05-01-preview: :class:`LocationExtensionTypesOperations` * 2021-11-01-preview: :class:`LocationExtensionTypesOperations` + * 2022-01-01-preview: :class:`LocationExtensionTypesOperations` """ api_version = self._get_api_version('location_extension_types') if api_version == '2021-05-01-preview': from ..v2021_05_01_preview.aio.operations import LocationExtensionTypesOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import LocationExtensionTypesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import LocationExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'location_extension_types'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -236,6 +261,7 @@ def operation_status(self): * 2021-05-01-preview: :class:`OperationStatusOperations` * 2021-09-01: :class:`OperationStatusOperations` * 2021-11-01-preview: :class:`OperationStatusOperations` + * 2022-01-01-preview: :class:`OperationStatusOperations` """ api_version = self._get_api_version('operation_status') if api_version == '2021-05-01-preview': @@ -244,6 +270,8 @@ def operation_status(self): from ..v2021_09_01.aio.operations import OperationStatusOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import OperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'operation_status'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -258,6 +286,7 @@ def operations(self): * 2021-05-01-preview: :class:`Operations` * 2021-09-01: :class:`Operations` * 2021-11-01-preview: :class:`Operations` + * 2022-01-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-07-01-preview': @@ -272,6 +301,8 @@ def operations(self): from ..v2021_09_01.aio.operations import Operations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -285,6 +316,7 @@ def source_control_configurations(self): * 2021-03-01: :class:`SourceControlConfigurationsOperations` * 2021-05-01-preview: :class:`SourceControlConfigurationsOperations` * 2021-11-01-preview: :class:`SourceControlConfigurationsOperations` + * 2022-01-01-preview: :class:`SourceControlConfigurationsOperations` """ api_version = self._get_api_version('source_control_configurations') if api_version == '2020-07-01-preview': @@ -297,6 +329,8 @@ def source_control_configurations(self): from ..v2021_05_01_preview.aio.operations import SourceControlConfigurationsOperations as OperationClass elif api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_01_preview.aio.operations import SourceControlConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'source_control_configurations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models.py index da4621b7737..c47ff7c1cde 100644 --- a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models.py +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models.py @@ -772,7 +772,7 @@ def __init__( ): super(FluxConfigurationPatch, self).__init__(**kwargs) self.source_kind = kwargs.get('source_kind', None) - self.suspend = kwargs.get('suspend', None) + self.suspend = kwargs.get('suspend', False) self.git_repository = kwargs.get('git_repository', None) self.kustomizations = kwargs.get('kustomizations', None) self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) @@ -996,6 +996,7 @@ class KustomizationDefinition(msrest.serialization.Model): 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, 'prune': {'key': 'prune', 'type': 'bool'}, + 'validation': {'key': 'validation', 'type': 'str'}, 'force': {'key': 'force', 'type': 'bool'}, } @@ -1009,8 +1010,9 @@ def __init__( self.timeout_in_seconds = kwargs.get('timeout_in_seconds', 600) self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', 600) self.retry_interval_in_seconds = kwargs.get('retry_interval_in_seconds', None) - self.prune = kwargs.get('prune', None) - self.force = kwargs.get('force', None) + self.prune = kwargs.get('prune', False) + self.validation = kwargs.get('validation', "none") + self.force = kwargs.get('force', False) class ObjectReferenceDefinition(msrest.serialization.Model): diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models_py3.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models_py3.py index 7ac4da66bdf..fa18f2b46c9 100644 --- a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models_py3.py +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2021_11_01_preview/models/_models_py3.py @@ -822,7 +822,7 @@ def __init__( self, *, source_kind: Optional[Union[str, "SourceKindType"]] = None, - suspend: Optional[bool] = None, + suspend: Optional[bool] = False, git_repository: Optional["GitRepositoryDefinition"] = None, kustomizations: Optional[Dict[str, "KustomizationDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, @@ -1057,6 +1057,11 @@ class KustomizationDefinition(msrest.serialization.Model): :param prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :type prune: bool + :param validation: Specify whether to validate the Kubernetes objects referenced in the + Kustomization before applying them to the cluster. Possible values include: "none", "client", + "server". Default value: "none". + :type validation: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.KustomizationValidationType :param force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails due to an immutable field change. :type force: bool @@ -1069,6 +1074,7 @@ class KustomizationDefinition(msrest.serialization.Model): 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, 'prune': {'key': 'prune', 'type': 'bool'}, + 'validation': {'key': 'validation', 'type': 'str'}, 'force': {'key': 'force', 'type': 'bool'}, } @@ -1080,8 +1086,9 @@ def __init__( timeout_in_seconds: Optional[int] = 600, sync_interval_in_seconds: Optional[int] = 600, retry_interval_in_seconds: Optional[int] = None, - prune: Optional[bool] = None, - force: Optional[bool] = None, + prune: Optional[bool] = False, + validation: Optional[Union[str, "KustomizationValidationType"]] = "none", + force: Optional[bool] = False, **kwargs ): super(KustomizationDefinition, self).__init__(**kwargs) @@ -1091,6 +1098,7 @@ def __init__( self.sync_interval_in_seconds = sync_interval_in_seconds self.retry_interval_in_seconds = retry_interval_in_seconds self.prune = prune + self.validation = validation self.force = force diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/__init__.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/__init__.py new file mode 100644 index 00000000000..f13062376d7 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/__init__.py @@ -0,0 +1,19 @@ +# 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 ._source_control_configuration_client import SourceControlConfigurationClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['SourceControlConfigurationClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_configuration.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_configuration.py new file mode 100644 index 00000000000..b75a1084ebc --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_configuration.py @@ -0,0 +1,71 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class SourceControlConfigurationClientConfiguration(Configuration): + """Configuration for SourceControlConfigurationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2022-01-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_source_control_configuration_client.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_source_control_configuration_client.py new file mode 100644 index 00000000000..4fd5d4958ff --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_source_control_configuration_client.py @@ -0,0 +1,134 @@ +# 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 + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import SourceControlConfigurationClientConfiguration +from .operations import ClusterExtensionTypeOperations +from .operations import ClusterExtensionTypesOperations +from .operations import ExtensionTypeVersionsOperations +from .operations import LocationExtensionTypesOperations +from .operations import ExtensionsOperations +from .operations import OperationStatusOperations +from .operations import FluxConfigurationsOperations +from .operations import FluxConfigOperationStatusOperations +from .operations import SourceControlConfigurationsOperations +from .operations import Operations +from . import models + + +class SourceControlConfigurationClient(object): + """KubernetesConfiguration Client. + + :ivar cluster_extension_type: ClusterExtensionTypeOperations operations + :vartype cluster_extension_type: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.ClusterExtensionTypeOperations + :ivar cluster_extension_types: ClusterExtensionTypesOperations operations + :vartype cluster_extension_types: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.ClusterExtensionTypesOperations + :ivar extension_type_versions: ExtensionTypeVersionsOperations operations + :vartype extension_type_versions: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.ExtensionTypeVersionsOperations + :ivar location_extension_types: LocationExtensionTypesOperations operations + :vartype location_extension_types: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.LocationExtensionTypesOperations + :ivar extensions: ExtensionsOperations operations + :vartype extensions: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = SourceControlConfigurationClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SourceControlConfigurationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_version.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_version.py new file mode 100644 index 00000000000..59deb8c7263 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.1.0" diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/__init__.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/__init__.py new file mode 100644 index 00000000000..ba52c91a7ba --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._source_control_configuration_client import SourceControlConfigurationClient +__all__ = ['SourceControlConfigurationClient'] diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_configuration.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_configuration.py new file mode 100644 index 00000000000..fc051b59148 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SourceControlConfigurationClientConfiguration(Configuration): + """Configuration for SourceControlConfigurationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2022-01-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_source_control_configuration_client.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_source_control_configuration_client.py new file mode 100644 index 00000000000..502030b5568 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/_source_control_configuration_client.py @@ -0,0 +1,127 @@ +# 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, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import SourceControlConfigurationClientConfiguration +from .operations import ClusterExtensionTypeOperations +from .operations import ClusterExtensionTypesOperations +from .operations import ExtensionTypeVersionsOperations +from .operations import LocationExtensionTypesOperations +from .operations import ExtensionsOperations +from .operations import OperationStatusOperations +from .operations import FluxConfigurationsOperations +from .operations import FluxConfigOperationStatusOperations +from .operations import SourceControlConfigurationsOperations +from .operations import Operations +from .. import models + + +class SourceControlConfigurationClient(object): + """KubernetesConfiguration Client. + + :ivar cluster_extension_type: ClusterExtensionTypeOperations operations + :vartype cluster_extension_type: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.ClusterExtensionTypeOperations + :ivar cluster_extension_types: ClusterExtensionTypesOperations operations + :vartype cluster_extension_types: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.ClusterExtensionTypesOperations + :ivar extension_type_versions: ExtensionTypeVersionsOperations operations + :vartype extension_type_versions: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.ExtensionTypeVersionsOperations + :ivar location_extension_types: LocationExtensionTypesOperations operations + :vartype location_extension_types: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.LocationExtensionTypesOperations + :ivar extensions: ExtensionsOperations operations + :vartype extensions: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = SourceControlConfigurationClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SourceControlConfigurationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/__init__.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/__init__.py new file mode 100644 index 00000000000..37008240af3 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# 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 ._cluster_extension_type_operations import ClusterExtensionTypeOperations +from ._cluster_extension_types_operations import ClusterExtensionTypesOperations +from ._extension_type_versions_operations import ExtensionTypeVersionsOperations +from ._location_extension_types_operations import LocationExtensionTypesOperations +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +__all__ = [ + 'ClusterExtensionTypeOperations', + 'ClusterExtensionTypesOperations', + 'ExtensionTypeVersionsOperations', + 'LocationExtensionTypesOperations', + 'ExtensionsOperations', + 'OperationStatusOperations', + 'FluxConfigurationsOperations', + 'FluxConfigOperationStatusOperations', + 'SourceControlConfigurationsOperations', + 'Operations', +] diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py new file mode 100644 index 00000000000..5ad38f9c1db --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py @@ -0,0 +1,114 @@ +# 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 ClusterExtensionTypeOperations: + """ClusterExtensionTypeOperations 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.kubernetesconfiguration.v2022_01_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, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_type_name: str, + **kwargs: Any + ) -> "_models.ExtensionType": + """Get Extension Type details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_type_name: Extension type name. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExtensionType, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionTypeName': self._serialize.url("extension_type_name", extension_type_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExtensionType', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py new file mode 100644 index 00000000000..271b9752354 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py @@ -0,0 +1,127 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 ClusterExtensionTypesOperations: + """ClusterExtensionTypesOperations 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.kubernetesconfiguration.v2022_01_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 + + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExtensionTypeList"]: + """Get Extension Types. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionTypeList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py new file mode 100644 index 00000000000..67d9ef02043 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py @@ -0,0 +1,117 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 ExtensionTypeVersionsOperations: + """ExtensionTypeVersionsOperations 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.kubernetesconfiguration.v2022_01_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 + + def list( + self, + location: str, + extension_type_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExtensionVersionList"]: + """List available versions for an Extension Type. + + :param location: extension location. + :type location: str + :param extension_type_name: Extension type name. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionVersionList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'location': self._serialize.url("location", location, 'str'), + 'extensionTypeName': self._serialize.url("extension_type_name", extension_type_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionVersionList', pipeline_response) + list_of_elem = deserialized.versions + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extensions_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extensions_operations.py new file mode 100644 index 00000000000..abfa18fde51 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_extensions_operations.py @@ -0,0 +1,643 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 ExtensionsOperations: + """ExtensionsOperations 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.kubernetesconfiguration.v2022_01_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 _create_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + extension: "_models.Extension", + **kwargs: Any + ) -> "_models.Extension": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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(extension, 'Extension') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Extension', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + extension: "_models.Extension", + **kwargs: Any + ) -> AsyncLROPoller["_models.Extension"]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + 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_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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('Extension', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> "_models.Extension": + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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') + if force_delete is not None: + query_parameters['forceDelete'] = self._serialize.query("force_delete", force_delete, 'bool') + + # 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. + :type force_delete: bool + :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._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + patch_extension: "_models.PatchExtension", + **kwargs: Any + ) -> "_models.Extension": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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(patch_extension, 'PatchExtension') + body_content_kwargs['content'] = body_content + request = self._client.patch(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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + patch_extension: "_models.PatchExtension", + **kwargs: Any + ) -> AsyncLROPoller["_models.Extension"]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + 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._update_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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('Extension', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExtensionsList"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py new file mode 100644 index 00000000000..22b61526ac8 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,118 @@ +# 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 FluxConfigOperationStatusOperations: + """FluxConfigOperationStatusOperations 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.kubernetesconfiguration.v2022_01_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, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> "_models.OperationStatusResult": + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param operation_id: operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_name, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, '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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py new file mode 100644 index 00000000000..175b59e0bed --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py @@ -0,0 +1,643 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 FluxConfigurationsOperations: + """FluxConfigurationsOperations 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.kubernetesconfiguration.v2022_01_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, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> "_models.FluxConfiguration": + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: "_models.FluxConfiguration", + **kwargs: Any + ) -> "_models.FluxConfiguration": + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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(flux_configuration, 'FluxConfiguration') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: "_models.FluxConfiguration", + **kwargs: Any + ) -> AsyncLROPoller["_models.FluxConfiguration"]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :type flux_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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('FluxConfiguration', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: "_models.FluxConfigurationPatch", + **kwargs: Any + ) -> "_models.FluxConfiguration": + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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(flux_configuration_patch, 'FluxConfigurationPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: "_models.FluxConfigurationPatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.FluxConfiguration"]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + 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._update_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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') + if force_delete is not None: + query_parameters['forceDelete'] = self._serialize.query("force_delete", force_delete, 'bool') + + # 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. + :type force_delete: bool + :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._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.FluxConfigurationsList"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfigurationsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('FluxConfigurationsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py new file mode 100644 index 00000000000..6962894f914 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py @@ -0,0 +1,113 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 LocationExtensionTypesOperations: + """LocationExtensionTypesOperations 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.kubernetesconfiguration.v2022_01_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 + + def list( + self, + location: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExtensionTypeList"]: + """List all Extension Types. + + :param location: extension location. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'location': self._serialize.url("location", location, '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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionTypeList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operation_status_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operation_status_operations.py new file mode 100644 index 00000000000..3f20c7ee86b --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operation_status_operations.py @@ -0,0 +1,204 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 OperationStatusOperations: + """OperationStatusOperations 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.kubernetesconfiguration.v2022_01_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, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> "_models.OperationStatusResult": + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param operation_id: operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, '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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.OperationStatusList"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationStatusList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operations.py new file mode 100644 index 00000000000..6881dde9984 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 Operations: + """Operations 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.kubernetesconfiguration.v2022_01_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 + + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ResourceProviderOperationList"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py new file mode 100644 index 00000000000..b1f67c247e3 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py @@ -0,0 +1,420 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 SourceControlConfigurationsOperations: + """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2022_01_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, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> "_models.SourceControlConfiguration": + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: "_models.SourceControlConfiguration", + **kwargs: Any + ) -> "_models.SourceControlConfiguration": + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_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(source_control_configuration, 'SourceControlConfiguration') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + source_control_configuration_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-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. + :type source_control_configuration_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._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, 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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, "_models.Enum0"], + cluster_resource_name: Union[str, "_models.Enum1"], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfigurationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfigurationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SourceControlConfigurationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/__init__.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/__init__.py new file mode 100644 index 00000000000..bd6cd25837f --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/__init__.py @@ -0,0 +1,181 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import BucketDefinition + from ._models_py3 import BucketPatchDefinition + from ._models_py3 import ClusterScopeSettings + from ._models_py3 import ComplianceStatus + from ._models_py3 import DependsOnDefinition + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import Extension + from ._models_py3 import ExtensionPropertiesAksAssignedIdentity + from ._models_py3 import ExtensionStatus + from ._models_py3 import ExtensionType + from ._models_py3 import ExtensionTypeList + from ._models_py3 import ExtensionVersionList + from ._models_py3 import ExtensionVersionListVersionsItem + from ._models_py3 import ExtensionsList + from ._models_py3 import FluxConfiguration + from ._models_py3 import FluxConfigurationPatch + from ._models_py3 import FluxConfigurationsList + from ._models_py3 import GitRepositoryDefinition + from ._models_py3 import GitRepositoryPatchDefinition + from ._models_py3 import HelmOperatorProperties + from ._models_py3 import HelmReleasePropertiesDefinition + from ._models_py3 import Identity + from ._models_py3 import KustomizationDefinition + from ._models_py3 import KustomizationPatchDefinition + from ._models_py3 import ObjectReferenceDefinition + from ._models_py3 import ObjectStatusConditionDefinition + from ._models_py3 import ObjectStatusDefinition + from ._models_py3 import OperationStatusList + from ._models_py3 import OperationStatusResult + from ._models_py3 import PatchExtension + from ._models_py3 import ProxyResource + from ._models_py3 import RepositoryRefDefinition + from ._models_py3 import Resource + from ._models_py3 import ResourceProviderOperation + from ._models_py3 import ResourceProviderOperationDisplay + from ._models_py3 import ResourceProviderOperationList + from ._models_py3 import Scope + from ._models_py3 import ScopeCluster + from ._models_py3 import ScopeNamespace + from ._models_py3 import SourceControlConfiguration + from ._models_py3 import SourceControlConfigurationList + from ._models_py3 import SupportedScopes + from ._models_py3 import SystemData +except (SyntaxError, ImportError): + from ._models import BucketDefinition # type: ignore + from ._models import BucketPatchDefinition # type: ignore + from ._models import ClusterScopeSettings # type: ignore + from ._models import ComplianceStatus # type: ignore + from ._models import DependsOnDefinition # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Extension # type: ignore + from ._models import ExtensionPropertiesAksAssignedIdentity # type: ignore + from ._models import ExtensionStatus # type: ignore + from ._models import ExtensionType # type: ignore + from ._models import ExtensionTypeList # type: ignore + from ._models import ExtensionVersionList # type: ignore + from ._models import ExtensionVersionListVersionsItem # type: ignore + from ._models import ExtensionsList # type: ignore + from ._models import FluxConfiguration # type: ignore + from ._models import FluxConfigurationPatch # type: ignore + from ._models import FluxConfigurationsList # type: ignore + from ._models import GitRepositoryDefinition # type: ignore + from ._models import GitRepositoryPatchDefinition # type: ignore + from ._models import HelmOperatorProperties # type: ignore + from ._models import HelmReleasePropertiesDefinition # type: ignore + from ._models import Identity # type: ignore + from ._models import KustomizationDefinition # type: ignore + from ._models import KustomizationPatchDefinition # type: ignore + from ._models import ObjectReferenceDefinition # type: ignore + from ._models import ObjectStatusConditionDefinition # type: ignore + from ._models import ObjectStatusDefinition # type: ignore + from ._models import OperationStatusList # type: ignore + from ._models import OperationStatusResult # type: ignore + from ._models import PatchExtension # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import RepositoryRefDefinition # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceProviderOperation # type: ignore + from ._models import ResourceProviderOperationDisplay # type: ignore + from ._models import ResourceProviderOperationList # type: ignore + from ._models import Scope # type: ignore + from ._models import ScopeCluster # type: ignore + from ._models import ScopeNamespace # type: ignore + from ._models import SourceControlConfiguration # type: ignore + from ._models import SourceControlConfigurationList # type: ignore + from ._models import SupportedScopes # type: ignore + from ._models import SystemData # type: ignore + +from ._source_control_configuration_client_enums import ( + ClusterTypes, + ComplianceStateType, + CreatedByType, + Enum0, + Enum1, + FluxComplianceState, + KustomizationValidationType, + LevelType, + MessageLevelType, + OperatorScopeType, + OperatorType, + ProvisioningState, + ProvisioningStateType, + ScopeType, + SourceKindType, +) + +__all__ = [ + 'BucketDefinition', + 'BucketPatchDefinition', + 'ClusterScopeSettings', + 'ComplianceStatus', + 'DependsOnDefinition', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'Extension', + 'ExtensionPropertiesAksAssignedIdentity', + 'ExtensionStatus', + 'ExtensionType', + 'ExtensionTypeList', + 'ExtensionVersionList', + 'ExtensionVersionListVersionsItem', + 'ExtensionsList', + 'FluxConfiguration', + 'FluxConfigurationPatch', + 'FluxConfigurationsList', + 'GitRepositoryDefinition', + 'GitRepositoryPatchDefinition', + 'HelmOperatorProperties', + 'HelmReleasePropertiesDefinition', + 'Identity', + 'KustomizationDefinition', + 'KustomizationPatchDefinition', + 'ObjectReferenceDefinition', + 'ObjectStatusConditionDefinition', + 'ObjectStatusDefinition', + 'OperationStatusList', + 'OperationStatusResult', + 'PatchExtension', + 'ProxyResource', + 'RepositoryRefDefinition', + 'Resource', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', + 'ResourceProviderOperationList', + 'Scope', + 'ScopeCluster', + 'ScopeNamespace', + 'SourceControlConfiguration', + 'SourceControlConfigurationList', + 'SupportedScopes', + 'SystemData', + 'ClusterTypes', + 'ComplianceStateType', + 'CreatedByType', + 'Enum0', + 'Enum1', + 'FluxComplianceState', + 'KustomizationValidationType', + 'LevelType', + 'MessageLevelType', + 'OperatorScopeType', + 'OperatorType', + 'ProvisioningState', + 'ProvisioningStateType', + 'ScopeType', + 'SourceKindType', +] diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models.py new file mode 100644 index 00000000000..cf53332d58c --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models.py @@ -0,0 +1,1836 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class BucketDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration S3 bucket. + :type url: str + :param bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :type bucket_name: str + :param insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :type insecure: bool + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param access_key: Plaintext access key used to securely access the S3 bucket. + :type access_key: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'bucket_name': {'key': 'bucketName', 'type': 'str'}, + 'insecure': {'key': 'insecure', 'type': 'bool'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'access_key': {'key': 'accessKey', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BucketDefinition, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + self.bucket_name = kwargs.get('bucket_name', None) + self.insecure = kwargs.get('insecure', True) + self.timeout_in_seconds = kwargs.get('timeout_in_seconds', 600) + self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', 600) + self.access_key = kwargs.get('access_key', None) + self.local_auth_ref = kwargs.get('local_auth_ref', None) + + +class BucketPatchDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration S3 bucket. + :type url: str + :param bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :type bucket_name: str + :param insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :type insecure: bool + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param access_key: Plaintext access key used to securely access the S3 bucket. + :type access_key: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'bucket_name': {'key': 'bucketName', 'type': 'str'}, + 'insecure': {'key': 'insecure', 'type': 'bool'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'access_key': {'key': 'accessKey', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BucketPatchDefinition, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + self.bucket_name = kwargs.get('bucket_name', None) + self.insecure = kwargs.get('insecure', None) + self.timeout_in_seconds = kwargs.get('timeout_in_seconds', None) + self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', None) + self.access_key = kwargs.get('access_key', None) + self.local_auth_ref = kwargs.get('local_auth_ref', None) + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _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'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _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'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + +class ClusterScopeSettings(ProxyResource): + """Extension scope settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param allow_multiple_instances: Describes if multiple instances of the extension are allowed. + :type allow_multiple_instances: bool + :param default_release_namespace: Default extension release namespace. + :type default_release_namespace: str + """ + + _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'}, + 'allow_multiple_instances': {'key': 'properties.allowMultipleInstances', 'type': 'bool'}, + 'default_release_namespace': {'key': 'properties.defaultReleaseNamespace', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ClusterScopeSettings, self).__init__(**kwargs) + self.allow_multiple_instances = kwargs.get('allow_multiple_instances', None) + self.default_release_namespace = kwargs.get('default_release_namespace', None) + + +class ComplianceStatus(msrest.serialization.Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar compliance_state: The compliance state of the configuration. Possible values include: + "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ComplianceStateType + :param last_config_applied: Datetime the configuration was last applied. + :type last_config_applied: ~datetime.datetime + :param message: Message from when the configuration was applied. + :type message: str + :param message_level: Level of the message. Possible values include: "Error", "Warning", + "Information". + :type message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.MessageLevelType + """ + + _validation = { + 'compliance_state': {'readonly': True}, + } + + _attribute_map = { + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + 'message_level': {'key': 'messageLevel', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ComplianceStatus, self).__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = kwargs.get('last_config_applied', None) + self.message = kwargs.get('message', None) + self.message_level = kwargs.get('message_level', None) + + +class DependsOnDefinition(msrest.serialization.Model): + """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling this kustomization. + + :param kustomization_name: Name of the kustomization to claim dependency on. + :type kustomization_name: str + """ + + _attribute_map = { + 'kustomization_name': {'key': 'kustomizationName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DependsOnDefinition, self).__init__(**kwargs) + self.kustomization_name = kwargs.get('kustomization_name', None) + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class Extension(ProxyResource): + """The Extension 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. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param identity: Identity of the Extension resource. + :type identity: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Identity + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :param extension_type: Type of the Extension, of which this resource is an instance of. It + must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :type version: str + :param scope: Scope at which the extension is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Scope + :param configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :type configuration_protected_settings: dict[str, str] + :ivar provisioning_state: Status of installation of this extension. Possible values include: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningState + :param statuses: Status from this extension. + :type statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionStatus] + :ivar error_info: Error information from the Agent - e.g. errors during installation. + :vartype error_info: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail + :ivar custom_location_settings: Custom Location settings properties. + :vartype custom_location_settings: dict[str, str] + :ivar package_uri: Uri of the Helm package. + :vartype package_uri: str + :param aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :type aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionPropertiesAksAssignedIdentity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'error_info': {'readonly': True}, + 'custom_location_settings': {'readonly': True}, + 'package_uri': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, + 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, + 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, + 'aks_assigned_identity': {'key': 'properties.aksAssignedIdentity', 'type': 'ExtensionPropertiesAksAssignedIdentity'}, + } + + def __init__( + self, + **kwargs + ): + super(Extension, self).__init__(**kwargs) + self.identity = kwargs.get('identity', None) + self.system_data = None + self.extension_type = kwargs.get('extension_type', None) + self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', True) + self.release_train = kwargs.get('release_train', "Stable") + self.version = kwargs.get('version', None) + self.scope = kwargs.get('scope', None) + self.configuration_settings = kwargs.get('configuration_settings', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + self.provisioning_state = None + self.statuses = kwargs.get('statuses', None) + self.error_info = None + self.custom_location_settings = None + self.package_uri = None + self.aks_assigned_identity = kwargs.get('aks_assigned_identity', None) + + +class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): + """Identity of the Extension resource in an AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :type type: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionPropertiesAksAssignedIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + + +class ExtensionsList(msrest.serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :ivar next_link: URL to get the next set of extension objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Extension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionsList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExtensionStatus(msrest.serialization.Model): + """Status from the extension. + + :param code: Status code provided by the Extension. + :type code: str + :param display_status: Short description of status of the extension. + :type display_status: str + :param level: Level of the status. Possible values include: "Error", "Warning", "Information". + Default value: "Information". + :type level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.LevelType + :param message: Detailed message of the status from the Extension. + :type message: str + :param time: DateLiteral (per ISO8601) noting the time of installation status. + :type time: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'display_status': {'key': 'displayStatus', 'type': 'str'}, + 'level': {'key': 'level', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionStatus, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.display_status = kwargs.get('display_status', None) + self.level = kwargs.get('level', "Information") + self.message = kwargs.get('message', None) + self.time = kwargs.get('time', None) + + +class ExtensionType(msrest.serialization.Model): + """Represents an Extension Type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :ivar release_trains: Extension release train: preview or stable. + :vartype release_trains: list[str] + :ivar cluster_types: Cluster types. Possible values include: "connectedClusters", + "managedClusters". + :vartype cluster_types: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ClusterTypes + :ivar supported_scopes: Extension scopes. + :vartype supported_scopes: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SupportedScopes + """ + + _validation = { + 'system_data': {'readonly': True}, + 'release_trains': {'readonly': True}, + 'cluster_types': {'readonly': True}, + 'supported_scopes': {'readonly': True}, + } + + _attribute_map = { + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'release_trains': {'key': 'properties.releaseTrains', 'type': '[str]'}, + 'cluster_types': {'key': 'properties.clusterTypes', 'type': 'str'}, + 'supported_scopes': {'key': 'properties.supportedScopes', 'type': 'SupportedScopes'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionType, self).__init__(**kwargs) + self.system_data = None + self.release_trains = None + self.cluster_types = None + self.supported_scopes = None + + +class ExtensionTypeList(msrest.serialization.Model): + """List Extension Types. + + :param value: The list of Extension Types. + :type value: list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType] + :param next_link: The link to fetch the next page of Extension Types. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ExtensionType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionTypeList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ExtensionVersionList(msrest.serialization.Model): + """List versions for an Extension. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param versions: Versions available for this Extension Type. + :type versions: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionListVersionsItem] + :param next_link: The link to fetch the next page of Extension Types. + :type next_link: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + """ + + _validation = { + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'versions': {'key': 'versions', 'type': '[ExtensionVersionListVersionsItem]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionVersionList, self).__init__(**kwargs) + self.versions = kwargs.get('versions', None) + self.next_link = kwargs.get('next_link', None) + self.system_data = None + + +class ExtensionVersionListVersionsItem(msrest.serialization.Model): + """ExtensionVersionListVersionsItem. + + :param release_train: The release train for this Extension Type. + :type release_train: str + :param versions: Versions available for this Extension Type and release train. + :type versions: list[str] + """ + + _attribute_map = { + 'release_train': {'key': 'releaseTrain', 'type': 'str'}, + 'versions': {'key': 'versions', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionVersionListVersionsItem, self).__init__(**kwargs) + self.release_train = kwargs.get('release_train', None) + self.versions = kwargs.get('versions', None) + + +class FluxConfiguration(ProxyResource): + """The Flux Configuration object returned in Get & Put response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :param scope: Scope at which the operator will be installed. Possible values include: + "cluster", "namespace". Default value: "cluster". + :type scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeType + :param namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :type namespace: str + :param source_kind: Source Kind to pull the configuration data from. Possible values include: + "GitRepository", "Bucket". + :type source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType + :param suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :type suspend: bool + :param git_repository: Parameters to reconcile to the GitRepository source kind type. + :type git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.GitRepositoryDefinition + :param bucket: Parameters to reconcile to the Bucket source kind type. + :type bucket: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.BucketDefinition + :param kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :type kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.KustomizationDefinition] + :param configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :type configuration_protected_settings: dict[str, str] + :ivar statuses: Statuses of the Flux Kubernetes resources created by the fluxConfiguration or + created by the managed objects provisioned by the fluxConfiguration. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectStatusDefinition] + :ivar repository_public_key: Public Key associated with this fluxConfiguration (either + generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar last_source_updated_commit_id: Branch and SHA of the last source commit synced with the + cluster. + :vartype last_source_updated_commit_id: str + :ivar last_source_updated_at: Datetime the fluxConfiguration last synced its source on the + cluster. + :vartype last_source_updated_at: ~datetime.datetime + :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the + fluxConfiguration or created by the managed objects. Possible values include: "Compliant", + "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Possible values + include: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningState + :ivar error_message: Error message returned to the user in the case of provisioning failure. + :vartype error_message: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'statuses': {'readonly': True}, + 'repository_public_key': {'readonly': True}, + 'last_source_updated_commit_id': {'readonly': True}, + 'last_source_updated_at': {'readonly': True}, + 'compliance_state': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'error_message': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'namespace': {'key': 'properties.namespace', 'type': 'str'}, + 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, + 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, + 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryDefinition'}, + 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, + 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationDefinition}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ObjectStatusDefinition]'}, + 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, + 'last_source_updated_commit_id': {'key': 'properties.lastSourceUpdatedCommitId', 'type': 'str'}, + 'last_source_updated_at': {'key': 'properties.lastSourceUpdatedAt', 'type': 'iso-8601'}, + 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FluxConfiguration, self).__init__(**kwargs) + self.system_data = None + self.scope = kwargs.get('scope', "cluster") + self.namespace = kwargs.get('namespace', "default") + self.source_kind = kwargs.get('source_kind', None) + self.suspend = kwargs.get('suspend', False) + self.git_repository = kwargs.get('git_repository', None) + self.bucket = kwargs.get('bucket', None) + self.kustomizations = kwargs.get('kustomizations', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + self.statuses = None + self.repository_public_key = None + self.last_source_updated_commit_id = None + self.last_source_updated_at = None + self.compliance_state = None + self.provisioning_state = None + self.error_message = None + + +class FluxConfigurationPatch(msrest.serialization.Model): + """The Flux Configuration Patch Request object. + + :param source_kind: Source Kind to pull the configuration data from. Possible values include: + "GitRepository", "Bucket". + :type source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType + :param suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :type suspend: bool + :param git_repository: Parameters to reconcile to the GitRepository source kind type. + :type git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.GitRepositoryPatchDefinition + :param bucket: Parameters to reconcile to the Bucket source kind type. + :type bucket: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.BucketDefinition + :param kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :type kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.KustomizationPatchDefinition] + :param configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :type configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, + 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, + 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryPatchDefinition'}, + 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, + 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationPatchDefinition}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(FluxConfigurationPatch, self).__init__(**kwargs) + self.source_kind = kwargs.get('source_kind', None) + self.suspend = kwargs.get('suspend', None) + self.git_repository = kwargs.get('git_repository', None) + self.bucket = kwargs.get('bucket', None) + self.kustomizations = kwargs.get('kustomizations', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + + +class FluxConfigurationsList(msrest.serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Flux Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FluxConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FluxConfigurationsList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class GitRepositoryDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration git repository. + :type url: str + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param repository_ref: The source reference for the GitRepository object. + :type repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition + :param ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :type ssh_known_hosts: str + :param https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :type https_user: str + :param https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :type https_ca_cert: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, + 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, + 'https_user': {'key': 'httpsUser', 'type': 'str'}, + 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GitRepositoryDefinition, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + self.timeout_in_seconds = kwargs.get('timeout_in_seconds', 600) + self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', 600) + self.repository_ref = kwargs.get('repository_ref', None) + self.ssh_known_hosts = kwargs.get('ssh_known_hosts', None) + self.https_user = kwargs.get('https_user', None) + self.https_ca_cert = kwargs.get('https_ca_cert', None) + self.local_auth_ref = kwargs.get('local_auth_ref', None) + + +class GitRepositoryPatchDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration git repository. + :type url: str + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param repository_ref: The source reference for the GitRepository object. + :type repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition + :param ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :type ssh_known_hosts: str + :param https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :type https_user: str + :param https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :type https_ca_cert: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, + 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, + 'https_user': {'key': 'httpsUser', 'type': 'str'}, + 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GitRepositoryPatchDefinition, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + self.timeout_in_seconds = kwargs.get('timeout_in_seconds', None) + self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', None) + self.repository_ref = kwargs.get('repository_ref', None) + self.ssh_known_hosts = kwargs.get('ssh_known_hosts', None) + self.https_user = kwargs.get('https_user', None) + self.https_ca_cert = kwargs.get('https_ca_cert', None) + self.local_auth_ref = kwargs.get('local_auth_ref', None) + + +class HelmOperatorProperties(msrest.serialization.Model): + """Properties for Helm operator. + + :param chart_version: Version of the operator Helm chart. + :type chart_version: str + :param chart_values: Values override for the operator Helm chart. + :type chart_values: str + """ + + _attribute_map = { + 'chart_version': {'key': 'chartVersion', 'type': 'str'}, + 'chart_values': {'key': 'chartValues', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(HelmOperatorProperties, self).__init__(**kwargs) + self.chart_version = kwargs.get('chart_version', None) + self.chart_values = kwargs.get('chart_values', None) + + +class HelmReleasePropertiesDefinition(msrest.serialization.Model): + """HelmReleasePropertiesDefinition. + + :param last_revision_applied: The revision number of the last released object change. + :type last_revision_applied: long + :param helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :type helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectReferenceDefinition + :param failure_count: Total number of times that the HelmRelease failed to install or upgrade. + :type failure_count: long + :param install_failure_count: Number of times that the HelmRelease failed to install. + :type install_failure_count: long + :param upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :type upgrade_failure_count: long + """ + + _attribute_map = { + 'last_revision_applied': {'key': 'lastRevisionApplied', 'type': 'long'}, + 'helm_chart_ref': {'key': 'helmChartRef', 'type': 'ObjectReferenceDefinition'}, + 'failure_count': {'key': 'failureCount', 'type': 'long'}, + 'install_failure_count': {'key': 'installFailureCount', 'type': 'long'}, + 'upgrade_failure_count': {'key': 'upgradeFailureCount', 'type': 'long'}, + } + + def __init__( + self, + **kwargs + ): + super(HelmReleasePropertiesDefinition, self).__init__(**kwargs) + self.last_revision_applied = kwargs.get('last_revision_applied', None) + self.helm_chart_ref = kwargs.get('helm_chart_ref', None) + self.failure_count = kwargs.get('failure_count', None) + self.install_failure_count = kwargs.get('install_failure_count', None) + self.upgrade_failure_count = kwargs.get('upgrade_failure_count', None) + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :type type: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + + +class KustomizationDefinition(msrest.serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. + + :param path: The path in the source reference to reconcile on the cluster. + :type path: str + :param depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :type depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] + :param timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :type sync_interval_in_seconds: long + :param retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :type retry_interval_in_seconds: long + :param prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :type prune: bool + :param force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :type force: bool + """ + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, + 'prune': {'key': 'prune', 'type': 'bool'}, + 'force': {'key': 'force', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(KustomizationDefinition, self).__init__(**kwargs) + self.path = kwargs.get('path', "") + self.depends_on = kwargs.get('depends_on', None) + self.timeout_in_seconds = kwargs.get('timeout_in_seconds', 600) + self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', 600) + self.retry_interval_in_seconds = kwargs.get('retry_interval_in_seconds', None) + self.prune = kwargs.get('prune', False) + self.force = kwargs.get('force', False) + + +class KustomizationPatchDefinition(msrest.serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. + + :param path: The path in the source reference to reconcile on the cluster. + :type path: str + :param depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :type depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] + :param timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :type sync_interval_in_seconds: long + :param retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :type retry_interval_in_seconds: long + :param prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :type prune: bool + :param force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :type force: bool + """ + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, + 'prune': {'key': 'prune', 'type': 'bool'}, + 'force': {'key': 'force', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(KustomizationPatchDefinition, self).__init__(**kwargs) + self.path = kwargs.get('path', None) + self.depends_on = kwargs.get('depends_on', None) + self.timeout_in_seconds = kwargs.get('timeout_in_seconds', None) + self.sync_interval_in_seconds = kwargs.get('sync_interval_in_seconds', None) + self.retry_interval_in_seconds = kwargs.get('retry_interval_in_seconds', None) + self.prune = kwargs.get('prune', None) + self.force = kwargs.get('force', None) + + +class ObjectReferenceDefinition(msrest.serialization.Model): + """Object reference to a Kubernetes object on a cluster. + + :param name: Name of the object. + :type name: str + :param namespace: Namespace of the object. + :type namespace: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'namespace': {'key': 'namespace', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ObjectReferenceDefinition, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.namespace = kwargs.get('namespace', None) + + +class ObjectStatusConditionDefinition(msrest.serialization.Model): + """Status condition of Kubernetes object. + + :param last_transition_time: Last time this status condition has changed. + :type last_transition_time: ~datetime.datetime + :param message: A more verbose description of the object status condition. + :type message: str + :param reason: Reason for the specified status condition type status. + :type reason: str + :param status: Status of the Kubernetes object condition type. + :type status: str + :param type: Object status condition type for this object. + :type type: str + """ + + _attribute_map = { + 'last_transition_time': {'key': 'lastTransitionTime', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ObjectStatusConditionDefinition, self).__init__(**kwargs) + self.last_transition_time = kwargs.get('last_transition_time', None) + self.message = kwargs.get('message', None) + self.reason = kwargs.get('reason', None) + self.status = kwargs.get('status', None) + self.type = kwargs.get('type', None) + + +class ObjectStatusDefinition(msrest.serialization.Model): + """Statuses of objects deployed by the user-specified kustomizations from the git repository. + + :param name: Name of the applied object. + :type name: str + :param namespace: Namespace of the applied object. + :type namespace: str + :param kind: Kind of the applied object. + :type kind: str + :param compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Possible values include: "Compliant", + "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + :type compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState + :param applied_by: Object reference to the Kustomization that applied this object. + :type applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectReferenceDefinition + :param status_conditions: List of Kubernetes object status conditions present on the cluster. + :type status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectStatusConditionDefinition] + :param helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :type helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmReleasePropertiesDefinition + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'namespace': {'key': 'namespace', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + 'applied_by': {'key': 'appliedBy', 'type': 'ObjectReferenceDefinition'}, + 'status_conditions': {'key': 'statusConditions', 'type': '[ObjectStatusConditionDefinition]'}, + 'helm_release_properties': {'key': 'helmReleaseProperties', 'type': 'HelmReleasePropertiesDefinition'}, + } + + def __init__( + self, + **kwargs + ): + super(ObjectStatusDefinition, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.namespace = kwargs.get('namespace', None) + self.kind = kwargs.get('kind', None) + self.compliance_state = kwargs.get('compliance_state', "Unknown") + self.applied_by = kwargs.get('applied_by', None) + self.status_conditions = kwargs.get('status_conditions', None) + self.helm_release_properties = kwargs.get('helm_release_properties', None) + + +class OperationStatusList(msrest.serialization.Model): + """The async operations in progress, in the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of async operations in progress, in the cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult] + :ivar next_link: URL to get the next set of Operation Result objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationStatusList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationStatusResult(msrest.serialization.Model): + """The current status of an async operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param id: Fully qualified ID for the async operation. + :type id: str + :param name: Name of the async operation. + :type name: str + :param status: Required. Operation status. + :type status: str + :param properties: Additional information, if available. + :type properties: dict[str, str] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail + """ + + _validation = { + 'status': {'required': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationStatusResult, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.status = kwargs['status'] + self.properties = kwargs.get('properties', None) + self.error = None + + +class PatchExtension(msrest.serialization.Model): + """The Extension Patch Request object. + + :param auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :type version: str + :param configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :type configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(PatchExtension, self).__init__(**kwargs) + self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', True) + self.release_train = kwargs.get('release_train', "Stable") + self.version = kwargs.get('version', None) + self.configuration_settings = kwargs.get('configuration_settings', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + + +class RepositoryRefDefinition(msrest.serialization.Model): + """The source reference for the GitRepository object. + + :param branch: The git repository branch name to checkout. + :type branch: str + :param tag: The git repository tag name to checkout. This takes precedence over branch. + :type tag: str + :param semver: The semver range used to match against git repository tags. This takes + precedence over tag. + :type semver: str + :param commit: The commit SHA to checkout. This value must be combined with the branch name to + be valid. This takes precedence over semver. + :type commit: str + """ + + _attribute_map = { + 'branch': {'key': 'branch', 'type': 'str'}, + 'tag': {'key': 'tag', 'type': 'str'}, + 'semver': {'key': 'semver', 'type': 'str'}, + 'commit': {'key': 'commit', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(RepositoryRefDefinition, self).__init__(**kwargs) + self.branch = kwargs.get('branch', None) + self.tag = kwargs.get('tag', None) + self.semver = kwargs.get('semver', None) + self.commit = kwargs.get('commit', None) + + +class ResourceProviderOperation(msrest.serialization.Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param name: Operation name, in format of {provider}/{resource}/{operation}. + :type name: str + :param display: Display metadata associated with the operation. + :type display: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _validation = { + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.is_data_action = None + self.origin = None + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft KubernetesConfiguration. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Result of the request to list operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of operations supported by this resource provider. + :type value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperation] + :ivar next_link: URL to the next set of results, if any. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class Scope(msrest.serialization.Model): + """Scope of the extension. It can be either Cluster or Namespace; but not both. + + :param cluster: Specifies that the scope of the extension is Cluster. + :type cluster: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeCluster + :param namespace: Specifies that the scope of the extension is Namespace. + :type namespace: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeNamespace + """ + + _attribute_map = { + 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, + 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + } + + def __init__( + self, + **kwargs + ): + super(Scope, self).__init__(**kwargs) + self.cluster = kwargs.get('cluster', None) + self.namespace = kwargs.get('namespace', None) + + +class ScopeCluster(msrest.serialization.Model): + """Specifies that the scope of the extension is Cluster. + + :param release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :type release_namespace: str + """ + + _attribute_map = { + 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ScopeCluster, self).__init__(**kwargs) + self.release_namespace = kwargs.get('release_namespace', None) + + +class ScopeNamespace(msrest.serialization.Model): + """Specifies that the scope of the extension is Namespace. + + :param target_namespace: Namespace where the extension will be created for an Namespace scoped + extension. If this namespace does not exist, it will be created. + :type target_namespace: str + """ + + _attribute_map = { + 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ScopeNamespace, self).__init__(**kwargs) + self.target_namespace = kwargs.get('target_namespace', None) + + +class SourceControlConfiguration(ProxyResource): + """The SourceControl Configuration object returned in Get & Put response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :param repository_url: Url of the SourceControl Repository. + :type repository_url: str + :param operator_namespace: The namespace to which this operator is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :type operator_namespace: str + :param operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :type operator_instance_name: str + :param operator_type: Type of the operator. Possible values include: "Flux". + :type operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorType + :param operator_params: Any Parameters for the Operator instance in string format. + :type operator_params: str + :param configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :type configuration_protected_settings: dict[str, str] + :param operator_scope: Scope at which the operator will be installed. Possible values include: + "cluster", "namespace". Default value: "cluster". + :type operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl configuration + (either generated within the cluster or provided by the user). + :vartype repository_public_key: str + :param ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH keys + required to access private Git instances. + :type ssh_known_hosts_contents: str + :param enable_helm_operator: Option to enable Helm Operator for this git configuration. + :type enable_helm_operator: bool + :param helm_operator_properties: Properties for Helm operator. + :type helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. Possible values + include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration. + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ComplianceStatus + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'repository_public_key': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'compliance_status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, + 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, + 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, + 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, + 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, + 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, + 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, + 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, + 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + } + + def __init__( + self, + **kwargs + ): + super(SourceControlConfiguration, self).__init__(**kwargs) + self.system_data = None + self.repository_url = kwargs.get('repository_url', None) + self.operator_namespace = kwargs.get('operator_namespace', "default") + self.operator_instance_name = kwargs.get('operator_instance_name', None) + self.operator_type = kwargs.get('operator_type', None) + self.operator_params = kwargs.get('operator_params', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + self.operator_scope = kwargs.get('operator_scope', "cluster") + self.repository_public_key = None + self.ssh_known_hosts_contents = kwargs.get('ssh_known_hosts_contents', None) + self.enable_helm_operator = kwargs.get('enable_helm_operator', None) + self.helm_operator_properties = kwargs.get('helm_operator_properties', None) + self.provisioning_state = None + self.compliance_status = None + + +class SourceControlConfigurationList(msrest.serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Source Control Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SourceControlConfigurationList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SupportedScopes(msrest.serialization.Model): + """Extension scopes. + + :param default_scope: Default extension scopes: cluster or namespace. + :type default_scope: str + :param cluster_scope_settings: Scope settings. + :type cluster_scope_settings: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ClusterScopeSettings + """ + + _attribute_map = { + 'default_scope': {'key': 'defaultScope', 'type': 'str'}, + 'cluster_scope_settings': {'key': 'clusterScopeSettings', 'type': 'ClusterScopeSettings'}, + } + + def __init__( + self, + **kwargs + ): + super(SupportedScopes, self).__init__(**kwargs) + self.default_scope = kwargs.get('default_scope', None) + self.cluster_scope_settings = kwargs.get('cluster_scope_settings', None) + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models_py3.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models_py3.py new file mode 100644 index 00000000000..23eef7e57d6 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_models_py3.py @@ -0,0 +1,2028 @@ +# 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. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._source_control_configuration_client_enums import * + + +class BucketDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration S3 bucket. + :type url: str + :param bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :type bucket_name: str + :param insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :type insecure: bool + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param access_key: Plaintext access key used to securely access the S3 bucket. + :type access_key: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'bucket_name': {'key': 'bucketName', 'type': 'str'}, + 'insecure': {'key': 'insecure', 'type': 'bool'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'access_key': {'key': 'accessKey', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: Optional[bool] = True, + timeout_in_seconds: Optional[int] = 600, + sync_interval_in_seconds: Optional[int] = 600, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs + ): + super(BucketDefinition, self).__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class BucketPatchDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration S3 bucket. + :type url: str + :param bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :type bucket_name: str + :param insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :type insecure: bool + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param access_key: Plaintext access key used to securely access the S3 bucket. + :type access_key: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'bucket_name': {'key': 'bucketName', 'type': 'str'}, + 'insecure': {'key': 'insecure', 'type': 'bool'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'access_key': {'key': 'accessKey', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: Optional[bool] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs + ): + super(BucketPatchDefinition, self).__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _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'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _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'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + +class ClusterScopeSettings(ProxyResource): + """Extension scope settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param allow_multiple_instances: Describes if multiple instances of the extension are allowed. + :type allow_multiple_instances: bool + :param default_release_namespace: Default extension release namespace. + :type default_release_namespace: str + """ + + _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'}, + 'allow_multiple_instances': {'key': 'properties.allowMultipleInstances', 'type': 'bool'}, + 'default_release_namespace': {'key': 'properties.defaultReleaseNamespace', 'type': 'str'}, + } + + def __init__( + self, + *, + allow_multiple_instances: Optional[bool] = None, + default_release_namespace: Optional[str] = None, + **kwargs + ): + super(ClusterScopeSettings, self).__init__(**kwargs) + self.allow_multiple_instances = allow_multiple_instances + self.default_release_namespace = default_release_namespace + + +class ComplianceStatus(msrest.serialization.Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar compliance_state: The compliance state of the configuration. Possible values include: + "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ComplianceStateType + :param last_config_applied: Datetime the configuration was last applied. + :type last_config_applied: ~datetime.datetime + :param message: Message from when the configuration was applied. + :type message: str + :param message_level: Level of the message. Possible values include: "Error", "Warning", + "Information". + :type message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.MessageLevelType + """ + + _validation = { + 'compliance_state': {'readonly': True}, + } + + _attribute_map = { + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + 'message_level': {'key': 'messageLevel', 'type': 'str'}, + } + + def __init__( + self, + *, + last_config_applied: Optional[datetime.datetime] = None, + message: Optional[str] = None, + message_level: Optional[Union[str, "MessageLevelType"]] = None, + **kwargs + ): + super(ComplianceStatus, self).__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = last_config_applied + self.message = message + self.message_level = message_level + + +class DependsOnDefinition(msrest.serialization.Model): + """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling this kustomization. + + :param kustomization_name: Name of the kustomization to claim dependency on. + :type kustomization_name: str + """ + + _attribute_map = { + 'kustomization_name': {'key': 'kustomizationName', 'type': 'str'}, + } + + def __init__( + self, + *, + kustomization_name: Optional[str] = None, + **kwargs + ): + super(DependsOnDefinition, self).__init__(**kwargs) + self.kustomization_name = kustomization_name + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Extension(ProxyResource): + """The Extension 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. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param identity: Identity of the Extension resource. + :type identity: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Identity + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :param extension_type: Type of the Extension, of which this resource is an instance of. It + must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :type version: str + :param scope: Scope at which the extension is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Scope + :param configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :type configuration_protected_settings: dict[str, str] + :ivar provisioning_state: Status of installation of this extension. Possible values include: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningState + :param statuses: Status from this extension. + :type statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionStatus] + :ivar error_info: Error information from the Agent - e.g. errors during installation. + :vartype error_info: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail + :ivar custom_location_settings: Custom Location settings properties. + :vartype custom_location_settings: dict[str, str] + :ivar package_uri: Uri of the Helm package. + :vartype package_uri: str + :param aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :type aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionPropertiesAksAssignedIdentity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'error_info': {'readonly': True}, + 'custom_location_settings': {'readonly': True}, + 'package_uri': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, + 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, + 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, + 'aks_assigned_identity': {'key': 'properties.aksAssignedIdentity', 'type': 'ExtensionPropertiesAksAssignedIdentity'}, + } + + def __init__( + self, + *, + identity: Optional["Identity"] = None, + extension_type: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = True, + release_train: Optional[str] = "Stable", + version: Optional[str] = None, + scope: Optional["Scope"] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + statuses: Optional[List["ExtensionStatus"]] = None, + aks_assigned_identity: Optional["ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs + ): + super(Extension, self).__init__(**kwargs) + self.identity = identity + self.system_data = None + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + self.provisioning_state = None + self.statuses = statuses + self.error_info = None + self.custom_location_settings = None + self.package_uri = None + self.aks_assigned_identity = aks_assigned_identity + + +class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): + """Identity of the Extension resource in an AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :type type: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + **kwargs + ): + super(ExtensionPropertiesAksAssignedIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ExtensionsList(msrest.serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :ivar next_link: URL to get the next set of extension objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Extension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionsList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExtensionStatus(msrest.serialization.Model): + """Status from the extension. + + :param code: Status code provided by the Extension. + :type code: str + :param display_status: Short description of status of the extension. + :type display_status: str + :param level: Level of the status. Possible values include: "Error", "Warning", "Information". + Default value: "Information". + :type level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.LevelType + :param message: Detailed message of the status from the Extension. + :type message: str + :param time: DateLiteral (per ISO8601) noting the time of installation status. + :type time: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'display_status': {'key': 'displayStatus', 'type': 'str'}, + 'level': {'key': 'level', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + display_status: Optional[str] = None, + level: Optional[Union[str, "LevelType"]] = "Information", + message: Optional[str] = None, + time: Optional[str] = None, + **kwargs + ): + super(ExtensionStatus, self).__init__(**kwargs) + self.code = code + self.display_status = display_status + self.level = level + self.message = message + self.time = time + + +class ExtensionType(msrest.serialization.Model): + """Represents an Extension Type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :ivar release_trains: Extension release train: preview or stable. + :vartype release_trains: list[str] + :ivar cluster_types: Cluster types. Possible values include: "connectedClusters", + "managedClusters". + :vartype cluster_types: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ClusterTypes + :ivar supported_scopes: Extension scopes. + :vartype supported_scopes: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SupportedScopes + """ + + _validation = { + 'system_data': {'readonly': True}, + 'release_trains': {'readonly': True}, + 'cluster_types': {'readonly': True}, + 'supported_scopes': {'readonly': True}, + } + + _attribute_map = { + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'release_trains': {'key': 'properties.releaseTrains', 'type': '[str]'}, + 'cluster_types': {'key': 'properties.clusterTypes', 'type': 'str'}, + 'supported_scopes': {'key': 'properties.supportedScopes', 'type': 'SupportedScopes'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionType, self).__init__(**kwargs) + self.system_data = None + self.release_trains = None + self.cluster_types = None + self.supported_scopes = None + + +class ExtensionTypeList(msrest.serialization.Model): + """List Extension Types. + + :param value: The list of Extension Types. + :type value: list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType] + :param next_link: The link to fetch the next page of Extension Types. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ExtensionType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ExtensionType"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ExtensionTypeList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ExtensionVersionList(msrest.serialization.Model): + """List versions for an Extension. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param versions: Versions available for this Extension Type. + :type versions: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionListVersionsItem] + :param next_link: The link to fetch the next page of Extension Types. + :type next_link: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + """ + + _validation = { + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'versions': {'key': 'versions', 'type': '[ExtensionVersionListVersionsItem]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + versions: Optional[List["ExtensionVersionListVersionsItem"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ExtensionVersionList, self).__init__(**kwargs) + self.versions = versions + self.next_link = next_link + self.system_data = None + + +class ExtensionVersionListVersionsItem(msrest.serialization.Model): + """ExtensionVersionListVersionsItem. + + :param release_train: The release train for this Extension Type. + :type release_train: str + :param versions: Versions available for this Extension Type and release train. + :type versions: list[str] + """ + + _attribute_map = { + 'release_train': {'key': 'releaseTrain', 'type': 'str'}, + 'versions': {'key': 'versions', 'type': '[str]'}, + } + + def __init__( + self, + *, + release_train: Optional[str] = None, + versions: Optional[List[str]] = None, + **kwargs + ): + super(ExtensionVersionListVersionsItem, self).__init__(**kwargs) + self.release_train = release_train + self.versions = versions + + +class FluxConfiguration(ProxyResource): + """The Flux Configuration object returned in Get & Put response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :param scope: Scope at which the operator will be installed. Possible values include: + "cluster", "namespace". Default value: "cluster". + :type scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeType + :param namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :type namespace: str + :param source_kind: Source Kind to pull the configuration data from. Possible values include: + "GitRepository", "Bucket". + :type source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType + :param suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :type suspend: bool + :param git_repository: Parameters to reconcile to the GitRepository source kind type. + :type git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.GitRepositoryDefinition + :param bucket: Parameters to reconcile to the Bucket source kind type. + :type bucket: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.BucketDefinition + :param kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :type kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.KustomizationDefinition] + :param configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :type configuration_protected_settings: dict[str, str] + :ivar statuses: Statuses of the Flux Kubernetes resources created by the fluxConfiguration or + created by the managed objects provisioned by the fluxConfiguration. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectStatusDefinition] + :ivar repository_public_key: Public Key associated with this fluxConfiguration (either + generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar last_source_updated_commit_id: Branch and SHA of the last source commit synced with the + cluster. + :vartype last_source_updated_commit_id: str + :ivar last_source_updated_at: Datetime the fluxConfiguration last synced its source on the + cluster. + :vartype last_source_updated_at: ~datetime.datetime + :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the + fluxConfiguration or created by the managed objects. Possible values include: "Compliant", + "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Possible values + include: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningState + :ivar error_message: Error message returned to the user in the case of provisioning failure. + :vartype error_message: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'statuses': {'readonly': True}, + 'repository_public_key': {'readonly': True}, + 'last_source_updated_commit_id': {'readonly': True}, + 'last_source_updated_at': {'readonly': True}, + 'compliance_state': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'error_message': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'namespace': {'key': 'properties.namespace', 'type': 'str'}, + 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, + 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, + 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryDefinition'}, + 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, + 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationDefinition}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ObjectStatusDefinition]'}, + 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, + 'last_source_updated_commit_id': {'key': 'properties.lastSourceUpdatedCommitId', 'type': 'str'}, + 'last_source_updated_at': {'key': 'properties.lastSourceUpdatedAt', 'type': 'iso-8601'}, + 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + } + + def __init__( + self, + *, + scope: Optional[Union[str, "ScopeType"]] = "cluster", + namespace: Optional[str] = "default", + source_kind: Optional[Union[str, "SourceKindType"]] = None, + suspend: Optional[bool] = False, + git_repository: Optional["GitRepositoryDefinition"] = None, + bucket: Optional["BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "KustomizationDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs + ): + super(FluxConfiguration, self).__init__(**kwargs) + self.system_data = None + self.scope = scope + self.namespace = namespace + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + self.statuses = None + self.repository_public_key = None + self.last_source_updated_commit_id = None + self.last_source_updated_at = None + self.compliance_state = None + self.provisioning_state = None + self.error_message = None + + +class FluxConfigurationPatch(msrest.serialization.Model): + """The Flux Configuration Patch Request object. + + :param source_kind: Source Kind to pull the configuration data from. Possible values include: + "GitRepository", "Bucket". + :type source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType + :param suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :type suspend: bool + :param git_repository: Parameters to reconcile to the GitRepository source kind type. + :type git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.GitRepositoryPatchDefinition + :param bucket: Parameters to reconcile to the Bucket source kind type. + :type bucket: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.BucketDefinition + :param kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :type kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.KustomizationPatchDefinition] + :param configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :type configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, + 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, + 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryPatchDefinition'}, + 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, + 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationPatchDefinition}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + } + + def __init__( + self, + *, + source_kind: Optional[Union[str, "SourceKindType"]] = None, + suspend: Optional[bool] = None, + git_repository: Optional["GitRepositoryPatchDefinition"] = None, + bucket: Optional["BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "KustomizationPatchDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs + ): + super(FluxConfigurationPatch, self).__init__(**kwargs) + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + + +class FluxConfigurationsList(msrest.serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Flux Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FluxConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FluxConfigurationsList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class GitRepositoryDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration git repository. + :type url: str + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param repository_ref: The source reference for the GitRepository object. + :type repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition + :param ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :type ssh_known_hosts: str + :param https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :type https_user: str + :param https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :type https_ca_cert: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, + 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, + 'https_user': {'key': 'httpsUser', 'type': 'str'}, + 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: Optional[int] = 600, + sync_interval_in_seconds: Optional[int] = 600, + repository_ref: Optional["RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs + ): + super(GitRepositoryDefinition, self).__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class GitRepositoryPatchDefinition(msrest.serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :param url: The URL to sync for the flux configuration git repository. + :type url: str + :param timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :type sync_interval_in_seconds: long + :param repository_ref: The source reference for the GitRepository object. + :type repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition + :param ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :type ssh_known_hosts: str + :param https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :type https_user: str + :param https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :type https_ca_cert: str + :param local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :type local_auth_ref: str + """ + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, + 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, + 'https_user': {'key': 'httpsUser', 'type': 'str'}, + 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, + 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + repository_ref: Optional["RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs + ): + super(GitRepositoryPatchDefinition, self).__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class HelmOperatorProperties(msrest.serialization.Model): + """Properties for Helm operator. + + :param chart_version: Version of the operator Helm chart. + :type chart_version: str + :param chart_values: Values override for the operator Helm chart. + :type chart_values: str + """ + + _attribute_map = { + 'chart_version': {'key': 'chartVersion', 'type': 'str'}, + 'chart_values': {'key': 'chartValues', 'type': 'str'}, + } + + def __init__( + self, + *, + chart_version: Optional[str] = None, + chart_values: Optional[str] = None, + **kwargs + ): + super(HelmOperatorProperties, self).__init__(**kwargs) + self.chart_version = chart_version + self.chart_values = chart_values + + +class HelmReleasePropertiesDefinition(msrest.serialization.Model): + """HelmReleasePropertiesDefinition. + + :param last_revision_applied: The revision number of the last released object change. + :type last_revision_applied: long + :param helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :type helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectReferenceDefinition + :param failure_count: Total number of times that the HelmRelease failed to install or upgrade. + :type failure_count: long + :param install_failure_count: Number of times that the HelmRelease failed to install. + :type install_failure_count: long + :param upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :type upgrade_failure_count: long + """ + + _attribute_map = { + 'last_revision_applied': {'key': 'lastRevisionApplied', 'type': 'long'}, + 'helm_chart_ref': {'key': 'helmChartRef', 'type': 'ObjectReferenceDefinition'}, + 'failure_count': {'key': 'failureCount', 'type': 'long'}, + 'install_failure_count': {'key': 'installFailureCount', 'type': 'long'}, + 'upgrade_failure_count': {'key': 'upgradeFailureCount', 'type': 'long'}, + } + + def __init__( + self, + *, + last_revision_applied: Optional[int] = None, + helm_chart_ref: Optional["ObjectReferenceDefinition"] = None, + failure_count: Optional[int] = None, + install_failure_count: Optional[int] = None, + upgrade_failure_count: Optional[int] = None, + **kwargs + ): + super(HelmReleasePropertiesDefinition, self).__init__(**kwargs) + self.last_revision_applied = last_revision_applied + self.helm_chart_ref = helm_chart_ref + self.failure_count = failure_count + self.install_failure_count = install_failure_count + self.upgrade_failure_count = upgrade_failure_count + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :type type: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + **kwargs + ): + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class KustomizationDefinition(msrest.serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. + + :param path: The path in the source reference to reconcile on the cluster. + :type path: str + :param depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :type depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] + :param timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :type sync_interval_in_seconds: long + :param retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :type retry_interval_in_seconds: long + :param prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :type prune: bool + :param force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :type force: bool + """ + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, + 'prune': {'key': 'prune', 'type': 'bool'}, + 'force': {'key': 'force', 'type': 'bool'}, + } + + def __init__( + self, + *, + path: Optional[str] = "", + depends_on: Optional[List["DependsOnDefinition"]] = None, + timeout_in_seconds: Optional[int] = 600, + sync_interval_in_seconds: Optional[int] = 600, + retry_interval_in_seconds: Optional[int] = None, + prune: Optional[bool] = False, + force: Optional[bool] = False, + **kwargs + ): + super(KustomizationDefinition, self).__init__(**kwargs) + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class KustomizationPatchDefinition(msrest.serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. + + :param path: The path in the source reference to reconcile on the cluster. + :type path: str + :param depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :type depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] + :param timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :type timeout_in_seconds: long + :param sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :type sync_interval_in_seconds: long + :param retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :type retry_interval_in_seconds: long + :param prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :type prune: bool + :param force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :type force: bool + """ + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, + 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, + 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, + 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, + 'prune': {'key': 'prune', 'type': 'bool'}, + 'force': {'key': 'force', 'type': 'bool'}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + depends_on: Optional[List["DependsOnDefinition"]] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + retry_interval_in_seconds: Optional[int] = None, + prune: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs + ): + super(KustomizationPatchDefinition, self).__init__(**kwargs) + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class ObjectReferenceDefinition(msrest.serialization.Model): + """Object reference to a Kubernetes object on a cluster. + + :param name: Name of the object. + :type name: str + :param namespace: Namespace of the object. + :type namespace: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'namespace': {'key': 'namespace', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + **kwargs + ): + super(ObjectReferenceDefinition, self).__init__(**kwargs) + self.name = name + self.namespace = namespace + + +class ObjectStatusConditionDefinition(msrest.serialization.Model): + """Status condition of Kubernetes object. + + :param last_transition_time: Last time this status condition has changed. + :type last_transition_time: ~datetime.datetime + :param message: A more verbose description of the object status condition. + :type message: str + :param reason: Reason for the specified status condition type status. + :type reason: str + :param status: Status of the Kubernetes object condition type. + :type status: str + :param type: Object status condition type for this object. + :type type: str + """ + + _attribute_map = { + 'last_transition_time': {'key': 'lastTransitionTime', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + last_transition_time: Optional[datetime.datetime] = None, + message: Optional[str] = None, + reason: Optional[str] = None, + status: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + super(ObjectStatusConditionDefinition, self).__init__(**kwargs) + self.last_transition_time = last_transition_time + self.message = message + self.reason = reason + self.status = status + self.type = type + + +class ObjectStatusDefinition(msrest.serialization.Model): + """Statuses of objects deployed by the user-specified kustomizations from the git repository. + + :param name: Name of the applied object. + :type name: str + :param namespace: Namespace of the applied object. + :type namespace: str + :param kind: Kind of the applied object. + :type kind: str + :param compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Possible values include: "Compliant", + "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + :type compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState + :param applied_by: Object reference to the Kustomization that applied this object. + :type applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectReferenceDefinition + :param status_conditions: List of Kubernetes object status conditions present on the cluster. + :type status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectStatusConditionDefinition] + :param helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :type helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmReleasePropertiesDefinition + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'namespace': {'key': 'namespace', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + 'applied_by': {'key': 'appliedBy', 'type': 'ObjectReferenceDefinition'}, + 'status_conditions': {'key': 'statusConditions', 'type': '[ObjectStatusConditionDefinition]'}, + 'helm_release_properties': {'key': 'helmReleaseProperties', 'type': 'HelmReleasePropertiesDefinition'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + kind: Optional[str] = None, + compliance_state: Optional[Union[str, "FluxComplianceState"]] = "Unknown", + applied_by: Optional["ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["HelmReleasePropertiesDefinition"] = None, + **kwargs + ): + super(ObjectStatusDefinition, self).__init__(**kwargs) + self.name = name + self.namespace = namespace + self.kind = kind + self.compliance_state = compliance_state + self.applied_by = applied_by + self.status_conditions = status_conditions + self.helm_release_properties = helm_release_properties + + +class OperationStatusList(msrest.serialization.Model): + """The async operations in progress, in the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of async operations in progress, in the cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult] + :ivar next_link: URL to get the next set of Operation Result objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationStatusList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationStatusResult(msrest.serialization.Model): + """The current status of an async operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param id: Fully qualified ID for the async operation. + :type id: str + :param name: Name of the async operation. + :type name: str + :param status: Required. Operation status. + :type status: str + :param properties: Additional information, if available. + :type properties: dict[str, str] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail + """ + + _validation = { + 'status': {'required': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, + name: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): + super(OperationStatusResult, self).__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = None + + +class PatchExtension(msrest.serialization.Model): + """The Extension Patch Request object. + + :param auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :type version: str + :param configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :type configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + } + + def __init__( + self, + *, + auto_upgrade_minor_version: Optional[bool] = True, + release_train: Optional[str] = "Stable", + version: Optional[str] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs + ): + super(PatchExtension, self).__init__(**kwargs) + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + + +class RepositoryRefDefinition(msrest.serialization.Model): + """The source reference for the GitRepository object. + + :param branch: The git repository branch name to checkout. + :type branch: str + :param tag: The git repository tag name to checkout. This takes precedence over branch. + :type tag: str + :param semver: The semver range used to match against git repository tags. This takes + precedence over tag. + :type semver: str + :param commit: The commit SHA to checkout. This value must be combined with the branch name to + be valid. This takes precedence over semver. + :type commit: str + """ + + _attribute_map = { + 'branch': {'key': 'branch', 'type': 'str'}, + 'tag': {'key': 'tag', 'type': 'str'}, + 'semver': {'key': 'semver', 'type': 'str'}, + 'commit': {'key': 'commit', 'type': 'str'}, + } + + def __init__( + self, + *, + branch: Optional[str] = None, + tag: Optional[str] = None, + semver: Optional[str] = None, + commit: Optional[str] = None, + **kwargs + ): + super(RepositoryRefDefinition, self).__init__(**kwargs) + self.branch = branch + self.tag = tag + self.semver = semver + self.commit = commit + + +class ResourceProviderOperation(msrest.serialization.Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param name: Operation name, in format of {provider}/{resource}/{operation}. + :type name: str + :param display: Display metadata associated with the operation. + :type display: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _validation = { + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["ResourceProviderOperationDisplay"] = None, + **kwargs + ): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = None + self.origin = None + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft KubernetesConfiguration. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Result of the request to list operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of operations supported by this resource provider. + :type value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperation] + :ivar next_link: URL to the next set of results, if any. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceProviderOperation"]] = None, + **kwargs + ): + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class Scope(msrest.serialization.Model): + """Scope of the extension. It can be either Cluster or Namespace; but not both. + + :param cluster: Specifies that the scope of the extension is Cluster. + :type cluster: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeCluster + :param namespace: Specifies that the scope of the extension is Namespace. + :type namespace: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeNamespace + """ + + _attribute_map = { + 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, + 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + } + + def __init__( + self, + *, + cluster: Optional["ScopeCluster"] = None, + namespace: Optional["ScopeNamespace"] = None, + **kwargs + ): + super(Scope, self).__init__(**kwargs) + self.cluster = cluster + self.namespace = namespace + + +class ScopeCluster(msrest.serialization.Model): + """Specifies that the scope of the extension is Cluster. + + :param release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :type release_namespace: str + """ + + _attribute_map = { + 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + } + + def __init__( + self, + *, + release_namespace: Optional[str] = None, + **kwargs + ): + super(ScopeCluster, self).__init__(**kwargs) + self.release_namespace = release_namespace + + +class ScopeNamespace(msrest.serialization.Model): + """Specifies that the scope of the extension is Namespace. + + :param target_namespace: Namespace where the extension will be created for an Namespace scoped + extension. If this namespace does not exist, it will be created. + :type target_namespace: str + """ + + _attribute_map = { + 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + } + + def __init__( + self, + *, + target_namespace: Optional[str] = None, + **kwargs + ): + super(ScopeNamespace, self).__init__(**kwargs) + self.target_namespace = target_namespace + + +class SourceControlConfiguration(ProxyResource): + """The SourceControl Configuration object returned in Get & Put response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData + :param repository_url: Url of the SourceControl Repository. + :type repository_url: str + :param operator_namespace: The namespace to which this operator is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :type operator_namespace: str + :param operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :type operator_instance_name: str + :param operator_type: Type of the operator. Possible values include: "Flux". + :type operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorType + :param operator_params: Any Parameters for the Operator instance in string format. + :type operator_params: str + :param configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :type configuration_protected_settings: dict[str, str] + :param operator_scope: Scope at which the operator will be installed. Possible values include: + "cluster", "namespace". Default value: "cluster". + :type operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl configuration + (either generated within the cluster or provided by the user). + :vartype repository_public_key: str + :param ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH keys + required to access private Git instances. + :type ssh_known_hosts_contents: str + :param enable_helm_operator: Option to enable Helm Operator for this git configuration. + :type enable_helm_operator: bool + :param helm_operator_properties: Properties for Helm operator. + :type helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. Possible values + include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration. + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ComplianceStatus + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'repository_public_key': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'compliance_status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, + 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, + 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, + 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, + 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, + 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, + 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, + 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, + 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + } + + def __init__( + self, + *, + repository_url: Optional[str] = None, + operator_namespace: Optional[str] = "default", + operator_instance_name: Optional[str] = None, + operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_params: Optional[str] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + ssh_known_hosts_contents: Optional[str] = None, + enable_helm_operator: Optional[bool] = None, + helm_operator_properties: Optional["HelmOperatorProperties"] = None, + **kwargs + ): + super(SourceControlConfiguration, self).__init__(**kwargs) + self.system_data = None + self.repository_url = repository_url + self.operator_namespace = operator_namespace + self.operator_instance_name = operator_instance_name + self.operator_type = operator_type + self.operator_params = operator_params + self.configuration_protected_settings = configuration_protected_settings + self.operator_scope = operator_scope + self.repository_public_key = None + self.ssh_known_hosts_contents = ssh_known_hosts_contents + self.enable_helm_operator = enable_helm_operator + self.helm_operator_properties = helm_operator_properties + self.provisioning_state = None + self.compliance_status = None + + +class SourceControlConfigurationList(msrest.serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Source Control Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SourceControlConfigurationList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SupportedScopes(msrest.serialization.Model): + """Extension scopes. + + :param default_scope: Default extension scopes: cluster or namespace. + :type default_scope: str + :param cluster_scope_settings: Scope settings. + :type cluster_scope_settings: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ClusterScopeSettings + """ + + _attribute_map = { + 'default_scope': {'key': 'defaultScope', 'type': 'str'}, + 'cluster_scope_settings': {'key': 'clusterScopeSettings', 'type': 'ClusterScopeSettings'}, + } + + def __init__( + self, + *, + default_scope: Optional[str] = None, + cluster_scope_settings: Optional["ClusterScopeSettings"] = None, + **kwargs + ): + super(SupportedScopes, self).__init__(**kwargs) + self.default_scope = default_scope + self.cluster_scope_settings = cluster_scope_settings + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_source_control_configuration_client_enums.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_source_control_configuration_client_enums.py new file mode 100644 index 00000000000..1396bc813d4 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/models/_source_control_configuration_client_enums.py @@ -0,0 +1,146 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ClusterTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Cluster types + """ + + CONNECTED_CLUSTERS = "connectedClusters" + MANAGED_CLUSTERS = "managedClusters" + +class ComplianceStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The compliance state of the configuration. + """ + + PENDING = "Pending" + COMPLIANT = "Compliant" + NONCOMPLIANT = "Noncompliant" + INSTALLED = "Installed" + FAILED = "Failed" + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class Enum0(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" + MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" + +class Enum1(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + MANAGED_CLUSTERS = "managedClusters" + CONNECTED_CLUSTERS = "connectedClusters" + +class FluxComplianceState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Compliance state of the cluster object. + """ + + COMPLIANT = "Compliant" + NON_COMPLIANT = "Non-Compliant" + PENDING = "Pending" + SUSPENDED = "Suspended" + UNKNOWN = "Unknown" + +class KustomizationValidationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specify whether to validate the Kubernetes objects referenced in the Kustomization before + applying them to the cluster. + """ + + NONE = "none" + CLIENT = "client" + SERVER = "server" + +class LevelType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Level of the status. + """ + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + +class MessageLevelType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Level of the message. + """ + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + +class OperatorScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Scope at which the operator will be installed. + """ + + CLUSTER = "cluster" + NAMESPACE = "namespace" + +class OperatorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of the operator + """ + + FLUX = "Flux" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The provisioning state of the resource. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + +class ProvisioningStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The provisioning state of the resource provider. + """ + + ACCEPTED = "Accepted" + DELETING = "Deleting" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + +class ScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Scope at which the configuration will be installed. + """ + + CLUSTER = "cluster" + NAMESPACE = "namespace" + +class SourceKindType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Source Kind to pull the configuration data from. + """ + + GIT_REPOSITORY = "GitRepository" + BUCKET = "Bucket" diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/__init__.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/__init__.py new file mode 100644 index 00000000000..37008240af3 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/__init__.py @@ -0,0 +1,31 @@ +# 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 ._cluster_extension_type_operations import ClusterExtensionTypeOperations +from ._cluster_extension_types_operations import ClusterExtensionTypesOperations +from ._extension_type_versions_operations import ExtensionTypeVersionsOperations +from ._location_extension_types_operations import LocationExtensionTypesOperations +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +__all__ = [ + 'ClusterExtensionTypeOperations', + 'ClusterExtensionTypesOperations', + 'ExtensionTypeVersionsOperations', + 'LocationExtensionTypesOperations', + 'ExtensionsOperations', + 'OperationStatusOperations', + 'FluxConfigurationsOperations', + 'FluxConfigOperationStatusOperations', + 'SourceControlConfigurationsOperations', + 'Operations', +] diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_type_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_type_operations.py new file mode 100644 index 00000000000..4392300f4a6 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_type_operations.py @@ -0,0 +1,119 @@ +# 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 ClusterExtensionTypeOperations(object): + """ClusterExtensionTypeOperations 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.kubernetesconfiguration.v2022_01_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 + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_type_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ExtensionType" + """Get Extension Type details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_type_name: Extension type name. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExtensionType, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionTypeName': self._serialize.url("extension_type_name", extension_type_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExtensionType', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_types_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_types_operations.py new file mode 100644 index 00000000000..61a5f735fcc --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_cluster_extension_types_operations.py @@ -0,0 +1,132 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ClusterExtensionTypesOperations(object): + """ClusterExtensionTypesOperations 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.kubernetesconfiguration.v2022_01_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 list( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExtensionTypeList"] + """Get Extension Types. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionTypeList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extension_type_versions_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extension_type_versions_operations.py new file mode 100644 index 00000000000..c4627a848b1 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extension_type_versions_operations.py @@ -0,0 +1,122 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ExtensionTypeVersionsOperations(object): + """ExtensionTypeVersionsOperations 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.kubernetesconfiguration.v2022_01_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 list( + self, + location, # type: str + extension_type_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExtensionVersionList"] + """List available versions for an Extension Type. + + :param location: extension location. + :type location: str + :param extension_type_name: Extension type name. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionVersionList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'location': self._serialize.url("location", location, 'str'), + 'extensionTypeName': self._serialize.url("extension_type_name", extension_type_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionVersionList', pipeline_response) + list_of_elem = deserialized.versions + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extensions_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extensions_operations.py new file mode 100644 index 00000000000..03f7f0ca45d --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_extensions_operations.py @@ -0,0 +1,655 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ExtensionsOperations(object): + """ExtensionsOperations 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.kubernetesconfiguration.v2022_01_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 _create_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + extension, # type: "_models.Extension" + **kwargs # type: Any + ): + # type: (...) -> "_models.Extension" + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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(extension, 'Extension') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Extension', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def begin_create( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + extension, # type: "_models.Extension" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Extension"] + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + 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_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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('Extension', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Extension" + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + force_delete=None, # type: Optional[bool] + **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-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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') + if force_delete is not None: + query_parameters['forceDelete'] = self._serialize.query("force_delete", force_delete, 'bool') + + # 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + force_delete=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. + :type force_delete: bool + :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._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def _update_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + patch_extension, # type: "_models.PatchExtension" + **kwargs # type: Any + ): + # type: (...) -> "_models.Extension" + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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(patch_extension, 'PatchExtension') + body_content_kwargs['content'] = body_content + request = self._client.patch(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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + patch_extension, # type: "_models.PatchExtension" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Extension"] + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + 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._update_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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('Extension', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExtensionsList"] + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py new file mode 100644 index 00000000000..ccb630e51f8 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,123 @@ +# 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 FluxConfigOperationStatusOperations(object): + """FluxConfigOperationStatusOperations 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.kubernetesconfiguration.v2022_01_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 + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.OperationStatusResult" + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param operation_id: operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_name, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, '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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_configurations_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_configurations_operations.py new file mode 100644 index 00000000000..a2129c8a800 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_flux_configurations_operations.py @@ -0,0 +1,655 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class FluxConfigurationsOperations(object): + """FluxConfigurationsOperations 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.kubernetesconfiguration.v2022_01_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 + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.FluxConfiguration" + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + flux_configuration, # type: "_models.FluxConfiguration" + **kwargs # type: Any + ): + # type: (...) -> "_models.FluxConfiguration" + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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(flux_configuration, 'FluxConfiguration') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + flux_configuration, # type: "_models.FluxConfiguration" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.FluxConfiguration"] + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :type flux_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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('FluxConfiguration', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def _update_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + flux_configuration_patch, # type: "_models.FluxConfigurationPatch" + **kwargs # type: Any + ): + # type: (...) -> "_models.FluxConfiguration" + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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(flux_configuration_patch, 'FluxConfigurationPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FluxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + flux_configuration_patch, # type: "_models.FluxConfigurationPatch" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.FluxConfiguration"] + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + 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._update_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + force_delete=None, # type: Optional[bool] + **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-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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') + if force_delete is not None: + query_parameters['forceDelete'] = self._serialize.query("force_delete", force_delete, 'bool') + + # 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + flux_configuration_name, # type: str + force_delete=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. + :type force_delete: bool + :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._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'fluxConfigurationName': self._serialize.url("flux_configuration_name", flux_configuration_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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.FluxConfigurationsList"] + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfigurationsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('FluxConfigurationsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_location_extension_types_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_location_extension_types_operations.py new file mode 100644 index 00000000000..454b01b9655 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_location_extension_types_operations.py @@ -0,0 +1,118 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class LocationExtensionTypesOperations(object): + """LocationExtensionTypesOperations 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.kubernetesconfiguration.v2022_01_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 list( + self, + location, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExtensionTypeList"] + """List all Extension Types. + + :param location: extension location. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'location': self._serialize.url("location", location, '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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionTypeList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operation_status_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operation_status_operations.py new file mode 100644 index 00000000000..4f88c2781a9 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operation_status_operations.py @@ -0,0 +1,210 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationStatusOperations(object): + """OperationStatusOperations 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.kubernetesconfiguration.v2022_01_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 + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + extension_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.OperationStatusResult" + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_name: Name of the Extension. + :type extension_name: str + :param operation_id: operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, '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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationStatusList"] + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationStatusList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operations.py new file mode 100644 index 00000000000..a52ba75a330 --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_operations.py @@ -0,0 +1,110 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations 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.kubernetesconfiguration.v2022_01_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 list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ResourceProviderOperationList"] + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore diff --git a/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_source_control_configurations_operations.py b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_source_control_configurations_operations.py new file mode 100644 index 00000000000..44412282d5a --- /dev/null +++ b/src/k8s-configuration/azext_k8s_configuration/vendored_sdks/v2022_01_01_preview/operations/_source_control_configurations_operations.py @@ -0,0 +1,429 @@ +# 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.paging import ItemPaged +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, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SourceControlConfigurationsOperations(object): + """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2022_01_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 + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + source_control_configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SourceControlConfiguration" + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + source_control_configuration_name, # type: str + source_control_configuration, # type: "_models.SourceControlConfiguration" + **kwargs # type: Any + ): + # type: (...) -> "_models.SourceControlConfiguration" + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_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(source_control_configuration, 'SourceControlConfiguration') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + source_control_configuration_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-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + source_control_configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. + :type source_control_configuration_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._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, 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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + cluster_rp, # type: Union[str, "_models.Enum0"] + cluster_resource_name, # type: Union[str, "_models.Enum1"] + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.SourceControlConfigurationList"] + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfigurationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfigurationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2022-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_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') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SourceControlConfigurationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore