(self, request, url)
return response_body[:-1]
Retrieves the current AWS region from either the AWS_REGION or
        AWS_DEFAULT_REGION environment variable or from the AWS metadata server.

        Args:
            request (google.auth.transport.Request): A callable used to make
                HTTP requests.
            url (str): The AWS metadata server region URL.

        Returns:
            str: The current AWS region.

        Raises:
            google.auth.exceptions.RefreshError: If an error occurs while
                retrieving the AWS region.
Retrieves the current AWS region from either the AWS_REGION or
        AWS_DEFAULT_REGION environment variable or from the AWS metadata server.
Retrieves the current AWS region from either the AWS_REGION or AWS_DEFAULT_REGION environment variable or from the AWS metadata server .
def _get_region(self, request, url):
        """Retrieves the current AWS region from either the AWS_REGION or
        AWS_DEFAULT_REGION environment variable or from the AWS metadata server.

        Args:
            request (google.auth.transport.Request): A callable used to make
                HTTP requests.
            url (str): The AWS metadata server region URL.

        Returns:
            str: The current AWS region.

        Raises:
            google.auth.exceptions.RefreshError: If an error occurs while
                retrieving the AWS region.
        """
        # The AWS metadata server is not available in some AWS environments
        # such as AWS lambda. Instead, it is available via environment
        # variable.
        env_aws_region = os.environ.get(environment_vars.AWS_REGION)
        if env_aws_region is not None:
            return env_aws_region

        env_aws_region = os.environ.get(environment_vars.AWS_DEFAULT_REGION)
        if env_aws_region is not None:
            return env_aws_region

        if not self._region_url:
            raise exceptions.RefreshError("Unable to determine AWS region")
        response = request(url=self._region_url, method="GET")

        # Support both string and bytes type response.data.
        response_body = (
            response.data.decode("utf-8")
            if hasattr(response.data, "decode")
            else response.data
        )

        if response.status != 200:
            raise exceptions.RefreshError(
                "Unable to retrieve AWS region", response_body
            )

        # This endpoint will return the region in format: us-east-2b.
        # Only the us-east-2 part should be used.
        return response_body[:-1]
def _get_region ( self , request , url ) : # The AWS metadata server is not available in some AWS environments # such as AWS lambda. Instead, it is available via environment # variable. env_aws_region = os . environ . get ( environment_vars . AWS_REGION ) if env_aws_region is not None : return env_aws_region env_aws_region = os . environ . get ( environment_vars . AWS_DEFAULT_REGION ) if env_aws_region is not None : return env_aws_region if not self . _region_url : raise exceptions . RefreshError ( "Unable to determine AWS region" ) response = request ( url = self . _region_url , method = "GET" ) # Support both string and bytes type response.data. response_body = ( response . data . decode ( "utf-8" ) if hasattr ( response . data , "decode" ) else response . data ) if response . status != 200 : raise exceptions . RefreshError ( "Unable to retrieve AWS region" , response_body ) # This endpoint will return the region in format: us-east-2b. # Only the us-east-2 part should be used. return response_body [ : - 1 ]