示例#1
0
文件: link.py 项目: sandredd/hue-1
def create_link(request):
    response = {'status': 0, 'errors': None, 'link': None}

    if 'link' not in request.POST:
        raise StructuredException(code="INVALID_REQUEST_ERROR",
                                  message=_('Error saving link'),
                                  data={'errors': 'Link is missing.'},
                                  error_code=400)

    d = json.loads(smart_str(request.POST.get('link')))
    link = client.Link.from_dict(d)

    try:
        c = client.SqoopClient(
            conf.SERVER_URL.get(),
            request.user.username,
            request.LANGUAGE_CODE,
            ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
        response['link'] = c.create_link(link).to_dict()
    except RestException as e:
        response.update(handle_rest_exception(e, _('Could not create link.')))
    except SqoopException as e:
        response['status'] = 100
        response['errors'] = e.to_dict()
    return JsonResponse(response)
示例#2
0
def create_job(request):
  if request.method != 'POST':
    raise StructuredException(code="INVALID_METHOD", message=_('POST request required.'), error_code=405)

  response = {
    'status': 0,
    'errors': None,
    'job': None
  }

  if 'job' not in request.POST:
    raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving job'), data={'errors': 'job is missing.'}, error_code=400)

  d = json.loads(smart_str(request.POST.get('job')))
  job = client.Job.from_dict(d)

  try:
    c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE, ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
    response['job'] = c.create_job(job).to_dict()
  except RestException as e:
    response.update(handle_rest_exception(e, _('Could not create job.')))
  except SqoopException as e:
    response['status'] = 100
    response['errors'] = e.to_dict()
  return JsonResponse(response)
示例#3
0
 def decorate(request, submission_id, *args, **kwargs):
   try:
     c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE, ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
     submission = c.get_submission(int(submission_id))
   except RestException as e:
     handle_rest_exception(e, _('Could not get submission.'))
   return view_func(request, submission=submission, *args, **kwargs)
示例#4
0
 def decorate(request, submission_id, *args, **kwargs):
     try:
         c = client.SqoopClient(conf.SERVER_URL.get(),
                                request.user.username,
                                request.LANGUAGE_CODE)
         submission = c.get_submission(int(submission_id))
     except RestException, e:
         handle_rest_exception(e, _('Could not get submission.'))
示例#5
0
def get_links(request):
    response = {'status': 0, 'errors': None, 'links': []}
    try:
        c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username,
                               request.LANGUAGE_CODE)
        response['links'] = list_to_dict(c.get_links())
    except RestException, e:
        response.update(handle_rest_exception(e, _('Could not get links.')))
示例#6
0
 def decorate(request, connector_id, *args, **kwargs):
     try:
         c = client.SqoopClient(conf.SERVER_URL.get(),
                                request.user.username,
                                request.LANGUAGE_CODE)
         connector = c.get_connector(int(connector_id))
     except RestException, e:
         handle_rest_exception(e, _('Could not get connector.'))
示例#7
0
 def decorate(request, job_id, *args, **kwargs):
     try:
         c = client.SqoopClient(conf.SERVER_URL.get(),
                                request.user.username,
                                request.LANGUAGE_CODE)
         job = c.get_job(int(job_id))
     except RestException, e:
         handle_rest_exception(e, _('Could not get job.'))
示例#8
0
 def decorate(request, link_id, *args, **kwargs):
     try:
         c = client.SqoopClient(
             conf.SERVER_URL.get(),
             request.user.username,
             request.LANGUAGE_CODE,
             ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
         link = c.get_link(int(link_id))
     except RestException, e:
         handle_rest_exception(e, _('Could not get link.'))
示例#9
0
def get_submissions(request):
    response = {'status': 0, 'errors': None, 'submissions': []}
    status = request.GET.get('status', 'submissions').split(',')
    try:
        c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username,
                               request.LANGUAGE_CODE)
        submissions = c.get_submissions()
        response['submissions'] = list_to_dict(submissions)
    except RestException, e:
        response.update(
            handle_rest_exception(e, _('Could not get submissions.')))
