Skip to content

Commit

Permalink
Small api fixes for shuffle tools/ai
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Jun 19, 2024
1 parent 9247bab commit d919784
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
9 changes: 4 additions & 5 deletions shuffle-ai/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def run_schemaless(self, category, action, app_name="", fields=""):
if app_name:
data["app_name"] = app_name

self.logger.info(f"\n\nFIELDS MAPPED\n\n: {fields}")

if fields:
if isinstance(fields, list):
data["fields"] = fields
Expand Down Expand Up @@ -291,7 +293,6 @@ def run_schemaless(self, category, action, app_name="", fields=""):
)

try:
self.logger.info("Starting url checker")
if "parameters" in self.action:
response_headers = request.headers
for key, value in response_headers.items():
Expand All @@ -303,11 +304,9 @@ def run_schemaless(self, category, action, app_name="", fields=""):
"value": value,
})

self.logger.info("[DEBUG] Response header: %s: %s" % (key, value))
else:
self.logger.info("[DEBUG] No parameters in action. Can't append url headers.")
#self.logger.info("[DEBUG] Response header: %s: %s" % (key, value))
except Exception as e:
self.logger.info("[ERROR] Failed to get response headers: %s" % e)
self.logger.info("[ERROR] Failed to get response headers (category action url debug mapping): %s" % e)

try:
return request.json()
Expand Down
82 changes: 41 additions & 41 deletions shuffle-tools/1.2.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,47 +184,47 @@ actions:
returns:
schema:
type: string
- name: send_email_shuffle
description: Send an email from Shuffle
parameters:
- name: apikey
description: Your https://shuffler.io organization apikey
multiline: false
example: "https://shuffler.io apikey"
required: true
schema:
type: string
- name: recipients
description: The recipients of the email
multiline: false
example: "[email protected],[email protected]"
required: true
schema:
type: string
- name: subject
description: The subject to use
multiline: false
example: "SOS this is an alert :o"
required: true
schema:
type: string
- name: body
description: The body to add to the email
multiline: true
example: "This is an email alert from Shuffler.io :)"
required: true
schema:
type: string
- name: attachments
description: The ID of files in Shuffle to add as attachments
multiline: false
example: "file_id1,file_id2,file_id3"
required: false
schema:
type: string
returns:
schema:
type: string
#- name: send_email_shuffle
# description: Send an email from Shuffle
# parameters:
# - name: apikey
# description: Your https://shuffler.io organization apikey
# multiline: false
# example: "https://shuffler.io apikey"
# required: true
# schema:
# type: string
# - name: recipients
# description: The recipients of the email
# multiline: false
# example: "[email protected],[email protected]"
# required: true
# schema:
# type: string
# - name: subject
# description: The subject to use
# multiline: false
# example: "SOS this is an alert :o"
# required: true
# schema:
# type: string
# - name: body
# description: The body to add to the email
# multiline: true
# example: "This is an email alert from Shuffler.io :)"
# required: true
# schema:
# type: string
# - name: attachments
# description: The ID of files in Shuffle to add as attachments
# multiline: false
# example: "file_id1,file_id2,file_id3"
# required: false
# schema:
# type: string
# returns:
# schema:
# type: string
- name: filter_list
description: Takes a list and filters based on your data
skip_multicheck: true
Expand Down
5 changes: 3 additions & 2 deletions shuffle-tools/1.2.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def send_email_shuffle(self, apikey, recipients, subject, body, attachments=""):
"subject": subject,
"body": body,
"type": "alert",
"email_app": True,
}

# Read the attachments
Expand All @@ -214,9 +215,9 @@ def send_email_shuffle(self, apikey, recipients, subject, body, attachments=""):
pass


url = "https://shuffler.io/api/v1/functions/sendmail"
url = "https://shuffler.io/functions/sendmail"
headers = {"Authorization": "Bearer %s" % apikey}
return requests.post(url, headers=headers, json=data, verify=False).text
return requests.post(url, headers=headers, json=data).text

def repeat_back_to_me(self, call):
return call
Expand Down

0 comments on commit d919784

Please sign in to comment.