diff --git a/CHANGELOG.md b/CHANGELOG.md index b8891a892..1b52ca3ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,27 @@ ### Highlights +- `authorization`: [v0.2.1](services/authorization/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `certificates`: [v0.2.1](services/certificates/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `dns`: [v0.2.1](services/dns/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `iaas`: [v0.3.1](services/iaas/CHANGELOG.md#v031-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `lbapplication`: [v0.2.1](services/lbapplication/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `loadbalancer`: [v0.2.1](services/loadbalancer/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `logme`: [v0.2.1](services/logme/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `mariadb`: [v0.2.1](services/mariadb/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `mongodbflex`: [v0.2.1](services/mongodbflex/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing +- `objectstorage`: [v0.2.1](services/objectstorage/CHANGELOG.md#v021-2025-01-14) + - **Bugfix**: `configuration.py` region adjustment was missing + - `authorization`: [v0.2.0](services/authorization/CHANGELOG.md#v020-2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. - `dns`: [v0.2.0](services/dns/CHANGELOG.md#v020-2025-01-13) diff --git a/services/authorization/CHANGELOG.md b/services/authorization/CHANGELOG.md index f346570fd..96aa243b5 100644 --- a/services/authorization/CHANGELOG.md +++ b/services/authorization/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/authorization/pyproject.toml b/services/authorization/pyproject.toml index 5a57f70f6..95138287c 100644 --- a/services/authorization/pyproject.toml +++ b/services/authorization/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-authorization" [tool.poetry] name = "stackit-authorization" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/authorization/src/stackit/authorization/configuration.py b/services/authorization/src/stackit/authorization/configuration.py index ba66f84de..b3d5d7992 100644 --- a/services/authorization/src/stackit/authorization/configuration.py +++ b/services/authorization/src/stackit/authorization/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,8 +24,15 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" - self._base_path = "https://authorization.api.stackit.cloud" + 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 = "https://authorization.api.eu01.stackit.cloud" """Default Base url """ self.server_index = 0 if server_index is None else server_index @@ -47,12 +56,13 @@ def get_host_settings(self): """ return [ { - "url": "https://authorization.api.stackit.cloud", + "url": "https://authorization.api.{region}stackit.cloud", "description": "No description provided", "variables": { "region": { "description": "No description provided", - "default_value": "global", + "default_value": "eu01.", + "enum_values": ["eu01.", "eu02."], } }, } @@ -63,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -81,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/certificates/CHANGELOG.md b/services/certificates/CHANGELOG.md index 15d315f21..89687b178 100644 --- a/services/certificates/CHANGELOG.md +++ b/services/certificates/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/certificates/pyproject.toml b/services/certificates/pyproject.toml index 0627063ed..d3d657846 100644 --- a/services/certificates/pyproject.toml +++ b/services/certificates/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-certificates" [tool.poetry] name = "stackit-certificates" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/certificates/src/stackit/certificates/configuration.py b/services/certificates/src/stackit/certificates/configuration.py index 6526275b1..d41b46371 100644 --- a/services/certificates/src/stackit/certificates/configuration.py +++ b/services/certificates/src/stackit/certificates/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,7 +24,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://certificates.api.eu01.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/dns/CHANGELOG.md b/services/dns/CHANGELOG.md index c623cb549..606744e40 100644 --- a/services/dns/CHANGELOG.md +++ b/services/dns/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/dns/pyproject.toml b/services/dns/pyproject.toml index e6d97cfc1..b24424de9 100644 --- a/services/dns/pyproject.toml +++ b/services/dns/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-dns" [tool.poetry] name = "stackit-dns" -version = "v0.2.0" +version = "v0.2.1" authors = ["STACKIT Developer Tools "] description = "STACKIT DNS API" readme = "README.md" diff --git a/services/dns/src/stackit/dns/configuration.py b/services/dns/src/stackit/dns/configuration.py index 612bc2759..1698e6a5d 100644 --- a/services/dns/src/stackit/dns/configuration.py +++ b/services/dns/src/stackit/dns/configuration.py @@ -12,6 +12,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -23,7 +25,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://dns.api.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/iaas/CHANGELOG.md b/services/iaas/CHANGELOG.md index 43a4e719d..1716ad5ee 100644 --- a/services/iaas/CHANGELOG.md +++ b/services/iaas/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.3.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/iaas/pyproject.toml b/services/iaas/pyproject.toml index 694795f14..982ffcec9 100644 --- a/services/iaas/pyproject.toml +++ b/services/iaas/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-iaas" [tool.poetry] name = "stackit-iaas" -version = "v0.3.0" +version = "v0.3.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/iaas/src/stackit/iaas/configuration.py b/services/iaas/src/stackit/iaas/configuration.py index 732cb7a96..f8641da82 100644 --- a/services/iaas/src/stackit/iaas/configuration.py +++ b/services/iaas/src/stackit/iaas/configuration.py @@ -12,6 +12,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -23,7 +25,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://iaas.api.eu01.stackit.cloud" """Default Base url """ @@ -65,6 +74,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -83,8 +93,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/iaasalpha/src/stackit/iaasalpha/configuration.py b/services/iaasalpha/src/stackit/iaasalpha/configuration.py index 3cbeec2d5..d8e954551 100644 --- a/services/iaasalpha/src/stackit/iaasalpha/configuration.py +++ b/services/iaasalpha/src/stackit/iaasalpha/configuration.py @@ -12,6 +12,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -23,7 +25,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://iaas.api.eu01.stackit.cloud" """Default Base url """ @@ -65,6 +74,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -83,8 +93,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/lbapplication/CHANGELOG.md b/services/lbapplication/CHANGELOG.md index addda376d..9cd61493b 100644 --- a/services/lbapplication/CHANGELOG.md +++ b/services/lbapplication/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/lbapplication/pyproject.toml b/services/lbapplication/pyproject.toml index 7756ef17a..8768147da 100644 --- a/services/lbapplication/pyproject.toml +++ b/services/lbapplication/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-lbapplication" [tool.poetry] name = "stackit-lbapplication" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/lbapplication/src/stackit/lbapplication/configuration.py b/services/lbapplication/src/stackit/lbapplication/configuration.py index 071903fe3..c9499db02 100644 --- a/services/lbapplication/src/stackit/lbapplication/configuration.py +++ b/services/lbapplication/src/stackit/lbapplication/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,7 +24,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://lb-application.api.eu01.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/loadbalancer/CHANGELOG.md b/services/loadbalancer/CHANGELOG.md index a8a42be0b..6268763bc 100644 --- a/services/loadbalancer/CHANGELOG.md +++ b/services/loadbalancer/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/loadbalancer/pyproject.toml b/services/loadbalancer/pyproject.toml index 32c61b361..cbe5bd4bb 100644 --- a/services/loadbalancer/pyproject.toml +++ b/services/loadbalancer/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-loadbalancer" [tool.poetry] name = "stackit-loadbalancer" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/loadbalancer/src/stackit/loadbalancer/configuration.py b/services/loadbalancer/src/stackit/loadbalancer/configuration.py index 8821e5d20..50b53a76b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/configuration.py +++ b/services/loadbalancer/src/stackit/loadbalancer/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,7 +24,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://load-balancer.api.eu01.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/logme/CHANGELOG.md b/services/logme/CHANGELOG.md index d2a5e32c3..c5612bded 100644 --- a/services/logme/CHANGELOG.md +++ b/services/logme/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/logme/pyproject.toml b/services/logme/pyproject.toml index ded48f9e2..802fbb4a7 100644 --- a/services/logme/pyproject.toml +++ b/services/logme/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-logme" [tool.poetry] name = "stackit-logme" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/logme/src/stackit/logme/configuration.py b/services/logme/src/stackit/logme/configuration.py index 5aa398c13..ae5c068a5 100644 --- a/services/logme/src/stackit/logme/configuration.py +++ b/services/logme/src/stackit/logme/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,7 +24,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://logme.api.eu01.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/mariadb/CHANGELOG.md b/services/mariadb/CHANGELOG.md index f181a0df4..0e58935d3 100644 --- a/services/mariadb/CHANGELOG.md +++ b/services/mariadb/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/mariadb/pyproject.toml b/services/mariadb/pyproject.toml index 59a140489..d74eeac75 100644 --- a/services/mariadb/pyproject.toml +++ b/services/mariadb/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-mariadb" [tool.poetry] name = "stackit-mariadb" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/mariadb/src/stackit/mariadb/configuration.py b/services/mariadb/src/stackit/mariadb/configuration.py index 6150a3a66..3e6932327 100644 --- a/services/mariadb/src/stackit/mariadb/configuration.py +++ b/services/mariadb/src/stackit/mariadb/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,7 +24,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://mariadb.api.eu01.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/mongodbflex/CHANGELOG.md b/services/mongodbflex/CHANGELOG.md index 091e898a8..3b49395c0 100644 --- a/services/mongodbflex/CHANGELOG.md +++ b/services/mongodbflex/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/mongodbflex/pyproject.toml b/services/mongodbflex/pyproject.toml index 38a1230a0..09551b098 100644 --- a/services/mongodbflex/pyproject.toml +++ b/services/mongodbflex/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-mongodbflex" [tool.poetry] name = "stackit-mongodbflex" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/mongodbflex/src/stackit/mongodbflex/configuration.py b/services/mongodbflex/src/stackit/mongodbflex/configuration.py index 3369a0be4..81166599f 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/configuration.py +++ b/services/mongodbflex/src/stackit/mongodbflex/configuration.py @@ -12,6 +12,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -23,7 +25,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://mongodb-flex-service.api.eu01.stackit.cloud" """Default Base url """ @@ -65,6 +74,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -83,8 +93,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: diff --git a/services/objectstorage/CHANGELOG.md b/services/objectstorage/CHANGELOG.md index 1ae7c335b..0ba35f3ab 100644 --- a/services/objectstorage/CHANGELOG.md +++ b/services/objectstorage/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 (2025-01-14) + +- **Bugfix**: `configuration.py` region adjustment was missing + ## v0.2.0 (2025-01-13) - **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL. diff --git a/services/objectstorage/pyproject.toml b/services/objectstorage/pyproject.toml index e14a77c7c..08ce08720 100644 --- a/services/objectstorage/pyproject.toml +++ b/services/objectstorage/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-objectstorage" [tool.poetry] name = "stackit-objectstorage" -version = "v0.2.0" +version = "v0.2.1" authors = [ "STACKIT Developer Tools ", ] diff --git a/services/objectstorage/src/stackit/objectstorage/configuration.py b/services/objectstorage/src/stackit/objectstorage/configuration.py index 29a2dfb7c..b6e5322f9 100644 --- a/services/objectstorage/src/stackit/objectstorage/configuration.py +++ b/services/objectstorage/src/stackit/objectstorage/configuration.py @@ -11,6 +11,8 @@ Do not edit the class manually. """ # noqa: E501 docstring might be too long +import os + class HostConfiguration: def __init__( @@ -22,7 +24,14 @@ def __init__( server_operation_variables=None, ignore_operation_servers=False, ) -> None: - """Constructor""" + 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 = "https://object-storage.api.eu01.stackit.cloud" """Default Base url """ @@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): :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: @@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None): 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"]) if "enum_values" in variable and used_value not in variable["enum_values"]: