Exemplo n.º 1
0
    def create(cls, issue_id, *, properties=None, auto_commit=False):
        """Creates a new Issue object with the properties and tags provided

        Attributes:
            issue_id (str): Unique identifier for the issue object
            account (:obj:`Account`): Account which owns the issue
            properties (dict): Dictionary of properties for the issue object.
        """
        if cls.get(issue_id):
            raise IssueException('Issue {} already exists'.format(issue_id))

        res = Issue()
        res.issue_id = issue_id
        res.issue_type_id = IssueType.get(cls.issue_type).issue_type_id

        if properties:
            for name, value in properties.items():
                prop = IssueProperty()
                prop.issue_id = res.issue_id
                prop.name = name
                prop.value = value.isoformat() if type(value) == datetime else value
                res.properties.append(prop)
                db.session.add(prop)

        db.session.add(res)
        if auto_commit:
            db.session.commit()

        return cls.get(res.issue_id)
Exemplo n.º 2
0
    def get(cls, issue_id):
        """Returns the class object identified by `issue_id`

        Args:
            issue_id (str): Unique EC2 Instance ID to load from database

        Returns:
            EC2 Instance object if found, else None
        """
        res = Issue.get(issue_id, IssueType.get(cls.issue_type).issue_type_id)
        return cls(res) if res else None