示例#1
0
def get_daemon_config_for_current_network(event, context):
    logger.info(f"event for get_daemon_config_for_current_network:: {event}")
    username = event["requestContext"]["authorizer"]["claims"]["email"]
    path_parameters = event["pathParameters"]
    query_parameters = event["queryStringParameters"]
    if not validate_dict(path_parameters,
                         ["org_uuid", "service_uuid", "group_id"
                          ]) or 'network' not in query_parameters:
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    service_uuid = path_parameters["service_uuid"]
    group_id = path_parameters["group_id"]
    if query_parameters["network"] == EnvironmentType.TEST.value:
        response = ServicePublisherService(
            username, org_uuid,
            service_uuid).daemon_config(environment=EnvironmentType.TEST.value)
    elif query_parameters["network"] == EnvironmentType.MAIN.value:
        response = ServicePublisherService(
            username, org_uuid,
            service_uuid).daemon_config(environment=EnvironmentType.MAIN.value)
    else:
        raise EnvironmentNotFoundException()
    return generate_lambda_response(StatusCode.OK, {
        "status": "success",
        "data": response,
        "error": {}
    },
                                    cors_enabled=True)
示例#2
0
def list_of_orgs_with_services_submitted_for_approval(event, context):
    response = ServicePublisherService(
        None, None,
        None).get_list_of_orgs_with_services_submitted_for_approval()
    return generate_lambda_response(StatusCode.OK, {
        "status": "success",
        "data": response,
        "error": {}
    },
                                    cors_enabled=True)
示例#3
0
 def get_list_of_service_pending_for_approval(self):
     list_of_service_pending_for_approval = \
         ServicePublisherService(username=None, org_uuid=None, service_uuid=None). \
             get_list_of_service_pending_for_approval(limit=MAX_SERVICES_SLACK_LISTING)
     slack_blocks = self.generate_slack_blocks_for_service_listing_template(
         list_of_service_pending_for_approval)
     slack_payload = {"blocks": slack_blocks}
     response = requests.post(url=SLACK_APPROVAL_CHANNEL_URL,
                              data=json.dumps(slack_payload))
     logger.info(f"{response.status_code} | {response.text}")
示例#4
0
def get_code_build_status_for_service(event, context):
    logger.info(f"Get code build status event :: {event}")
    path_parameters = event["pathParameters"]
    org_uuid = path_parameters["org_uuid"]
    service_uuid = path_parameters["service_uuid"]
    response = ServicePublisherService(org_uuid=org_uuid, service_uuid=service_uuid, username=None) \
        .get_service_demo_component_build_status()
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )
示例#5
0
def create_service(event, context):
    username = event["requestContext"]["authorizer"]["claims"]["email"]
    path_parameters = event["pathParameters"]
    payload = json.loads(event["body"])
    if not path_parameters.get("org_uuid", ""):
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    response = ServicePublisherService(username, org_uuid, None).create_service(payload)
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )
示例#6
0
def service_deployment_status_notification_handler(event, context):
    logger.info(f"Service Build status event {event}")
    org_id = event['org_id']
    service_id = event['service_id']
    build_status = int(event['build_status'])

    ServicePublisherService("BUILD_PROCESS", "", "").service_build_status_notifier(org_id, service_id, build_status)

    return generate_lambda_response(
        StatusCode.CREATED,
        {"status": "success", "data": "Build failure notified", "error": {}}, cors_enabled=True
    )
示例#7
0
def get_service_details_using_org_id_service_id(event, context):
    logger.info(f"event: {event}")
    query_parameters = event["queryStringParameters"]
    if not validate_dict(query_parameters, ["org_id", "service_id"]):
        raise BadRequestException()
    org_id = query_parameters["org_id"]
    service_id = query_parameters["service_id"]
    response = ServicePublisherService.get_service_for_org_id_and_service_id(org_id, service_id)
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )
示例#8
0
def publish_service_metadata_to_ipfs(event, context):
    username = event["requestContext"]["authorizer"]["claims"]["email"]
    path_parameters = event["pathParameters"]
    if "org_uuid" not in path_parameters and "service_uuid" not in path_parameters:
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    service_uuid = path_parameters["service_uuid"]
    response = ServicePublisherService(username, org_uuid, service_uuid).publish_service_data_to_ipfs()
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )
示例#9
0
def list_of_service_pending_for_approval_from_slack(event, context):
    path_parameters = event["pathParameters"]
    if "org_uuid" not in path_parameters:
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    response = ServicePublisherService(
        None, org_uuid, None).get_list_of_service_pending_for_approval()
    return generate_lambda_response(StatusCode.OK, {
        "status": "success",
        "data": response,
        "error": {}
    },
                                    cors_enabled=True)
示例#10
0
def verify_service_id(event, context):
    username = event["requestContext"]["authorizer"]["claims"]["email"]
    path_parameters = event["pathParameters"]
    query_parameters = event["queryStringParameters"]
    if "org_uuid" not in path_parameters and "service_id" not in query_parameters:
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    service_id = query_parameters["service_id"]
    response = ServicePublisherService(username, org_uuid, None).get_service_id_availability_status(service_id)
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )
示例#11
0
def legal_approval_of_service(event, context):
    path_parameters = event["pathParameters"]
    if "org_uuid" not in path_parameters and "service_uuid" not in path_parameters:
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    service_uuid = path_parameters["service_uuid"]
    response = ServicePublisherService(None, org_uuid,
                                       service_uuid).approve_service()
    return generate_lambda_response(StatusCode.OK, {
        "status": "success",
        "data": response,
        "error": {}
    },
                                    cors_enabled=True)
示例#12
0
def save_service_attributes(event, context):
    logger.info(f"Event for save service {event}")
    username = event["requestContext"]["authorizer"]["claims"]["email"]
    path_parameters = event["pathParameters"]
    payload = json.loads(event["body"])
    if not path_parameters.get("org_uuid", "") and not path_parameters.get("service_uuid", ""):
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    service_uuid = path_parameters["service_uuid"]
    response = ServicePublisherService(username, org_uuid, service_uuid).save_service_attributes(payload)
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )
示例#13
0
def save_transaction_hash_for_published_service(event, context):
    username = event["requestContext"]["authorizer"]["claims"]["email"]
    path_parameters = event["pathParameters"]
    payload = json.loads(event["body"])
    if "org_uuid" not in path_parameters and "service_uuid" not in path_parameters:
        raise BadRequestException()
    org_uuid = path_parameters["org_uuid"]
    service_uuid = path_parameters["service_uuid"]
    response = ServicePublisherService(username, org_uuid, service_uuid).save_transaction_hash_for_published_service(
        payload)
    return generate_lambda_response(
        StatusCode.OK,
        {"status": "success", "data": response, "error": {}}, cors_enabled=True
    )