| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import typing as t |
| 4 |
import uuid |
| 5 |
|
| 6 |
from globus_sdk._missing import MISSING, MissingType |
| 7 |
from globus_sdk._payload import GlobusPayload |
| 8 |
|
| 9 |
|
| 10 |
class GCSRoleDocument(GlobusPayload): |
| 11 |
""" |
| 12 |
Convenience class for constructing a Role document |
| 13 |
to use as the `data` parameter to `create_role` |
| 14 |
|
| 15 |
:param DATA_TYPE: Versioned document type. |
| 16 |
:param collection: Collection ID for the collection the role will apply to. |
| 17 |
This value is omitted when creating an endpoint |
| 18 |
role or when creating role definitions when creating collections. |
| 19 |
:param principal: Auth identity or group id URN. Should be in the format |
| 20 |
urn:globus:auth:[identity|group]:{uuid of identity or group} |
| 21 |
:param role: Role assigned to the principal. Known values are owner, |
| 22 |
administrator, access_manager, activity_manager, and activity_monitor |
| 23 |
""" |
| 24 |
|
| 25 |
def __init__( |
| 26 |
self, |
| 27 |
DATA_TYPE: str = "role#1.0.0", |
| 28 |
collection: uuid.UUID | str | MissingType = MISSING, |
| 29 |
principal: str | MissingType = MISSING, |
| 30 |
role: str | MissingType = MISSING, |
| 31 |
additional_fields: dict[str, t.Any] | None = None, |
| 32 |
) -> None: |
| 33 |
super().__init__() |
| 34 |
self["DATA_TYPE"] = DATA_TYPE |
| 35 |
self["collection"] = collection |
| 36 |
self["principal"] = principal |
| 37 |
self["role"] = role |
| 38 |
self.update(additional_fields or {}) |