from moto.ec2.utils import add_tag_specification
from ._base_response import EC2BaseResponse
class CarrierGateway(EC2BaseResponse):
def create_carrier_gateway(self) -> str:
vpc_id = self._get_param("VpcId")
tag_param = self._get_multi_param("TagSpecification")
tags = add_tag_specification(tag_param)
carrier_gateway = self.ec2_backend.create_carrier_gateway(
vpc_id=vpc_id, tags=tags
)
template = self.response_template(CREATE_CARRIER_GATEWAY_RESPONSE)
return template.render(carrier_gateway=carrier_gateway)
def delete_carrier_gateway(self) -> str:
carrier_gateway_id = self._get_param("CarrierGatewayId")
carrier_gateway = self.ec2_backend.delete_carrier_gateway(carrier_gateway_id)
template = self.response_template(DELETE_CARRIER_GATEWAY_RESPONSE)
return template.render(carrier_gateway=carrier_gateway)
def describe_carrier_gateways(self) -> str:
carrier_gateway_ids = self._get_multi_param("CarrierGatewayId")
filters = self._filters_from_querystring()
carrier_gateways = self.ec2_backend.describe_carrier_gateways(
carrier_gateway_ids, filters
)
template = self.response_template(DESCRIBE_CARRIER_GATEWAYS_RESPONSE)
return template.render(carrier_gateways=carrier_gateways)
CREATE_CARRIER_GATEWAY_RESPONSE = """
c617595f-6c29-4a00-a941-example
{{ carrier_gateway.state }}
{{ carrier_gateway.vpc_id }}
{{ carrier_gateway.id }}
{{ carrier_gateway.owner_id }}
{% for tag in carrier_gateway.get_tags() %}
-
{{ tag.key }}
{{ tag.value }}
{% endfor %}
"""
DELETE_CARRIER_GATEWAY_RESPONSE = """
c617595f-6c29-4a00-a941-example
{{ carrier_gateway.state }}
{{ carrier_gateway.vpc_id }}
{{ carrier_gateway.id }}
{{ carrier_gateway.owner_id }}
{% for tag in carrier_gateway.get_tags() %}
-
{{ tag.key }}
{{ tag.value }}
{% endfor %}
"""
DESCRIBE_CARRIER_GATEWAYS_RESPONSE = """
151283df-f7dc-4317-89b4-01c9888b1d45
{% for carrier_gateway in carrier_gateways %}
-
{{ carrier_gateway.state }}
{{ carrier_gateway.vpc_id }}
{{ carrier_gateway.id }}
{{ carrier_gateway.owner_id }}
{% for tag in carrier_gateway.get_tags() %}
-
{{ tag.key }}
{{ tag.value }}
{% endfor %}
{% endfor %}
"""