예제 #1
0
    def callback_url(self, callback_type, **params):
        if params:
            query_string = '?%s' % urllib.urlencode(params)
        else:
            query_string = ''

        base_url = url_for('task-callback',
                task_id=self.id, callback_type=callback_type)
        return base_url + query_string
예제 #2
0
    def post(self):
        if 'name' in request.json:
            name = request.json['name']
        else:
            name = str(uuid.uuid4())

        name_part = ' for workflow "%s"' % name

        LOG.info("Handling workflow POST from %s%s",
                 request.access_route[0],
                 name_part,
                 extra={'workflowName': name})

        try:
            LOG.debug("Validating JSON body of request%s",
                      name_part,
                      extra={'workflowName': name})
            data = validators.get_workflow_post_data()
            data['name'] = name
        except ValidationError as e:
            LOG.exception(
                "Exception occured while validating JSON "
                "body of workflow POST from %s%s",
                request.access_route[0],
                name_part,
                extra={'workflowName': name})
            LOG.info("Responding 400 to workflow POST %s",
                     name_part,
                     extra={'workflowName': name})
            msg = "JSON schema validation error: %s" % e.message
            return {'error': msg}, 400

        try:
            if 'parentExecutionUrl' in data:
                parent_execution_id = get_execution_id_from_url(
                    data['parentExecutionUrl'])
                workflow_id, workflow_as_dict = g.backend.create_spawned_workflow(
                    data, parent_execution_id=parent_execution_id)
            else:
                workflow_id, workflow_as_dict = g.backend.create_workflow(data)
        except PteroValidationError as e:
            LOG.exception(
                'Exception occured while validating '
                'specification of workflow "%s"',
                name,
                extra={'workflowName': name})
            LOG.info("Responding 400 to workflow POST %s",
                     name_part,
                     extra={'workflowName': name})
            return {'error': e.message}, 400

        LOG.info("Responding 201 to workflow POST%s",
                 name_part,
                 extra={'workflowName': name})
        return _prepare_workflow_data(workflow_id, workflow_as_dict), 201, {
            'Location': url_for('workflow-detail', workflow_id=workflow_id)
        }
예제 #3
0
    def callback_url(self, callback_type, **params):
        if params:
            query_string = '?%s' % urllib.urlencode(params)
        else:
            query_string = ''

        base_url = url_for('method-callback',
                           method_id=self.id,
                           callback_type=callback_type)
        return base_url + query_string
예제 #4
0
    def post(self):
        if 'name' in request.json:
            name = request.json['name']
        else:
            name = str(uuid.uuid4())

        name_part = ' for workflow "%s"' % name

        LOG.info("Handling workflow POST from %s%s",
                request.access_route[0], name_part,
                extra={'workflowName':name})

        try:
            LOG.debug("Validating JSON body of request%s", name_part,
                extra={'workflowName':name})
            data = validators.get_workflow_post_data()
            data['name'] = name
        except ValidationError as e:
            LOG.exception("Exception occured while validating JSON "
                "body of workflow POST from %s%s", request.access_route[0],
                name_part, extra={'workflowName':name})
            LOG.info("Responding 400 to workflow POST %s",
                    name_part, extra={'workflowName':name})
            msg = "JSON schema validation error: %s" % e.message
            return {'error': msg}, 400

        try:
            if 'parentExecutionUrl' in data:
                parent_execution_id = get_execution_id_from_url(
                        data['parentExecutionUrl'])
                workflow_id, workflow_as_dict = g.backend.create_spawned_workflow(data,
                    parent_execution_id=parent_execution_id)
            else:
                workflow_id, workflow_as_dict = g.backend.create_workflow(data)
        except PteroValidationError as e:
            LOG.exception('Exception occured while validating '
                'specification of workflow "%s"', name,
                extra={'workflowName':name})
            LOG.info("Responding 400 to workflow POST %s",
                    name_part, extra={'workflowName':name})
            return {'error': e.message}, 400

        LOG.info("Responding 201 to workflow POST%s",
                name_part, extra={'workflowName':name})
        return _prepare_workflow_data(workflow_id, workflow_as_dict), 201, {
            'Location': url_for('workflow-detail', workflow_id=workflow_id)
        }
