def put_bucket_acl(bucket_name, gratee_list, permission_list): check_bucket_name(bucket_name=bucket_name) bucketAcl = AccessControlList() for role in gratee_list: grant = Grant(Grantee(role), Permission(permission).get_value()) if role in [UserGroups.ALL_USERS, UserGroups.AUTHENTICATED_USERS]: grant.type = GrantType.GROUP bucketAcl.add_grant(grant) fds_client.set_bucket_acl(bucket_name=bucket_name, acl=bucketAcl)
def delete_bucket_acl(bucket_name, gratee_list, permission_list): check_bucket_name(bucket_name=bucket_name) bucketAcl = AccessControlList() for role in gratee_list: grant = Grant(Grantee(role), Permission(permission_list).get_value()) if role in [UserGroups.ALL_USERS, UserGroups.AUTHENTICATED_USERS]: grant.type = GrantType.GROUP bucketAcl.add_grant(grant) fds_client.delete_bucket_acl(bucket_name=bucket_name, acl=bucketAcl)
def delete_object_acl(bucket_name, object_name, gratee_list, permission_list, is_archive=False): check_bucket_name(bucket_name) check_bucket_name(object_name) object_acl = AccessControlList() for role in gratee_list: grant = Grant(Grantee(role), Permission(permission_list).get_value()) if role in [UserGroups.ALL_USERS, UserGroups.AUTHENTICATED_USERS]: grant.type = GrantType.GROUP object_acl.add_grant(grant) fds_client.delete_object_acl(bucket_name, object_name, object_acl, is_archive=is_archive)
def put_object_acl(bucket_name, object_name, gratee_list, permission_list): check_bucket_name(bucket_name=bucket_name) check_object_name(object_name=object_name) object_acl = AccessControlList() for role in gratee_list: grant = Grant(Grantee(role), Permission(permission_list).get_value()) if role in [UserGroups.ALL_USERS, UserGroups.AUTHENTICATED_USERS]: grant.type = GrantType.GROUP object_acl.add_grant(grant) fds_client.set_object_acl(bucket_name, object_name, object_acl) logger.info('set [%s/%s] acl success', bucket_name, object_name)
def put_object_acl(bucket_name, object_name, gratee_list, permission_list): check_bucket_name(bucket_name=bucket_name) check_object_name(object_name=object_name) object_acl = AccessControlList() for role in gratee_list: grant = Grant(Grantee(role), Permission(permission).get_value()) if role in [UserGroups.ALL_USERS, UserGroups.AUTHENTICATED_USERS]: grant.type = GrantType.GROUP object_acl.add_grant(grant) fds_client.set_object_acl(bucket_name, object_name, object_acl) logger.info('set [%s/%s] acl success', bucket_name, object_name)
def make_public(self, url): if not FDSURL.is_fds_url(url): CLIPrinter.wrong_format() return url = FDSURL(url) if url.is_object_url(): try: self._fds.set_public(url.bucket_name(), url.object_name()) except GalaxyFDSClientException as e: CLIPrinter.fail(e.message) return elif url.is_bucket_url(): try: acl = AccessControlList() grant = Grant(Grantee(UserGroups.ALL_USERS), Permission.READ) grant.type = GrantType.GROUP acl.add_grant(grant) self._fds.set_bucket_acl(url.bucket_name(), acl) except GalaxyFDSClientException as e: CLIPrinter.fail(e.message) return else: CLIPrinter.wrong_format() return
def set_public(self, bucket_name, object_name): acl = AccessControlList() grant = Grant(Grantee(UserGroups.ALL_USERS), Permission.READ) grant.type = GrantType.GROUP acl.add_grant(grant) self.set_object_acl(bucket_name, object_name, acl)