From 07ae963f147e8b70b7c3e72257b294fad5979d71 Mon Sep 17 00:00:00 2001 From: Alexander Dahmen Date: Wed, 8 Jan 2025 08:23:09 +0100 Subject: [PATCH 1/2] Region adjustment STACKIT will move to a new way of specifying regions, where the region is provided as a function argument instead of being set in the client configuration. Once all services have migrated, the methods to specify the region in the client configuration will be removed. Signed-off-by: Alexander Dahmen --- templates/python/configuration.mustache | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/templates/python/configuration.mustache b/templates/python/configuration.mustache index a5d8c63..3fc1ab8 100644 --- a/templates/python/configuration.mustache +++ b/templates/python/configuration.mustache @@ -8,6 +8,10 @@ class HostConfiguration: server_operation_index=None, server_operation_variables=None, ignore_operation_servers=False, ) -> None: + print("WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n", + "as a function argument instead of being set in the client configuration.\n" + "Once all services have migrated, the methods to specify the region in the client configuration " + "will be removed.") """Constructor """ self._base_path = "{{{basePath}}}" @@ -67,6 +71,7 @@ class HostConfiguration: :param index: array index of the host settings :param variables: hash of variable and the corresponding value :param servers: an array of host settings or None + :error: if a region is given for a global url :return: URL based on host settings """ if index is None: @@ -84,8 +89,23 @@ class HostConfiguration: url = server['url'] + # check if environment variable was provided for region + # if nothing was set this is None + region_env = os.environ.get("STACKIT_REGION") + # go through variables and replace placeholders for variable_name, variable in server.get('variables', {}).items(): + # If a region is provided by the user for a global url + # return an error (except for providing via environment variable). + # The region is provided as a function argument instead of being set in the client configuration. + if variable_name == 'region' and \ + (variable['default_value'] == 'global' or variable['default_value'] == '') and \ + region_env is None and \ + variables.get(variable_name) is not None: + raise ValueError( + "this API does not support setting a region in the the client configuration, " + "please check if the region can be specified as a function parameter" + ) used_value = variables.get( variable_name, variable['default_value']) From 5c228e90f6e63383fa2433db5fd7260a14b62d53 Mon Sep 17 00:00:00 2001 From: Alexander Dahmen Date: Thu, 9 Jan 2025 12:25:46 +0100 Subject: [PATCH 2/2] Add project name to pyproject.toml mustache file Fix for new poetry version Signed-off-by: Alexander Dahmen --- templates/python/pyproject.mustache | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/python/pyproject.mustache b/templates/python/pyproject.mustache index aa150cb..589a361 100644 --- a/templates/python/pyproject.mustache +++ b/templates/python/pyproject.mustache @@ -1,3 +1,6 @@ +[project] +name = "{{{pythonPackageName}}}" + [tool.poetry] name = "{{{pythonPackageName}}}" version = "v0.0.1a"