Пример #1
0
 def post(self):
     loggerService.info("Sending a message to MS Teams")
     message = api.payload
     return send_teams_card_message(
         message['title'], message['activity_title'],
         message['activity_subtitle'], message['activity_image'],
         message['activity_text'], message['facts'],
         message['section_text'], message['section_image'],
         message['section_image_title'])
Пример #2
0
 def build_inventory(self):
     if self.NETWORK_SUBMISSION != None and len(self.NETWORK_SUBMISSION) != 0:
         data = self.formio.get_submission(self.NETWORK_SERVICE, self.NETWORK_SUBMISSION)
         loggerService.info(json.dumps(data, indent=4, sort_keys=True))
     else:
         data = self.formio.get_submissions(self.NETWORK_SERVICE)
         loggerService.info(json.dumps(data, indent=4, sort_keys=True))
     
     self.ansible.submission_adapter(data)
     return self.ansible.get_inventory()
Пример #3
0
 def post(self):
     loggerService.info("Sending a message to MS Teams")
     message = api.payload
     send_teams_message(message['from'] + ': ' + message['message'])
     return {
         'channel': 'DevOps',
         'organization': 'Newtech',
         'message': message['message'],
         'from': message['from']
     }
Пример #4
0
 def get(self):
     loggerService.info("Sending a test template message to MS Teams")
     return send_teams_test_message()
Пример #5
0
from flask_restx import Namespace, Api, Resource, fields
from services.LoggerService import loggerService
from services.MSTeamsService import send_teams_message, send_teams_card_message, send_teams_test_message
from models.message import message_model_definition, message_card_model, facts_model

loggerService.info("initializing namespace with Teams endpoints from " +
                   str(__name__))

api = Namespace('MicrosoftTeams',
                description='Endpoints for Microsoft Teams integration')

# models
message_model = api.model('Message model', message_model_definition)
facts_model = api.model('Facts card message model', facts_model)
message_card_model = api.model(
    'Card message model', {
        'title': fields.String('Card title'),
        'activity_title': fields.String('Activity title'),
        'activity_subtitle': fields.String('Activity subtitle'),
        'activity_image': fields.String('Activity image url'),
        'activity_text': fields.String('Activity text'),
        'facts': fields.List(fields.Nested(facts_model)),
        'section_text': fields.String('Section image description text'),
        'section_image': fields.String('Section image url'),
        'section_image_title': fields.String('Section image url')
    })


@api.route('/sendTextMessage')
class SendTextMessage(Resource):
    @api.expect(message_model, validate=True)
Пример #6
0
 def get(self):
     loggerService.info("alguien entro a hello!")
     return {'hello': 'world'}
Пример #7
0
from config.settings import config
from flask import Blueprint
from flask_restx import Api
from services.LoggerService import loggerService
from api.endpoints.teams import api as ns_teams
from api.endpoints.users import api as ns_users
from models.message import message_model_definition, message_card_model, facts_model

loggerService.info("initializing blueprint api v2")

blueprint = Blueprint("api app 2", __name__, url_prefix='/app2/api')

api = Api(blueprint, title='API APP 2', version=config['RESTX']['VERSION']['APP2'])
api.add_namespace(ns_teams)
api.add_namespace(ns_users)
Пример #8
0
            except Exception as e:
                loggerService.error('Error trying to get submission: ' + str(e))
                submission = str(e)
        return submission 

    def open_file(self, filename, with_bom):
        data = None
        try:
            if not with_bom:
                f = open(filename)
                data = json.load(f)
            else:
                if sys.version_info.major < 3:
                    f = open(filename)
                    data = f.read().decode('utf-8-sig') # Python 2
                    return json.loads(data)
                else:
                    f = open(filename, encoding='utf-8-sig') # Python 3
                    data = json.load(f)
        except Exception as e:
            loggerService.error("Error opening requested file! \n" + str(e))
        return data

if __name__ == "__main__":
    loggerService.info('Formio interface!')
    formio = Formio()
    loggerService.info('Token: ' + str(formio.token))
    formio.get_submissions('automationSipTrunk')
    result = json.dumps(formio.resources['automationSipTrunk'][0]['data'], indent=4, sort_keys=True)
    loggerService.info(result)
    #loggerService.info(send_teams_message(result))