def get_job(job_id): db_handler = get_handler() job_dict = db_handler.get_document( object_name=JOB_COLLECTION, query_filter={"job_id": job_id}) return build_job_from_dict(job_dict)
def get_jobs(tenant_id): db_handler = get_handler() jobs_dict = db_handler.get_documents( object_name=JOB_COLLECTION, query_filter={"tenant_id": tenant_id}) return [build_job_from_dict(job) for job in jobs_dict]
def update_job(cls, job, handler=None): db_handler = handler or get_handler() db_handler.update_document( object_name=JOB_COLLECTION, document=job.as_dict(), query_filter={"id": job.id} )
def update_job(job): db_handler = get_handler() db_handler.update_document( object_name=JOB_COLLECTION, document=job.as_dict(), query_filter={"job_id": job.job_id} )
def get_job(cls, job_id, handler=None): db_handler = handler or get_handler() job_dict = db_handler.get_document( object_name=JOB_COLLECTION, query_filter={"id": job_id}) return Job.build_job_from_dict(job_dict)
def get_schedules(cls, tenant_id): db_handler = get_handler() schedules_dict = db_handler.get_documents( object_name=SCHEDULE_COLLECTION, query_filter={"tenant_id": tenant_id}) return [cls.build_schedule_from_dict(tenant_id, schedule) for schedule in schedules_dict]
def get_jobs(cls, tenant_id, handler=None): db_handler = handler or get_handler() jobs_dict = db_handler.get_documents( object_name=JOB_COLLECTION, query_filter={"tenant_id": tenant_id}) return [Job.build_job_from_dict(job) for job in jobs_dict]
def get_job(cls, run_number, handler=None): db_handler = handler or get_handler() job_dict = db_handler.get_document( object_name=JOB_RUN_COLLECTION, query_filter={"run_number": run_number}) return JobExecution.build_job_from_dict(job_dict)
def save_schedule(cls, schedule): db_dict = schedule.as_dict() db_dict['tenant_id'] = schedule.tenant_id db_handler = get_handler() db_handler.insert_document(object_name=SCHEDULE_COLLECTION, document=db_dict)
def update_tenant(cls, tenant): db_handler = get_handler() db_handler.update_document( object_name=TENANT_COLLECTION, document=tenant.as_dict(), query_filter={"tenant_id": tenant.tenant_id} )
def save_job(cls, job, handler=None): job_dict = job.as_dict() job_dict['tenant_id'] = job.tenant_id db_handler = handler or get_handler() db_handler.insert_document(object_name=JOB_COLLECTION, document=job_dict)
def save_schedule(cls, schedule): db_dict = schedule.as_dict() db_dict['tenant_id'] = schedule.tenant_id db_handler = get_handler() db_handler.insert_document( object_name=SCHEDULE_COLLECTION, document=db_dict )
def save_job(cls, job, handler=None): job_dict = job.as_dict() job_dict['tenant_id'] = job.tenant_id db_handler = handler or get_handler() db_handler.insert_document( object_name=JOB_COLLECTION, document=job_dict )
def get_schedules(cls, tenant_id): db_handler = get_handler() schedules_dict = db_handler.get_documents( object_name=SCHEDULE_COLLECTION, query_filter={"tenant_id": tenant_id}) return [ cls.build_schedule_from_dict(tenant_id, schedule) for schedule in schedules_dict ]
def get_target(cls, tenant_id, target_id): db_handler = get_handler() target_dict = db_handler.get_document( object_name=TARGET_COLLECTION, query_filter={"$or": [{"id": target_id}, {"name": target_id}]}) target_dict = Target.decrypt_auth_data(target_dict) return Target.build_target_from_dict(tenant_id, target_dict)
def save_target(cls, target): db_dict = target.as_dict() db_dict['tenant_id'] = target.tenant_id # Make sure we encrypt the auth data db_dict = Target.encrypt_auth_data(db_dict) db_handler = get_handler() db_handler.insert_document( object_name=TARGET_COLLECTION, document=db_dict )
def get_targets(cls, tenant_id): db_handler = get_handler() targets_dict = db_handler.get_documents( object_name=TARGET_COLLECTION, query_filter={"tenant_id": tenant_id}) # Make sure and decrypt the auth data targets = [Target.decrypt_auth_data(target) for target in targets_dict] return [Target.build_target_from_dict(tenant_id, target) for target in targets]
def get_tenant(cls, tenant_id): db_handler = get_handler() tenant_dict = db_handler.get_document( object_name=TENANT_COLLECTION, query_filter={"tenant_id": tenant_id}) # Create Tenant if it doesn't exist if not tenant_dict: LOG.info('Tenant {0} not found. Creating...'.format(tenant_id)) tenant = cls(tenant_id) cls.save_tenant(tenant) else: tenant = Tenant.build_tenant_from_dict(tenant_dict) return tenant
def save_tenant(cls, tenant): db_handler = get_handler() db_handler.insert_document( object_name=TENANT_COLLECTION, document=tenant.as_dict() )
def delete_schedule(cls, schedule_id): db_handler = get_handler() db_handler.delete_document(object_name=SCHEDULE_COLLECTION, query_filter={"id": schedule_id})
def delete_job(cls, run_number, handler=None): db_handler = handler or get_handler() db_handler.delete_document(object_name=JOB_RUN_COLLECTION, query_filter={"run_number": run_number})
def update_job(cls, job, handler=None): db_handler = handler or get_handler() db_handler.update_document(object_name=JOB_COLLECTION, document=job.as_dict(), query_filter={"id": job.id})
def update_tenant(cls, tenant): db_handler = get_handler() db_handler.update_document( object_name=TENANT_COLLECTION, document=tenant.as_dict(), query_filter={"tenant_id": tenant.tenant_id})
def save_tenant(cls, tenant): db_handler = get_handler() db_handler.insert_document(object_name=TENANT_COLLECTION, document=tenant.as_dict())
def get_schedule(cls, tenant_id, schedule_id): db_handler = get_handler() schedule_dict = db_handler.get_document( object_name=SCHEDULE_COLLECTION, query_filter={"id": schedule_id}) return cls.build_schedule_from_dict(tenant_id, schedule_dict)
def delete_schedule(cls, schedule_id): db_handler = get_handler() db_handler.delete_document( object_name=SCHEDULE_COLLECTION, query_filter={"id": schedule_id})
def delete_job(job_id): db_handler = get_handler() db_handler.delete_document( object_name=JOB_COLLECTION, query_filter={"job_id": job_id} )
def get_job(job_id): db_handler = get_handler() job_dict = db_handler.get_document(object_name=JOB_COLLECTION, query_filter={"job_id": job_id}) return build_job_from_dict(job_dict)
def delete_target(cls, target_id, handler=None): db_handler = handler or get_handler() db_handler.delete_document( object_name=TARGET_COLLECTION, query_filter={"id": target_id} )
def save_job(job): db_handler = get_handler() db_handler.insert_document(object_name=JOB_COLLECTION, document=job.as_dict())
def delete_job(cls, job_id, handler=None): db_handler = handler or get_handler() db_handler.delete_document( object_name=JOB_COLLECTION, query_filter={"id": job_id} )
def get_job(cls, run_number, handler=None): db_handler = handler or get_handler() job_dict = db_handler.get_document(object_name=JOB_RUN_COLLECTION, query_filter={"run_number": run_number}) return JobExecution.build_job_from_dict(job_dict)
def delete_job(job_id): db_handler = get_handler() db_handler.delete_document(object_name=JOB_COLLECTION, query_filter={"job_id": job_id})
def get_job(cls, job_id, handler=None): db_handler = handler or get_handler() job_dict = db_handler.get_document(object_name=JOB_COLLECTION, query_filter={"id": job_id}) return Job.build_job_from_dict(job_dict)
def save_job(job): db_handler = get_handler() db_handler.insert_document( object_name=JOB_COLLECTION, document=job.as_dict() )
def delete_job(cls, job_id, handler=None): db_handler = handler or get_handler() db_handler.delete_document(object_name=JOB_COLLECTION, query_filter={"id": job_id})
def update_job(job): db_handler = get_handler() db_handler.update_document(object_name=JOB_COLLECTION, document=job.as_dict(), query_filter={"job_id": job.job_id})