Ejemplo n.º 1
0
    def __init__(self):
        super(User, self).__init__()
        self.resourceName = 'user'
        self._model = UserModel()

        self.route('DELETE', ('authentication', ), self.logout)
        self.route('DELETE', (':id', ), self.deleteUser)
        self.route('GET', (), self.find)
        self.route('GET', ('me', ), self.getMe)
        self.route('GET', ('authentication', ), self.login)
        self.route('GET', (':id', ), self.getUser)
        self.route('GET', (':id', 'details'), self.getUserDetails)
        self.route('GET', ('details', ), self.getUsersDetails)
        self.route('POST', (), self.createUser)
        self.route('PUT', (':id', ), self.updateUser)
        self.route('PUT', ('password', ), self.changePassword)
        self.route('PUT', (':id', 'password'), self.changeUserPassword)
        self.route('GET', ('password', 'temporary', ':id'),
                   self.checkTemporaryPassword)
        self.route('PUT', ('password', 'temporary'),
                   self.generateTemporaryPassword)
        self.route('POST', (':id', 'otp'), self.initializeOtp)
        self.route('PUT', (':id', 'otp'), self.finalizeOtp)
        self.route('DELETE', (':id', 'otp'), self.removeOtp)
        self.route('PUT', (':id', 'verification'), self.verifyEmail)
        self.route('POST', ('verification', ), self.sendVerificationEmail)
Ejemplo n.º 2
0
def on_taskflow_status_update(event):
    taskflow = event.info['taskflow']
    queue_id = taskflow.get('meta', {}).get('queueId')
    if queue_id is None:
        return

    if taskflow['status'] in TASKFLOW_NON_RUNNING_STATES:
        queue = Queue().load(queue_id, force=True)
        user = UserModel().load(queue['userId'], force=True)
        Queue().finish(queue, taskflow, user)
        Queue().pop(queue, sys.maxsize, user)
Ejemplo n.º 3
0
def cleanup_failed_taskflows():
    queues = list(Queue().find(limit=sys.maxsize, force=True))
    for queue in queues:
        user = UserModel().load(queue['userId'], force=True)
        if user is None:
            continue

        for taskflow_id, status in queue['taskflows'].items():
            if status == TaskStatus.RUNNING:
                taskflow = TaskflowModel().load(taskflow_id, force=True)
                if taskflow['status'] in TASKFLOW_NON_RUNNING_STATES:
                    logger.warning("Removing non-running taskflow {} from the queue {}".format(taskflow_id, queue["_id"]))
                    Queue().finish(queue, taskflow, user)
Ejemplo n.º 4
0
def load(info):
    # Model PipelineExecution
    info['apiRoot'].pipeline_execution = pipeline_rest.PipelineExecution()

    # Model User
    UserModel().exposeFields(level=AccessType.READ, fields={'apiKeyVip'})
    user = user_rest.UserExtend()
    info['apiRoot'].user.route('GET', (':id', 'apiKeyVip'), user.getApiKeyVip)
    info['apiRoot'].user.route('PUT', (':id', 'apiKeyVip'), user.setApiKeyVip)

    # Customizing the swagger page
    baseTemplateFilename = info['apiRoot'].templateFilename
    info['apiRoot'].updateHtmlVars({
	'baseTemplateFilename': baseTemplateFilename
    })

    templatePath = os.path.join(info['pluginRootDir'], 'server', 'custom_api_docs.mako')
    info['apiRoot'].setTemplatePath(templatePath)
    def load(self, info):
        vipHandler = VipHandler()
        # Model PipelineExecution
        info['apiRoot'].vip_execution = execution_rest.Execution()

        # Model User - extend user/
        UserModel().exposeFields(level=AccessType.READ, fields={'apiKeyVip'})
        info['apiRoot'].user.route('PUT', (':id', 'apiKeyVip'),
                                   vipHandler.setApiKeyVip)
        info['apiRoot'].user.route('GET', (':id', 'apiKeyVip'),
                                   vipHandler.getApiKeyVip)

        # expose plugin conf
        info['apiRoot'].system.route('GET', ('setting', 'vip_plugin'),
                                     vipHandler.getVipPluginConf)

        # Customizing the swagger page
        # Don't change this part
        baseTemplateFilename = info['apiRoot'].templateFilename
        info['apiRoot'].updateHtmlVars(
            {'baseTemplateFilename': baseTemplateFilename})
 def __init__(self):
     super(VipHandler, self).__init__()
     self._model = UserModel()
     self.__users = User()