def transfer_resource(self, resource: Resource,
                          receiving_project_uid: Union[str, UUID]) -> bool:
        """
        Transfer ownership of a resource.

        The new owner of the the supplied resource becomes the project
        with ``uid == receiving_project_uid``.

        Parameters
        ----------
        resource: Resource
            The resource owned by this project, which will get transferred to
            the project with ``uid == receiving_project_uid``.
        receiving_project_uid: Union[string, UUID]
            The uid of the project to which the resource will be transferred.

        Returns
        -------
        bool
            Returns ``True`` upon successful resource transfer.

        """
        try:
            self.session.checked_post(
                self._path() + "/transfer-resource", {
                    "to_project_id": str(receiving_project_uid),
                    "resource": resource.as_entity_dict()
                })
        except AttributeError:  # If _resource_type is not implemented
            raise RuntimeError(
                f"Resource of type  {resource.__class__.__name__} "
                f"cannot be made transferred")

        return True
示例#2
0
    def transfer_resource(self, resource: Resource,
                          receiving_project_uid: Union[str, UUID]) -> bool:
        """
        Transfer ownership of a resource.

        The new owner of the the supplied resource becomes the project
        with uid = receiving_project_uid.

        Parameters
        ----------
        resource: Resource
            The resource owned by this project, which will get transferred to
            the project with uid = receiving_project_uid.
        receiving_project_uid: Union[string, UUID]
            The uid of the project to which the resource will be transferred.

        Returns
        -------
        bool
            Returns True upon successful resource transfer.

        """
        self.session.checked_post(self._path() + "/transfer-resource", {
            "to_project_id": str(receiving_project_uid),
            "resource": resource.as_entity_dict()})

        return True
示例#3
0
    def make_private(self, resource: Resource) -> bool:
        """
        Remove public access for a resource owned by this project.

        Parameters
        ----------
        resource: Resource
            An instance of a resource owned by this project (e.g. a dataset).

        Returns
        -------
        bool
            True if the action was performed successfully

        """
        self.session.checked_post(self._path() + "/make-private",
                                  {"resource": resource.as_entity_dict()})
        return True
    def make_private(self, resource: Resource) -> bool:
        """
        Remove public access for a resource owned by this project.

        Parameters
        ----------
        resource: Resource
            An instance of a resource owned by this project (e.g., a dataset).

        Returns
        -------
        bool
            ``True`` if the action was performed successfully

        """
        try:
            self.session.checked_post(self._path() + "/make-private",
                                      {"resource": resource.as_entity_dict()})
        except AttributeError:  # If _resource_type is not implemented
            raise RuntimeError(
                f"Resource of type  {resource.__class__.__name__} "
                f"cannot be made private")
        return True