示例#1
0
 def editResourceCategory(self,
                          resourceCategory,
                          name=None,
                          deleted_at=None,
                          extraParams={}):
     params = {"name": name, "deleted_at": deleted_at, **extraParams}
     return entityRepository.editEntity(resourceCategory, params)
示例#2
0
    def editProtocol(self,
                     protocol,
                     name=None,
                     body=None,
                     deleted_at=None,
                     extraParams={}):
        params = {"name": name, "deleted_at": deleted_at, **extraParams}

        if body is not None:
            entityRepository.editEntity(
                ProtocolVersion(protocol.last_version, protocol.__user__),
                {"state": body},
            )
            protocol.update()

        return entityRepository.editEntity(protocol, params)
示例#3
0
 def disableUser(self, organizationUser):
     params = {
         "deleted_at": getTime(),
     }
     user = User({"id": organizationUser.user['username']})
     user.__user__ = organizationUser.__user__
     return entityRepository.editEntity(user, params)
示例#4
0
    def edit(self, permission=None, extraParams={}):
        """
        Edit a sharelink.

        Parameters
        ----------
        permission (str)
            Set the permission granted by the sharelink
            can be either 'view' or 'edit'

        Returns
        -------
        :class:`~labstep.entities.sharelink.model.Sharelink`
            An object representing the edited Sharelink.

        Example
        -------
        ::

            # Get an experiment
            experiment = user.getExperiment(123)

            # Get the sharelink for the experiment
            sharelink = experiment.getSharelink()

            # Edit the sharelink
            sharelink.edit(type='view')
        """
        from labstep.generic.entity.repository import entityRepository

        fields = {
            "type": permission,
            **extraParams,
        }
        return entityRepository.editEntity(self, fields=fields)
示例#5
0
 def editDataField(self, dataField, fieldName=None, value=None, extraParams={}):
     params = {
         "label": handleString(fieldName),
         "value": handleString(value),
         **extraParams
     }
     return entityRepository.editEntity(dataField, params)
示例#6
0
    def setHome(self):
        """
        Sets this workspace as the default workspace for the active user.
        """
        member = WorkspaceMember(self.logged_user_user_group, self.__user__)
        from labstep.generic.entity.repository import entityRepository

        return entityRepository.editEntity(member, {"is_home": True})
示例#7
0
    def editJupyterInstance(self,
                            jupyterInstance,
                            startedAt=None,
                            endedAt=None):
        params = {
            "started_at": startedAt,
            "ended_at": endedAt,
        }

        return entityRepository.editEntity(jupyterInstance, params)
示例#8
0
    def editProtocolMaterial(self, protocol_material, name=None, amount=None, units=None, resource_id=None, extraParams={}):
        params = {
            "name": name,
            "value": amount,
            "units": units,
            "resource_id": resource_id,
            **extraParams
        }

        return entityRepository.editEntity(protocol_material, params)
示例#9
0
    def edit(
        self,
        experiment_sharing=None,
        protocol_sharing=None,
        resource_sharing=None,
        extraParams={},
    ):
        """
        Edit an autosharing policy.

        Parameters
        ----------
        experiment_sharing (str)
            Automatically share experiments
            you create and own with this workspace. Set to True or False

        protocol_sharing (str)
            Automatically share protocols
            you create and own with this workspace. Set to True or False

        resource_sharing (str)
            Automatically share resources
            you create and own with this workspace. Set to True or False


        Returns
        -------
        :class:`~labstep.entities.autoshare.model.Autoshare`
            An object representing the Autosharing policy.

        Example
        -------
        ::

            # Get an workspace
            workspace = user.getExperiment(123)

            # Get the sharelink for the experiment
            sharelink = experiment.getSharelink()

            # Edit the sharelink
            sharelink.edit(type='view')
        """
        from labstep.generic.entity.repository import entityRepository

        options = {True: "edit", False: "none", None: None}

        fields = {
            "experiment_workflow": options[experiment_sharing],
            "protocol_collection": options[protocol_sharing],
            "resource": options[resource_sharing],
            **extraParams,
        }
        return entityRepository.editEntity(self, fields=fields)
示例#10
0
 def editMetadata(self,
                  metadata,
                  fieldName=None,
                  value=None,
                  extraParams={}):
     params = {
         "label": handleString(fieldName),
         "value": handleString(value),
         **extraParams
     }
     return entityRepository.editEntity(metadata, params)
示例#11
0
    def delete(self):
        """
        Delete a DeviceData.

        Example
        -------
        ::

            deviceData.delete()
        """
        from labstep.generic.entity.repository import entityRepository

        return entityRepository.editEntity(self, fields={"deleted_at": getTime()})
示例#12
0
    def cancel(self):
        """
        Cancels the signature request.

        Returns
        -------
        :class:`~labstep.entities.experimentSignatureRequest.model.ExperimentSignatureRequest`
            An object representing the revoked signature.
        """
        from labstep.generic.entity.repository import entityRepository

        fields = {"deleted_at": getTime()}
        return entityRepository.editEntity(self, fields)
