def post(): content = request.get_json() with open('temp.json', 'w') as f: json.dump(content, f) json_obj = JsonParser("temp.json") json_obj.validate_json_data_type(content) json_obj.parse_json_data() ml_uuid = uuidutils.generate_uuid() url = content['DataURL'] ml_lib = content['variables']['mlLib'] is_form_cluster = content['variables']['isFormCluster'] storage_name = content['variables']['storageAccountName'] storage_type = content['variables']['storageAccountType'] api.mldata_create(ml_uuid, url, ml_lib, is_form_cluster, storage_name, storage_type) resources = content['resource'] for res in resources: res_uuid = uuidutils.generate_uuid() resource_type = res.get('InfrastrctureType') provider = res.get('provider') if res.get('APIEndpoint'): endpoint = res.get('APIEndpoint') if res.get('PublicEndpoint'): endpoint = res.get('PublicEndpoint') username = res.get('username') password = res.get('password') token = res.get('token') availability_zone = res.get('availabilityZone') region = res.get('Region') api.resource_create(res_uuid, resource_type, provider, endpoint, username, password, token, availability_zone, region) if res['NodeList']: for node in res['NodeList']: uuid = uuidutils.generate_uuid() resource_id = res_uuid node_ip = node.get('NodeIP') username = node.get('Username') password = node.get('Password') api.node_create(uuid, resource_id, node_ip, username, password) return json.dumps(201, {'ContentType': 'application/json'})
def postJsonHandler(): db.create_all() content = request.get_json() with open('temp.json', 'w') as f: json.dump(content, f) json_obj = JsonParser("temp.json") username = content['username'] email = content['email'] new_user = User(username, email) db.session.add(new_user) db.session.commit() json_obj.validate_json_data_type(content) json_data = json_obj.parse_json_data() return json_data