def report(workflow_id, since=None):
    executions, timestamp = g.backend.get_workflow_executions(
        workflow_id=workflow_id, since=since)

    base_url = url_for('report', report_type='workflow-executions')

    url_query_string_args = {'workflow_id': workflow_id}

    if timestamp is not None:
        format_str = '%Y-%m-%d %H:%M:%S.%f'
        url_query_string_args['since'] = timestamp.strftime(format_str)
    else:
        url_query_string_args['since'] = since

    url = '%s?%s' % (base_url, urllib.urlencode(url_query_string_args))

    return {
        'updateUrl': url,
        'executions': executions,
    }
def report(workflow_id, since=None):
    executions, timestamp = g.backend.get_workflow_executions(
            workflow_id=workflow_id, since=since)

    base_url = url_for('report', report_type='workflow-executions')

    url_query_string_args = {'workflow_id': workflow_id}

    if timestamp is not None:
        format_str = '%Y-%m-%d %H:%M:%S.%f'
        url_query_string_args['since'] = timestamp.strftime(format_str)
    else:
        url_query_string_args['since'] = since

    url = '%s?%s' % (base_url, urllib.urlencode(url_query_string_args))

    return {
            'updateUrl': url,
            'executions': executions,
    }
def report(workflow_id, since=None, limit=LIMIT):
    executions, timestamp, num_remaining = g.backend.get_limited_workflow_executions(
        workflow_id=workflow_id, since=since, limit=int(limit))

    base_url = url_for('report', report_type='limited-workflow-executions')

    url_query_string_args = {'workflow_id': workflow_id, 'limit': limit}

    if timestamp is not None:
        format_str = '%Y-%m-%d %H:%M:%S.%f'
        url_query_string_args['since'] = timestamp.strftime(format_str)
    else:
        url_query_string_args['since'] = since

    url = '%s?%s' % (base_url, urllib.urlencode(url_query_string_args))

    return {
        'updateUrl': url,
        'executions': executions,
        'numRemaining': num_remaining,
    }
def report(workflow_id, since=None, limit=LIMIT):
    updates, timestamp, num_remaining = g.backend.get_limited_workflow_status_updates(
            workflow_id=workflow_id, since=since, limit=int(limit))

    base_url = url_for('report', report_type='limited-workflow-status-updates')

    url_query_string_args = {'workflow_id': workflow_id, 'limit':limit}

    if timestamp is not None:
        format_str = '%Y-%m-%d %H:%M:%S.%f'
        url_query_string_args['since'] = timestamp.strftime(format_str)
    else:
        url_query_string_args['since'] = since

    url = '%s?%s' % (base_url, urllib.urlencode(url_query_string_args))

    return {
            'updateUrl': url,
            'statusUpdates': updates,
            'numRemaining': num_remaining,
    }
예제 #9
0
 def url(self):
     return url_for('workflow-detail', workflow_id=self.id)
예제 #10
0
 def url(self):
     return url_for('workflow-detail', workflow_id=self.id)
예제 #11
0
 def url(self):
     return url_for('execution-detail', execution_id=self.id)
예제 #12
0
 def workflow_submit_url(self):
     return url_for('workflow-list')
예제 #13
0
def _report_url(workflow_id, report_type):
    base_url = url_for('report', report_type=report_type)

    return '%s?%s' % (base_url, urllib.urlencode({'workflow_id': workflow_id}))
예제 #14
0
 def execution_url(self, execution_id):
     return url_for('execution-detail', execution_id=execution_id)
예제 #15
0
 def workflow_submit_url(self):
     return url_for('workflow-list')
예제 #16
0
 def execution_url(self, execution_id):
     return url_for('execution-detail', execution_id=execution_id)
예제 #17
0
 def url(self):
     return url_for('execution-detail', execution_id=self.id)
예제 #18
0
def _report_url(workflow_id, report_type):
    base_url = url_for('report', report_type=report_type)

    return '%s?%s' % (base_url, urllib.urlencode({'workflow_id': workflow_id}))