def delete_attachments(url=None, headers=None, issue_key=None, attachment_id=None): """" Delete all issue attachments or only one attachment depending on the input """ if issue_key is not None and attachment_id is None: attachments_id_list = JiraIssue.get_issue_attachments_id( url=url, headers=headers, issue_key=issue_key) for attachment_id in attachments_id_list: JiraAttachments.delete_attachments(url=url, headers=headers, attachment_id=attachment_id) elif issue_key is None and attachment_id is not None: return requests.delete("{}/rest/api/2/attachment/{}".format( url, attachment_id), headers=headers) else: print("Error")
def get_issue_attachments_id(self, issue_key=None): assert isinstance(issue_key, str), "issue_key must be a string" return JiraIssue.get_issue_attachments_id(url=self.url, headers=self.header(), issue_key=issue_key)