示例#13
0
 def editResource(
     self,
     resource,
     name=None,
     deleted_at=None,
     resource_category_id=None,
     extraParams={},
 ):
     params = {
         "name": name,
         "template_id": resource_category_id,
         "deleted_at": deleted_at,
         **extraParams,
     }
     return entityRepository.editEntity(resource, params)
示例#14
0
    def editJupyterNotebook(
        self,
        jupyterNotebook,
        name=None,
        status=None,
        data=None,
        extraParams={},
    ):
        params = {
            "name": name,
            "status": status,
            "data": data,
            **extraParams,
        }

        return entityRepository.editEntity(jupyterNotebook, params)
示例#15
0
    def edit(self,
             name=None,
             hours=None,
             minutes=None,
             seconds=None,
             extraParams={}):
        """
        Edit an existing Protocol Timer.

        Parameters
        ----------
        name (str)
            The name of the timer.
        hours (int)
            The hours of the timer.
        minutes (int)
            The minutes of the timer.
        seconds (int)
            The seconds of the timer.

        Returns
        -------
        :class:`~labstep.entities.protocolTimer.model.ProtocolTimer`
            An object representing the edited Protocol Timer.

        Example
        -------
        ::

            protocol = user.getProtocol(17000)
            protocol_timers = protocol.getTimers()
            protocol_timers[0].edit(name='New Timer Name',
                                    minutes=1, seconds=17)
        """
        from labstep.generic.entity.repository import entityRepository

        params = {"name": name, **extraParams}

        if hours is not None:
            params["hours"] = hours
        if minutes is not None:
            params["minutes"] = minutes
        if seconds is not None:
            params["seconds"] = seconds

        return entityRepository.editEntity(self, params)
示例#16
0
    def edit(self, name=None, data=None):
        """
        Edit an existing Experiment Table.

        Parameters
        ----------
        name (str)
            The name of the Experiment Table.
        data (str)
            The data of the table.

        Returns
        -------
        :class:`~labstep.entities.experimentTable.model.ExperimentTable`
            An object representing the edited Experiment Table.

        Example
        -------
        ::

            experiment = user.getExperiment(17000)
            exp_protocol = experiment.getProtocols()[0]
            exp_protocol_tables = exp_protocol.getTables()
            data = {
                "rowCount": 12,
                "columnCount": 12,
                "colHeaderData": {},
                "data": {
                    "dataTable": {
                        0: {
                            0: {
                                "value": 'Cell A1'
                            },
                            1: {
                                "value": 'Cell B1'
                            }
                        }
                    }
                }
            }
            exp_protocol_tables[0].edit(data=data)
        """
        from labstep.generic.entity.repository import entityRepository

        params = {"name": name, "data": data}
        return entityRepository.editEntity(self, params)
示例#17
0
    def edit(self,
             name=None,
             body=None,
             started_at=None,
             ended_at=None,
             extraParams={}):
        """
        Edit an existing ExperimentProtocol.

        Parameters
        ----------
        name (str)
            The new name of the ExperimentProtocol.
        body (dict)
            A JSON object representing the new body of the ExperimentProtocol.
        started_at (str)
            The date the ExperimentProtocol was started
            in the format of "YYYY-MM-DD HH:MM".
        ended_at (str)
            The date the ExperimentProtocol was finished
            in the format of "YYYY-MM-DD HH:MM".

        Returns
        -------
        :class:`~labstep.entities.experimentProtocol.model.ExperimentProtocol`
            An object representing the edited ExperimentProtocol.

        Example
        -------
        ::

            my_experiment = user.getExperiment(17000)
            protocols = my_experiment.getProtocols()
            protocols[0].edit(name='A New Experiment Name',
                               started_at='2018-06-06 12:05')
        """
        from labstep.generic.entity.repository import entityRepository

        fields = {
            "name": name,
            "state": body,
            "started_at": started_at,
            "ended_at": ended_at,
            **extraParams,
        }
        return entityRepository.editEntity(self, fields)
示例#18
0
    def edit(self, name=None, data=None, extraParams={}):
        """
        Edit an existing Protocol Table.

        Parameters
        ----------
        name (str)
            The name of the Protocol Table.
        data (str)
            The data of the table in json format.

        Returns
        -------
        :class:`~labstep.entities.protocolTable.model.ProtocolTable`
            An object representing the edited Protocol Table.

        Example
        -------
        ::

            data = {
                "rowCount": 6,
                "columnCount": 6,
                "colHeaderData": {},
                "data": {
                    "dataTable": {
                        0: {
                            0: {
                                "value": 'Cell A1'
                            },
                            1: {
                                "value": 'Cell B1'
                            }
                        }
                    }
                }
            }

            protocol = user.getProtocol(17000)
            protocol_tables = protocol.getTables()
            protocol_tables[0].edit(name='New Table Name', data=data)
        """
        from labstep.generic.entity.repository import entityRepository

        params = {"name": name, "data": data, **extraParams}
        return entityRepository.editEntity(self, params)
