stackit-vpn 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. src/stackit/vpn/__init__.py +145 -0
  2. src/stackit/vpn/api/__init__.py +4 -0
  3. src/stackit/vpn/api/default_api.py +3947 -0
  4. src/stackit/vpn/api_client.py +652 -0
  5. src/stackit/vpn/api_response.py +23 -0
  6. src/stackit/vpn/configuration.py +164 -0
  7. src/stackit/vpn/exceptions.py +217 -0
  8. src/stackit/vpn/models/__init__.py +58 -0
  9. src/stackit/vpn/models/api_error.py +104 -0
  10. src/stackit/vpn/models/api_error_detail.py +99 -0
  11. src/stackit/vpn/models/api_error_response.py +86 -0
  12. src/stackit/vpn/models/bgp_gateway_config.py +94 -0
  13. src/stackit/vpn/models/bgp_status.py +112 -0
  14. src/stackit/vpn/models/bgp_status_peers.py +97 -0
  15. src/stackit/vpn/models/bgp_status_routes.py +93 -0
  16. src/stackit/vpn/models/bgp_tunnel_config.py +84 -0
  17. src/stackit/vpn/models/connection_list.py +98 -0
  18. src/stackit/vpn/models/connection_response.py +149 -0
  19. src/stackit/vpn/models/connection_status_response.py +113 -0
  20. src/stackit/vpn/models/create_gateway_connection_payload.py +139 -0
  21. src/stackit/vpn/models/create_vpn_gateway_payload.py +124 -0
  22. src/stackit/vpn/models/create_vpn_gateway_payload_availability_zones.py +82 -0
  23. src/stackit/vpn/models/gateway.py +124 -0
  24. src/stackit/vpn/models/gateway_list.py +98 -0
  25. src/stackit/vpn/models/gateway_response.py +144 -0
  26. src/stackit/vpn/models/gateway_status.py +38 -0
  27. src/stackit/vpn/models/gateway_status_response.py +122 -0
  28. src/stackit/vpn/models/peering_config.py +103 -0
  29. src/stackit/vpn/models/phase.py +122 -0
  30. src/stackit/vpn/models/phase1_status.py +99 -0
  31. src/stackit/vpn/models/phase2_status.py +143 -0
  32. src/stackit/vpn/models/plan.py +101 -0
  33. src/stackit/vpn/models/plan_list.py +98 -0
  34. src/stackit/vpn/models/quota.py +82 -0
  35. src/stackit/vpn/models/quota_list.py +88 -0
  36. src/stackit/vpn/models/quota_list_response.py +88 -0
  37. src/stackit/vpn/models/region.py +36 -0
  38. src/stackit/vpn/models/routing_type.py +37 -0
  39. src/stackit/vpn/models/tunnel_configuration.py +124 -0
  40. src/stackit/vpn/models/tunnel_configuration_phase1.py +126 -0
  41. src/stackit/vpn/models/tunnel_configuration_phase2.py +165 -0
  42. src/stackit/vpn/models/tunnel_status.py +110 -0
  43. src/stackit/vpn/models/update_gateway_connection_payload.py +139 -0
  44. src/stackit/vpn/models/update_vpn_gateway_payload.py +124 -0
  45. src/stackit/vpn/models/vpn_tunnels.py +114 -0
  46. src/stackit/vpn/py.typed +0 -0
  47. src/stackit/vpn/rest.py +164 -0
  48. stackit_vpn-0.1.0.dist-info/METADATA +53 -0
  49. stackit_vpn-0.1.0.dist-info/RECORD +52 -0
  50. stackit_vpn-0.1.0.dist-info/WHEEL +4 -0
  51. stackit_vpn-0.1.0.dist-info/licenses/LICENSE.md +201 -0
  52. stackit_vpn-0.1.0.dist-info/licenses/NOTICE.txt +2 -0
