How to use the pyotrs.Article function in pyotrs

To help you get started, we’ve selected a few pyotrs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / insightconnect-plugins / otrs / komand_otrs / actions / update / action.py View on Github external
if params.get("Article"):
            del(params["Article"])
            # helper.clean will not remove empty list. If these are left empty and not removed the plugin will fail
            if "ExcludeMuteNotificationToUserID" in new_article:
                if not new_article["ExcludeMuteNotificationToUserID"]:
                    del(new_article["ExcludeMuteNotificationToUserID"])
            if "ExcludeNotificationToUserID" in new_article:
                if not new_article["ExcludeNotificationToUserID"]:
                    del(new_article["ExcludeNotificationToUserID"])

            if "ForceNotificationToUserID" in new_article:
                if not new_article["ForceNotificationToUserID"]:
                    del(new_article["ForceNotificationToUserID"])


            new_article = Article(new_article)

        # Set attachments
        if params.get("Attachments"):
            new_attachments = params.pop("Attachments")


            for attachment in new_attachments:
                filename = attachment['filename']
                content = attachment['content']
                mimetype = mimetypes.guess_type(filename)
                attachments.append(Attachment.create_basic(Content=content,
                                                           ContentType=
                                                           mimetype[0],
                                                           Filename=filename))

        ticket_id = params.get('TicketID')
github rapid7 / insightconnect-plugins / otrs / komand_otrs / actions / create / action.py View on Github external
raise Exception("Parameter {} was not found. This is required to create a ticket".format(basic_param))
        # left over params added to other_basics
        other_basics = {}
        for k, v in params.items():
            if v:
                other_basics[k] = v
        # build attachments
        attachments = []
        for attachment in new_attachments:
            a = Attachment.create_basic(Content=attachment["content"], ContentType=mimetypes.guess_type(attachment["filename"])[0], Filename=attachment["filename"])
            attachments.append(a)
        # build dynamic fields
        dynamic_fields = list(map(lambda f: DynamicField(**f), new_dynamic_fields))
        # create ticket from basics and all other params
        new_ticket = Ticket.create_basic(**basics)
        new_article = Article(new_article)
        new_attachments = attachments
        new_dynamic_fields = dynamic_fields

        # Create Ticket
        ticket_results = client.ticket_create(
            ticket=new_ticket,
            article=new_article,
            attachments=new_attachments,
            dynamic_fields=new_dynamic_fields,
            **other_basics
        )

        ticket_id = ticket_results.get("TicketID")
        # check if pendingtime is left unmodified
        if params.get("PendingTime").startswith("0001-01-01"):
            del(params["PendingTime"])

pyotrs

Python wrapper for OTRS (using REST API)

MIT
Latest version published 9 months ago

Package Health Score

53 / 100
Full package analysis