Exemplo n.º 1
0
 def _GetEntriesClass(self, current_acl):
     # Entries will share the same class, so just return the first one.
     for acl_entry in current_acl:
         return acl_entry.__class__
     # It's possible that a default object ACL is empty, so if we have
     # an empty list, assume it is an object ACL.
     return apitools_messages.ObjectAccessControl().__class__
Exemplo n.º 2
0
# distinguish the default value from when we actually want to remove the CORS
# configuration.  To work around this, we create a dummy CORS entry that
# signifies that we should nullify the CORS configuration.
# A value of [] means don't modify the CORS configuration.
# A value of REMOVE_CORS_CONFIG means remove the CORS configuration.
REMOVE_CORS_CONFIG = [
    apitools_messages.Bucket.CorsValueListEntry(maxAgeSeconds=-1,
                                                method=['REMOVE_CORS_CONFIG'])
]

# Similar to CORS above, we need a sentinel value allowing us to specify
# when a default object ACL should be private (containing no entries).
# A defaultObjectAcl value of [] means don't modify the default object ACL.
# A value of [PRIVATE_DEFAULT_OBJ_ACL] means create an empty/private default
# object ACL.
PRIVATE_DEFAULT_OBJ_ACL = apitools_messages.ObjectAccessControl(
    id='PRIVATE_DEFAULT_OBJ_ACL')


def ObjectMetadataFromHeaders(headers):
    """Creates object metadata according to the provided headers.

  gsutil -h allows specifiying various headers (originally intended
  to be passed to boto in gsutil v3).  For the JSON API to be compatible with
  this option, we need to parse these headers into gsutil_api Object fields.

  Args:
    headers: Dict of headers passed via gsutil -h

  Raises:
    ArgumentException if an invalid header is encountered.