@@ -0,0 +1,110 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT VPN API
5
+
6
+ Provision and manage STACKIT VPN gateways. Use this API to establish secure, encrypted IPsec tunnels between your STACKIT Network Area (SNA) and external networks. The service supports the following routing architectures: - Policy-based IPsec - Static route-based IPsec - Dynamic BGP IPsec
7
+
8
+ The version of the OpenAPI document: 1beta1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator
21
+ from typing_extensions import Self
22
+
23
+ from stackit.vpn.models.phase1_status import Phase1Status
24
+ from stackit.vpn.models.phase2_status import Phase2Status
25
+
26
+
27
+ class TunnelStatus(BaseModel):
28
+ """
29
+ Describes the status of the VPN itself.
30
+ """ # noqa: E501
31
+
32
+ established: Optional[StrictBool] = None
33
+ name: Optional[StrictStr] = None
34
+ phase1: Optional[Phase1Status] = None
35
+ phase2: Optional[Phase2Status] = None
36
+ __properties: ClassVar[List[str]] = ["established", "name", "phase1", "phase2"]
37
+
38
+ @field_validator("name")
39
+ def name_validate_enum(cls, value):
40
+ """Validates the enum"""
41
+ if value is None:
42
+ return value
43
+
44
+ if value not in set(["tunnel1", "tunnel2"]):
45
+ raise ValueError("must be one of enum values ('tunnel1', 'tunnel2')")
46
+ return value
47
+
48
+ model_config = ConfigDict(
49
+ populate_by_name=True,
50
+ validate_assignment=True,
51
+ protected_namespaces=(),
52
+ )
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61
+ return json.dumps(self.to_dict())
62
+
63
+ @classmethod
64
+ def from_json(cls, json_str: str) -> Optional[Self]:
65
+ """Create an instance of TunnelStatus from a JSON string"""
66
+ return cls.from_dict(json.loads(json_str))
67
+
68
+ def to_dict(self) -> Dict[str, Any]:
69
+ """Return the dictionary representation of the model using alias.
70
+
71
+ This has the following differences from calling pydantic's
72
+ `self.model_dump(by_alias=True)`:
73
+
74
+ * `None` is only added to the output dict for nullable fields that
75
+ were set at model initialization. Other fields with value `None`
76
+ are ignored.
77
+ """
78
+ excluded_fields: Set[str] = set([])
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ # override the default output from pydantic by calling `to_dict()` of phase1
86
+ if self.phase1:
87
+ _dict["phase1"] = self.phase1.to_dict()
88
+ # override the default output from pydantic by calling `to_dict()` of phase2
89
+ if self.phase2:
90
+ _dict["phase2"] = self.phase2.to_dict()
91
+ return _dict
92
+
93
+ @classmethod
94
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
95
+ """Create an instance of TunnelStatus from a dict"""
96
+ if obj is None:
97
+ return None
98
+
99
+ if not isinstance(obj, dict):
100
+ return cls.model_validate(obj)
101
+
102
+ _obj = cls.model_validate(
103
+ {
104
+ "established": obj.get("established"),
105
+ "name": obj.get("name"),
106
+ "phase1": Phase1Status.from_dict(obj["phase1"]) if obj.get("phase1") is not None else None,
107
+ "phase2": Phase2Status.from_dict(obj["phase2"]) if obj.get("phase2") is not None else None,
108
+ }
109
+ )
110
+ return _obj
@@ -0,0 +1,139 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT VPN API
5
+
6
+ Provision and manage STACKIT VPN gateways. Use this API to establish secure, encrypted IPsec tunnels between your STACKIT Network Area (SNA) and external networks. The service supports the following routing architectures: - Policy-based IPsec - Static route-based IPsec - Dynamic BGP IPsec
7
+
8
+ The version of the OpenAPI document: 1beta1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re # noqa: F401
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+ from stackit.vpn.models.tunnel_configuration import TunnelConfiguration
25
+
26
+
27
+ class UpdateGatewayConnectionPayload(BaseModel):
28
+ """
29
+ UpdateGatewayConnectionPayload
30
+ """ # noqa: E501
31
+
32
+ display_name: Annotated[str, Field(strict=True)] = Field(
33
+ description="A user-friendly name for the connection.", alias="displayName"
34
+ )
35
+ enabled: Optional[StrictBool] = Field(
36
+ default=None, description="This flag decides whether this connection should be enabled or disabled"
37
+ )
38
+ local_subnets: Optional[
39
+ Annotated[List[Annotated[str, Field(strict=True)]], Field(min_length=1, max_length=100)]
40
+ ] = Field(
41
+ default=None,
42
+ description="Optional. Defaults to 0.0.0.0/0 for Route-based VPN configurations. Mandatory for Policy-based.",
43
+ alias="localSubnets",
44
+ )
45
+ remote_subnets: Optional[
46
+ Annotated[List[Annotated[str, Field(strict=True)]], Field(min_length=1, max_length=100)]
47
+ ] = Field(
48
+ default=None,
49
+ description="Optional. Defaults to 0.0.0.0/0 for Route-based VPN configurations. Mandatory for Policy-based.",
50
+ alias="remoteSubnets",
51
+ )
52
+ static_routes: Optional[List[Annotated[str, Field(strict=True)]]] = Field(
53
+ default=None, description="Optional. Use this for route-based VPN.", alias="staticRoutes"
54
+ )
55
+ tunnel1: TunnelConfiguration
56
+ tunnel2: TunnelConfiguration
57
+ __properties: ClassVar[List[str]] = [
58
+ "displayName",
59
+ "enabled",
60
+ "localSubnets",
61
+ "remoteSubnets",
62
+ "staticRoutes",
63
+ "tunnel1",
64
+ "tunnel2",
65
+ ]
66
+
67
+ @field_validator("display_name")
68
+ def display_name_validate_regular_expression(cls, value):
69
+ """Validates the regular expression"""
70
+ if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value):
71
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/")
72
+ return value
73
+
74
+ model_config = ConfigDict(
75
+ populate_by_name=True,
76
+ validate_assignment=True,
77
+ protected_namespaces=(),
78
+ )
79
+
80
+ def to_str(self) -> str:
81
+ """Returns the string representation of the model using alias"""
82
+ return pprint.pformat(self.model_dump(by_alias=True))
83
+
84
+ def to_json(self) -> str:
85
+ """Returns the JSON representation of the model using alias"""
86
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
87
+ return json.dumps(self.to_dict())
88
+
89
+ @classmethod
90
+ def from_json(cls, json_str: str) -> Optional[Self]:
91
+ """Create an instance of UpdateGatewayConnectionPayload from a JSON string"""
92
+ return cls.from_dict(json.loads(json_str))
93
+
94
+ def to_dict(self) -> Dict[str, Any]:
95
+ """Return the dictionary representation of the model using alias.
96
+
97
+ This has the following differences from calling pydantic's
98
+ `self.model_dump(by_alias=True)`:
99
+
100
+ * `None` is only added to the output dict for nullable fields that
101
+ were set at model initialization. Other fields with value `None`
102
+ are ignored.
103
+ """
104
+ excluded_fields: Set[str] = set([])
105
+
106
+ _dict = self.model_dump(
107
+ by_alias=True,
108
+ exclude=excluded_fields,
109
+ exclude_none=True,
110
+ )
111
+ # override the default output from pydantic by calling `to_dict()` of tunnel1
112
+ if self.tunnel1:
113
+ _dict["tunnel1"] = self.tunnel1.to_dict()
114
+ # override the default output from pydantic by calling `to_dict()` of tunnel2
115
+ if self.tunnel2:
116
+ _dict["tunnel2"] = self.tunnel2.to_dict()
117
+ return _dict
118
+
119
+ @classmethod
120
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
121
+ """Create an instance of UpdateGatewayConnectionPayload from a dict"""
122
+ if obj is None:
123
+ return None
124
+
125
+ if not isinstance(obj, dict):
126
+ return cls.model_validate(obj)
127
+
128
+ _obj = cls.model_validate(
129
+ {
130
+ "displayName": obj.get("displayName"),
131
+ "enabled": obj.get("enabled"),
132
+ "localSubnets": obj.get("localSubnets"),
133
+ "remoteSubnets": obj.get("remoteSubnets"),
134
+ "staticRoutes": obj.get("staticRoutes"),
135
+ "tunnel1": TunnelConfiguration.from_dict(obj["tunnel1"]) if obj.get("tunnel1") is not None else None,
136
+ "tunnel2": TunnelConfiguration.from_dict(obj["tunnel2"]) if obj.get("tunnel2") is not None else None,
137
+ }
138
+ )
139
+ return _obj
@@ -0,0 +1,124 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT VPN API
5
+
6
+ Provision and manage STACKIT VPN gateways. Use this API to establish secure, encrypted IPsec tunnels between your STACKIT Network Area (SNA) and external networks. The service supports the following routing architectures: - Policy-based IPsec - Static route-based IPsec - Dynamic BGP IPsec
7
+
8
+ The version of the OpenAPI document: 1beta1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re # noqa: F401
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+ from stackit.vpn.models.bgp_gateway_config import BGPGatewayConfig
25
+ from stackit.vpn.models.create_vpn_gateway_payload_availability_zones import (
26
+ CreateVPNGatewayPayloadAvailabilityZones,
27
+ )
28
+ from stackit.vpn.models.routing_type import RoutingType
29
+
30
+
31
+ class UpdateVPNGatewayPayload(BaseModel):
32
+ """
33
+ UpdateVPNGatewayPayload
34
+ """ # noqa: E501
35
+
36
+ availability_zones: CreateVPNGatewayPayloadAvailabilityZones = Field(alias="availabilityZones")
37
+ bgp: Optional[BGPGatewayConfig] = None
38
+ display_name: Annotated[str, Field(strict=True)] = Field(
39
+ description="A user-friendly name for the VPN gateway.", alias="displayName"
40
+ )
41
+ labels: Optional[Dict[str, Annotated[str, Field(strict=True, max_length=63)]]] = Field(
42
+ default=None,
43
+ description="Map of custom labels. Key and values must be a string with max 63 chars, start/end with alphanumeric. The key of a label follows the same rules as the `LabelValue` except that it cannot be empty. ",
44
+ )
45
+ plan_id: StrictStr = Field(description="The service plan identifier.", alias="planId")
46
+ routing_type: RoutingType = Field(alias="routingType")
47
+ __properties: ClassVar[List[str]] = ["availabilityZones", "bgp", "displayName", "labels", "planId", "routingType"]
48
+
49
+ @field_validator("display_name")
50
+ def display_name_validate_regular_expression(cls, value):
51
+ """Validates the regular expression"""
52
+ if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value):
53
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/")
54
+ return value
55
+
56
+ model_config = ConfigDict(
57
+ populate_by_name=True,
58
+ validate_assignment=True,
59
+ protected_namespaces=(),
60
+ )
61
+
62
+ def to_str(self) -> str:
63
+ """Returns the string representation of the model using alias"""
64
+ return pprint.pformat(self.model_dump(by_alias=True))
65
+
66
+ def to_json(self) -> str:
67
+ """Returns the JSON representation of the model using alias"""
68
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
69
+ return json.dumps(self.to_dict())
70
+
71
+ @classmethod
72
+ def from_json(cls, json_str: str) -> Optional[Self]:
73
+ """Create an instance of UpdateVPNGatewayPayload from a JSON string"""
74
+ return cls.from_dict(json.loads(json_str))
75
+
76
+ def to_dict(self) -> Dict[str, Any]:
77
+ """Return the dictionary representation of the model using alias.
78
+
79
+ This has the following differences from calling pydantic's
80
+ `self.model_dump(by_alias=True)`:
81
+
82
+ * `None` is only added to the output dict for nullable fields that
83
+ were set at model initialization. Other fields with value `None`
84
+ are ignored.
85
+ """
86
+ excluded_fields: Set[str] = set([])
87
+
88
+ _dict = self.model_dump(
89
+ by_alias=True,
90
+ exclude=excluded_fields,
91
+ exclude_none=True,
92
+ )
93
+ # override the default output from pydantic by calling `to_dict()` of availability_zones
94
+ if self.availability_zones:
95
+ _dict["availabilityZones"] = self.availability_zones.to_dict()
96
+ # override the default output from pydantic by calling `to_dict()` of bgp
97
+ if self.bgp:
98
+ _dict["bgp"] = self.bgp.to_dict()
99
+ return _dict
100
+
101
+ @classmethod
102
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
103
+ """Create an instance of UpdateVPNGatewayPayload from a dict"""
104
+ if obj is None:
105
+ return None
106
+
107
+ if not isinstance(obj, dict):
108
+ return cls.model_validate(obj)
109
+
110
+ _obj = cls.model_validate(
111
+ {
112
+ "availabilityZones": (
113
+ CreateVPNGatewayPayloadAvailabilityZones.from_dict(obj["availabilityZones"])
114
+ if obj.get("availabilityZones") is not None
115
+ else None
116
+ ),
117
+ "bgp": BGPGatewayConfig.from_dict(obj["bgp"]) if obj.get("bgp") is not None else None,
118
+ "displayName": obj.get("displayName"),
119
+ "labels": obj.get("labels"),
120
+ "planId": obj.get("planId"),
121
+ "routingType": obj.get("routingType"),
122
+ }
123
+ )
124
+ return _obj
@@ -0,0 +1,114 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT VPN API
5
+
6
+ Provision and manage STACKIT VPN gateways. Use this API to establish secure, encrypted IPsec tunnels between your STACKIT Network Area (SNA) and external networks. The service supports the following routing architectures: - Policy-based IPsec - Static route-based IPsec - Dynamic BGP IPsec
7
+
8
+ The version of the OpenAPI document: 1beta1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
+ from typing_extensions import Self
22
+
23
+ from stackit.vpn.models.bgp_status import BGPStatus
24
+ from stackit.vpn.models.gateway_status import GatewayStatus
25
+
26
+
27
+ class VPNTunnels(BaseModel):
28
+ """
29
+ Status of the underlying tunnel instances.
30
+ """ # noqa: E501
31
+
32
+ bgp_status: Optional[BGPStatus] = Field(default=None, alias="bgpStatus")
33
+ instance_state: Optional[GatewayStatus] = Field(default=None, alias="instanceState")
34
+ name: Optional[StrictStr] = None
35
+ public_ip: Optional[StrictStr] = Field(
36
+ default=None, description="The public IPv4 address of this endpoint.", alias="publicIP"
37
+ )
38
+ __properties: ClassVar[List[str]] = ["bgpStatus", "instanceState", "name", "publicIP"]
39
+
40
+ @field_validator("name")
41
+ def name_validate_enum(cls, value):
42
+ """Validates the enum"""
43
+ if value is None:
44
+ return value
45
+
46
+ if value not in set(["tunnel1", "tunnel2"]):
47
+ raise ValueError("must be one of enum values ('tunnel1', 'tunnel2')")
48
+ return value
49
+
50
+ model_config = ConfigDict(
51
+ populate_by_name=True,
52
+ validate_assignment=True,
53
+ protected_namespaces=(),
54
+ )
55
+
56
+ def to_str(self) -> str:
57
+ """Returns the string representation of the model using alias"""
58
+ return pprint.pformat(self.model_dump(by_alias=True))
59
+
60
+ def to_json(self) -> str:
61
+ """Returns the JSON representation of the model using alias"""
62
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
63
+ return json.dumps(self.to_dict())
64
+
65
+ @classmethod
66
+ def from_json(cls, json_str: str) -> Optional[Self]:
67
+ """Create an instance of VPNTunnels from a JSON string"""
68
+ return cls.from_dict(json.loads(json_str))
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ """Return the dictionary representation of the model using alias.
72
+
73
+ This has the following differences from calling pydantic's
74
+ `self.model_dump(by_alias=True)`:
75
+
76
+ * `None` is only added to the output dict for nullable fields that
77
+ were set at model initialization. Other fields with value `None`
78
+ are ignored.
79
+ """
80
+ excluded_fields: Set[str] = set([])
81
+
82
+ _dict = self.model_dump(
83
+ by_alias=True,
84
+ exclude=excluded_fields,
85
+ exclude_none=True,
86
+ )
87
+ # override the default output from pydantic by calling `to_dict()` of bgp_status
88
+ if self.bgp_status:
89
+ _dict["bgpStatus"] = self.bgp_status.to_dict()
90
+ # set to None if bgp_status (nullable) is None
91
+ # and model_fields_set contains the field
92
+ if self.bgp_status is None and "bgp_status" in self.model_fields_set:
93
+ _dict["bgpStatus"] = None
94
+
95
+ return _dict
96
+
97
+ @classmethod
98
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
99
+ """Create an instance of VPNTunnels from a dict"""
100
+ if obj is None:
101
+ return None
102
+
103
+ if not isinstance(obj, dict):
104
+ return cls.model_validate(obj)
105
+
106
+ _obj = cls.model_validate(
107
+ {
108
+ "bgpStatus": BGPStatus.from_dict(obj["bgpStatus"]) if obj.get("bgpStatus") is not None else None,
109
+ "instanceState": obj.get("instanceState"),
110
+ "name": obj.get("name"),
111
+ "publicIP": obj.get("publicIP"),
112
+ }
113
+ )
114
+ return _obj
File without changes
@@ -0,0 +1,164 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT VPN API
5
+
6
+ Provision and manage STACKIT VPN gateways. Use this API to establish secure, encrypted IPsec tunnels between your STACKIT Network Area (SNA) and external networks. The service supports the following routing architectures: - Policy-based IPsec - Static route-based IPsec - Dynamic BGP IPsec
7
+
8
+ The version of the OpenAPI document: 1beta1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ import io
15
+ import json
16
+ import re
17
+
18
+ import requests
19
+ from stackit.core.authorization import Authorization
20
+ from stackit.core.configuration import Configuration
21
+
22
+ from stackit.vpn.exceptions import ApiException, ApiValueError
23
+
24
+
25
+ RESTResponseType = requests.Response
26
+
27
+
28
+ class RESTResponse(io.IOBase):
29
+
30
+ def __init__(self, resp) -> None:
31
+ self.response = resp
32
+ self.status = resp.status_code
33
+ self.reason = resp.reason
34
+ self.data = None
35
+
36
+ def read(self):
37
+ if self.data is None:
38
+ self.data = self.response.content
39
+ return self.data
40
+
41
+ @property
42
+ def headers(self):
43
+ """Returns a dictionary of response headers."""
44
+ return self.response.headers
45
+
46
+ def getheaders(self):
47
+ """Returns a dictionary of the response headers; use ``headers`` instead."""
48
+ return self.response.headers
49
+
50
+ def getheader(self, name, default=None):
51
+ """Returns a given response header; use ``headers.get()`` instead."""
52
+ return self.response.headers.get(name, default)
53
+
54
+
55
+ class RESTClientObject:
56
+ def __init__(self, config: Configuration) -> None:
57
+ self.session = config.custom_http_session if config.custom_http_session else requests.Session()
58
+ authorization = Authorization(config)
59
+ self.session.auth = authorization.auth_method
60
+
61
+ def request(self, method, url, headers=None, body=None, post_params=None, _request_timeout=None):
62
+ """Perform requests.
63
+
64
+ :param method: http request method
65
+ :param url: http request url
66
+ :param headers: http request headers
67
+ :param body: request json body, for `application/json`
68
+ :param post_params: request post parameters,
69
+ `application/x-www-form-urlencoded`
70
+ and `multipart/form-data`
71
+ :param _request_timeout: timeout setting for this request. If one
72
+ number provided, it will be total request
73
+ timeout. It can also be a pair (tuple) of
74
+ (connection, read) timeouts.
75
+ """
76
+ method = method.upper()
77
+ if method not in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]:
78
+ raise ValueError("Method %s not allowed", method)
79
+
80
+ if post_params and body:
81
+ raise ApiValueError("body parameter cannot be used with post_params parameter.")
82
+
83
+ post_params = post_params or {}
84
+ headers = headers or {}
85
+
86
+ try:
87
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
88
+ if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]:
89
+
90
+ # no content type provided or payload is json
91
+ content_type = headers.get("Content-Type")
92
+ if not content_type or re.search("json", content_type, re.IGNORECASE):
93
+ request_body = None
94
+ if body is not None:
95
+ request_body = json.dumps(body)
96
+ r = self.session.request(
97
+ method,
98
+ url,
99
+ data=request_body,
100
+ headers=headers,
101
+ timeout=_request_timeout,
102
+ )
103
+ elif content_type == "application/x-www-form-urlencoded":
104
+ r = self.session.request(
105
+ method,
106
+ url,
107
+ params=post_params,
108
+ headers=headers,
109
+ timeout=_request_timeout,
110
+ )
111
+ elif content_type == "multipart/form-data":
112
+ # must del headers['Content-Type'], or the correct
113
+ # Content-Type which generated by urllib3 will be
114
+ # overwritten.
115
+ del headers["Content-Type"]
116
+ # Ensures that dict objects are serialized
117
+ post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a, b) for a, b in post_params]
118
+ r = self.session.request(
119
+ method,
120
+ url,
121
+ files=post_params,
122
+ headers=headers,
123
+ timeout=_request_timeout,
124
+ )
125
+ # Pass a `string` parameter directly in the body to support
126
+ # other content types than JSON when `body` argument is
127
+ # provided in serialized form.
128
+ elif isinstance(body, str) or isinstance(body, bytes):
129
+ r = self.session.request(
130
+ method,
131
+ url,
132
+ data=body,
133
+ headers=headers,
134
+ timeout=_request_timeout,
135
+ )
136
+ elif headers["Content-Type"].startswith("text/") and isinstance(body, bool):
137
+ request_body = "true" if body else "false"
138
+ r = self.session.request(
139
+ method,
140
+ url,
141
+ data=request_body,
142
+ headers=headers,
143
+ timeout=_request_timeout,
144
+ )
145
+ else:
146
+ # Cannot generate the request from given parameters
147
+ msg = """Cannot prepare a request message for provided
148
+ arguments. Please check that your arguments match
149
+ declared content type."""
150
+ raise ApiException(status=0, reason=msg)
151
+ # For `GET`, `HEAD`
152
+ else:
153
+ r = self.session.request(
154
+ method,
155
+ url,
156
+ params={},
157
+ headers=headers,
158
+ timeout=_request_timeout,
159
+ )
160
+ except requests.exceptions.SSLError as e:
161
+ msg = "\n".join([type(e).__name__, str(e)])
162
+ raise ApiException(status=0, reason=msg)
163
+
164
+ return RESTResponse(r)