示例#19
0
    def edit(self, completed_at=None):
        """
        Edit an existing Experiment Step.

        Parameters
        ----------
        completed_at (str)
            The datetime at which the Experiment Step was completed.

        Returns
        -------
        :class:`~labstep.entities.experimentStep.model.ExperimentStep`
            An object representing the edited Experiment Step.
        """
        from labstep.generic.entity.repository import entityRepository

        params = {"ended_at": completed_at}
        return entityRepository.editEntity(self, params)
示例#20
0
    def editTag(self, tag, name, extraParams={}):
        """
        Edit the name of an existing Tag.

        Parameters
        ----------
        tag (obj)
            The Tag to edit.
        name (str)
            The new name of the Tag.

        Returns
        -------
        tag
            An object representing the edited Tag.
        """
        params = {"name": name, **extraParams}
        return entityRepository.editEntity(tag, params)
示例#21
0
    def editExperimentMaterial(self,
                               expermient_material,
                               name=None,
                               amount=None,
                               units=None,
                               resource_id=None,
                               resource_item_id=None,
                               extraParams={}):
        params = {
            "name": name,
            "value": amount,
            "units": units,
            "resource_id": resource_id,
            "resource_item_id": resource_item_id,
            **extraParams
        }

        return entityRepository.editEntity(expermient_material, params)
示例#22
0
    def editExperiment(
        self,
        experiment,
        name=None,
        entry=None,
        started_at=None,
        deleted_at=None,
        extraParams={},
    ):
        params = {
            "name": name,
            "started_at": handleDate(started_at),
            "deleted_at": deleted_at,
            **extraParams,
        }

        if entry is not None:
            experiment.root_experiment.edit(body=entry)
            experiment.update()

        return entityRepository.editEntity(experiment, params)
示例#23
0
    def edit(self, hours=None, minutes=None, seconds=None):
        """
        Edit an existing Experiment Timer.

        Parameters
        ----------
        hours (int)
            The hours of the timer.
        minutes (int)
            The minutes of the timer.
        seconds (int)
            The seconds of the timer.

        Returns
        -------
        :class:`~labstep.entities.experimentTimer.model.ExperimentTimer`
            An object representing the edited Experiment Timer.

        Example
        -------
        ::

            experiment = user.getExperiment(17000)
            exp_protocol = experiment.getProtocols()[0]
            exp_protocol_timers = exp_protocol.getTimers()
            exp_protocol_timers[0].edit(minutes=1, seconds=7)
        """
        from labstep.generic.entity.repository import entityRepository

        fields = {}

        if hours is not None:
            fields["hours"] = hours
        if minutes is not None:
            fields["minutes"] = minutes
        if seconds is not None:
            fields["seconds"] = seconds

        return entityRepository.editEntity(self, fields)
示例#24
0
    def editOrderRequest(
        self,
        orderRequest,
        status=None,
        resource_id=None,
        quantity=None,
        price=None,
        currency=None,
        deleted_at=None,
        extraParams={},
    ):
        params = {
            "status": handleKeyword(status),
            "resource_id": resource_id,
            "quantity": quantity,
            "price": price,
            "currency": currency,
            "deleted_at": deleted_at,
            **extraParams,
        }

        return entityRepository.editEntity(orderRequest, params)
示例#25
0
    def editResourceItem(
        self,
        resourceItem,
        name=None,
        availability=None,
        quantity_amount=None,
        quantity_unit=None,
        resource_location_id=None,
        deleted_at=None,
        extraParams={},
    ):
        params = {
            "name": name,
            "status": handleKeyword(availability),
            "resource_location_id": resource_location_id,
            "quantity_unit": quantity_unit,
            "deleted_at": deleted_at,
            **extraParams,
        }

        if quantity_amount is not None:
            params["quantity_amount"] = float(quantity_amount)

        return entityRepository.editEntity(resourceItem, params)
示例#26
0
 def editResourceLocation(self, resourceLocation, name, extraParams={}):
     params = {"name": name, **extraParams}
     return entityRepository.editEntity(resourceLocation, params)
示例#27
0
 def editMemberPermission(self, member, permission):
     params = {
         "type": permission,
     }
     return entityRepository.editEntity(member, params)
示例#28
0
 def editWorkspace(self, workspace, name=None, deleted_at=None, extraParams={}):
     params = {"name": name, "deleted_at": deleted_at, **extraParams}
     return entityRepository.editEntity(workspace, params)
示例#29
0
 def promoteUser(self, organizationUser):
     params = {
         "type": "admin",
     }
     return entityRepository.editEntity(organizationUser, params)
示例#30
0
 def demoteUser(self, organizationUser):
     params = {
         "type": "member",
     }
     return entityRepository.editEntity(organizationUser, params)