Code Monkey home page Code Monkey logo

Comments (4)

dwang159 avatar dwang159 commented on July 21, 2024

Custom vendors are supported (for example, see the community-contributed messagebird vendor: https://github.com/linkedin/iris/blob/master/src/iris/vendors/iris_messagebird.py). You'll need to create a vendor class that defines a supports attribute, which defines what modes this vendor supports. Then, you need to define a send() function (e.g. https://github.com/linkedin/iris/blob/master/src/iris/vendors/iris_messagebird.py#L98), which can handle all the logic of calling your API to send the messages.

from iris.

tsimyau1612 avatar tsimyau1612 commented on July 21, 2024

I created a script for handling a custom vendor in /vendors called iris_otpapp_call.py. Like this right?

# Copyright (c) LinkedIn Corporation. All rights reserved. Licensed under the BSD-2 Clause license.
# See LICENSE in the project root for license information.

import logging
import requests
import time
from iris.constants import OTPAPP_CALL_SUPPORT

logger = logging.getLogger(__name__)

class iris_otpapp_call(object):
    supports = frozenset([OTPAPP_CALL_SUPPORT])

    def __init__(self, config):
        self.config = config
        self.modes = {
            OTPAPP_CALL_SUPPORT: self.send_message,
        }

    def send_message(self, message):
        logging.info("##### It's here! #####")
        return "ok"

I have also inserted the custom support like this:

# Copyright (c) LinkedIn Corporation. All rights reserved. Licensed under the BSD-2 Clause license.
# See LICENSE in the project root for license information.

# Headers
XFRAME = ('X-Frame-Options', 'SAMEORIGIN')
XCONTENTTYPEOPTIONS = ('X-Content-Type-Options', 'nosniff')
XXSSPROTECTION = ('X-XSS-Protection', '1; mode=block')

# Avoid using magic strings when referring to the transports vendors support
SMS_SUPPORT = 'sms'
CALL_SUPPORT = 'call'
EMAIL_SUPPORT = 'email'
IM_SUPPORT = 'im'
SLACK_SUPPORT = 'slack'
HIPCHAT_SUPPORT = 'hipchat'
OTPAPP_CALL_SUPPORT = 'otpapp_call'

Also, configuring the iris config file like this:

vendors:
- type: iris_otpapp_call
  name: otpapp_call

And, injecting the database with a new priority and mode like this:

mysql> select * from priority;
+----+-------------+---------+
| id | name        | mode_id |
+----+-------------+---------+
|  8 | urgent      |      26 |
| 17 | high        |       8 |
| 26 | medium      |      35 |
| 35 | low         |      35 |
| 36 | otpapp_call |      37 |
+----+-------------+---------+
5 rows in set (0,00 sec)

mysql> select * from mode;
+----+-------------+
| id | name        |
+----+-------------+
| 26 | call        |
| 36 | drop        |
| 35 | email       |
| 37 | otpapp_call |
| 17 | slack       |
|  8 | sms         |
+----+-------------+
6 rows in set (0,00 sec)

I have also created a plan that calls the priority: otpapp_call, but the send_message() function still can't be called. What did I miss?

from iris.

dwang159 avatar dwang159 commented on July 21, 2024

You'll need to run the Iris sender for messages to send. make sender should do that in the dev environment. You don't actually need to define a new priority unless you want to; making it available as a contact mode is sufficient as long as users update their default priority -> mode settings.

from iris.

tsimyau1612 avatar tsimyau1612 commented on July 21, 2024

I've run make sender, but this block of code here still couldn't be called

def send_message(self, message):
        logging.info("##### It's here! #####")

from iris.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.