예제 #1
0
    def getItemType(self, title, returned_properties=None):
        """Get the :class:`rtcclient.models.ItemType` object by the title

        :param title: the title (e.g. Story/Epic/..)
        :param returned_properties: the returned properties that you want.
            Refer to :class:`rtcclient.client.RTCClient` for more explanations
        :return: the :class:`rtcclient.models.ItemType` object
        :rtype: rtcclient.models.ItemType
        """

        if not isinstance(title, six.string_types) or not title:
            excp_msg = "Please specify a valid email address name"
            self.log.error(excp_msg)
            raise exception.BadValue(excp_msg)

        self.log.debug("Try to get <ItemType %s>", title)
        itemtypes = self._getItemTypes(returned_properties=returned_properties,
                                       title=title)
        if itemtypes is not None:
            itemtype = itemtypes[0]
            self.log.info("Get <ItemType %s> in <ProjectArea %s>", itemtype,
                          self)
            return itemtype

        excp_msg = "No itemtype's name is %s in <ProjectArea %s>" % (title,
                                                                     self)
        self.log.error(excp_msg)
        raise exception.NotFound(excp_msg)
예제 #2
0
    def getAdministrator(self, email, returned_properties=None):
        """Get the :class:`rtcclient.models.Administrator` object
        by the email address

        :param email: the email address (e.g. [email protected])
        :param returned_properties: the returned properties that you want.
            Refer to :class:`rtcclient.client.RTCClient` for more explanations
        :return: the :class:`rtcclient.models.Administrator` object
        :rtype: rtcclient.models.Administrator
        """

        if not isinstance(email, six.string_types) or "@" not in email:
            excp_msg = "Please specify a valid email address name"
            self.log.error(excp_msg)
            raise exception.BadValue(excp_msg)

        self.log.debug("Try to get Administrator whose email is %s", email)
        rp = returned_properties
        administrators = self._getAdministrators(returned_properties=rp,
                                                 email=email)
        if administrators is not None:
            administrator = administrators[0]
            self.log.info("Get <Administrator %s> in <ProjectArea %s>",
                          administrator, self)
            return administrator

        msg = "No administrator's email is %s in <ProjectArea %s>" % (email,
                                                                      self)
        self.log.error(msg)
        raise exception.NotFound(msg)
예제 #3
0
    def getAction(self, action_name):
        """Get the :class:`rtcclient.models.Action` object by its name

        :param action_name: the name/title of the action
        :return: the :class:`rtcclient.models.Action` object
        :rtype: rtcclient.models.Action
        """

        self.log.debug("Try to get <Action %s>", action_name)
        if not isinstance(action_name, six.string_types) or not action_name:
            excp_msg = "Please specify a valid action name"
            self.log.error(excp_msg)
            raise exception.BadValue(excp_msg)

        actions = self._getActions(action_name=action_name)

        if actions is not None:
            action = actions[0]
            self.log.info("Find <Action %s>", action)
            return action

        self.log.error("No Action named %s", action_name)
        raise exception.NotFound("No Action named %s" % action_name)
예제 #4
0
    def getRole(self, label):
        """Get the :class:`rtcclient.models.Role` object by the label name

        :param label: the label name of the role
        :return: the :class:`rtcclient.models.Role` object
        :rtype: :class:`rtcclient.models.Role`
        """

        if not isinstance(label, six.string_types) or not label:
            excp_msg = "Please specify a valid role label"
            self.log.error(excp_msg)
            raise exception.BadValue(excp_msg)

        roles = self.getRoles()
        if roles is not None:
            for role in roles:
                if role.label == label:
                    self.log.info("Get <Role %s> in <ProjectArea %s>", role,
                                  self)
                    return role

        excp_msg = "No role's label is %s in <ProjectArea %s>" % (label, self)
        self.log.error(excp_msg)
        raise exception.NotFound(excp_msg)