# Path: google/api_core/exceptions.py
# _HTTP_CODE_TO_EXCEPTION: Dict[int, Exception] = {}
# _GRPC_CODE_TO_EXCEPTION: Dict[int, Exception] = {}
# _INT_TO_GRPC_CODE = {}
# class GoogleAPIError(Exception):
# class DuplicateCredentialArgs(GoogleAPIError):
# class RetryError(GoogleAPIError):
# class _GoogleAPICallErrorMeta(type):
# class GoogleAPICallError(GoogleAPIError, metaclass=_GoogleAPICallErrorMeta):
# class Redirection(GoogleAPICallError):
# class MovedPermanently(Redirection):
# class NotModified(Redirection):
# class TemporaryRedirect(Redirection):
# class ResumeIncomplete(Redirection):
# class ClientError(GoogleAPICallError):
# class BadRequest(ClientError):
# class InvalidArgument(BadRequest):
# class FailedPrecondition(BadRequest):
# class OutOfRange(BadRequest):
# class Unauthorized(ClientError):
# class Unauthenticated(Unauthorized):
# class Forbidden(ClientError):
# class PermissionDenied(Forbidden):
# class NotFound(ClientError):
# class MethodNotAllowed(ClientError):
# class Conflict(ClientError):
# class AlreadyExists(Conflict):
# class Aborted(Conflict):
# class LengthRequired(ClientError):
# class PreconditionFailed(ClientError):
# class RequestRangeNotSatisfiable(ClientError):
# class TooManyRequests(ClientError):
# class ResourceExhausted(TooManyRequests):
# class Cancelled(ClientError):
# class ServerError(GoogleAPICallError):
# class InternalServerError(ServerError):
# class Unknown(ServerError):
# class DataLoss(ServerError):
# class MethodNotImplemented(ServerError):
# class BadGateway(ServerError):
# class ServiceUnavailable(ServerError):
# class GatewayTimeout(ServerError):
# class DeadlineExceeded(GatewayTimeout):
#     def __init__(self, message, cause):
#     def cause(self):
#     def __str__(self):
#     def __new__(mcs, name, bases, class_dict):
#     def __init__(self, message, errors=(), details=(), response=None, error_info=None):
#     def __str__(self):
#     def reason(self):
#     def domain(self):
#     def metadata(self):
#     def errors(self):
#     def details(self):
#     def response(self):
# def exception_class_for_http_status(status_code):
# def from_http_status(status_code, message, **kwargs):
# def from_http_response(response):
# def exception_class_for_grpc_status(status_code):
# def from_grpc_status(status_code, message, **kwargs):
# def _is_informative_grpc_error(rpc_exc):
# def _parse_grpc_error_details(rpc_exc):
# def from_grpc_error(rpc_exc):


import threading
from google.api_core import exceptions
from google.api_core.future import polling

    def cancelled(self):
        # TODO(dovs): there is not currently a good way to determine whether the
        # operation has been cancelled.
        # The best we can do is manually keep track of cancellation
        # and check for doneness.
        if not self._cancelled:
            return False

        self._refresh_and_update()
        return self._extended_operation.done

    def _refresh_and_update(self, retry=polling.DEFAULT_RETRY):
        if not self._extended_operation.done:
            self._extended_operation = self._refresh(retry=retry)
            self._handle_refreshed_operation()

    def _handle_refreshed_operation(self):
        with self._completion_lock:
            if not self._extended_operation.done:
                return

            if self.error_code and self.error_message:
                exception = exceptions.from_http_status(
                    status_code=self.error_code,
                    message=self.error_message,
                    response=self._extended_operation,
                )
                self.set_exception(exception)
            elif self.error_code or self.error_message:

# Path: google/api_core/exceptions.py
# _HTTP_CODE_TO_EXCEPTION: Dict[int, Exception] = {}
# _GRPC_CODE_TO_EXCEPTION: Dict[int, Exception] = {}
# _INT_TO_GRPC_CODE = {}
# class GoogleAPIError(Exception):
# class DuplicateCredentialArgs(GoogleAPIError):
# class RetryError(GoogleAPIError):
# class _GoogleAPICallErrorMeta(type):
# class GoogleAPICallError(GoogleAPIError, metaclass=_GoogleAPICallErrorMeta):
# class Redirection(GoogleAPICallError):
# class MovedPermanently(Redirection):
# class NotModified(Redirection):
# class TemporaryRedirect(Redirection):
# class ResumeIncomplete(Redirection):
# class ClientError(GoogleAPICallError):
# class BadRequest(ClientError):
# class InvalidArgument(BadRequest):
# class FailedPrecondition(BadRequest):
# class OutOfRange(BadRequest):
# class Unauthorized(ClientError):
# class Unauthenticated(Unauthorized):
# class Forbidden(ClientError):
# class PermissionDenied(Forbidden):
# class NotFound(ClientError):
# class MethodNotAllowed(ClientError):
# class Conflict(ClientError):
# class AlreadyExists(Conflict):
# class Aborted(Conflict):
# class LengthRequired(ClientError):
# class PreconditionFailed(ClientError):
# class RequestRangeNotSatisfiable(ClientError):
# class TooManyRequests(ClientError):
# class ResourceExhausted(TooManyRequests):
# class Cancelled(ClientError):
# class ServerError(GoogleAPICallError):
# class InternalServerError(ServerError):
# class Unknown(ServerError):
# class DataLoss(ServerError):
# class MethodNotImplemented(ServerError):
# class BadGateway(ServerError):
# class ServiceUnavailable(ServerError):
# class GatewayTimeout(ServerError):
# class DeadlineExceeded(GatewayTimeout):
#     def __init__(self, message, cause):
#     def cause(self):
#     def __str__(self):
#     def __new__(mcs, name, bases, class_dict):
#     def __init__(self, message, errors=(), details=(), response=None, error_info=None):
#     def __str__(self):
#     def reason(self):
#     def domain(self):
#     def metadata(self):
#     def errors(self):
#     def details(self):
#     def response(self):
# def exception_class_for_http_status(status_code):
# def from_http_status(status_code, message, **kwargs):
# def from_http_response(response):
# def exception_class_for_grpc_status(status_code):
# def from_grpc_status(status_code, message, **kwargs):
# def _is_informative_grpc_error(rpc_exc):
# def _parse_grpc_error_details(rpc_exc):
# def from_grpc_error(rpc_exc):


# Path: google/api_core/extended_operation.py
import threading
from google.api_core import exceptions
from google.api_core.future import polling


    def cancelled(self):
        # TODO(dovs): there is not currently a good way to determine whether the
        # operation has been cancelled.
        # The best we can do is manually keep track of cancellation
        # and check for doneness.
        if not self._cancelled:
            return False

        self._refresh_and_update()
        return self._extended_operation.done

    def _refresh_and_update(self, retry=polling.DEFAULT_RETRY):
        if not self._extended_operation.done:
            self._extended_operation = self._refresh(retry=retry)
            self._handle_refreshed_operation()

    def _handle_refreshed_operation(self):
        with self._completion_lock:
            if not self._extended_operation.done:
                return

            if self.error_code and self.error_message:
                exception = exceptions.from_http_status(
                    status_code=self.error_code,
                    message=self.error_message,
                    response=self._extended_operation,
                )
                self.set_exception(exception)
            elif self.error_code or self.error_message:

                exception = exceptions.GoogleAPICallError(