Skip to content

Commit e2eeafa

Browse files
Ft/region adjustment fix (#567)
* Generate objectstorage * Generate mongodbflex * Generate mariadb * Generate logme * Generate loadbalancer * Generate lbapplication * Generate iaasalpha * Generate iaas * Generate dns * Generate certificates * Generate authorization * Bugfix: Region adjustment Signed-off-by: Alexander Dahmen <[email protected]> --------- Signed-off-by: Alexander Dahmen <[email protected]> Co-authored-by: SDK Generator Bot <[email protected]>
1 parent bf079ce commit e2eeafa

File tree

32 files changed

+383
-24
lines changed

32 files changed

+383
-24
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
### Highlights
44

5+
- `authorization`: [v0.2.1](services/authorization/CHANGELOG.md#v021-2025-01-14)
6+
- **Bugfix**: `configuration.py` region adjustment was missing
7+
- `certificates`: [v0.2.1](services/certificates/CHANGELOG.md#v021-2025-01-14)
8+
- **Bugfix**: `configuration.py` region adjustment was missing
9+
- `dns`: [v0.2.1](services/dns/CHANGELOG.md#v021-2025-01-14)
10+
- **Bugfix**: `configuration.py` region adjustment was missing
11+
- `iaas`: [v0.3.1](services/iaas/CHANGELOG.md#v031-2025-01-14)
12+
- **Bugfix**: `configuration.py` region adjustment was missing
13+
- `lbapplication`: [v0.2.1](services/lbapplication/CHANGELOG.md#v021-2025-01-14)
14+
- **Bugfix**: `configuration.py` region adjustment was missing
15+
- `loadbalancer`: [v0.2.1](services/loadbalancer/CHANGELOG.md#v021-2025-01-14)
16+
- **Bugfix**: `configuration.py` region adjustment was missing
17+
- `logme`: [v0.2.1](services/logme/CHANGELOG.md#v021-2025-01-14)
18+
- **Bugfix**: `configuration.py` region adjustment was missing
19+
- `mariadb`: [v0.2.1](services/mariadb/CHANGELOG.md#v021-2025-01-14)
20+
- **Bugfix**: `configuration.py` region adjustment was missing
21+
- `mongodbflex`: [v0.2.1](services/mongodbflex/CHANGELOG.md#v021-2025-01-14)
22+
- **Bugfix**: `configuration.py` region adjustment was missing
23+
- `objectstorage`: [v0.2.1](services/objectstorage/CHANGELOG.md#v021-2025-01-14)
24+
- **Bugfix**: `configuration.py` region adjustment was missing
25+
526
- `authorization`: [v0.2.0](services/authorization/CHANGELOG.md#v020-2025-01-13)
627
- **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL.
728
- `dns`: [v0.2.0](services/dns/CHANGELOG.md#v020-2025-01-13)

services/authorization/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.2.1 (2025-01-14)
2+
3+
- **Bugfix**: `configuration.py` region adjustment was missing
4+
15
## v0.2.0 (2025-01-13)
26

37
- **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL.

services/authorization/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "stackit-authorization"
33

44
[tool.poetry]
55
name = "stackit-authorization"
6-
version = "v0.2.0"
6+
version = "v0.2.1"
77
authors = [
88
"STACKIT Developer Tools <[email protected]>",
99
]

services/authorization/src/stackit/authorization/configuration.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
Do not edit the class manually.
1212
""" # noqa: E501 docstring might be too long
1313

14+
import os
15+
1416

1517
class HostConfiguration:
1618
def __init__(
@@ -22,8 +24,15 @@ def __init__(
2224
server_operation_variables=None,
2325
ignore_operation_servers=False,
2426
) -> None:
25-
"""Constructor"""
26-
self._base_path = "https://authorization.api.stackit.cloud"
27+
print(
28+
"WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
29+
"as a function argument instead of being set in the client configuration.\n"
30+
"Once all services have migrated, the methods to specify the region in the client configuration "
31+
"will be removed.",
32+
)
33+
"""Constructor
34+
"""
35+
self._base_path = "https://authorization.api.eu01.stackit.cloud"
2736
"""Default Base url
2837
"""
2938
self.server_index = 0 if server_index is None else server_index
@@ -47,12 +56,13 @@ def get_host_settings(self):
4756
"""
4857
return [
4958
{
50-
"url": "https://authorization.api.stackit.cloud",
59+
"url": "https://authorization.api.{region}stackit.cloud",
5160
"description": "No description provided",
5261
"variables": {
5362
"region": {
5463
"description": "No description provided",
55-
"default_value": "global",
64+
"default_value": "eu01.",
65+
"enum_values": ["eu01.", "eu02."],
5666
}
5767
},
5868
}
@@ -63,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
6373
:param index: array index of the host settings
6474
:param variables: hash of variable and the corresponding value
6575
:param servers: an array of host settings or None
76+
:error: if a region is given for a global url
6677
:return: URL based on host settings
6778
"""
6879
if index is None:
@@ -81,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None):
8192

8293
url = server["url"]
8394

95+
# check if environment variable was provided for region
96+
# if nothing was set this is None
97+
region_env = os.environ.get("STACKIT_REGION")
98+
8499
# go through variables and replace placeholders
85100
for variable_name, variable in server.get("variables", {}).items():
101+
# If a region is provided by the user for a global url
102+
# return an error (except for providing via environment variable).
103+
# The region is provided as a function argument instead of being set in the client configuration.
104+
if (
105+
variable_name == "region"
106+
and (variable["default_value"] == "global" or variable["default_value"] == "")
107+
and region_env is None
108+
and variables.get(variable_name) is not None
109+
):
110+
raise ValueError(
111+
"this API does not support setting a region in the the client configuration, "
112+
"please check if the region can be specified as a function parameter"
113+
)
86114
used_value = variables.get(variable_name, variable["default_value"])
87115

88116
if "enum_values" in variable and used_value not in variable["enum_values"]:

services/certificates/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.2.1 (2025-01-14)
2+
3+
- **Bugfix**: `configuration.py` region adjustment was missing
4+
15
## v0.2.0 (2025-01-13)
26

37
- **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL.

services/certificates/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "stackit-certificates"
33

44
[tool.poetry]
55
name = "stackit-certificates"
6-
version = "v0.2.0"
6+
version = "v0.2.1"
77
authors = [
88
"STACKIT Developer Tools <[email protected]>",
99
]

services/certificates/src/stackit/certificates/configuration.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
Do not edit the class manually.
1212
""" # noqa: E501 docstring might be too long
1313

14+
import os
15+
1416

1517
class HostConfiguration:
1618
def __init__(
@@ -22,7 +24,14 @@ def __init__(
2224
server_operation_variables=None,
2325
ignore_operation_servers=False,
2426
) -> None:
25-
"""Constructor"""
27+
print(
28+
"WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
29+
"as a function argument instead of being set in the client configuration.\n"
30+
"Once all services have migrated, the methods to specify the region in the client configuration "
31+
"will be removed.",
32+
)
33+
"""Constructor
34+
"""
2635
self._base_path = "https://certificates.api.eu01.stackit.cloud"
2736
"""Default Base url
2837
"""
@@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
6473
:param index: array index of the host settings
6574
:param variables: hash of variable and the corresponding value
6675
:param servers: an array of host settings or None
76+
:error: if a region is given for a global url
6777
:return: URL based on host settings
6878
"""
6979
if index is None:
@@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None):
8292

8393
url = server["url"]
8494

95+
# check if environment variable was provided for region
96+
# if nothing was set this is None
97+
region_env = os.environ.get("STACKIT_REGION")
98+
8599
# go through variables and replace placeholders
86100
for variable_name, variable in server.get("variables", {}).items():
101+
# If a region is provided by the user for a global url
102+
# return an error (except for providing via environment variable).
103+
# The region is provided as a function argument instead of being set in the client configuration.
104+
if (
105+
variable_name == "region"
106+
and (variable["default_value"] == "global" or variable["default_value"] == "")
107+
and region_env is None
108+
and variables.get(variable_name) is not None
109+
):
110+
raise ValueError(
111+
"this API does not support setting a region in the the client configuration, "
112+
"please check if the region can be specified as a function parameter"
113+
)
87114
used_value = variables.get(variable_name, variable["default_value"])
88115

89116
if "enum_values" in variable and used_value not in variable["enum_values"]:

services/dns/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.2.1 (2025-01-14)
2+
3+
- **Bugfix**: `configuration.py` region adjustment was missing
4+
15
## v0.2.0 (2025-01-13)
26

37
- **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL.

services/dns/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "stackit-dns"
33

44
[tool.poetry]
55
name = "stackit-dns"
6-
version = "v0.2.0"
6+
version = "v0.2.1"
77
authors = ["STACKIT Developer Tools <[email protected]>"]
88
description = "STACKIT DNS API"
99
readme = "README.md"

services/dns/src/stackit/dns/configuration.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
Do not edit the class manually.
1313
""" # noqa: E501 docstring might be too long
1414

15+
import os
16+
1517

1618
class HostConfiguration:
1719
def __init__(
@@ -23,7 +25,14 @@ def __init__(
2325
server_operation_variables=None,
2426
ignore_operation_servers=False,
2527
) -> None:
26-
"""Constructor"""
28+
print(
29+
"WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
30+
"as a function argument instead of being set in the client configuration.\n"
31+
"Once all services have migrated, the methods to specify the region in the client configuration "
32+
"will be removed.",
33+
)
34+
"""Constructor
35+
"""
2736
self._base_path = "https://dns.api.stackit.cloud"
2837
"""Default Base url
2938
"""
@@ -64,6 +73,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
6473
:param index: array index of the host settings
6574
:param variables: hash of variable and the corresponding value
6675
:param servers: an array of host settings or None
76+
:error: if a region is given for a global url
6777
:return: URL based on host settings
6878
"""
6979
if index is None:
@@ -82,8 +92,25 @@ def get_host_from_settings(self, index, variables=None, servers=None):
8292

8393
url = server["url"]
8494

95+
# check if environment variable was provided for region
96+
# if nothing was set this is None
97+
region_env = os.environ.get("STACKIT_REGION")
98+
8599
# go through variables and replace placeholders
86100
for variable_name, variable in server.get("variables", {}).items():
101+
# If a region is provided by the user for a global url
102+
# return an error (except for providing via environment variable).
103+
# The region is provided as a function argument instead of being set in the client configuration.
104+
if (
105+
variable_name == "region"
106+
and (variable["default_value"] == "global" or variable["default_value"] == "")
107+
and region_env is None
108+
and variables.get(variable_name) is not None
109+
):
110+
raise ValueError(
111+
"this API does not support setting a region in the the client configuration, "
112+
"please check if the region can be specified as a function parameter"
113+
)
87114
used_value = variables.get(variable_name, variable["default_value"])
88115

89116
if "enum_values" in variable and used_value not in variable["enum_values"]:

services/iaas/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.2.1 (2025-01-14)
2+
3+
- **Bugfix**: `configuration.py` region adjustment was missing
4+
15
## v0.3.0 (2025-01-13)
26

37
- **Breaking Change:**: `get_host_from_settings` returns an error if a region is specified for a global URL.

services/iaas/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "stackit-iaas"
33

44
[tool.poetry]
55
name = "stackit-iaas"
6-
version = "v0.3.0"
6+
version = "v0.3.1"
77
authors = [
88
"STACKIT Developer Tools <[email protected]>",
99
]

services/iaas/src/stackit/iaas/configuration.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
Do not edit the class manually.
1313
""" # noqa: E501 docstring might be too long
1414

15+
import os
16+
1517

1618
class HostConfiguration:
1719
def __init__(
@@ -23,7 +25,14 @@ def __init__(
2325
server_operation_variables=None,
2426
ignore_operation_servers=False,
2527
) -> None:
26-
"""Constructor"""
28+
print(
29+
"WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
30+
"as a function argument instead of being set in the client configuration.\n"
31+
"Once all services have migrated, the methods to specify the region in the client configuration "
32+
"will be removed.",
33+
)
34+
"""Constructor
35+
"""
2736
self._base_path = "https://iaas.api.eu01.stackit.cloud"
2837
"""Default Base url
2938
"""
@@ -65,6 +74,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
6574
:param index: array index of the host settings
6675
:param variables: hash of variable and the corresponding value
6776
:param servers: an array of host settings or None
77+
:error: if a region is given for a global url
6878
:return: URL based on host settings
6979
"""
7080
if index is None:
@@ -83,8 +93,25 @@ def get_host_from_settings(self, index, variables=None, servers=None):
8393

8494
url = server["url"]
8595

96+
# check if environment variable was provided for region
97+
# if nothing was set this is None
98+
region_env = os.environ.get("STACKIT_REGION")
99+
86100
# go through variables and replace placeholders
87101
for variable_name, variable in server.get("variables", {}).items():
102+
# If a region is provided by the user for a global url
103+
# return an error (except for providing via environment variable).
104+
# The region is provided as a function argument instead of being set in the client configuration.
105+
if (
106+
variable_name == "region"
107+
and (variable["default_value"] == "global" or variable["default_value"] == "")
108+
and region_env is None
109+
and variables.get(variable_name) is not None
110+
):
111+
raise ValueError(
112+
"this API does not support setting a region in the the client configuration, "
113+
"please check if the region can be specified as a function parameter"
114+
)
88115
used_value = variables.get(variable_name, variable["default_value"])
89116

90117
if "enum_values" in variable and used_value not in variable["enum_values"]:

0 commit comments

Comments
 (0)