in cvm-attestation/src/EndpointSelector.py [0:0]
def get_attestation_endpoint(self, isolation_type: IsolationType, attestation_type: str):
"""
Get the attestation endpoint based on the region.
Parameters:
isolation_type (IsolationType): Isolation type.
attestation_type (str): Attestation type.
Returns:
str: Attestation endpoint.
"""
imds_client = ImdsClient(self.logger)
region = imds_client.get_region_from_compute_metadata()
base_url = self._get_endpoint(region)
type = attestation_type.lower()
if type not in ATTESTATION_TYPES:
raise ValueError(f"Invalid attestation type '{type}'. Supported types: {', '.join(ATTESTATION_TYPES.keys())}")
if type == "guest":
return base_url + ATTESTATION_TYPES[type]["path"] + ATTESTATION_TYPES[type]["query"]
if isolation_type not in SUPPORTED_ISOLATION_TYPES:
supported_types = ", ".join(SUPPORTED_ISOLATION_TYPES.keys())
raise ValueError(f"Invalid isolation type '{type}'. Supported types: {supported_types}")
isolation_info = SUPPORTED_ISOLATION_TYPES[isolation_type]
return base_url + isolation_info["path"] + isolation_info["query"]