(f)
return cast(CallableT, wrapper)
A function decorated with this `@smart_retry` will trigger a new authentication if it fails. The function
    will then be retried.
    This is useful when the integration keeps a semi-healthy connection to the vSphere API
A function decorated with this `
A function decorated with this
def smart_retry(f):
    # type: (CallableT) -> CallableT
    """A function decorated with this `@smart_retry` will trigger a new authentication if it fails. The function
    will then be retried.
    This is useful when the integration keeps a semi-healthy connection to the vSphere API"""

    @functools.wraps(f)
    def wrapper(api_instance, *args, **kwargs):
        # type: (VSphereAPI, *Any, **Any) -> Any
        try:
            return f(api_instance, *args, **kwargs)
        except vmodl.fault.InvalidArgument:
            # This error is raised when the api call request is invalid. This error also appear when
            # requesting non existing metrics. Retrying won't help
            # https://code.vmware.com/apis/704/vsphere/vmodl.fault.InvalidArgument.html
            raise
        except vim.fault.InvalidName:
            # For the scope of this integration, this is raised when fetching a config value from vCenter
            # that doesn't exist (especially maxQueryMetrics). Retrying won't help
            # https://code.vmware.com/apis/704/vsphere/vim.fault.InvalidName.html
            raise
        except vim.fault.RestrictedByAdministrator:
            # The operation cannot complete because of some restriction set by the server administrator.
            # Retrying won't help
            # https://code.vmware.com/apis/704/vsphere/vim.fault.RestrictedByAdministrator.html
            raise
        except Exception as e:
            api_instance.log.debug(
                "An exception occurred when executing %s: %s. Refreshing the connection to vCenter and retrying",
                f.__name__,
                e,
            )
            api_instance.smart_connect()
            return f(api_instance, *args, **kwargs)

    return cast(CallableT, wrapper)
def smart_retry ( f ) : # type: (CallableT) -> CallableT @ functools . wraps ( f ) def wrapper ( api_instance , * args , * * kwargs ) : # type: (VSphereAPI, *Any, **Any) -> Any try : return f ( api_instance , * args , * * kwargs ) except vmodl . fault . InvalidArgument : # This error is raised when the api call request is invalid. This error also appear when # requesting non existing metrics. Retrying won't help # https://code.vmware.com/apis/704/vsphere/vmodl.fault.InvalidArgument.html raise except vim . fault . InvalidName : # For the scope of this integration, this is raised when fetching a config value from vCenter # that doesn't exist (especially maxQueryMetrics). Retrying won't help # https://code.vmware.com/apis/704/vsphere/vim.fault.InvalidName.html raise except vim . fault . RestrictedByAdministrator : # The operation cannot complete because of some restriction set by the server administrator. # Retrying won't help # https://code.vmware.com/apis/704/vsphere/vim.fault.RestrictedByAdministrator.html raise except Exception as e : api_instance . log . debug ( "An exception occurred when executing %s: %s. Refreshing the connection to vCenter and retrying" , f . __name__ , e , ) api_instance . smart_connect ( ) return f ( api_instance , * args , * * kwargs ) return cast ( CallableT , wrapper )