"""JSON Draft3 Schema Validators. This file loads HTTP header and body validation schemas as defined in RAML into Draft3Validator classes and keeps them ready for use in memory. Draft3Validator validator classes are used in the json_schema.validate() function definition. """ from jsonschema import Draft3Validator from project_manager import config from project_manager.validation import json_schema # CHECK_PROJECT_OWNERSHIP_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/ownership'] resource = resource.resources['/{accountType}'] resource = resource.resources['/{accountId}'] resource = resource.resources['/project'] resource = resource.resources['/{projectId}'] CHECK_PROJECT_OWNERSHIP_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['head'].headers)) # POST_PROJECT_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/project'] POST_PROJECT_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['post'].headers)) # POST_PROJECT_BODY_VALIDATOR POST_PROJECT_BODY_VALIDATOR = Draft3Validator( resource.methods['post'].body['application/json'].schema) # GET_PROJECT_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/project'] resource = resource.resources['/{projectId}'] GET_PROJECT_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # PUT_PROJECT_HEADER_VALIDATOR PUT_PROJECT_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['put'].headers)) # PUT_PROJECT_BODY_VALIDATOR PUT_PROJECT_BODY_VALIDATOR = Draft3Validator( resource.methods['put'].body['application/json'].schema) # GET_PROJECT_IMPRINTS_HEADER_VALIDATOR resource = resource.resources['/product'].resources['/imprints'] GET_PROJECT_IMPRINTS_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_PROJECT_PRODUCT_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/project'] resource = resource.resources['/{projectId}'].resources['/product'] resource = resource.resources['/{productId}'] GET_PROJECT_PRODUCT_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_PROJECT_PRODUCTS_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/project'] resource = resource.resources['/{projectId}'].resources['/products'] GET_PROJECT_PRODUCTS_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_PROJECTS_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/projects'] GET_PROJECTS_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_PRODUCT_GENRES_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/product'].resources['/genres'] GET_PRODUCT_GENRES_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_PRODUCT_SUBGENRES_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/product'].resources['/genres'] resource = resource.resources['/{genreId}'].resources['/subgenres'] GET_PRODUCT_SUBGENRES_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_PRODUCT_SUBGENRES_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/product'].resources['/types'] GET_PRODUCT_TYPES_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # GET_REPORT_HEADER_VALIDATOR resource = config.API_DEFINITION.resources['/report'] resource = resource.resources['/{projectId}'] GET_REPORT_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['get'].headers)) # POST_REPORT_HEADER_VALIDATOR POST_REPORT_HEADER_VALIDATOR = Draft3Validator( json_schema.raml_header_to_json_schema(resource.methods['post'].headers))