def POST(self, key): """ Create a new allowed key (value is NULL). HTTP Success: 201 Created HTTP Error: 401 Unauthorized 404 Not Found 409 Conflict 500 Internal Error :param Rucio-Auth-Account: Account identifier. :param Rucio-Auth-Token: as an 32 character hex string. :params Rucio-Account: account belonging to the new scope. """ json_data = data() try: params = json_data and loads(json_data) if params and 'value_type' in params: value_type = params['value_type'] if params and 'value_regexp' in params: value_regexp = params['value_regexp'] if params and 'key_type' in params: key_type = params['key_type'] except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: add_key(key=key, key_type=key_type, value_type=value_type, value_regexp=value_regexp, issuer=ctx.env.get('issuer')) except Duplicate, e: raise generate_http_error(409, 'Duplicate', e[0][0])
def post(self, key): """ Create a new allowed key (value is NULL). .. :quickref: Meta; Create new key. :<json dict parameter: Dictionary with 'value_type', 'value_regexp' and 'key_type'. :status 201: Created. :status 400: Cannot decode json parameter list. :status 400: Unsupported Value Type. :status 401: Invalid Auth Token. :status 409: Key already exists. """ parameters = json_parameters() try: add_key( key=key, key_type=param_get(parameters, 'key_type', default=None), value_type=param_get(parameters, 'value_type', default=None), value_regexp=param_get(parameters, 'value_regexp', default=None), issuer=request.environ.get('issuer'), vo=request.environ.get('vo'), ) except Duplicate as error: return generate_http_error_flask(409, error) except (UnsupportedValueType, UnsupportedKeyType) as error: return generate_http_error_flask(400, error) return 'Created', 201
def post(self, key): """ Create a new allowed key (value is NULL). .. :quickref: Meta; Create new key. :<json dict parameter: Dictionary with 'value_type', 'value_regexp' and 'key_type'. :status 201: Created. :status 400: Cannot decode json parameter list. :status 400: Unsupported Value Type. :status 401: Invalid Auth Token. :status 409: Key already exists. :status 500: Internal Error. """ json_data = request.data try: params = json_data and loads(json_data) if params and 'value_type' in params: value_type = params['value_type'] if params and 'value_regexp' in params: value_regexp = params['value_regexp'] if params and 'key_type' in params: key_type = params['key_type'] except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') try: add_key(key=key, key_type=key_type, value_type=value_type, value_regexp=value_regexp, issuer=request.environ.get('issuer')) except Duplicate, e: return generate_http_error_flask(409, 'Duplicate', e[0][0])
def post(self, key): """ Create a new allowed key (value is NULL). .. :quickref: Meta; Create new key. :<json dict parameter: Dictionary with 'value_type', 'value_regexp' and 'key_type'. :status 201: Created. :status 400: Cannot decode json parameter list. :status 400: Unsupported Value Type. :status 401: Invalid Auth Token. :status 409: Key already exists. :status 500: Internal Error. """ json_data = request.data.decode() try: params = json_data and loads(json_data) if params and 'value_type' in params: value_type = params['value_type'] if params and 'value_regexp' in params: value_regexp = params['value_regexp'] if params and 'key_type' in params: key_type = params['key_type'] except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') try: add_key(key=key, key_type=key_type, value_type=value_type, value_regexp=value_regexp, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except Duplicate as error: return generate_http_error_flask(409, 'Duplicate', error.args[0]) except UnsupportedValueType as error: return generate_http_error_flask(400, 'UnsupportedValueType', error.args[0]) except UnsupportedKeyType as error: return generate_http_error_flask(400, 'UnsupportedKeyType', error.args[0]) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) return str(error), 500 return 'Created', 201
def createMetadata(): add_key('project', 'all', 'root') add_key('run_number', 'all', 'root') add_key('stream_name', 'all', 'root') add_key('prod_step', 'all', 'root') add_key('datatype', 'all', 'root') add_key('campaign', 'all', 'root') add_key('provenance', 'all', 'root') add_key('group', 'all', 'root')
def createMetadata(): add_key('project', 'all', 'root') add_key('run_number', 'all', 'root') add_key('stream_name', 'all', 'root') add_key('prod_step', 'all', 'root') add_key('datatype', 'all', 'root') add_key('provenance', 'all', 'root') add_key('group', 'all', 'root')
def post(self, key): """ --- summary: Create key description: Creates a new allowed key (value is NULL). tags: - Meta parameters: - name: key in: path description: The name of the key. schema: type: string style: simple requestBody: content: application/json: schema: type: object properties: key_type: description: The key tpye. type: string value_type: description: The value type. type: string value_regexp: description: The value regexpression. type: string responses: 201: description: OK content: application/json: schema: type: string enum: ['Created'] 400: description: Cannot decode json parameter list / Unsupported value type. 401: description: Invalid Auth Token. 409: description: Key already exists. """ parameters = json_parameters() try: add_key( key=key, key_type=param_get(parameters, 'key_type', default=None), value_type=param_get(parameters, 'value_type', default=None), value_regexp=param_get(parameters, 'value_regexp', default=None), issuer=request.environ.get('issuer'), vo=request.environ.get('vo'), ) except Duplicate as error: return generate_http_error_flask(409, error) except (UnsupportedValueType, UnsupportedKeyType) as error: return generate_http_error_flask(400, error) return 'Created', 201