-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement Meta and Resource classes
And tests validation of RFC7643 user examples.
- Loading branch information
Showing
6 changed files
with
302 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
from datetime import datetime | ||
from typing import List | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class Meta(BaseModel): | ||
"""All "meta" sub-attributes are assigned by the service provider (have a | ||
"mutability" of "readOnly"), and all of these sub-attributes have a | ||
"returned" characteristic of "default". | ||
This attribute SHALL be | ||
ignored when provided by clients. "meta" contains the following | ||
sub-attributes: | ||
""" | ||
|
||
resourceType: str | ||
"""The name of the resource type of the resource. | ||
This attribute has a mutability of "readOnly" and "caseExact" as | ||
"true". | ||
""" | ||
|
||
created: datetime | ||
"""The "DateTime" that the resource was added to the service provider. | ||
This attribute MUST be a DateTime. | ||
""" | ||
|
||
lastModified: datetime | ||
"""The most recent DateTime that the details of this resource were updated | ||
at the service provider. | ||
If this resource has never been modified since its initial creation, | ||
the value MUST be the same as the value of "created". | ||
""" | ||
|
||
location: str | ||
"""The URI of the resource being returned. | ||
This value MUST be the same as the "Content-Location" HTTP response | ||
header (see Section 3.1.4.2 of [RFC7231]). | ||
""" | ||
|
||
version: str | ||
"""The version of the resource being returned. | ||
This value must be the same as the entity-tag (ETag) HTTP response | ||
header (see Sections 2.1 and 2.3 of [RFC7232]). This attribute has | ||
"caseExact" as "true". Service provider support for this attribute | ||
is optional and subject to the service provider's support for | ||
versioning (see Section 3.14 of [RFC7644]). If a service provider | ||
provides "version" (entity-tag) for a representation and the | ||
generation of that entity-tag does not satisfy all of the | ||
characteristics of a strong validator (see Section 2.1 of | ||
[RFC7232]), then the origin server MUST mark the "version" (entity- | ||
tag) as weak by prefixing its opaque value with "W/" (case | ||
sensitive). | ||
""" | ||
|
||
|
||
class Resource(BaseModel): | ||
schemas: List[str] | ||
"""The "schemas" attribute is a REQUIRED attribute and is an array of | ||
Strings containing URIs that are used to indicate the namespaces of the | ||
SCIM schemas that define the attributes present in the current JSON | ||
structure. | ||
This attribute may be used by parsers to define the attributes | ||
present in the JSON structure that is the body to an HTTP request or | ||
response. Each String value must be a unique URI. All | ||
representations of SCIM schemas MUST include a non-empty array with | ||
value(s) of the URIs supported by that representation. The | ||
"schemas" attribute for a resource MUST only contain values defined | ||
as "schema" and "schemaExtensions" for the resource's defined | ||
"resourceType". Duplicate values MUST NOT be included. Value order | ||
is not specified and MUST NOT impact behavior. | ||
""" | ||
|
||
# Common attributes as defined by | ||
# https://www.rfc-editor.org/rfc/rfc7643#section-3.1 | ||
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. | ||
""" | ||
|
||
externalId: Optional[str] = None | ||
"""A String that is an identifier for the resource as defined by the | ||
provisioning client. | ||
The "externalId" may simplify identification of a resource between | ||
the provisioning client and the service provider by allowing the | ||
client to use a filter to locate the resource with an identifier | ||
from the provisioning domain, obviating the need to store a local | ||
mapping between the provisioning domain's identifier of the resource | ||
and the identifier used by the service provider. Each resource MAY | ||
include a non-empty "externalId" value. The value of the | ||
"externalId" attribute is always issued by the provisioning client | ||
and MUST NOT be specified by the service provider. The service | ||
provider MUST always interpret the externalId as scoped to the | ||
provisioning domain. While the server does not enforce uniqueness, | ||
it is assumed that the value's uniqueness is controlled by the | ||
client setting the value. See Section 9 for additional | ||
considerations regarding privacy. This attribute has "caseExact" as | ||
"true" and a mutability of "readWrite". This attribute is OPTIONAL. | ||
""" | ||
|
||
meta: Meta | ||
"""A complex attribute containing resource metadata.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.