def user_info(team_id=None, channel=None, params=None): if len(params) > 0: user_name = ' '.join(params) users = slack(team_id).users() user = users.get(user_name) if user: return "```{0}```".format(Misc.json_format(user)) for user in users.values(): if user.get('id') == user_name or user.get( 'real_name') == user_name: return "```{0}```".format(Misc.json_format(user)) return ":exclamation: Sorry, could not find user with alias `{0}`".format( user_name)
def run(event, context): team_id = 'T7F3AUXGV' channel = 'DDKUZTK6X' text = "in API Gateway test..." attachments = [ {'text': "{0}".format(Misc.json_format(event)) , 'color':'good'}] #attachments = [{'text': "{0}".format(event), 'color': 'good'}] slack_message(text, attachments, channel,team_id) result = Misc.json_format({'text': text}) return { 'headers' : {'Content-Type': 'application/json'}, "statusCode" : 209, "body" : result }
def run(event, context): project_name = 'Code_Build_Test' build_id = CodeBuild(project_name=project_name, role_name=project_name).build_start() return { 'headers': { 'Content-Type': 'application/json' }, "statusCode": 200, "body": Misc.json_format({'build_id': build_id}) }
def run(event, context): team_id = 'T7F3AUXGV' channel = 'DDKUZTK6X' querystring = event.get('queryStringParameters') if querystring and querystring.get('file_id'): file_id = querystring.get('file_id') if querystring.get('action') == 'diff': payload = { "params": ["diff_sheet", file_id], "channel": "DDKUZTK6X", 'team_id': 'T7F3AUXGV' } elif querystring.get('action') == 'sync': payload = { "params": ["sync_sheet", file_id], "channel": "DDKUZTK6X", 'team_id': 'T7F3AUXGV' } else: payload = { "params": ["load_sheet", file_id], "channel": "DDKUZTK6X", 'team_id': 'T7F3AUXGV' } Lambdas('gs.elastic_jira').invoke(payload) text = ":point_right: [trigger_sync_jira_sheets] completed workflow for file_id: {0} , see channel {1} for more details".format( file_id, channel) status_code = 201 else: text = "Error: file_id value not provided" status_code = 501 slack_message(text, [], channel, team_id) return { 'headers': { 'Content-Type': 'application/json' }, "statusCode": status_code, "body": Misc.json_format({'text': text}) }
def run(event, context): team_id = 'T7F3AUXGV' channel = 'DDKUZTK6X' text = ":robot_face: In trigger_server_reload lambda function \n" payload = { "params": ["server", "reload"], "channel": channel, 'team_id': team_id } result = Lambdas('gs.elastic_jira').invoke(payload) attachments = [{'text': result, 'color': 'good'}] slack_message(text, attachments, channel, team_id) result = Misc.json_format({'text': text}) return { 'headers': { 'Content-Type': 'application/json' }, "statusCode": 209, "body": result }
def stats(team_id=None, channel=None, params=None): stats = {"# of users": len(list(set(slack(team_id).users())))} return Misc.json_format(stats)