-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
878c809
commit 757047a
Showing
7 changed files
with
325 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Script leverages the WebexTeamssdk | ||
Sends a webex teams message | ||
Will create room if not created | ||
Deletes a supplied webex room | ||
To obtain a webex token https://developer.webex.com/ | ||
""" | ||
from webexteamssdk import WebexTeamsAPI | ||
|
||
|
||
def get_webex_token(webex_access_token): | ||
""" | ||
Get developer webex token to be used for future request | ||
Arguments: | ||
webex_access_token (str): Webex developer api token | ||
return: Return API Token | ||
rtype: obj | ||
""" | ||
return WebexTeamsAPI(webex_access_token) | ||
|
||
def send_webex_message(webex_token, webex_room, webex_email=None, | ||
webex_message=None, webex_card=None): | ||
""" | ||
Send a message to a supplied webex room | ||
Creates room if not listed | ||
Arguments: | ||
webex_token (cls): Api token for future requests | ||
webex_room (str): Name of webex room | ||
webex_email (str): Email to be added to the webex room | ||
webex_message (str): Str message to be sent | ||
webex_card (dict): Adaptive card for webex message | ||
""" | ||
rooms = webex_token.rooms.list() | ||
aci_room = [room.id for room in rooms if room.title == webex_room] | ||
if aci_room: | ||
if webex_card: | ||
webex_token.messages.create(aci_room[0], text='\n', | ||
attachments=webex_card) | ||
else: | ||
webex_token.messages.create(aci_room[0], markdown=webex_message) | ||
else: | ||
webex_room = webex_token.rooms.create(webex_room) | ||
webex_token.memberships.create(webex_room.id, personEmail=webex_email) | ||
webex_token.messages.create(webex_room.id, text=webex_message) | ||
|
||
def delete_webex_room(webex_token, webex_room): | ||
""" | ||
Send a message to a supplied webex room | ||
Creates room if not listed | ||
Arguments: | ||
message (str): Str message to be sent | ||
webex_token (cls): Api token for future requests | ||
webex_room (str): Name of webex room | ||
webex_email (str): Email to be added to the webex room | ||
""" | ||
rooms = webex_token.rooms.list() | ||
aci_room = [room.id for room in rooms if room.title == webex_room] | ||
if aci_room: | ||
webex_token.rooms.delete(aci_room[0]) | ||
print(f"Sucessfully deleted {webex_room}") | ||
else: | ||
print(f"Webex room {webex_room}: Not Found") |
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 |
---|---|---|
@@ -0,0 +1,150 @@ | ||
[ | ||
{ | ||
"contentType": "application/vnd.microsoft.card.adaptive", | ||
"content": | ||
|
||
{ | ||
"type": "AdaptiveCard", | ||
"body": [ | ||
{ | ||
"type": "ColumnSet", | ||
"columns": [ | ||
{ | ||
"type": "Column", | ||
"items": [ | ||
{ | ||
"type": "Image", | ||
"style": "Person", | ||
"url": "https://raw.githubusercontent.com/kiskander/assets/main/mask-icon-01.jpg", | ||
"size": "Medium", | ||
"height": "50px" | ||
} | ||
], | ||
"width": "auto" | ||
}, | ||
{ | ||
"type": "Column", | ||
"items": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "Cisco DNA Center", | ||
"weight": "Lighter", | ||
"color": "Accent" | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"weight": "Bolder", | ||
"text": "Contact Tracing", | ||
"horizontalAlignment": "Left", | ||
"wrap": true, | ||
"color": "Light", | ||
"size": "Large", | ||
"spacing": "Small" | ||
} | ||
], | ||
"width": "stretch" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "Fill in the form below to generate a report based on an identified Pandemic Positive Employee.", | ||
"wrap": true | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "Username:", | ||
"wrap": true, | ||
"weight": "Bolder", | ||
"color": "Attention" | ||
}, | ||
{ | ||
"type": "Input.Text", | ||
"style": "text", | ||
"id": "username", | ||
"placeholder": "Enter a valid username", | ||
"spacing": "Small", | ||
"value": "kevinm" | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "Select number of days to trace:", | ||
"weight": "Bolder", | ||
"color": "Attention", | ||
"horizontalAlignment": "Left", | ||
"wrap": true | ||
}, | ||
{ | ||
"type": "Input.Number", | ||
"id": "report_days", | ||
"placeholder": "Pick number of days between 1-14", | ||
"spacing": "Small", | ||
"min": 0, | ||
"max": 14, | ||
"value": 14 | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "Enter potential exposure time (min):", | ||
"wrap": true, | ||
"weight": "Bolder", | ||
"color": "Attention" | ||
}, | ||
{ | ||
"type": "Input.ChoiceSet", | ||
"id": "exposure_time", | ||
"placeholder": "Select 5, 10 or 15 minutes", | ||
"spacing": "Small", | ||
"min": 0, | ||
"max": 15, | ||
"choices": [ | ||
{ | ||
"title": "5 Min", | ||
"value": "5" | ||
}, | ||
{ | ||
"title": "10 Min", | ||
"value": "10" | ||
}, | ||
{ | ||
"title": "15 min", | ||
"value": "15" | ||
} | ||
], | ||
"value": "15" | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "Additional Notes:", | ||
"wrap": true, | ||
"weight": "Bolder", | ||
"color": "Attention" | ||
}, | ||
{ | ||
"type": "Input.Text", | ||
"style": "text", | ||
"id": "notes", | ||
"placeholder": "Attach additional Notes to the final report", | ||
"isMultiline": true | ||
}, | ||
{ | ||
"type": "ActionSet", | ||
"actions": [ | ||
{ | ||
"type": "Action.Submit", | ||
"title": "Generate Report", | ||
"data": { | ||
"subscribe": true | ||
}, | ||
"id": "submit" | ||
} | ||
], | ||
"horizontalAlignment": "Left", | ||
"spacing": "None" | ||
} | ||
], | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"version": "1.2" | ||
} | ||
} | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.