diff --git a/scaleway-async/scaleway_async/vpcgw/v2/__init__.py b/scaleway-async/scaleway_async/vpcgw/v2/__init__.py index 7c1cd4fe3..8856eb505 100644 --- a/scaleway-async/scaleway_async/vpcgw/v2/__init__.py +++ b/scaleway-async/scaleway_async/vpcgw/v2/__init__.py @@ -15,10 +15,13 @@ from .types import Gateway from .types import PatRule from .types import SetPatRulesRequestRule +from .types import AddBastionAllowedIPsRequest +from .types import AddBastionAllowedIPsResponse from .types import CreateGatewayNetworkRequest from .types import CreateGatewayRequest from .types import CreateIPRequest from .types import CreatePatRuleRequest +from .types import DeleteBastionAllowedIPsRequest from .types import DeleteGatewayNetworkRequest from .types import DeleteGatewayRequest from .types import DeleteIPRequest @@ -38,6 +41,8 @@ from .types import ListPatRulesRequest from .types import ListPatRulesResponse from .types import RefreshSSHKeysRequest +from .types import SetBastionAllowedIPsRequest +from .types import SetBastionAllowedIPsResponse from .types import SetPatRulesRequest from .types import SetPatRulesResponse from .types import UpdateGatewayNetworkRequest @@ -63,10 +68,13 @@ "Gateway", "PatRule", "SetPatRulesRequestRule", + "AddBastionAllowedIPsRequest", + "AddBastionAllowedIPsResponse", "CreateGatewayNetworkRequest", "CreateGatewayRequest", "CreateIPRequest", "CreatePatRuleRequest", + "DeleteBastionAllowedIPsRequest", "DeleteGatewayNetworkRequest", "DeleteGatewayRequest", "DeleteIPRequest", @@ -86,6 +94,8 @@ "ListPatRulesRequest", "ListPatRulesResponse", "RefreshSSHKeysRequest", + "SetBastionAllowedIPsRequest", + "SetBastionAllowedIPsResponse", "SetPatRulesRequest", "SetPatRulesResponse", "UpdateGatewayNetworkRequest", diff --git a/scaleway-async/scaleway_async/vpcgw/v2/api.py b/scaleway-async/scaleway_async/vpcgw/v2/api.py index a29e79e5f..fb2eba0b7 100644 --- a/scaleway-async/scaleway_async/vpcgw/v2/api.py +++ b/scaleway-async/scaleway_async/vpcgw/v2/api.py @@ -22,6 +22,8 @@ ListIPsRequestOrderBy, ListPatRulesRequestOrderBy, PatRuleProtocol, + AddBastionAllowedIPsRequest, + AddBastionAllowedIPsResponse, CreateGatewayNetworkRequest, CreateGatewayRequest, CreateIPRequest, @@ -35,6 +37,8 @@ ListIPsResponse, ListPatRulesResponse, PatRule, + SetBastionAllowedIPsRequest, + SetBastionAllowedIPsResponse, SetPatRulesRequest, SetPatRulesRequestRule, SetPatRulesResponse, @@ -53,16 +57,20 @@ unmarshal_IP, unmarshal_Gateway, unmarshal_PatRule, + unmarshal_AddBastionAllowedIPsResponse, unmarshal_ListGatewayNetworksResponse, unmarshal_ListGatewayTypesResponse, unmarshal_ListGatewaysResponse, unmarshal_ListIPsResponse, unmarshal_ListPatRulesResponse, + unmarshal_SetBastionAllowedIPsResponse, unmarshal_SetPatRulesResponse, + marshal_AddBastionAllowedIPsRequest, marshal_CreateGatewayNetworkRequest, marshal_CreateGatewayRequest, marshal_CreateIPRequest, marshal_CreatePatRuleRequest, + marshal_SetBastionAllowedIPsRequest, marshal_SetPatRulesRequest, marshal_UpdateGatewayNetworkRequest, marshal_UpdateGatewayRequest, @@ -1383,3 +1391,122 @@ async def refresh_ssh_keys( self._throw_on_error(res) return unmarshal_Gateway(res.json()) + + async def add_bastion_allowed_i_ps( + self, + *, + gateway_id: str, + ip_range: str, + zone: Optional[Zone] = None, + ) -> AddBastionAllowedIPsResponse: + """ + Add allowed IP range to SSH bastion. + Add an IP range (in CIDR notation) to be allowed to connect to the SSH bastion. + :param gateway_id: ID of the gateway to add the allowed IP range to. + :param ip_range: IP range allowed to connect to the SSH bastion. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`AddBastionAllowedIPsResponse ` + + Usage: + :: + + result = await api.add_bastion_allowed_i_ps( + gateway_id="example", + ip_range="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/bastion-allowed-ips", + body=marshal_AddBastionAllowedIPsRequest( + AddBastionAllowedIPsRequest( + gateway_id=gateway_id, + ip_range=ip_range, + zone=zone, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_AddBastionAllowedIPsResponse(res.json()) + + async def set_bastion_allowed_i_ps( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + ip_ranges: Optional[List[str]] = None, + ) -> SetBastionAllowedIPsResponse: + """ + Set all IP ranges allowed for SSH bastion. + Set a definitive list of IP ranges (in CIDR notation) allowed to connect to the SSH bastion. + :param gateway_id: ID of the gateway on which to set the allowed IP range. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param ip_ranges: New list of IP ranges (each range in CIDR notation) allowed to connect to the SSH bastion. + :return: :class:`SetBastionAllowedIPsResponse ` + + Usage: + :: + + result = await api.set_bastion_allowed_i_ps( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PUT", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/bastion-allowed-ips", + body=marshal_SetBastionAllowedIPsRequest( + SetBastionAllowedIPsRequest( + gateway_id=gateway_id, + zone=zone, + ip_ranges=ip_ranges, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetBastionAllowedIPsResponse(res.json()) + + async def delete_bastion_allowed_i_ps( + self, + *, + gateway_id: str, + ip_range: str, + zone: Optional[Zone] = None, + ) -> None: + """ + Delete allowed IP range from SSH bastion. + Delete an IP range (defined in CIDR notation) from SSH bastion, so that it is no longer allowed to connect. + :param gateway_id: ID of the gateway on which to delete the allowed IP range. + :param ip_range: IP range to delete from SSH bastion's list of allowed IPs. + :param zone: Zone to target. If none is passed will use default zone from the config. + + Usage: + :: + + result = await api.delete_bastion_allowed_i_ps( + gateway_id="example", + ip_range="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + param_ip_range = validate_path_param("ip_range", ip_range) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/bastion-allowed-ips/{param_ip_range}", + ) + + self._throw_on_error(res) diff --git a/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py b/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py index ff9cb1e66..2c01ee753 100644 --- a/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py +++ b/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py @@ -10,17 +10,21 @@ IP, Gateway, PatRule, + AddBastionAllowedIPsResponse, ListGatewayNetworksResponse, GatewayType, ListGatewayTypesResponse, ListGatewaysResponse, ListIPsResponse, ListPatRulesResponse, + SetBastionAllowedIPsResponse, SetPatRulesResponse, + AddBastionAllowedIPsRequest, CreateGatewayNetworkRequest, CreateGatewayRequest, CreateIPRequest, CreatePatRuleRequest, + SetBastionAllowedIPsRequest, SetPatRulesRequestRule, SetPatRulesRequest, UpdateGatewayNetworkRequest, @@ -183,6 +187,10 @@ def unmarshal_Gateway(data: Any) -> Gateway: if field is not None: args["status"] = field + field = data.get("name", None) + if field is not None: + args["name"] = field + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -195,10 +203,6 @@ def unmarshal_Gateway(data: Any) -> Gateway: else: args["updated_at"] = None - field = data.get("name", None) - if field is not None: - args["name"] = field - field = data.get("tags", None) if field is not None: args["tags"] = field @@ -213,22 +217,6 @@ def unmarshal_Gateway(data: Any) -> Gateway: if field is not None: args["bastion_enabled"] = field - field = data.get("bastion_port", None) - if field is not None: - args["bastion_port"] = field - - field = data.get("smtp_enabled", None) - if field is not None: - args["smtp_enabled"] = field - - field = data.get("is_legacy", None) - if field is not None: - args["is_legacy"] = field - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - field = data.get("ipv4", None) if field is not None: args["ipv4"] = unmarshal_IP(field) @@ -247,6 +235,26 @@ def unmarshal_Gateway(data: Any) -> Gateway: else: args["can_upgrade_to"] = None + field = data.get("bastion_port", None) + if field is not None: + args["bastion_port"] = field + + field = data.get("smtp_enabled", None) + if field is not None: + args["smtp_enabled"] = field + + field = data.get("is_legacy", None) + if field is not None: + args["is_legacy"] = field + + field = data.get("bastion_allowed_ips", None) + if field is not None: + args["bastion_allowed_ips"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + return Gateway(**args) @@ -301,6 +309,21 @@ def unmarshal_PatRule(data: Any) -> PatRule: return PatRule(**args) +def unmarshal_AddBastionAllowedIPsResponse(data: Any) -> AddBastionAllowedIPsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'AddBastionAllowedIPsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("ip_ranges", None) + if field is not None: + args["ip_ranges"] = field + + return AddBastionAllowedIPsResponse(**args) + + def unmarshal_ListGatewayNetworksResponse(data: Any) -> ListGatewayNetworksResponse: if not isinstance(data, dict): raise TypeError( @@ -423,6 +446,21 @@ def unmarshal_ListPatRulesResponse(data: Any) -> ListPatRulesResponse: return ListPatRulesResponse(**args) +def unmarshal_SetBastionAllowedIPsResponse(data: Any) -> SetBastionAllowedIPsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetBastionAllowedIPsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("ip_ranges", None) + if field is not None: + args["ip_ranges"] = field + + return SetBastionAllowedIPsResponse(**args) + + def unmarshal_SetPatRulesResponse(data: Any) -> SetPatRulesResponse: if not isinstance(data, dict): raise TypeError( @@ -440,6 +478,18 @@ def unmarshal_SetPatRulesResponse(data: Any) -> SetPatRulesResponse: return SetPatRulesResponse(**args) +def marshal_AddBastionAllowedIPsRequest( + request: AddBastionAllowedIPsRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.ip_range is not None: + output["ip_range"] = request.ip_range + + return output + + def marshal_CreateGatewayNetworkRequest( request: CreateGatewayNetworkRequest, defaults: ProfileDefaults, @@ -536,6 +586,18 @@ def marshal_CreatePatRuleRequest( return output +def marshal_SetBastionAllowedIPsRequest( + request: SetBastionAllowedIPsRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.ip_ranges is not None: + output["ip_ranges"] = request.ip_ranges + + return output + + def marshal_SetPatRulesRequestRule( request: SetPatRulesRequestRule, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/vpcgw/v2/types.py b/scaleway-async/scaleway_async/vpcgw/v2/types.py index 9bcf99b86..04b73ab43 100644 --- a/scaleway-async/scaleway_async/vpcgw/v2/types.py +++ b/scaleway-async/scaleway_async/vpcgw/v2/types.py @@ -259,6 +259,11 @@ class Gateway: Current status of the gateway. """ + name: str + """ + Name of the gateway. + """ + created_at: Optional[datetime] """ Gateway creation date. @@ -269,11 +274,6 @@ class Gateway: Gateway last modification date. """ - name: str - """ - Name of the gateway. - """ - tags: List[str] """ Tags associated with the gateway. @@ -289,39 +289,44 @@ class Gateway: Defines whether SSH bastion is enabled on the gateway. """ - bastion_port: int + ipv4: Optional[IP] """ - Port of the SSH bastion. + Public IPv4 address of the gateway. """ - smtp_enabled: bool + version: Optional[str] """ - Defines whether SMTP traffic is allowed to pass through the gateway. + Version of the running gateway software. """ - is_legacy: bool + can_upgrade_to: Optional[str] """ - Defines whether the gateway uses non-IPAM IP configurations. + Newly available gateway software version that can be updated to. """ - zone: Zone + bastion_port: int """ - Zone of the gateway. + Port of the SSH bastion. """ - ipv4: Optional[IP] + smtp_enabled: bool """ - Public IPv4 address of the gateway. + Defines whether SMTP traffic is allowed to pass through the gateway. """ - version: Optional[str] + is_legacy: bool """ - Version of the running gateway software. + Defines whether the gateway uses non-IPAM IP configurations. """ - can_upgrade_to: Optional[str] + bastion_allowed_ips: List[str] """ - Newly available gateway software version that can be updated to. + Ranges of IP addresses allowed to connect to the gateway's SSH bastion. + """ + + zone: Zone + """ + Zone of the gateway. """ @@ -396,6 +401,32 @@ class SetPatRulesRequestRule: """ +@dataclass +class AddBastionAllowedIPsRequest: + gateway_id: str + """ + ID of the gateway to add the allowed IP range to. + """ + + ip_range: str + """ + IP range allowed to connect to the SSH bastion. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class AddBastionAllowedIPsResponse: + ip_ranges: List[str] + """ + Ranges of IP addresses allowed to connect to the gateway's SSH bastion. + """ + + @dataclass class CreateGatewayNetworkRequest: gateway_id: str @@ -528,6 +559,24 @@ class CreatePatRuleRequest: """ +@dataclass +class DeleteBastionAllowedIPsRequest: + gateway_id: str + """ + ID of the gateway on which to delete the allowed IP range. + """ + + ip_range: str + """ + IP range to delete from SSH bastion's list of allowed IPs. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + @dataclass class DeleteGatewayNetworkRequest: gateway_network_id: str @@ -910,6 +959,32 @@ class RefreshSSHKeysRequest: """ +@dataclass +class SetBastionAllowedIPsRequest: + gateway_id: str + """ + ID of the gateway on which to set the allowed IP range. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + ip_ranges: Optional[List[str]] + """ + New list of IP ranges (each range in CIDR notation) allowed to connect to the SSH bastion. + """ + + +@dataclass +class SetBastionAllowedIPsResponse: + ip_ranges: List[str] + """ + Ranges of IP addresses allowed to connect to the gateway's SSH bastion. + """ + + @dataclass class SetPatRulesRequest: gateway_id: str diff --git a/scaleway/scaleway/vpcgw/v2/__init__.py b/scaleway/scaleway/vpcgw/v2/__init__.py index 7c1cd4fe3..8856eb505 100644 --- a/scaleway/scaleway/vpcgw/v2/__init__.py +++ b/scaleway/scaleway/vpcgw/v2/__init__.py @@ -15,10 +15,13 @@ from .types import Gateway from .types import PatRule from .types import SetPatRulesRequestRule +from .types import AddBastionAllowedIPsRequest +from .types import AddBastionAllowedIPsResponse from .types import CreateGatewayNetworkRequest from .types import CreateGatewayRequest from .types import CreateIPRequest from .types import CreatePatRuleRequest +from .types import DeleteBastionAllowedIPsRequest from .types import DeleteGatewayNetworkRequest from .types import DeleteGatewayRequest from .types import DeleteIPRequest @@ -38,6 +41,8 @@ from .types import ListPatRulesRequest from .types import ListPatRulesResponse from .types import RefreshSSHKeysRequest +from .types import SetBastionAllowedIPsRequest +from .types import SetBastionAllowedIPsResponse from .types import SetPatRulesRequest from .types import SetPatRulesResponse from .types import UpdateGatewayNetworkRequest @@ -63,10 +68,13 @@ "Gateway", "PatRule", "SetPatRulesRequestRule", + "AddBastionAllowedIPsRequest", + "AddBastionAllowedIPsResponse", "CreateGatewayNetworkRequest", "CreateGatewayRequest", "CreateIPRequest", "CreatePatRuleRequest", + "DeleteBastionAllowedIPsRequest", "DeleteGatewayNetworkRequest", "DeleteGatewayRequest", "DeleteIPRequest", @@ -86,6 +94,8 @@ "ListPatRulesRequest", "ListPatRulesResponse", "RefreshSSHKeysRequest", + "SetBastionAllowedIPsRequest", + "SetBastionAllowedIPsResponse", "SetPatRulesRequest", "SetPatRulesResponse", "UpdateGatewayNetworkRequest", diff --git a/scaleway/scaleway/vpcgw/v2/api.py b/scaleway/scaleway/vpcgw/v2/api.py index 42d7b57d7..256b66e97 100644 --- a/scaleway/scaleway/vpcgw/v2/api.py +++ b/scaleway/scaleway/vpcgw/v2/api.py @@ -22,6 +22,8 @@ ListIPsRequestOrderBy, ListPatRulesRequestOrderBy, PatRuleProtocol, + AddBastionAllowedIPsRequest, + AddBastionAllowedIPsResponse, CreateGatewayNetworkRequest, CreateGatewayRequest, CreateIPRequest, @@ -35,6 +37,8 @@ ListIPsResponse, ListPatRulesResponse, PatRule, + SetBastionAllowedIPsRequest, + SetBastionAllowedIPsResponse, SetPatRulesRequest, SetPatRulesRequestRule, SetPatRulesResponse, @@ -53,16 +57,20 @@ unmarshal_IP, unmarshal_Gateway, unmarshal_PatRule, + unmarshal_AddBastionAllowedIPsResponse, unmarshal_ListGatewayNetworksResponse, unmarshal_ListGatewayTypesResponse, unmarshal_ListGatewaysResponse, unmarshal_ListIPsResponse, unmarshal_ListPatRulesResponse, + unmarshal_SetBastionAllowedIPsResponse, unmarshal_SetPatRulesResponse, + marshal_AddBastionAllowedIPsRequest, marshal_CreateGatewayNetworkRequest, marshal_CreateGatewayRequest, marshal_CreateIPRequest, marshal_CreatePatRuleRequest, + marshal_SetBastionAllowedIPsRequest, marshal_SetPatRulesRequest, marshal_UpdateGatewayNetworkRequest, marshal_UpdateGatewayRequest, @@ -1381,3 +1389,122 @@ def refresh_ssh_keys( self._throw_on_error(res) return unmarshal_Gateway(res.json()) + + def add_bastion_allowed_i_ps( + self, + *, + gateway_id: str, + ip_range: str, + zone: Optional[Zone] = None, + ) -> AddBastionAllowedIPsResponse: + """ + Add allowed IP range to SSH bastion. + Add an IP range (in CIDR notation) to be allowed to connect to the SSH bastion. + :param gateway_id: ID of the gateway to add the allowed IP range to. + :param ip_range: IP range allowed to connect to the SSH bastion. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`AddBastionAllowedIPsResponse ` + + Usage: + :: + + result = api.add_bastion_allowed_i_ps( + gateway_id="example", + ip_range="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/bastion-allowed-ips", + body=marshal_AddBastionAllowedIPsRequest( + AddBastionAllowedIPsRequest( + gateway_id=gateway_id, + ip_range=ip_range, + zone=zone, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_AddBastionAllowedIPsResponse(res.json()) + + def set_bastion_allowed_i_ps( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + ip_ranges: Optional[List[str]] = None, + ) -> SetBastionAllowedIPsResponse: + """ + Set all IP ranges allowed for SSH bastion. + Set a definitive list of IP ranges (in CIDR notation) allowed to connect to the SSH bastion. + :param gateway_id: ID of the gateway on which to set the allowed IP range. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param ip_ranges: New list of IP ranges (each range in CIDR notation) allowed to connect to the SSH bastion. + :return: :class:`SetBastionAllowedIPsResponse ` + + Usage: + :: + + result = api.set_bastion_allowed_i_ps( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PUT", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/bastion-allowed-ips", + body=marshal_SetBastionAllowedIPsRequest( + SetBastionAllowedIPsRequest( + gateway_id=gateway_id, + zone=zone, + ip_ranges=ip_ranges, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetBastionAllowedIPsResponse(res.json()) + + def delete_bastion_allowed_i_ps( + self, + *, + gateway_id: str, + ip_range: str, + zone: Optional[Zone] = None, + ) -> None: + """ + Delete allowed IP range from SSH bastion. + Delete an IP range (defined in CIDR notation) from SSH bastion, so that it is no longer allowed to connect. + :param gateway_id: ID of the gateway on which to delete the allowed IP range. + :param ip_range: IP range to delete from SSH bastion's list of allowed IPs. + :param zone: Zone to target. If none is passed will use default zone from the config. + + Usage: + :: + + result = api.delete_bastion_allowed_i_ps( + gateway_id="example", + ip_range="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + param_ip_range = validate_path_param("ip_range", ip_range) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/bastion-allowed-ips/{param_ip_range}", + ) + + self._throw_on_error(res) diff --git a/scaleway/scaleway/vpcgw/v2/marshalling.py b/scaleway/scaleway/vpcgw/v2/marshalling.py index ff9cb1e66..2c01ee753 100644 --- a/scaleway/scaleway/vpcgw/v2/marshalling.py +++ b/scaleway/scaleway/vpcgw/v2/marshalling.py @@ -10,17 +10,21 @@ IP, Gateway, PatRule, + AddBastionAllowedIPsResponse, ListGatewayNetworksResponse, GatewayType, ListGatewayTypesResponse, ListGatewaysResponse, ListIPsResponse, ListPatRulesResponse, + SetBastionAllowedIPsResponse, SetPatRulesResponse, + AddBastionAllowedIPsRequest, CreateGatewayNetworkRequest, CreateGatewayRequest, CreateIPRequest, CreatePatRuleRequest, + SetBastionAllowedIPsRequest, SetPatRulesRequestRule, SetPatRulesRequest, UpdateGatewayNetworkRequest, @@ -183,6 +187,10 @@ def unmarshal_Gateway(data: Any) -> Gateway: if field is not None: args["status"] = field + field = data.get("name", None) + if field is not None: + args["name"] = field + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -195,10 +203,6 @@ def unmarshal_Gateway(data: Any) -> Gateway: else: args["updated_at"] = None - field = data.get("name", None) - if field is not None: - args["name"] = field - field = data.get("tags", None) if field is not None: args["tags"] = field @@ -213,22 +217,6 @@ def unmarshal_Gateway(data: Any) -> Gateway: if field is not None: args["bastion_enabled"] = field - field = data.get("bastion_port", None) - if field is not None: - args["bastion_port"] = field - - field = data.get("smtp_enabled", None) - if field is not None: - args["smtp_enabled"] = field - - field = data.get("is_legacy", None) - if field is not None: - args["is_legacy"] = field - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - field = data.get("ipv4", None) if field is not None: args["ipv4"] = unmarshal_IP(field) @@ -247,6 +235,26 @@ def unmarshal_Gateway(data: Any) -> Gateway: else: args["can_upgrade_to"] = None + field = data.get("bastion_port", None) + if field is not None: + args["bastion_port"] = field + + field = data.get("smtp_enabled", None) + if field is not None: + args["smtp_enabled"] = field + + field = data.get("is_legacy", None) + if field is not None: + args["is_legacy"] = field + + field = data.get("bastion_allowed_ips", None) + if field is not None: + args["bastion_allowed_ips"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + return Gateway(**args) @@ -301,6 +309,21 @@ def unmarshal_PatRule(data: Any) -> PatRule: return PatRule(**args) +def unmarshal_AddBastionAllowedIPsResponse(data: Any) -> AddBastionAllowedIPsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'AddBastionAllowedIPsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("ip_ranges", None) + if field is not None: + args["ip_ranges"] = field + + return AddBastionAllowedIPsResponse(**args) + + def unmarshal_ListGatewayNetworksResponse(data: Any) -> ListGatewayNetworksResponse: if not isinstance(data, dict): raise TypeError( @@ -423,6 +446,21 @@ def unmarshal_ListPatRulesResponse(data: Any) -> ListPatRulesResponse: return ListPatRulesResponse(**args) +def unmarshal_SetBastionAllowedIPsResponse(data: Any) -> SetBastionAllowedIPsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetBastionAllowedIPsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("ip_ranges", None) + if field is not None: + args["ip_ranges"] = field + + return SetBastionAllowedIPsResponse(**args) + + def unmarshal_SetPatRulesResponse(data: Any) -> SetPatRulesResponse: if not isinstance(data, dict): raise TypeError( @@ -440,6 +478,18 @@ def unmarshal_SetPatRulesResponse(data: Any) -> SetPatRulesResponse: return SetPatRulesResponse(**args) +def marshal_AddBastionAllowedIPsRequest( + request: AddBastionAllowedIPsRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.ip_range is not None: + output["ip_range"] = request.ip_range + + return output + + def marshal_CreateGatewayNetworkRequest( request: CreateGatewayNetworkRequest, defaults: ProfileDefaults, @@ -536,6 +586,18 @@ def marshal_CreatePatRuleRequest( return output +def marshal_SetBastionAllowedIPsRequest( + request: SetBastionAllowedIPsRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.ip_ranges is not None: + output["ip_ranges"] = request.ip_ranges + + return output + + def marshal_SetPatRulesRequestRule( request: SetPatRulesRequestRule, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/vpcgw/v2/types.py b/scaleway/scaleway/vpcgw/v2/types.py index 9bcf99b86..04b73ab43 100644 --- a/scaleway/scaleway/vpcgw/v2/types.py +++ b/scaleway/scaleway/vpcgw/v2/types.py @@ -259,6 +259,11 @@ class Gateway: Current status of the gateway. """ + name: str + """ + Name of the gateway. + """ + created_at: Optional[datetime] """ Gateway creation date. @@ -269,11 +274,6 @@ class Gateway: Gateway last modification date. """ - name: str - """ - Name of the gateway. - """ - tags: List[str] """ Tags associated with the gateway. @@ -289,39 +289,44 @@ class Gateway: Defines whether SSH bastion is enabled on the gateway. """ - bastion_port: int + ipv4: Optional[IP] """ - Port of the SSH bastion. + Public IPv4 address of the gateway. """ - smtp_enabled: bool + version: Optional[str] """ - Defines whether SMTP traffic is allowed to pass through the gateway. + Version of the running gateway software. """ - is_legacy: bool + can_upgrade_to: Optional[str] """ - Defines whether the gateway uses non-IPAM IP configurations. + Newly available gateway software version that can be updated to. """ - zone: Zone + bastion_port: int """ - Zone of the gateway. + Port of the SSH bastion. """ - ipv4: Optional[IP] + smtp_enabled: bool """ - Public IPv4 address of the gateway. + Defines whether SMTP traffic is allowed to pass through the gateway. """ - version: Optional[str] + is_legacy: bool """ - Version of the running gateway software. + Defines whether the gateway uses non-IPAM IP configurations. """ - can_upgrade_to: Optional[str] + bastion_allowed_ips: List[str] """ - Newly available gateway software version that can be updated to. + Ranges of IP addresses allowed to connect to the gateway's SSH bastion. + """ + + zone: Zone + """ + Zone of the gateway. """ @@ -396,6 +401,32 @@ class SetPatRulesRequestRule: """ +@dataclass +class AddBastionAllowedIPsRequest: + gateway_id: str + """ + ID of the gateway to add the allowed IP range to. + """ + + ip_range: str + """ + IP range allowed to connect to the SSH bastion. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class AddBastionAllowedIPsResponse: + ip_ranges: List[str] + """ + Ranges of IP addresses allowed to connect to the gateway's SSH bastion. + """ + + @dataclass class CreateGatewayNetworkRequest: gateway_id: str @@ -528,6 +559,24 @@ class CreatePatRuleRequest: """ +@dataclass +class DeleteBastionAllowedIPsRequest: + gateway_id: str + """ + ID of the gateway on which to delete the allowed IP range. + """ + + ip_range: str + """ + IP range to delete from SSH bastion's list of allowed IPs. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + @dataclass class DeleteGatewayNetworkRequest: gateway_network_id: str @@ -910,6 +959,32 @@ class RefreshSSHKeysRequest: """ +@dataclass +class SetBastionAllowedIPsRequest: + gateway_id: str + """ + ID of the gateway on which to set the allowed IP range. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + ip_ranges: Optional[List[str]] + """ + New list of IP ranges (each range in CIDR notation) allowed to connect to the SSH bastion. + """ + + +@dataclass +class SetBastionAllowedIPsResponse: + ip_ranges: List[str] + """ + Ranges of IP addresses allowed to connect to the gateway's SSH bastion. + """ + + @dataclass class SetPatRulesRequest: gateway_id: str