def GET(self, rule_id): """ get rule information for given rule id. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/json') try: estimate_ttc = False json_data = data() params = loads(json_data) if 'estimate_ttc' in params: estimate_ttc = params['estimate_ttc'] except ValueError: estimate_ttc = False try: rule = get_replication_rule(rule_id, estimate_ttc=estimate_ttc) except RuleNotFound as error: raise generate_http_error(404, 'RuleNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) return render_json(**rule)
def get(self, rule_id): """ get rule information for given rule id. .. :quickref: Rule; get rule info :returns: JSON dict containing informations about the requested user. :status 200: Rule found :status 406: Not Acceptable :status 410: Invalid Auth Token :status 404: no rule found for id """ try: estimate_ttc = False json_data = request.data params = loads(json_data) if 'estimate_ttc' in params: estimate_ttc = params['estimate_ttc'] except ValueError: estimate_ttc = False try: rule = get_replication_rule(rule_id, estimate_ttc=estimate_ttc) except RuleNotFound as error: return generate_http_error_flask(404, 'RuleNotFound', error.args[0]) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: return error, 500 return Response(render_json(**rule), content_type="application/json")
def GET(self, rule_id): """ get rule information for given rule id. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/json') try: rule = get_replication_rule(rule_id) except RuleNotFound, e: raise generate_http_error(404, 'RuleNotFound', e.args[0][0])
def get(self, rule_id): """ --- summary: Return a Rule tags: - Rule parameters: - name: rule_id in: path description: The id of the replication rule. schema: type: string style: simple responses: 200: description: OK content: application/json: schema: type: string 406: description: Not Acceptable 401: description: Invalid Auth Token 404: description: No rule found for the given id """ parameters = json_parameters(optional=True) estimate_ttc = param_get(parameters, 'estimate_ttc', default=False) if estimate_ttc: return generate_http_error_flask( 501, "NotImplemented", exc_msg="estimate_ttc is not implemented!") try: rule = get_replication_rule(rule_id, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except RuleNotFound as error: return generate_http_error_flask(404, error) return Response(render_json(**rule), content_type="application/json")
def get(self, rule_id): """ get rule information for given rule id. .. :quickref: Rule; get rule info :returns: JSON dict containing informations about the requested user. :status 200: Rule found :status 406: Not Acceptable :status 410: Invalid Auth Token :status 404: no rule found for id """ parameters = json_parameters(optional=True) estimate_ttc = param_get(parameters, 'estimate_ttc', default=False) try: rule = get_replication_rule(rule_id, estimate_ttc=estimate_ttc, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except RuleNotFound as error: return generate_http_error_flask(404, error) return Response(render_json(**rule), content_type="application/json")
def test_access_rule_vo(self): """ MULTI VO (CORE): Test accessing rules from a different VO """ scope = InternalScope('mock', **self.vo) dataset = 'dataset_' + str(generate_uuid()) account = InternalAccount('root', **self.vo) rse_str = ''.join(choice(ascii_uppercase) for x in range(10)) rse_name = 'MOCK_%s' % rse_str rse_id = add_rse(rse_name, 'root', **self.vo) add_replica(rse_id=rse_id, scope=scope, name=dataset, bytes=10, account=account) rule_id = add_rule(dids=[{'scope': scope, 'name': dataset}], account=account, copies=1, rse_expression='MOCK', grouping='NONE', weight='fakeweight', lifetime=None, locked=False, subscription_id=None)[0] with assert_raises(AccessDenied): delete_replication_rule(rule_id=rule_id, purge_replicas=False, issuer='root', **self.new_vo) # check locks are not accessible from other VO locks = list(get_replica_locks_for_rule_id(rule_id, **self.vo)) assert_equal(len(locks), 1) locks = list(get_replica_locks_for_rule_id(rule_id, **self.new_vo)) assert_equal(len(locks), 0) delete_replication_rule(rule_id=rule_id, purge_replicas=False, issuer='root', **self.vo) rule_dict = get_replication_rule(rule_id=rule_id, issuer='root', **self.vo) assert_is_not_none(rule_dict['expires_at'])