-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Twilio - 27416 - Updated dependencies | Updated SDK to the latest ver…
…sion
- Loading branch information
1 parent
55f5e0e
commit ff3bacf
Showing
21 changed files
with
378 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{ | ||
"spec": "c44c0f5ab7e3a322044a83acfb10b817", | ||
"manifest": "621d693d051b5c4549806163cea779b7", | ||
"setup": "50e952cec8d2c9a5404f295fcf472b33", | ||
"spec": "e87fd8ad2c7e366705ec83b56f1ee15d", | ||
"manifest": "796fa28ed7a5550eff84aca20e347207", | ||
"setup": "0aa42478906c348fb90dce4ab409e91f", | ||
"schemas": [ | ||
{ | ||
"identifier": "send_sms/schema.py", | ||
"hash": "af20fb89e065530bc9ca6b92313cf3dc" | ||
"hash": "d2bd4c43600e8995db3526323e37d446" | ||
}, | ||
{ | ||
"identifier": "connection/schema.py", | ||
"hash": "08ac8deb36b6dc3f3430221f8c2a20c8" | ||
"hash": "f43143c7fef8d5dff52d63bbff8ece45" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
FROM komand/python-2-plugin:2 | ||
# The three supported python parent images are: | ||
# - komand/python-2-plugin | ||
# - komand/python-3-plugin | ||
# - komand/python-pypy3-plugin | ||
# | ||
# Update the tag to a full semver version | ||
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.2.2 | ||
|
||
# Add any custom package dependencies here | ||
# NOTE: Add pip packages to requirements.txt | ||
LABEL organization=rapid7 | ||
LABEL sdk=python | ||
|
||
# End package dependencies | ||
|
||
# Add source code | ||
WORKDIR /python/src | ||
|
||
ADD ./plugin.spec.yaml /plugin.spec.yaml | ||
ADD . /python/src | ||
ADD ./requirements.txt /python/src/requirements.txt | ||
|
||
# Install pip dependencies | ||
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
|
||
# Install plugin | ||
ADD . /python/src | ||
|
||
RUN python setup.py build && python setup.py install | ||
|
||
ENTRYPOINT ["/usr/local/bin/komand_twilio"] | ||
# User to run plugin code. The two supported users are: root, nobody | ||
USER nobody | ||
|
||
ENTRYPOINT ["/usr/local/bin/komand_twilio"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# GENERATED BY KOMAND SDK - DO NOT EDIT | ||
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT | ||
|
||
from .send_sms.action import SendSms | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# GENERATED BY KOMAND SDK - DO NOT EDIT | ||
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT | ||
from .action import SendSms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
import komand | ||
from .schema import SendSmsInput, SendSmsOutput | ||
import insightconnect_plugin_runtime | ||
from insightconnect_plugin_runtime.exceptions import PluginException | ||
from .schema import SendSmsInput, SendSmsOutput, Input, Output, Component | ||
from twilio.base.exceptions import TwilioRestException | ||
from komand_twilio.util.utils import handle_exception_status_code | ||
|
||
|
||
class SendSms(komand.Action): | ||
class SendSms(insightconnect_plugin_runtime.Action): | ||
def __init__(self): | ||
super(self.__class__, self).__init__( | ||
name="send_sms", | ||
description="Send an SMS message to a phone number", | ||
description=Component.DESCRIPTION, | ||
input=SendSmsInput(), | ||
output=SendSmsOutput(), | ||
) | ||
|
||
def run(self, params={}): | ||
message = self.connection.client.messages.create( | ||
body=params.get("message"), | ||
to=params.get("to_number"), | ||
from_=self.connection.twilio_phone_number, | ||
) | ||
return {"message_sid": message.sid} | ||
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION | ||
message = params.get(Input.MESSAGE, "") | ||
send_to_number = params.get(Input.TO_NUMBER, "").strip() | ||
# END INPUT BINDING - DO NOT REMOVE | ||
|
||
def test(self): | ||
return {"message_sid": "SM91b89296d763426db7b50d165f6eadfb"} | ||
try: | ||
message = self.connection.client.messages.create( | ||
body=message, | ||
to=send_to_number, | ||
from_=self.connection.twilio_phone_number, | ||
) | ||
return {Output.MESSAGE_SID: message.sid} | ||
except TwilioRestException as error: | ||
handle_exception_status_code(error) | ||
except Exception as error: | ||
raise PluginException(preset=PluginException.Preset.UNKNOWN, data=error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# GENERATED BY KOMAND SDK - DO NOT EDIT | ||
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT | ||
from .connection import Connection |
Oops, something went wrong.