def handler(*args, **kwargs): if id_prop and not get_args: get_args['id'] = id_prop[0] if 'marker' in id_prop: if 'marker' not in u.get_request_args(): return func(*args, **kwargs) kwargs['marker'] = u.get_request_args()['marker'] get_kwargs = {} for get_arg in get_args: get_kwargs[get_arg] = kwargs[get_args[get_arg]] obj = None try: obj = get_func(**get_kwargs) except Exception as e: cls_name = reflection.get_class_name(e, fully_qualified=False) if 'notfound' not in cls_name.lower(): raise e if obj is None: e = ex.NotFoundException(get_kwargs, _('Object with %s not found')) return u.not_found(e) if 'marker' in kwargs: del(kwargs['marker']) return func(*args, **kwargs)
def handler(*args, **kwargs): if id_prop and not get_args: get_args['id'] = id_prop[0] if 'marker' in id_prop: if 'marker' not in u.get_request_args(): return func(*args, **kwargs) kwargs['marker'] = u.get_request_args()['marker'] get_kwargs = {} for get_arg in get_args: get_kwargs[get_arg] = kwargs[get_args[get_arg]] obj = None try: obj = get_func(**get_kwargs) except Exception as e: cls_name = reflection.get_class_name(e, fully_qualified=False) if 'notfound' not in cls_name.lower(): raise e if obj is None: e = ex.NotFoundException(get_kwargs, _('Object with %s not found')) return u.not_found(e) if 'marker' in kwargs: del (kwargs['marker']) return func(*args, **kwargs)
def job_templates_list(): result = api.get_job_templates(**u.get_request_args().to_dict()) for jt in result: u._replace_tenant_id_project_id(jt) _replace_tenant_id_project_id_job_binary(jt['mains']) _replace_tenant_id_project_id_job_binary(jt['libs']) return u.render(res=result, name='job_templates')
def jobs_get(job_id): data = u.get_request_args() refresh_status = six.text_type(data.get('refresh_status', 'false')).lower() == 'true' result = {'job': api.get_job_execution(job_id, refresh_status)} result['job'].pop('oozie_job_id', force=True) return u.render(result)
def get_sorting_field(): request_args = u.get_request_args() if 'sort_by' in request_args: sort_by = request_args['sort_by'] if sort_by: sort_by = sort_by[1:] if sort_by[0] == '-' else sort_by return sort_by return None
def clusters_get(cluster_id): data = u.get_request_args() show_events = six.text_type(data.get('show_progress', 'false')).lower() == 'true' result = u.to_wrapped_dict_no_render(api.get_cluster, cluster_id, show_events) u._replace_hadoop_version_plugin_version(result['cluster']) return u.render(result)
def jobs_list(): result = api.job_execution_list(**u.get_request_args().to_dict()) # APIv2: renaming oozie_job_id -> engine_job_id # once APIv1 is deprecated this can be # removed for je in result: je.pop('oozie_job_id', force=True) return u.render(res=result, name='jobs')
def jobs_get(job_id): data = u.get_request_args() refresh_status = six.text_type( data.get('refresh_status', 'false')).lower() == 'true' result = {'job': api.get_job_execution(job_id, refresh_status)} result['job'].pop('oozie_job_id', force=True) u._replace_tenant_id_project_id(result['job']) _replace_job_id_job_template_id(result['job']) return u.render(result)
def job_types_get(): # We want to use flat=False with to_dict() so that # the value of each arg is given as a list. This supports # filters of the form ?type=Pig&type=Java, etc. request_args = u.get_request_args().to_dict(flat=False) if 'plugin_version' in request_args: request_args['hadoop_version'] = request_args['plugin_version'] del request_args['plugin_version'] return u.render(job_types=api.get_job_types(**request_args))
def jobs_get(job_id): data = u.get_request_args() refresh_status = six.text_type(data.get('refresh_status', 'false')).lower() == 'true' result = u.to_wrapped_dict_no_render(api.get_job_execution, job_id, refresh_status) result['engine_job_id'] = result['oozie_job_id'] del result['oozie_job_id'] return u.render(result)
def cluster_templates_list(): request_args = u.get_request_args().to_dict() if 'plugin_version' in request_args: request_args['hadoop_version'] = request_args['plugin_version'] del request_args['plugin_version'] result = api.get_cluster_templates(**request_args) for ct in result: u._replace_hadoop_version_plugin_version(ct) u._replace_tenant_id_project_id(ct) return u.render(res=result, name='cluster_templates')
def node_group_templates_list(): request_args = u.get_request_args().to_dict() if 'plugin_version' in request_args: request_args['hadoop_version'] = request_args['plugin_version'] del request_args['plugin_version'] result = api.get_node_group_templates(**request_args) for ngt in result: u._replace_hadoop_version_plugin_version(ngt) u._replace_tenant_id_project_id(ngt) return u.render(res=result, name="node_group_templates")
def validate_pagination_limit(): request_args = u.get_request_args() if 'limit' in request_args: if types.is_int(request_args['limit']): if not int(request_args['limit']) > 0: raise ex.SaharaException( _("'limit' must be positive integer"), 400) else: raise ex.SaharaException( _("'limit' must be positive integer"), 400)
def jobs_list(): result = api.job_execution_list(**u.get_request_args().to_dict()) # APIv2: renaming oozie_job_id -> engine_job_id # once APIv1 is deprecated this can be # removed for je in result: je.pop('oozie_job_id', force=True) u._replace_tenant_id_project_id(je) _replace_job_id_job_template_id(je) return u.render(res=result, name='jobs')
def validate_pagination_limit(): request_args = u.get_request_args() if 'limit' in request_args: if types.is_int(request_args['limit']): if not int(request_args['limit']) > 0: raise ex.SaharaException(_("'limit' must be positive integer"), 400) else: raise ex.SaharaException(_("'limit' must be positive integer"), 400)
def clusters_get(cluster_id): data = u.get_request_args() show_events = six.text_type( data.get('show_progress', 'false')).lower() == 'true' result = u.to_wrapped_dict_no_render( api.get_cluster, cluster_id, show_events) u._replace_hadoop_version_plugin_version(result['cluster']) u._replace_tenant_id_project_id(result['cluster']) _replace_tenant_id_project_id_provision_steps(result['cluster']) return u.render(result)
def handler(*args, **kwargs): pagination_params = ['marker', 'limit', 'sort_by'] func_name = func.__name__ params = u.get_request_args() for param in params.keys(): if (param not in supported_params and param not in pagination_params): return u.invalid_param_error( 400, 'The only valid params for %s are %s and %s' % (func_name, supported_params, pagination_params)) return func(*args, **kwargs)
def clusters_list(): request_args = u.get_request_args().to_dict() if 'plugin_version' in request_args: request_args['hadoop_version'] = request_args['plugin_version'] del request_args['plugin_version'] result = api.get_clusters(**request_args) for c in result: u._replace_hadoop_version_plugin_version(c) u._replace_tenant_id_project_id(c) _replace_tenant_id_project_id_provision_steps(c) return u.render(res=result, name='clusters')
def handler(*args, **kwargs): pagination_params = ['marker', 'limit', 'sort_by'] func_name = func.__name__ params = u.get_request_args() for param in params.keys(): if (param not in supported_params and param not in pagination_params): return u.invalid_param_error( 400, 'The only valid params for %s are %s and %s' % ( func_name, supported_params, pagination_params)) return func(*args, **kwargs)
def clusters_get(cluster_id): data = u.get_request_args() show_events = six.text_type( data.get('show_progress', 'false')).lower() == 'true' return u.to_wrapped_dict(api.get_cluster, cluster_id, show_events)
def data_sources_list(): result = api.get_data_sources(**u.get_request_args().to_dict()) for ds in result: u._replace_tenant_id_project_id(ds) return u.render(res=result, name='data_sources')
def job_list(): result = api.get_jobs(**u.get_request_args().to_dict()) return u.render(res=result, name='job_templates')
def job_binary_list(): result = api.get_job_binaries(**u.get_request_args().to_dict()) for jb in result: u._replace_tenant_id_project_id(jb) return u.render(res=result, name='binaries')
def cluster_templates_list(): return u.render(cluster_templates=[ t.to_dict() for t in api.get_cluster_templates(**u.get_request_args().to_dict()) ])
def clusters_get(cluster_id): data = u.get_request_args() show_events = unicode(data.get('show_progress', 'false')).lower() == 'true' return u.render(api.get_cluster(cluster_id, show_events).to_wrapped_dict())
def job_binary_internal_list(): return u.render(binaries=[j.to_dict() for j in api.get_job_binary_internals( **u.get_request_args().to_dict())])
def node_group_templates_list(): result = api.get_node_group_templates(**u.get_request_args().to_dict()) return u.render(res=result, name="node_group_templates")
def data_sources_list(): result = api.get_data_sources(**u.get_request_args().to_dict()) return u.render(res=result, name='data_sources')
def clusters_get(cluster_id): data = u.get_request_args() show_events = six.text_type(data.get('show_progress', 'false')).lower() == 'true' return u.to_wrapped_dict(api.get_cluster, cluster_id, show_events)
def job_binary_internal_list(): result = api.get_job_binary_internals(**u.get_request_args().to_dict()) return u.render(res=result, name='binaries')
def data_sources_list(): return u.render( data_sources=[ds.to_dict() for ds in api.get_data_sources( **u.get_request_args().to_dict())])
def images_list(): tags = u.get_request_args().getlist('tags') name = u.get_request_args().get('name', None) return u.render(images=[i.dict for i in api.get_images(name, tags)])
def job_list(): result = api.get_jobs(**u.get_request_args().to_dict()) return u.render(res=result, name='jobs')
def job_types_get(): # We want to use flat=False with to_dict() so that # the value of each arg is given as a list. This supports # filters of the form ?type=Pig&type=Java, etc. return u.render(job_types=api.get_job_types( **u.get_request_args().to_dict(flat=False)))
def job_executions_list(): result = api.job_execution_list( **u.get_request_args().to_dict()) return u.render(res=result, name='job_executions')
def job_executions_list(): job_executions = [je.to_dict() for je in api.job_execution_list( **u.get_request_args().to_dict())] return u.render(job_executions=job_executions)
def images_list(): tags = u.get_request_args().getlist('tags') return u.render(images=[i.dict for i in api.get_images(tags)])
def job_list(): return u.render(jobs=[j.to_dict() for j in api.get_jobs( **u.get_request_args().to_dict())])
def job_executions_list(): result = api.job_execution_list(**u.get_request_args().to_dict()) return u.render(res=result, name='jobs')
def clusters_list(): return u.render(clusters=[c.to_dict() for c in api.get_clusters( **u.get_request_args().to_dict())])
def job_types_get(): # We want to use flat=False with to_dict() so that # the value of each arg is given as a list. This supports # filters of the form ?type=Pig&type=Java, etc. return u.render(job_types=api.get_job_types(**u.get_request_args().to_dict( flat=False)))
def node_group_templates_list(): return u.render( node_group_templates=[t.to_dict() for t in api.get_node_group_templates( **u.get_request_args().to_dict())])
def job_binary_list(): result = api.get_job_binaries(**u.get_request_args().to_dict()) return u.render(res=result, name='binaries')
def node_group_templates_list(): return u.render(node_group_templates=[ t.to_dict() for t in api.get_node_group_templates(**u.get_request_args().to_dict()) ])
def cluster_templates_list(): return u.render( cluster_templates=[t.to_dict() for t in api.get_cluster_templates( **u.get_request_args().to_dict())])
def cluster_templates_list(): result = api.get_cluster_templates(**u.get_request_args().to_dict()) return u.render(res=result, name='cluster_templates')
def clusters_list(): return u.render(clusters=[ c.to_dict() for c in api.get_clusters(**u.get_request_args().to_dict()) ])