Aller au contenu

Schemas

ApiClient

Bases: Model

has_perm(perm)

Return True if the client has the specified permission.

Source code in api/models.py
def has_perm(self, perm: str):
    """Return True if the client has the specified permission."""
    return perm in self.all_permissions

has_perms(perm_list)

Return True if the client has each of the specified permissions.

Source code in api/models.py
def has_perms(self, perm_list: Iterable[str]) -> bool:
    """Return True if the client has each of the specified permissions."""
    if not isinstance(perm_list, Iterable) or isinstance(perm_list, str):
        raise ValueError("perm_list must be an iterable of permissions.")
    return all(self.has_perm(perm) for perm in perm_list)

reset_hmac(*, commit=True)

Reset and return the HMAC key for this client.

Parameters:

Name Type Description Default
commit bool

if True (the default), persist the new hmac in db.

True
Source code in api/models.py
def reset_hmac(self, *, commit: bool = True) -> str:
    """Reset and return the HMAC key for this client.

    Args:
        commit: if True (the default), persist the new hmac in db.
    """
    self.hmac_key = get_hmac_key()
    if commit:
        self.save()
    return self.hmac_key

ApiClientSchema

Bases: ModelSchema

ThirdPartyAuthParamsSchema

Bases: Schema