refactor: set default values for models

This commit is contained in:
Éloi Rivard 2024-04-01 18:47:42 +02:00
parent 18e3f8cde5
commit 4344bfacbc
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184
2 changed files with 46 additions and 46 deletions

View file

@ -36,7 +36,7 @@ class User(Model):
Section 9 for additional considerations regarding privacy.
"""
user_name: Optional[str]
user_name: str
"""A service provider's unique identifier for the user, typically used by
the user to directly authenticate to the service provider.
@ -48,7 +48,7 @@ class User(Model):
and is case insensitive.
"""
password: Optional[str]
password: Optional[str] = None
"""
This attribute is intended to be used as a means to set, replace,
or compare (i.e., filter for equality) a password. The cleartext
@ -93,7 +93,7 @@ class User(Model):
"never").
"""
preferred_language: Optional[str]
preferred_language: Optional[str] = None
"""Indicates the user's preferred written or spoken languages and is
generally used for selecting a localized user interface.
@ -109,20 +109,20 @@ class User(Model):
negotiation cannot take place.
"""
family_name: Optional[str]
family_name: Optional[str] = None
"""The family name of the User, or last name in most Western languages
(e.g., "Jensen" given the full name "Ms. Barbara Jane Jensen, III")."""
given_name: Optional[str]
given_name: Optional[str] = None
"""The given name of the User, or first name in most Western languages
(e.g., "Barbara" given the full name "Ms. Barbara Jane Jensen, III")."""
formatted_name: Optional[str]
formatted_name: Optional[str] = None
"""The full name, including all middle names, titles, and suffixes as
appropriate, formatted for display (e.g., "Ms. Barbara Jane Jensen,
III")."""
display_name: Optional[str]
display_name: Optional[str] = None
"""The name of the user, suitable for display to end-users.
Each user returned MAY include a non-empty displayName value. The
@ -134,7 +134,7 @@ class User(Model):
when presenting it to end-users.
"""
emails: List[str]
emails: List[str] = []
"""Email addresses for the User.
The value SHOULD be specified according to [RFC5321]. Service
@ -148,7 +148,7 @@ class User(Model):
at the discretion of SCIM clients.
"""
phone_numbers: List[str]
phone_numbers: List[str] = []
"""Phone numbers for the user.
The value SHOULD be specified according to the format defined in
@ -161,14 +161,14 @@ class User(Model):
defined by the SCIM clients.
"""
formatted_address: Optional[str]
formatted_address: Optional[str] = None
"""The full mailing address, formatted for display or use with a mailing
label.
This attribute MAY contain newlines.
"""
street: Optional[str]
street: Optional[str] = None
"""The full street address component, which may include house number,
street name, P.O.
@ -176,16 +176,16 @@ class User(Model):
attribute MAY contain newlines.
"""
postal_code: Optional[str]
postal_code: Optional[str] = None
"""The zip code or postal code component."""
locality: Optional[str]
locality: Optional[str] = None
"""The city or locality component."""
region: Optional[str]
region: Optional[str] = None
"""The state or region component."""
photo: Optional[str]
photo: Optional[str] = None
"""A URI that is a uniform resource locator (as defined in Section 1.1.3 of
[RFC3986]) that points to a resource location representing the user's
image.
@ -203,7 +203,7 @@ class User(Model):
sizes: "photo" and "thumbnail".
"""
profile_url: Optional[str]
profile_url: Optional[str] = None
"""A URI that is a uniform resource locator (as defined in Section 1.1.3 of
[RFC3986]) and that points to a location representing the user's online
profile (e.g., a web page).
@ -211,21 +211,21 @@ class User(Model):
URIs are canonicalized per Section 6.2 of [RFC3986].
"""
title: Optional[str]
title: Optional[str] = None
"""The user's title, such as "Vice President"."""
organization: Optional[str]
organization: Optional[str] = None
"""Identifies the name of an organization."""
employee_number: Optional[str]
employee_number: Optional[str] = None
"""A string identifier, typically numeric or alphanumeric, assigned to a
person, typically based on order of hire or association with an
organization."""
department: Optional[str]
department: Optional[str] = None
"""Identifies the name of a department."""
groups: List["Group"]
groups: List["Group"] = []
"""A list of groups to which the user belongs, either through direct
membership, through nested groups, or dynamically calculated.
@ -251,7 +251,7 @@ class User(Model):
"readOnly".
"""
lock_date: Optional[datetime.datetime]
lock_date: Optional[datetime.datetime] = None
"""A DateTime indicating when the resource was locked."""
def __init__(self, *args, **kwargs):
@ -327,7 +327,7 @@ class Group(Model):
REQUIRED.
"""
members: List["User"]
members: List["User"] = []
"""A list of members of the Group.
While values MAY be added or removed, sub-attributes of members are
@ -341,4 +341,4 @@ class Group(Model):
"Group" resource schema.
"""
description: Optional[str]
description: Optional[str] = None

View file

@ -17,9 +17,9 @@ class Client(Model):
"""
id: str
description: Optional[str]
preconsent: Optional[bool]
audience: List["Client"]
description: Optional[str] = None
preconsent: Optional[bool] = False
audience: List["Client"] = []
client_id: Optional[str]
"""REQUIRED.
@ -30,7 +30,7 @@ class Client(Model):
a registered client at its discretion.
"""
client_secret: Optional[str]
client_secret: Optional[str] = None
"""OPTIONAL.
OAuth 2.0 client secret string. If issued, this MUST be unique for
@ -40,7 +40,7 @@ class Client(Model):
described in OAuth 2.0 [RFC6749], Section 2.3.1.
"""
client_id_issued_at: Optional[datetime.datetime]
client_id_issued_at: Optional[datetime.datetime] = None
"""OPTIONAL.
Time at which the client identifier was issued. The time is
@ -48,7 +48,7 @@ class Client(Model):
measured in UTC until the date/time of issuance.
"""
client_secret_expires_at: Optional[datetime.datetime]
client_secret_expires_at: Optional[datetime.datetime] = None
"""REQUIRED if "client_secret" is issued.
Time at which the client secret will expire or 0 if it will not
@ -57,7 +57,7 @@ class Client(Model):
expiration.
"""
redirect_uris: List[str]
redirect_uris: List[str] = []
"""Array of redirection URI strings for use in redirect-based flows such as
the authorization code and implicit flows.
@ -67,7 +67,7 @@ class Client(Model):
redirect-based flows MUST implement support for this metadata value.
"""
token_endpoint_auth_method: Optional[str]
token_endpoint_auth_method: Optional[str] = None
"""String indicator of the requested authentication method for the token
endpoint. Values defined by this specification are:
@ -88,7 +88,7 @@ class Client(Model):
authentication scheme as specified in Section 2.3.1 of OAuth 2.0.
"""
grant_types: List[str]
grant_types: List[str] = ["authorization_code", "refresh_token"]
"""Array of OAuth 2.0 grant type strings that the client can use at the
token endpoint. These grant types are defined as follows:
@ -124,7 +124,7 @@ class Client(Model):
client will use only the "authorization_code" Grant Type.
"""
response_types: List[str]
response_types: List[str] = []
"""
Array of the OAuth 2.0 response type strings that the client can
use at the authorization endpoint. These response types are
@ -145,7 +145,7 @@ class Client(Model):
default is that the client will use only the "code" response type.
"""
client_name: Optional[str]
client_name: Optional[str] = None
"""Human-readable string name of the client to be presented to the end-user
during authorization.
@ -155,7 +155,7 @@ class Client(Model):
internationalized, as described in Section 2.2.
"""
client_uri: Optional[str]
client_uri: Optional[str] = None
"""URL string of a web page providing information about the client.
If present, the server SHOULD display this URL to the end-user in a
@ -165,7 +165,7 @@ class Client(Model):
Section 2.2.
"""
logo_uri: Optional[str]
logo_uri: Optional[str] = None
"""URL string that references a logo for the client.
If present, the server SHOULD display this image to the end-user
@ -174,7 +174,7 @@ class Client(Model):
described in Section 2.2.
"""
scope: List[str]
scope: List[str] = []
"""String containing a space-separated list of scope values (as described
in Section 3.3 of OAuth 2.0 [RFC6749]) that the client can use when
requesting access tokens.
@ -184,7 +184,7 @@ class Client(Model):
default set of scopes.
"""
contacts: List[str]
contacts: List[str] = None
"""Array of strings representing ways to contact people responsible for
this client, typically email addresses.
@ -193,7 +193,7 @@ class Client(Model):
information on Privacy Considerations.
"""
tos_uri: Optional[str]
tos_uri: Optional[str] = None
"""URL string that points to a human-readable terms of service document for
the client that describes a contractual relationship between the end-user
and the client that the end-user accepts when authorizing the client.
@ -204,7 +204,7 @@ class Client(Model):
described in Section 2.2.
"""
policy_uri: Optional[str]
policy_uri: Optional[str] = None
"""URL string that points to a human-readable privacy policy document that
describes how the deployment organization collects, uses, retains, and
discloses personal data.
@ -215,7 +215,7 @@ class Client(Model):
described in Section 2.2.
"""
jwks_uri: Optional[str]
jwks_uri: Optional[str] = None
"""URL string referencing the client's JSON Web Key (JWK) Set [RFC7517]
document, which contains the client's public keys.
@ -229,7 +229,7 @@ class Client(Model):
parameters MUST NOT both be present in the same request or response.
"""
jwk: Optional[str]
jwk: Optional[str] = None
"""Client's JSON Web Key Set [RFC7517] document value, which contains the
client's public keys.
@ -241,7 +241,7 @@ class Client(Model):
parameters MUST NOT both be present in the same request or response.
"""
software_id: Optional[str]
software_id: Optional[str] = None
"""A unique identifier string (e.g., a Universally Unique Identifier
(UUID)) assigned by the client developer or software publisher used by
registration endpoints to identify the client software to be dynamically
@ -256,7 +256,7 @@ class Client(Model):
authorization server.
"""
software_version: Optional[str]
software_version: Optional[str] = None
"""A version identifier string for the client software identified by
"software_id".
@ -272,7 +272,7 @@ class Client(Model):
itself and is outside the scope of this specification.
"""
post_logout_redirect_uris: List[str]
post_logout_redirect_uris: List[str] = []
"""OPTIONAL.
Array of URLs supplied by the RP to which it MAY request that the