Example #1
0
 def patch(self, pipeline_id):
     pipeline = Pipeline.find(pipeline_id)
     args = parser.parse_args()
     schedule_pipeline = (args['run_on_schedule'] == 'True')
     pipeline.update(run_on_schedule=schedule_pipeline)
     tracker = insight.GAProvider()
     tracker.track_event(
         category='pipelines',
         action=('schedule' if schedule_pipeline else 'unschedule'))
     return pipeline
Example #2
0
    def delete(self, pipeline_id):
        pipeline = Pipeline.find(pipeline_id)

        abort_if_pipeline_doesnt_exist(pipeline, pipeline_id)
        if pipeline.is_blocked():
            return {
                'message': 'Removing of active pipeline is unavailable'
            }, 422

        pipeline.destroy()
        return {}, 204
Example #3
0
    def put(self, pipeline_id):
        pipeline = Pipeline.find(pipeline_id)
        abort_if_pipeline_doesnt_exist(pipeline, pipeline_id)

        if pipeline.is_blocked():
            return {
                'message': 'Editing of active pipeline is unavailable'
            }, 422

        args = parser.parse_args()

        pipeline.assign_attributes(args)
        pipeline.save()
        pipeline.save_relations(args)
        return pipeline, 200
Example #4
0
    def post(self):
        args = parser.parse_args()
        pipeline = Pipeline.find(args['pipeline_id'])

        if pipeline.is_blocked():
            return {
                'message':
                'Creating new jobs for active pipeline is unavailable'
            }, 422

        job = Job(args['name'], args['worker_class'], args['pipeline_id'])
        job.assign_attributes(args)
        job.save()
        job.save_relations(args)
        return job, 201
Example #5
0
    def post(self):
        args = parser.parse_args()
        pipeline = Pipeline.find(args['pipeline_id'])

        if pipeline.is_blocked():
            return {
                'message':
                'Creating new jobs for active pipeline is unavailable'
            }, 422

        job = Job(args['name'], args['worker_class'], args['pipeline_id'])
        job.assign_attributes(args)
        job.save()
        job.save_relations(args)
        tracker = insight.GAProvider()
        tracker.track_event(category='jobs',
                            action='create',
                            label=args['worker_class'])
        return job, 201
Example #6
0
    def get(self, pipeline_id):
        tracker = insight.GAProvider()
        tracker.track_event(category='pipelines', action='export')

        pipeline = Pipeline.find(pipeline_id)

        jobs = self.__get_jobs__(pipeline)

        pipeline_params = []
        for param in pipeline.params:
            pipeline_params.append({
                'name': param.name,
                'value': param.value,
                'type': param.type,
            })

        pipeline_schedules = []
        for schedule in pipeline.schedules:
            pipeline_schedules.append({
                'cron': schedule.cron,
            })

        data = {
            'name': pipeline.name,
            'jobs': jobs,
            'params': pipeline_params,
            'schedules': pipeline_schedules
        }

        ts = time.time()
        pipeline_date = datetime.datetime.fromtimestamp(ts)
        pipeline_date_formatted = pipeline_date.strftime('%Y%m%d%H%M%S')
        filename = pipeline.name.lower(
        ) + "-" + pipeline_date_formatted + ".json"
        return data, 200, {
            'Access-Control-Expose-Headers': 'Filename',
            'Content-Disposition': "attachment; filename=" + filename,
            'Filename': filename,
            'Content-type': 'text/json'
        }
Example #7
0
 def get(self, pipeline_id):
     pipeline = Pipeline.find(pipeline_id)
     abort_if_pipeline_doesnt_exist(pipeline, pipeline_id)
     return pipeline
Example #8
0
 def post(self, pipeline_id):
     pipeline = Pipeline.find(pipeline_id)
     pipeline.stop()
     tracker = insight.GAProvider()
     tracker.track_event(category='pipelines', action='manual_stop')
     return pipeline
Example #9
0
 def get(self):
     args = parser.parse_args()
     pipeline = Pipeline.find(args['pipeline_id'])
     jobs = pipeline.jobs.all()
     return jobs
Example #10
0
 def patch(self, pipeline_id):
     pipeline = Pipeline.find(pipeline_id)
     args = parser.parse_args()
     pipeline.update(run_on_schedule=(args['run_on_schedule'] == 'True'))
     return pipeline
Example #11
0
 def post(self, pipeline_id):
     pipeline = Pipeline.find(pipeline_id)
     pipeline.stop()
     return pipeline