refactor: the id attribute is attached to the Model class

This commit is contained in:
Éloi Rivard 2024-04-05 16:05:17 +02:00
parent 47ef573917
commit 7734ed185e
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184
3 changed files with 18 additions and 38 deletions

View file

@ -11,6 +11,24 @@ class Model:
It details all the common attributes shared by every models. It details all the common attributes shared by every models.
""" """
id: Optional[str]
"""A unique identifier for a SCIM resource as defined by the service
provider. Id will be :py:data:`None` until the
:meth:`~canaille.backends.models.BackendModel.save` method is called.
Each representation of the resource MUST include a non-empty "id"
value. This identifier MUST be unique across the SCIM service
provider's entire set of resources. It MUST be a stable, non-
reassignable identifier that does not change when the same resource
is returned in subsequent requests. The value of the "id" attribute
is always issued by the service provider and MUST NOT be specified
by the client. The string "bulkId" is a reserved keyword and MUST
NOT be used within any unique identifier value. The attribute
characteristics are "caseExact" as "true", a mutability of
"readOnly", and a "returned" characteristic of "always". See
Section 9 for additional considerations regarding privacy.
"""
created: Optional[datetime.datetime] created: Optional[datetime.datetime]
"""The :class:`~datetime.datetime` that the resource was added to the """The :class:`~datetime.datetime` that the resource was added to the
service provider.""" service provider."""

View file

@ -19,23 +19,6 @@ class User(Model):
implementation in Canaille. implementation in Canaille.
""" """
id: str
"""A unique identifier for a SCIM resource as defined by the service
provider.
Each representation of the resource MUST include a non-empty "id"
value. This identifier MUST be unique across the SCIM service
provider's entire set of resources. It MUST be a stable, non-
reassignable identifier that does not change when the same resource
is returned in subsequent requests. The value of the "id" attribute
is always issued by the service provider and MUST NOT be specified
by the client. The string "bulkId" is a reserved keyword and MUST
NOT be used within any unique identifier value. The attribute
characteristics are "caseExact" as "true", a mutability of
"readOnly", and a "returned" characteristic of "always". See
Section 9 for additional considerations regarding privacy.
"""
user_name: str user_name: str
"""A service provider's unique identifier for the user, typically used by """A service provider's unique identifier for the user, typically used by
the user to directly authenticate to the service provider. the user to directly authenticate to the service provider.
@ -304,23 +287,6 @@ class Group(Model):
<https://datatracker.ietf.org/doc/html/rfc7643#section-4.2>`_. <https://datatracker.ietf.org/doc/html/rfc7643#section-4.2>`_.
""" """
id: str
"""A unique identifier for a SCIM resource as defined by the service
provider.
Each representation of the resource MUST include a non-empty "id"
value. This identifier MUST be unique across the SCIM service
provider's entire set of resources. It MUST be a stable, non-
reassignable identifier that does not change when the same resource
is returned in subsequent requests. The value of the "id" attribute
is always issued by the service provider and MUST NOT be specified
by the client. The string "bulkId" is a reserved keyword and MUST
NOT be used within any unique identifier value. The attribute
characteristics are "caseExact" as "true", a mutability of
"readOnly", and a "returned" characteristic of "always". See
Section 9 for additional considerations regarding privacy.
"""
display_name: str display_name: str
"""A human-readable name for the Group. """A human-readable name for the Group.

View file

@ -16,7 +16,6 @@ class Client(Model):
specifications. specifications.
""" """
id: str
description: Optional[str] = None description: Optional[str] = None
preconsent: Optional[bool] = False preconsent: Optional[bool] = False
audience: List["Client"] = [] audience: List["Client"] = []
@ -289,7 +288,6 @@ class Client(Model):
class AuthorizationCode(Model): class AuthorizationCode(Model):
"""OpenID Connect temporary authorization code definition.""" """OpenID Connect temporary authorization code definition."""
id: str
authorization_code_id: str authorization_code_id: str
code: str code: str
client: "Client" client: "Client"
@ -308,7 +306,6 @@ class AuthorizationCode(Model):
class Token(Model): class Token(Model):
"""OpenID Connect token definition.""" """OpenID Connect token definition."""
id: str
token_id: str token_id: str
access_token: str access_token: str
client: "Client" client: "Client"
@ -325,7 +322,6 @@ class Token(Model):
class Consent(Model): class Consent(Model):
"""Long-term user consent to an application.""" """Long-term user consent to an application."""
id: str
consent_id: str consent_id: str
subject: User subject: User
client: "Client" client: "Client"