示例#10
0
文件: framework.py 项目: ymc/hue
def framework(request):
    response = {'status': 0, 'errors': None, 'framework': None}
    if request.method == 'GET':
        try:
            c = client.SqoopClient(conf.SERVER_URL.get(),
                                   request.user.username,
                                   request.LANGUAGE_CODE)
            response['framework'] = c.get_framework().to_dict()
        except RestException, e:
            response.update(
                handle_rest_exception(e, _('Could not get framework.')))
        return HttpResponse(json.dumps(response), mimetype="application/json")
示例#11
0
文件: link.py 项目: sandredd/hue-1
def get_links(request):
    response = {'status': 0, 'errors': None, 'links': []}
    try:
        c = client.SqoopClient(
            conf.SERVER_URL.get(),
            request.user.username,
            request.LANGUAGE_CODE,
            ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
        response['links'] = list_to_dict(c.get_links())
    except RestException as e:
        response.update(handle_rest_exception(e, _('Could not get links.')))
    return JsonResponse(response)
示例#12
0
文件: driver.py 项目: igloosec/hue
def driver(request):
  response = {
    'status': 0,
    'errors': None,
    'driver': None
  }
  if request.method == 'GET':
    try:
      c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE)
      response['driver'] = c.get_driver().to_dict()
    except RestException, e:
      response.update(handle_rest_exception(e, _('Could not get driver.')))
    return JsonResponse(response)
示例#13
0
def link_delete(request, link):
  if request.method != 'POST':
    raise StructuredException(code="INVALID_METHOD", message=_('POST request required.'), error_code=405)

  response = {
    'status': 0,
    'errors': None
  }

  try:
    c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE)
    c.delete_link(link)
  except RestException, e:
    response.update(handle_rest_exception(e, _('Could not delete link.')))
示例#14
0
def job_stop(request, job):
    if request.method != 'POST':
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('POST request required.'),
                                  error_code=405)

    response = {'status': 0, 'errors': None, 'submission': None}

    try:
        c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username,
                               request.LANGUAGE_CODE)
        response['submission'] = c.stop_job(job).to_dict()
    except RestException, e:
        response.update(handle_rest_exception(e, _('Could not stop job.')))
示例#15
0
def get_submissions(request):
  response = {
    'status': 0,
    'errors': None,
    'submissions': []
  }
  status = request.GET.get('status', 'submissions').split(',')
  try:
    c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE, ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
    submissions = c.get_submissions()
    response['submissions'] = list_to_dict(submissions)
  except RestException as e:
    response.update(handle_rest_exception(e, _('Could not get submissions.')))
  return JsonResponse(response)
示例#16
0
def job_clone(request, job):
    if request.method != 'POST':
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('POST request required.'),
                                  error_code=405)

    response = {'status': 0, 'errors': None, 'job': None}

    job.id = -1
    job.name = '%s-copy' % job.name
    try:
        c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username,
                               request.LANGUAGE_CODE)
        response['job'] = c.create_job(job).to_dict()
    except RestException, e:
        response.update(handle_rest_exception(e, _('Could not clone job.')))
示例#17
0
def update_link(request, link):
  response = {
    'status': 0,
    'errors': None,
    'link': None
  }

  if 'link' not in request.POST:
    raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving link'), data={'errors': 'Link is missing.'}, error_code=400)

  link.update_from_dict(json.loads(smart_str(request.POST['link'])))

  try:
    c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE)
    response['link'] = c.update_link(link).to_dict()
  except RestException, e:
    response.update(handle_rest_exception(e, _('Could not update link.')))
