| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import abc |
| 4 |
import typing as t |
| 5 |
import uuid |
| 6 |
|
| 7 |
from globus_sdk._internal.remarshal import strseq_listify |
| 8 |
from globus_sdk._missing import MISSING, MissingType |
| 9 |
from globus_sdk._payload import AbstractGlobusPayload |
| 10 |
|
| 11 |
from ._common import ( |
| 12 |
DatatypeCallback, |
| 13 |
DocumentWithInducedDatatype, |
| 14 |
VersionTuple, |
| 15 |
ensure_datatype, |
| 16 |
) |
| 17 |
|
| 18 |
# |
| 19 |
# NOTE -- on the organization of arguments in this module -- |
| 20 |
# |
| 21 |
# The arguments to each collection type are defined explicitly for good type annotations |
| 22 |
# and documentation. |
| 23 |
# However, it's easy for things to get out of sync or different between the various |
| 24 |
# locations, so we need to impose some order on things to make comparisons easy. |
| 25 |
# |
| 26 |
# Complicating this, there are some arguments to specific types which aren't shared |
| 27 |
# by the common base. |
| 28 |
# |
| 29 |
# The rule and rationale used is as follows: |
| 30 |
# - DATA_TYPE is special, and always first |
| 31 |
# - next, the common optional arguments (shared by all) |
| 32 |
# - after that, the specific optional arguments for this type/subtype |
| 33 |
# - 'additional_fields' is special, and always last |
| 34 |
# |
| 35 |
# within those listings of common and specific arguments, the following ordering is |
| 36 |
# maintained: |
| 37 |
# - strings, sorted alphabetically |
| 38 |
# - string lists, sorted alphabetically |
| 39 |
# - bools, sorted alphabetically |
| 40 |
# - ints, sorted alphabetically |
| 41 |
# - dicts and other types, sorted alphabetically |
| 42 |
# |
| 43 |
# This makes it possible to do side-by-side comparison of common arguments, to ensure |
| 44 |
# that they are all present and accounted-for in all contexts, and allows us to compare |
| 45 |
# definition lists for param docs and arguments against usage sites to ensure that all |
| 46 |
# arguments which are passed are actually used |
| 47 |
# |
| 48 |
|
| 49 |
|
| 50 |
def _user_message_length_callback( |
| 51 |
obj: DocumentWithInducedDatatype, |
| 52 |
) -> VersionTuple | None: |
| 53 |
if ( |
| 54 |
"user_message" in obj |
| 55 |
and isinstance(obj["user_message"], str) |
| 56 |
and len(obj["user_message"]) > 64 |
| 57 |
): |
| 58 |
return (1, 7, 0) |
| 59 |
return None |
| 60 |
|
| 61 |
|
| 62 |
# Declare a metaclass of ABCMeta even though inheriting from `Payload` renders it |
| 63 |
# inert. This will let type checkers understand that this class is abstract. |
| 64 |
class CollectionDocument(AbstractGlobusPayload): |
| 65 |
""" |
| 66 |
This is the base class for :class:`~.MappedCollectionDocument` and |
| 67 |
:class:`~.GuestCollectionDocument`. |
| 68 |
|
| 69 |
Parameters common to both of those are defined and documented here. |
| 70 |
|
| 71 |
:param data_type: Explicitly set the ``DATA_TYPE`` value for this collection. |
| 72 |
Normally ``DATA_TYPE`` is deduced from the provided parameters and should not be |
| 73 |
set. To maximize compatibility with different versions of GCS, only set this |
| 74 |
value when necessary. |
| 75 |
|
| 76 |
:param collection_base_path: The location of the collection on its underlying |
| 77 |
storage. For a mapped collection, this is an absolute path on the storage system |
| 78 |
named by the ``storage_gateway_id``. For a guest collection, this is a path |
| 79 |
relative to the value of the ``root_path`` attribute on the mapped collection |
| 80 |
identified by the ``mapped_collection_id``. This parameter is optional for |
| 81 |
updates but required when creating a new collection. |
| 82 |
:param contact_email: Email address of the support contact for the collection |
| 83 |
:param contact_info: Other contact information for the collection, e.g. phone number |
| 84 |
or mailing address |
| 85 |
:param default_directory: Default directory when using the collection |
| 86 |
:param department: The department which operates the collection |
| 87 |
:param description: A text description of the collection |
| 88 |
:param display_name: Friendly name for the collection |
| 89 |
:param identity_id: The Globus Auth identity which acts as the owner of the |
| 90 |
collection |
| 91 |
:param info_link: Link for more info about the collection |
| 92 |
:param organization: The organization which maintains the collection |
| 93 |
:param restrict_transfers_to_high_assurance: Require that transfers of the |
| 94 |
given type involve only collections that are high assurance. |
| 95 |
Valid values: "inbound", "outbound", "all", None |
| 96 |
:param user_message: A message to display to users when interacting with this |
| 97 |
collection |
| 98 |
:param user_message_link: A link to additional messaging for users when interacting |
| 99 |
with this collection |
| 100 |
|
| 101 |
:param keywords: A list of keywords used to help searches for the collection |
| 102 |
|
| 103 |
:param disable_verify: Disable verification checksums on transfers to and from this |
| 104 |
collection |
| 105 |
:param enable_https: Enable or disable HTTPS support (requires a managed endpoint) |
| 106 |
:param force_encryption: When set to True, all transfers to and from the collection |
| 107 |
are always encrypted |
| 108 |
:param force_verify: Force verification checksums on transfers to and from this |
| 109 |
collection |
| 110 |
:param public: If True, the collection will be visible to other Globus users |
| 111 |
|
| 112 |
:param acl_expiration_mins: Length of time that guest collection permissions are |
| 113 |
valid. Only settable on HA guest collections and HA mapped collections and |
| 114 |
used by guest collections attached to it. When set on both the mapped and guest |
| 115 |
collections, the lesser value is in effect. |
| 116 |
|
| 117 |
:param associated_flow_policy: Policy describing Globus flows to run when the |
| 118 |
collection is accessed. See |
| 119 |
https://docs.globus.org/api/transfer/endpoints_and_collections/#associated_flow_policy |
| 120 |
for expected shape. |
| 121 |
|
| 122 |
:param additional_fields: Additional data for inclusion in the collection document |
| 123 |
""" |
| 124 |
|
| 125 |
DATATYPE_BASE: str = "collection" |
| 126 |
DATATYPE_VERSION_IMPLICATIONS: dict[str, tuple[int, int, int]] = { |
| 127 |
"associated_flow_policy": (1, 15, 0), |
| 128 |
"activity_notification_policy": (1, 14, 0), |
| 129 |
"auto_delete_timeout": (1, 13, 0), |
| 130 |
"skip_auto_delete": (1, 13, 0), |
| 131 |
"restrict_transfers_to_high_assurance": (1, 12, 0), |
| 132 |
"acl_expiration_mins": (1, 10, 0), |
| 133 |
"delete_protected": (1, 8, 0), |
| 134 |
"guest_auth_policy_id": (1, 6, 0), |
| 135 |
"disable_anonymous_writes": (1, 5, 0), |
| 136 |
"force_verify": (1, 4, 0), |
| 137 |
"sharing_users_allow": (1, 2, 0), |
| 138 |
"sharing_users_deny": (1, 2, 0), |
| 139 |
"enable_https": (1, 1, 0), |
| 140 |
"user_message": (1, 1, 0), |
| 141 |
"user_message_link": (1, 1, 0), |
| 142 |
} |
| 143 |
DATATYPE_VERSION_CALLBACKS: tuple[DatatypeCallback, ...] = ( |
| 144 |
_user_message_length_callback, |
| 145 |
) |
| 146 |
|
| 147 |
def __init__( |
| 148 |
self, |
| 149 |
*, |
| 150 |
# data_type |
| 151 |
data_type: str | MissingType = MISSING, |
| 152 |
# strs |
| 153 |
collection_base_path: str | MissingType = MISSING, |
| 154 |
contact_email: str | None | MissingType = MISSING, |
| 155 |
contact_info: str | None | MissingType = MISSING, |
| 156 |
default_directory: str | MissingType = MISSING, |
| 157 |
department: str | None | MissingType = MISSING, |
| 158 |
description: str | None | MissingType = MISSING, |
| 159 |
display_name: str | MissingType = MISSING, |
| 160 |
identity_id: uuid.UUID | str | MissingType = MISSING, |
| 161 |
info_link: str | None | MissingType = MISSING, |
| 162 |
organization: str | MissingType = MISSING, |
| 163 |
restrict_transfers_to_high_assurance: ( |
| 164 |
t.Literal["inbound", "outbound", "all"] | MissingType |
| 165 |
) = MISSING, |
| 166 |
user_message: str | None | MissingType = MISSING, |
| 167 |
user_message_link: str | None | MissingType = MISSING, |
| 168 |
# str lists |
| 169 |
keywords: t.Iterable[str] | MissingType = MISSING, |
| 170 |
# bools |
| 171 |
disable_verify: bool | MissingType = MISSING, |
| 172 |
enable_https: bool | MissingType = MISSING, |
| 173 |
force_encryption: bool | MissingType = MISSING, |
| 174 |
force_verify: bool | MissingType = MISSING, |
| 175 |
public: bool | MissingType = MISSING, |
| 176 |
# ints |
| 177 |
acl_expiration_mins: int | MissingType = MISSING, |
| 178 |
# dicts |
| 179 |
associated_flow_policy: dict[str, t.Any] | MissingType = MISSING, |
| 180 |
# additional fields |
| 181 |
additional_fields: dict[str, t.Any] | MissingType = MISSING, |
| 182 |
) -> None: |
| 183 |
super().__init__() |
| 184 |
self["collection_type"] = self.collection_type |
| 185 |
self["DATA_TYPE"] = data_type |
| 186 |
self["collection_base_path"] = collection_base_path |
| 187 |
self["contact_email"] = contact_email |
| 188 |
self["contact_info"] = contact_info |
| 189 |
self["default_directory"] = default_directory |
| 190 |
self["department"] = department |
| 191 |
self["description"] = description |
| 192 |
self["display_name"] = display_name |
| 193 |
self["identity_id"] = identity_id |
| 194 |
self["info_link"] = info_link |
| 195 |
self["organization"] = organization |
| 196 |
self["restrict_transfers_to_high_assurance"] = ( |
| 197 |
restrict_transfers_to_high_assurance |
| 198 |
) |
| 199 |
self["user_message"] = user_message |
| 200 |
self["user_message_link"] = user_message_link |
| 201 |
self["keywords"] = strseq_listify(keywords) |
| 202 |
self["disable_verify"] = disable_verify |
| 203 |
self["enable_https"] = enable_https |
| 204 |
self["force_encryption"] = force_encryption |
| 205 |
self["force_verify"] = force_verify |
| 206 |
self["public"] = public |
| 207 |
self["acl_expiration_mins"] = acl_expiration_mins |
| 208 |
self["associated_flow_policy"] = associated_flow_policy |
| 209 |
|
| 210 |
if additional_fields is not MISSING: |
| 211 |
self.update(additional_fields) |
| 212 |
|
| 213 |
@property |
| 214 |
@abc.abstractmethod |
| 215 |
def collection_type(self) -> str: |
| 216 |
raise NotImplementedError |
| 217 |
|
| 218 |
|
| 219 |
class MappedCollectionDocument(CollectionDocument): |
| 220 |
""" |
| 221 |
An object used to represent a Mapped Collection for creation or update operations. |
| 222 |
The initializer supports all writable fields on Mapped Collections but does not |
| 223 |
include read-only fields like ``id``. |
| 224 |
|
| 225 |
Because these documents may be used for updates, no fields are strictly required. |
| 226 |
However, GCS will require the following fields for creation: |
| 227 |
|
| 228 |
- ``storage_gateway_id`` |
| 229 |
- ``collection_base_path`` |
| 230 |
|
| 231 |
All parameters for :class:`~.CollectionDocument` are supported in addition to the |
| 232 |
parameters below. |
| 233 |
|
| 234 |
:param storage_gateway_id: The ID of the storage gateway which hosts this mapped |
| 235 |
collection. This parameter is required when creating a collection. |
| 236 |
|
| 237 |
:param domain_name: DNS name of the virtual host serving this collection |
| 238 |
:param guest_auth_policy_id: Globus Auth policy ID to set on a mapped collection |
| 239 |
which is then inherited by its guest collections. |
| 240 |
|
| 241 |
:param sharing_users_allow: Connector-specific usernames allowed to create guest |
| 242 |
collections |
| 243 |
:param sharing_users_deny: Connector-specific usernames forbidden from creating |
| 244 |
guest collections |
| 245 |
|
| 246 |
:param delete_protected: Enable or disable deletion protection on this collection. |
| 247 |
Defaults to ``True`` during creation. |
| 248 |
|
| 249 |
:param allow_guest_collections: Enable or disable creation and use of Guest |
| 250 |
Collections on this Mapped Collection |
| 251 |
:param disable_anonymous_writes: Allow anonymous write ACLs on Guest Collections |
| 252 |
attached to this Mapped Collection. This option is only usable on non |
| 253 |
high-assurance collections |
| 254 |
|
| 255 |
:param auto_delete_timeout: Delete child guest collections that have not been |
| 256 |
accessed within the specified timeout period in days. |
| 257 |
|
| 258 |
:param policies: Connector-specific collection policies |
| 259 |
:param sharing_restrict_paths: A PathRestrictions document |
| 260 |
""" |
| 261 |
|
| 262 |
@property |
| 263 |
def collection_type(self) -> str: |
| 264 |
return "mapped" |
| 265 |
|
| 266 |
def __init__( |
| 267 |
self, |
| 268 |
*, |
| 269 |
# data type |
| 270 |
data_type: str | MissingType = MISSING, |
| 271 |
# > common args start < |
| 272 |
# strs |
| 273 |
collection_base_path: str | MissingType = MISSING, |
| 274 |
contact_email: str | None | MissingType = MISSING, |
| 275 |
contact_info: str | None | MissingType = MISSING, |
| 276 |
default_directory: str | MissingType = MISSING, |
| 277 |
department: str | None | MissingType = MISSING, |
| 278 |
description: str | None | MissingType = MISSING, |
| 279 |
display_name: str | MissingType = MISSING, |
| 280 |
identity_id: uuid.UUID | str | MissingType = MISSING, |
| 281 |
info_link: str | None | MissingType = MISSING, |
| 282 |
organization: str | MissingType = MISSING, |
| 283 |
restrict_transfers_to_high_assurance: ( |
| 284 |
t.Literal["inbound", "outbound", "all"] | MissingType |
| 285 |
) = MISSING, |
| 286 |
user_message: str | None | MissingType = MISSING, |
| 287 |
user_message_link: str | None | MissingType = MISSING, |
| 288 |
# str lists |
| 289 |
keywords: t.Iterable[str] | MissingType = MISSING, |
| 290 |
# bools |
| 291 |
disable_verify: bool | MissingType = MISSING, |
| 292 |
enable_https: bool | MissingType = MISSING, |
| 293 |
force_encryption: bool | MissingType = MISSING, |
| 294 |
force_verify: bool | MissingType = MISSING, |
| 295 |
public: bool | MissingType = MISSING, |
| 296 |
# ints |
| 297 |
acl_expiration_mins: int | MissingType = MISSING, |
| 298 |
# > common args end < |
| 299 |
# > specific args start < |
| 300 |
# strs |
| 301 |
domain_name: str | MissingType = MISSING, |
| 302 |
guest_auth_policy_id: uuid.UUID | str | None | MissingType = MISSING, |
| 303 |
storage_gateway_id: uuid.UUID | str | MissingType = MISSING, |
| 304 |
# str lists |
| 305 |
sharing_users_allow: t.Iterable[str] | None | MissingType = MISSING, |
| 306 |
sharing_users_deny: t.Iterable[str] | None | MissingType = MISSING, |
| 307 |
sharing_restrict_paths: dict[str, t.Any] | None | MissingType = MISSING, |
| 308 |
# bools |
| 309 |
delete_protected: bool | MissingType = MISSING, |
| 310 |
allow_guest_collections: bool | MissingType = MISSING, |
| 311 |
disable_anonymous_writes: bool | MissingType = MISSING, |
| 312 |
# ints |
| 313 |
auto_delete_timeout: int | MissingType = MISSING, |
| 314 |
# dicts |
| 315 |
associated_flow_policy: dict[str, t.Any] | MissingType = MISSING, |
| 316 |
policies: CollectionPolicies | dict[str, t.Any] | MissingType = MISSING, |
| 317 |
# > specific args end < |
| 318 |
# additional fields |
| 319 |
additional_fields: dict[str, t.Any] | MissingType = MISSING, |
| 320 |
) -> None: |
| 321 |
super().__init__( |
| 322 |
# data type |
| 323 |
data_type=data_type, |
| 324 |
# strings |
| 325 |
collection_base_path=collection_base_path, |
| 326 |
contact_email=contact_email, |
| 327 |
contact_info=contact_info, |
| 328 |
default_directory=default_directory, |
| 329 |
department=department, |
| 330 |
description=description, |
| 331 |
display_name=display_name, |
| 332 |
identity_id=identity_id, |
| 333 |
info_link=info_link, |
| 334 |
organization=organization, |
| 335 |
restrict_transfers_to_high_assurance=restrict_transfers_to_high_assurance, |
| 336 |
user_message=user_message, |
| 337 |
user_message_link=user_message_link, |
| 338 |
# bools |
| 339 |
disable_verify=disable_verify, |
| 340 |
enable_https=enable_https, |
| 341 |
force_encryption=force_encryption, |
| 342 |
force_verify=force_verify, |
| 343 |
public=public, |
| 344 |
# ints |
| 345 |
acl_expiration_mins=acl_expiration_mins, |
| 346 |
# str lists |
| 347 |
keywords=keywords, |
| 348 |
# str dicts |
| 349 |
associated_flow_policy=associated_flow_policy, |
| 350 |
# additional fields |
| 351 |
additional_fields=additional_fields, |
| 352 |
) |
| 353 |
self["domain_name"] = domain_name |
| 354 |
self["restrict_transfers_to_high_assurance"] = ( |
| 355 |
restrict_transfers_to_high_assurance |
| 356 |
) |
| 357 |
self["guest_auth_policy_id"] = guest_auth_policy_id |
| 358 |
self["storage_gateway_id"] = storage_gateway_id |
| 359 |
|
| 360 |
self["sharing_users_allow"] = strseq_listify(sharing_users_allow) |
| 361 |
self["sharing_users_deny"] = strseq_listify(sharing_users_deny) |
| 362 |
|
| 363 |
self["delete_protected"] = delete_protected |
| 364 |
self["allow_guest_collections"] = allow_guest_collections |
| 365 |
self["disable_anonymous_writes"] = disable_anonymous_writes |
| 366 |
self["auto_delete_timeout"] = auto_delete_timeout |
| 367 |
self["sharing_restrict_paths"] = sharing_restrict_paths |
| 368 |
self["policies"] = policies |
| 369 |
ensure_datatype(self) |
| 370 |
|
| 371 |
|
| 372 |
class GuestCollectionDocument(CollectionDocument): |
| 373 |
""" |
| 374 |
An object used to represent a Guest Collection for creation or update operations. |
| 375 |
The initializer supports all writable fields on Guest Collections but does not |
| 376 |
include read-only fields like ``id``. |
| 377 |
|
| 378 |
Because these documents may be used for updates, no fields are strictly required. |
| 379 |
However, GCS will require the following fields for creation: |
| 380 |
|
| 381 |
- ``mapped_collection_id`` |
| 382 |
- ``user_credential_id`` |
| 383 |
- ``collection_base_path`` |
| 384 |
|
| 385 |
All parameters for :class:`~.CollectionDocument` are supported in addition to the |
| 386 |
parameters below. |
| 387 |
|
| 388 |
:param mapped_collection_id: The ID of the mapped collection which hosts this guest |
| 389 |
collection |
| 390 |
:param user_credential_id: The ID of the User Credential which is used to access |
| 391 |
data on this collection. This credential must be owned by the collection’s |
| 392 |
``identity_id``. |
| 393 |
|
| 394 |
:param skip_auto_delete: Indicates whether the collection is exempt from its |
| 395 |
parent mapped collection's automatic deletion policy. |
| 396 |
|
| 397 |
:param activity_notification_policy: Specification for when a notification email |
| 398 |
should be sent to a guest collection ``administrator``, ``activity_manager``, |
| 399 |
and ``activity_monitor`` roles when a transfer task reaches completion. |
| 400 |
""" |
| 401 |
|
| 402 |
@property |
| 403 |
def collection_type(self) -> str: |
| 404 |
return "guest" |
| 405 |
|
| 406 |
def __init__( |
| 407 |
self, |
| 408 |
*, |
| 409 |
# data type |
| 410 |
data_type: str | MissingType = MISSING, |
| 411 |
# > common args start < |
| 412 |
# strs |
| 413 |
collection_base_path: str | MissingType = MISSING, |
| 414 |
contact_email: str | None | MissingType = MISSING, |
| 415 |
contact_info: str | None | MissingType = MISSING, |
| 416 |
default_directory: str | MissingType = MISSING, |
| 417 |
department: str | None | MissingType = MISSING, |
| 418 |
description: str | None | MissingType = MISSING, |
| 419 |
display_name: str | MissingType = MISSING, |
| 420 |
identity_id: uuid.UUID | str | MissingType = MISSING, |
| 421 |
info_link: str | None | MissingType = MISSING, |
| 422 |
organization: str | MissingType = MISSING, |
| 423 |
restrict_transfers_to_high_assurance: ( |
| 424 |
t.Literal["inbound", "outbound", "all"] | MissingType |
| 425 |
) = MISSING, |
| 426 |
user_message: str | None | MissingType = MISSING, |
| 427 |
user_message_link: str | None | MissingType = MISSING, |
| 428 |
# str lists |
| 429 |
keywords: t.Iterable[str] | MissingType = MISSING, |
| 430 |
# bools |
| 431 |
disable_verify: bool | MissingType = MISSING, |
| 432 |
enable_https: bool | MissingType = MISSING, |
| 433 |
force_encryption: bool | MissingType = MISSING, |
| 434 |
force_verify: bool | MissingType = MISSING, |
| 435 |
public: bool | MissingType = MISSING, |
| 436 |
# ints |
| 437 |
acl_expiration_mins: int | MissingType = MISSING, |
| 438 |
# dicts |
| 439 |
associated_flow_policy: dict[str, t.Any] | MissingType = MISSING, |
| 440 |
# > common args end < |
| 441 |
# > specific args start < |
| 442 |
mapped_collection_id: uuid.UUID | str | MissingType = MISSING, |
| 443 |
user_credential_id: uuid.UUID | str | MissingType = MISSING, |
| 444 |
skip_auto_delete: bool | MissingType = MISSING, |
| 445 |
activity_notification_policy: dict[str, list[str]] | MissingType = MISSING, |
| 446 |
# > specific args end < |
| 447 |
# additional fields |
| 448 |
additional_fields: dict[str, t.Any] | MissingType = MISSING, |
| 449 |
) -> None: |
| 450 |
super().__init__( |
| 451 |
# data type |
| 452 |
data_type=data_type, |
| 453 |
# strings |
| 454 |
collection_base_path=collection_base_path, |
| 455 |
contact_email=contact_email, |
| 456 |
contact_info=contact_info, |
| 457 |
default_directory=default_directory, |
| 458 |
department=department, |
| 459 |
description=description, |
| 460 |
display_name=display_name, |
| 461 |
identity_id=identity_id, |
| 462 |
info_link=info_link, |
| 463 |
organization=organization, |
| 464 |
restrict_transfers_to_high_assurance=restrict_transfers_to_high_assurance, |
| 465 |
user_message=user_message, |
| 466 |
user_message_link=user_message_link, |
| 467 |
# bools |
| 468 |
disable_verify=disable_verify, |
| 469 |
enable_https=enable_https, |
| 470 |
force_encryption=force_encryption, |
| 471 |
force_verify=force_verify, |
| 472 |
public=public, |
| 473 |
# ints |
| 474 |
acl_expiration_mins=acl_expiration_mins, |
| 475 |
# str lists |
| 476 |
keywords=keywords, |
| 477 |
# dicts |
| 478 |
associated_flow_policy=associated_flow_policy, |
| 479 |
# additional fields |
| 480 |
additional_fields=additional_fields, |
| 481 |
) |
| 482 |
|
| 483 |
self["mapped_collection_id"] = mapped_collection_id |
| 484 |
self["user_credential_id"] = user_credential_id |
| 485 |
self["skip_auto_delete"] = skip_auto_delete |
| 486 |
self["activity_notification_policy"] = activity_notification_policy |
| 487 |
ensure_datatype(self) |
| 488 |
|
| 489 |
|
| 490 |
class CollectionPolicies(AbstractGlobusPayload): |
| 491 |
""" |
| 492 |
This is the abstract base type for Collection Policies documents to use as the |
| 493 |
``policies`` parameter when creating a MappedCollectionDocument. |
| 494 |
""" |
| 495 |
|
| 496 |
|
| 497 |
class POSIXCollectionPolicies(CollectionPolicies): |
| 498 |
""" |
| 499 |
Convenience class for constructing a Posix Collection Policy |
| 500 |
document to use as the `policies` parameter when creating a |
| 501 |
CollectionDocument |
| 502 |
|
| 503 |
:param DATA_TYPE: Versioned document type. Defaults to the appropriate type for |
| 504 |
this class. |
| 505 |
:param sharing_groups_allow: POSIX groups which are allowed to create guest |
| 506 |
collections. |
| 507 |
:param sharing_groups_deny: POSIX groups which are not allowed to create guest |
| 508 |
collections. |
| 509 |
:param additional_fields: Additional data for inclusion in the policy document |
| 510 |
""" |
| 511 |
|
| 512 |
def __init__( |
| 513 |
self, |
| 514 |
DATA_TYPE: str = "posix_collection_policies#1.0.0", |
| 515 |
sharing_groups_allow: str | t.Iterable[str] | None | MissingType = MISSING, |
| 516 |
sharing_groups_deny: str | t.Iterable[str] | None | MissingType = MISSING, |
| 517 |
additional_fields: dict[str, t.Any] | MissingType = MISSING, |
| 518 |
) -> None: |
| 519 |
super().__init__() |
| 520 |
self["DATA_TYPE"] = DATA_TYPE |
| 521 |
|
| 522 |
self["sharing_groups_allow"] = strseq_listify(sharing_groups_allow) |
| 523 |
self["sharing_groups_deny"] = strseq_listify(sharing_groups_deny) |
| 524 |
|
| 525 |
if additional_fields is not MISSING: |
| 526 |
self.update(additional_fields) |
| 527 |
|
| 528 |
|
| 529 |
class POSIXStagingCollectionPolicies(CollectionPolicies): |
| 530 |
""" |
| 531 |
Convenience class for constructing a Posix Staging Collection Policy |
| 532 |
document to use as the ``policies`` parameter when creating a |
| 533 |
CollectionDocument |
| 534 |
|
| 535 |
:param DATA_TYPE: Versioned document type. Defaults to the appropriate type for |
| 536 |
this class. |
| 537 |
:param sharing_groups_allow: POSIX groups which are allowed to create guest |
| 538 |
collections. |
| 539 |
:param sharing_groups_deny: POSIX groups which are not allowed to create guest |
| 540 |
collections. |
| 541 |
:param additional_fields: Additional data for inclusion in the policy document |
| 542 |
""" |
| 543 |
|
| 544 |
def __init__( |
| 545 |
self, |
| 546 |
DATA_TYPE: str = "posix_staging_collection_policies#1.0.0", |
| 547 |
sharing_groups_allow: str | t.Iterable[str] | None | MissingType = MISSING, |
| 548 |
sharing_groups_deny: str | t.Iterable[str] | None | MissingType = MISSING, |
| 549 |
additional_fields: dict[str, t.Any] | MissingType = MISSING, |
| 550 |
) -> None: |
| 551 |
super().__init__() |
| 552 |
self["DATA_TYPE"] = DATA_TYPE |
| 553 |
self["sharing_groups_allow"] = strseq_listify(sharing_groups_allow) |
| 554 |
self["sharing_groups_deny"] = strseq_listify(sharing_groups_deny) |
| 555 |
|
| 556 |
if additional_fields is not MISSING: |
| 557 |
self.update(additional_fields) |
| 558 |
|
| 559 |
|
| 560 |
class GoogleCloudStorageCollectionPolicies(CollectionPolicies): |
| 561 |
""" |
| 562 |
Convenience class for constructing a Google Cloud Storage Collection Policy |
| 563 |
document to use as the ``policies`` parameter when creating a CollectionDocument |
| 564 |
|
| 565 |
:param DATA_TYPE: Versioned document type. Defaults to the appropriate type for |
| 566 |
this class. |
| 567 |
:param project: Google Cloud Platform project ID that is used by this collection |
| 568 |
:param additional_fields: Additional data for inclusion in the policy document |
| 569 |
""" |
| 570 |
|
| 571 |
def __init__( |
| 572 |
self, |
| 573 |
DATA_TYPE: str = "google_cloud_storage_collection_policies#1.0.0", |
| 574 |
project: str | MissingType = MISSING, |
| 575 |
additional_fields: dict[str, t.Any] | MissingType = MISSING, |
| 576 |
) -> None: |
| 577 |
super().__init__() |
| 578 |
self["DATA_TYPE"] = DATA_TYPE |
| 579 |
self["project"] = project |
| 580 |
if additional_fields is not MISSING: |
| 581 |
self.update(additional_fields) |