Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- service = {
- "service_id": "sps:service:template-test",
- "service_name": "template-test",
- "urn": "{}/template.format(version_slug)",
- "actions": [
- {
- "action": "render-jinja2",
- "params": [
- {"name": "source", "type": "string", "required": "True"},
- {"name": "variables", "type": "dict", "required": "True"}
- ]
- },
- {
- "action": "render-jinja2",
- "params": [
- {"name": "source", "type": "string", "required": "True"},
- {"name": "variables", "type": "dict", "required": "True"}
- ]
- },
- ]
- }
- service_id = service['service_id']
- service_name = service['service_name']
- service_url = service['urn']
- actions = service['actions']
- if service_id is None or service_name is None or service_url is None:
- # log().error("event does not contain neccessary params")
- # raise BadRequestException, "Missing params"
- print ('there are missing params in service')
- if re.match("^[a-zA-Z0-9_:-]*$", service_id) is None:
- print ('service_id has wrong format')
- if re.match("^[a-zA-Z0-9_:-]*$", service_name) is None:
- print ('service_name has wrong format')
- for index in range(0, len(actions)):
- if re.match("^[a-zA-Z0-9_:-]*$", actions[index]['action']) is None:
- print ('action_name {} has wrong format'.format(actions[index]['action']))
- params = actions[index]['params']
- for param_index in range(0, len(params)):
- params_keys = params[param_index].keys()
- if 'required' not in params_keys or 'name' not in params_keys:
- print ("action params don't contain all neccesary attributes")
- if params[param_index]['required'] not in ('True', 'False'):
- print ("value of 'required' param attribute can be True or False only")
- if re.match("^[a-zA-Z0-9_:-]*$", params[param_index]['name']) is None:
- print "value of 'name' param attribute contains illegal characters"
- print ('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement