Skip to content

Commit f1ffd14

Browse files
authored
feat(s2s_vpn): use secret manager to store connection psk (#1337)
1 parent 7e22778 commit f1ffd14

File tree

4 files changed

+96
-52
lines changed

4 files changed

+96
-52
lines changed

scaleway-async/scaleway_async/s2s_vpn/v1alpha1/marshalling.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ def unmarshal_Connection(data: Any) -> Connection:
154154
else:
155155
args["is_ipv6"] = False
156156

157+
field = data.get("initiation_policy", None)
158+
if field is not None:
159+
args["initiation_policy"] = field
160+
else:
161+
args["initiation_policy"] = ConnectionInitiationPolicy.UNKNOWN_INITIATION_POLICY
162+
163+
field = data.get("secret_id", None)
164+
if field is not None:
165+
args["secret_id"] = field
166+
else:
167+
args["secret_id"] = None
168+
169+
field = data.get("secret_revision", None)
170+
if field is not None:
171+
args["secret_revision"] = field
172+
else:
173+
args["secret_revision"] = 0
174+
157175
field = data.get("created_at", None)
158176
if field is not None:
159177
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
@@ -166,12 +184,6 @@ def unmarshal_Connection(data: Any) -> Connection:
166184
else:
167185
args["updated_at"] = None
168186

169-
field = data.get("initiation_policy", None)
170-
if field is not None:
171-
args["initiation_policy"] = field
172-
else:
173-
args["initiation_policy"] = ConnectionInitiationPolicy.UNKNOWN_INITIATION_POLICY
174-
175187
field = data.get("ikev2_ciphers", None)
176188
if field is not None:
177189
args["ikev2_ciphers"] = (
@@ -564,18 +576,18 @@ def unmarshal_CreateConnectionResponse(data: Any) -> CreateConnectionResponse:
564576

565577
args: dict[str, Any] = {}
566578

567-
field = data.get("pre_shared_key", None)
568-
if field is not None:
569-
args["pre_shared_key"] = field
570-
else:
571-
args["pre_shared_key"] = None
572-
573579
field = data.get("connection", None)
574580
if field is not None:
575581
args["connection"] = unmarshal_Connection(field)
576582
else:
577583
args["connection"] = None
578584

585+
field = data.get("pre_shared_key", None)
586+
if field is not None:
587+
args["pre_shared_key"] = field
588+
else:
589+
args["pre_shared_key"] = None
590+
579591
return CreateConnectionResponse(**args)
580592

581593

@@ -747,18 +759,18 @@ def unmarshal_RenewConnectionPskResponse(data: Any) -> RenewConnectionPskRespons
747759

748760
args: dict[str, Any] = {}
749761

750-
field = data.get("pre_shared_key", None)
751-
if field is not None:
752-
args["pre_shared_key"] = field
753-
else:
754-
args["pre_shared_key"] = None
755-
756762
field = data.get("connection", None)
757763
if field is not None:
758764
args["connection"] = unmarshal_Connection(field)
759765
else:
760766
args["connection"] = None
761767

768+
field = data.get("pre_shared_key", None)
769+
if field is not None:
770+
args["pre_shared_key"] = field
771+
else:
772+
args["pre_shared_key"] = None
773+
762774
return RenewConnectionPskResponse(**args)
763775

764776

scaleway-async/scaleway_async/s2s_vpn/v1alpha1/types.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ class Connection:
237237
Who initiates the IPsec tunnel.
238238
"""
239239

240+
secret_id: str
241+
"""
242+
ID of the secret in Secret Manager which contains the PSK.
243+
"""
244+
245+
secret_revision: int
246+
"""
247+
Version number of the secret in Secret Manager which contains the PSK.
248+
"""
249+
240250
ikev2_ciphers: list[ConnectionCipher]
241251
"""
242252
List of IKE v2 ciphers proposed for the IPsec tunnel.
@@ -593,14 +603,14 @@ class CreateConnectionRequest:
593603

594604
@dataclass
595605
class CreateConnectionResponse:
596-
pre_shared_key: str
606+
connection: Optional[Connection] = None
597607
"""
598-
New PSK generated for this connection.
608+
This connection.
599609
"""
600610

601-
connection: Optional[Connection] = None
611+
pre_shared_key: Optional[str] = None
602612
"""
603-
This connection.
613+
Deprecated, use secret_id & secret_revision fields.
604614
"""
605615

606616

@@ -1178,14 +1188,14 @@ class RenewConnectionPskRequest:
11781188

11791189
@dataclass
11801190
class RenewConnectionPskResponse:
1181-
pre_shared_key: str
1191+
connection: Optional[Connection] = None
11821192
"""
1183-
New PSK generated for this connection.
1193+
This connection.
11841194
"""
11851195

1186-
connection: Optional[Connection] = None
1196+
pre_shared_key: Optional[str] = None
11871197
"""
1188-
This connection.
1198+
Deprecated, use secret_id & secret_revision fields.
11891199
"""
11901200

11911201

scaleway/scaleway/s2s_vpn/v1alpha1/marshalling.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ def unmarshal_Connection(data: Any) -> Connection:
154154
else:
155155
args["is_ipv6"] = False
156156

157+
field = data.get("initiation_policy", None)
158+
if field is not None:
159+
args["initiation_policy"] = field
160+
else:
161+
args["initiation_policy"] = ConnectionInitiationPolicy.UNKNOWN_INITIATION_POLICY
162+
163+
field = data.get("secret_id", None)
164+
if field is not None:
165+
args["secret_id"] = field
166+
else:
167+
args["secret_id"] = None
168+
169+
field = data.get("secret_revision", None)
170+
if field is not None:
171+
args["secret_revision"] = field
172+
else:
173+
args["secret_revision"] = 0
174+
157175
field = data.get("created_at", None)
158176
if field is not None:
159177
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
@@ -166,12 +184,6 @@ def unmarshal_Connection(data: Any) -> Connection:
166184
else:
167185
args["updated_at"] = None
168186

169-
field = data.get("initiation_policy", None)
170-
if field is not None:
171-
args["initiation_policy"] = field
172-
else:
173-
args["initiation_policy"] = ConnectionInitiationPolicy.UNKNOWN_INITIATION_POLICY
174-
175187
field = data.get("ikev2_ciphers", None)
176188
if field is not None:
177189
args["ikev2_ciphers"] = (
@@ -564,18 +576,18 @@ def unmarshal_CreateConnectionResponse(data: Any) -> CreateConnectionResponse:
564576

565577
args: dict[str, Any] = {}
566578

567-
field = data.get("pre_shared_key", None)
568-
if field is not None:
569-
args["pre_shared_key"] = field
570-
else:
571-
args["pre_shared_key"] = None
572-
573579
field = data.get("connection", None)
574580
if field is not None:
575581
args["connection"] = unmarshal_Connection(field)
576582
else:
577583
args["connection"] = None
578584

585+
field = data.get("pre_shared_key", None)
586+
if field is not None:
587+
args["pre_shared_key"] = field
588+
else:
589+
args["pre_shared_key"] = None
590+
579591
return CreateConnectionResponse(**args)
580592

581593

@@ -747,18 +759,18 @@ def unmarshal_RenewConnectionPskResponse(data: Any) -> RenewConnectionPskRespons
747759

748760
args: dict[str, Any] = {}
749761

750-
field = data.get("pre_shared_key", None)
751-
if field is not None:
752-
args["pre_shared_key"] = field
753-
else:
754-
args["pre_shared_key"] = None
755-
756762
field = data.get("connection", None)
757763
if field is not None:
758764
args["connection"] = unmarshal_Connection(field)
759765
else:
760766
args["connection"] = None
761767

768+
field = data.get("pre_shared_key", None)
769+
if field is not None:
770+
args["pre_shared_key"] = field
771+
else:
772+
args["pre_shared_key"] = None
773+
762774
return RenewConnectionPskResponse(**args)
763775

764776

scaleway/scaleway/s2s_vpn/v1alpha1/types.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ class Connection:
237237
Who initiates the IPsec tunnel.
238238
"""
239239

240+
secret_id: str
241+
"""
242+
ID of the secret in Secret Manager which contains the PSK.
243+
"""
244+
245+
secret_revision: int
246+
"""
247+
Version number of the secret in Secret Manager which contains the PSK.
248+
"""
249+
240250
ikev2_ciphers: list[ConnectionCipher]
241251
"""
242252
List of IKE v2 ciphers proposed for the IPsec tunnel.
@@ -593,14 +603,14 @@ class CreateConnectionRequest:
593603

594604
@dataclass
595605
class CreateConnectionResponse:
596-
pre_shared_key: str
606+
connection: Optional[Connection] = None
597607
"""
598-
New PSK generated for this connection.
608+
This connection.
599609
"""
600610

601-
connection: Optional[Connection] = None
611+
pre_shared_key: Optional[str] = None
602612
"""
603-
This connection.
613+
Deprecated, use secret_id & secret_revision fields.
604614
"""
605615

606616

@@ -1178,14 +1188,14 @@ class RenewConnectionPskRequest:
11781188

11791189
@dataclass
11801190
class RenewConnectionPskResponse:
1181-
pre_shared_key: str
1191+
connection: Optional[Connection] = None
11821192
"""
1183-
New PSK generated for this connection.
1193+
This connection.
11841194
"""
11851195

1186-
connection: Optional[Connection] = None
1196+
pre_shared_key: Optional[str] = None
11871197
"""
1188-
This connection.
1198+
Deprecated, use secret_id & secret_revision fields.
11891199
"""
11901200

11911201

0 commit comments

Comments
 (0)