示例#18
0
def job_delete(request, job):
    if request.method != 'POST':
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('POST request required.'),
                                  error_code=405)

    response = {'status': 0, 'errors': None, 'job': None}

    try:
        c = client.SqoopClient(
            conf.SERVER_URL.get(),
            request.user.username,
            request.LANGUAGE_CODE,
            ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
        c.delete_job(job)
    except RestException, e:
        response.update(handle_rest_exception(e, _('Could not delete job.')))
示例#19
0
文件: connection.py 项目: ymc/hue
def update_connection(request, connection):
    response = {'status': 0, 'errors': None, 'connection': None}

    if 'connection' not in request.POST:
        raise StructuredException(code="INVALID_REQUEST_ERROR",
                                  message=_('Error saving connection'),
                                  data={'errors': 'Connection is missing.'},
                                  error_code=400)

    connection.update_from_dict(json.loads(request.POST['connection']))

    try:
        c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username,
                               request.LANGUAGE_CODE)
        response['connection'] = c.update_connection(connection).to_dict()
    except RestException, e:
        response.update(
            handle_rest_exception(e, _('Could not update connection.')))
示例#20
0
def job_status(request, job):
    if request.method != 'GET':
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('GET request required.'),
                                  error_code=405)

    response = {'status': 0, 'errors': None, 'submission': None}

    try:
        c = client.SqoopClient(
            conf.SERVER_URL.get(),
            request.user.username,
            request.LANGUAGE_CODE,
            ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
        response['submission'] = c.get_job_status(job).to_dict()
    except RestException, e:
        response.update(
            handle_rest_exception(e, _('Could not get job status.')))
示例#21
0
文件: driver.py 项目: sandredd/hue-1
def driver(request):
    response = {'status': 0, 'errors': None, 'driver': None}
    if request.method == 'GET':
        try:
            c = client.SqoopClient(
                conf.SERVER_URL.get(),
                request.user.username,
                request.LANGUAGE_CODE,
                ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
            response['driver'] = c.get_driver().to_dict()
        except RestException as e:
            response.update(
                handle_rest_exception(e, _('Could not get driver.')))
        return JsonResponse(response)
    else:
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('GET request required.'),
                                  error_code=405)
示例#22
0
def link_clone(request, link):
    if request.method != 'POST':
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('POST request required.'),
                                  error_code=405)

    response = {'status': 0, 'errors': None, 'link': None}

    link.id = -1
    link.name = '%s-copy' % link.name
    try:
        c = client.SqoopClient(
            conf.SERVER_URL.get(),
            request.user.username,
            request.LANGUAGE_CODE,
            ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
        response['link'] = c.create_link(link).to_dict()
    except RestException, e:
        response.update(handle_rest_exception(e, _('Could not clone link.')))
示例#23
0
文件: job.py 项目: zkenstein/hue
def update_job(request, job):
  if request.method != 'POST':
    raise StructuredException(code="INVALID_METHOD", message=_('POST request required.'), error_code=405)

  response = {
    'status': 0,
    'errors': None,
    'job': None
  }

  if 'job' not in request.POST:
    raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving job'), data={'errors': 'job is missing.'}, error_code=400)

  job.update_from_dict(json.loads(smart_str(request.POST.get('job'))))

  try:
    c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE)
    response['job'] = c.update_job(job).to_dict()
  except RestException, e:
    response.update(handle_rest_exception(e, _('Could not update job.')))
示例#24
0
文件: link.py 项目: sandredd/hue-1
def link_delete(request, link):
    if request.method != 'POST':
        raise StructuredException(code="INVALID_METHOD",
                                  message=_('POST request required.'),
                                  error_code=405)

    response = {'status': 0, 'errors': None}

    try:
        c = client.SqoopClient(
            conf.SERVER_URL.get(),
            request.user.username,
            request.LANGUAGE_CODE,
            ssl_cert_ca_verify=conf.SSL_CERT_CA_VERIFY.get())
        c.delete_link(link)
    except RestException as e:
        response.update(handle_rest_exception(e, _('Could not delete link.')))
    except SqoopException as e:
        response['status'] = 100
        response['errors'] = e.to_dict()
    return JsonResponse(response)