def query_project_index(trace_id,
                        project_id,
                        user_id=None,
                        filter_expression=None,
                        convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'ProjectID': {
            'AttributeValueList': [project_id],
            'ComparisonOperator': 'EQ'
        }
    }
    if common_utils.is_null(user_id) is False:
        key_conditions['UserID'] = {
            'AttributeValueList': [user_id],
            'ComparisonOperator': 'EQ'
        }

    result = DB_utils.query_index(trace_id, Tables.PM_SECURITY_CHECK_WEBHOOK,
                                  PROJECT_INDEX, key_conditions,
                                  filter_expression)
    if result and convert_response:
        result = common_utils.convert_list_response(
            trace_id, result, RESPONSE_SECURITY_CHECK_WEBHOOK)
    return common_utils.response(result, pm_logger)
def query_history_index(trace_id,
                        check_history_id,
                        filter_expression=None,
                        convert_response=None,
                        is_cw_logger=False):
    if (is_cw_logger):
        logger = common_utils.begin_cw_logger(trace_id, __name__,
                                              inspect.currentframe())
    else:
        logger = common_utils.begin_logger(trace_id, __name__,
                                           inspect.currentframe())
    key_conditions = {
        'CheckHistoryID': {
            'AttributeValueList': [check_history_id],
            'ComparisonOperator': 'EQ'
        }
    }
    result = DB_utils.query_index(trace_id,
                                  Tables.PM_CHECK_RESULTS,
                                  CHECK_HISTORY_INDEX,
                                  key_conditions,
                                  filter_expression,
                                  is_cw_logger=is_cw_logger)
    if result and convert_response:
        result = common_utils.convert_list_response(trace_id,
                                                    result,
                                                    RESPONSE_CHECK_RESULTS,
                                                    RESPONSE_REQUIRED,
                                                    is_cw_logger=is_cw_logger)
    return common_utils.response(result, logger)
def query_check_history_index(trace_id,
                              check_history_id,
                              sort_code=None,
                              filter_expression=None,
                              is_cw_logger=False):
    if (is_cw_logger):
        logger = common_utils.begin_cw_logger(trace_id, __name__,
                                              inspect.currentframe())
    else:
        logger = common_utils.begin_logger(trace_id, __name__,
                                           inspect.currentframe())
    key_conditions = {
        'CheckHistoryID': {
            'AttributeValueList': [check_history_id],
            'ComparisonOperator': 'EQ'
        }
    }
    if sort_code is not None:
        key_conditions['SortCode'] = {
            'AttributeValueList': [sort_code],
            'ComparisonOperator': 'EQ'
        }
    result = DB_utils.query_index(trace_id,
                                  Tables.PM_CHECK_RESULT_ITEMS,
                                  CHECK_HISTORY_INDEX,
                                  key_conditions,
                                  filter_expression,
                                  is_cw_logger=is_cw_logger)
    return common_utils.response(result, logger)
示例#4
0
def query_organization_by_email(trace_id, mail_address):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'MailAddress': {
            'AttributeValueList': [mail_address],
            'ComparisonOperator': 'EQ'
        }
    }
    filter_expression = Attr('InvitationStatus').eq(1)
    result = DB_utils.query_index(trace_id, Tables.PM_AFFILIATION,
                                  MAILADDRESS_INDEX, key_conditions,
                                  filter_expression)
    return common_utils.response(result, pm_logger)
示例#5
0
def query_user_index(user_id, filter_expression=None, convert_response=None):
    pm_logger = common_utils.begin_logger(user_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'UserID': {
            'AttributeValueList': [user_id],
            'ComparisonOperator': 'EQ'
        }
    }
    result = DB_utils.query_index(user_id, Tables.PM_EMAIL_CHANGE_APPLY,
                                  USER_INDEX, key_conditions,
                                  filter_expression)
    if convert_response:
        result = common_utils.convert_list_response(
            user_id, result, RESPONSE_EMAIL_CHANGE_APPLY)
    return common_utils.response(result, pm_logger)
示例#6
0
def query_organization_index(trace_id, organization_id,
                             filter_expression=None, convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'OrganizationID': {
            'AttributeValueList': [organization_id],
            'ComparisonOperator': 'EQ'
        }
    }
    result = DB_utils.query_index(trace_id, Tables.PM_PROJECTS,
                                  ORGANIZATION_INDEX, key_conditions,
                                  filter_expression)

    if convert_response:
        result = common_utils.convert_list_response(
            trace_id, result, RESPONSE_PROJECTS)
    return common_utils.response(result, pm_logger)
def query_check_item_refine_code(trace_id,
                                 check_item_refine_code,
                                 filter_expression=None,
                                 convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'CheckItemRefineCode': {
            'AttributeValueList': [check_item_refine_code],
            'ComparisonOperator': 'EQ'
        }
    }
    result = DB_utils.query_index(trace_id, Tables.PM_EXCLUSION_RESOURCES,
                                  CHECK_ITEM_REFINE_INDEX, key_conditions,
                                  filter_expression)
    if result and convert_response:
        result = common_utils.convert_list_response(
            trace_id, result, RESPONSE_EXCLUSION_RESOURCES)
    return common_utils.response(result, pm_logger)
def query_project_index_by_organization_id(trace_id,
                                           organization_id,
                                           project_id,
                                           convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'ProjectID': {
            'AttributeValueList': [project_id],
            'ComparisonOperator': 'EQ'
        }
    }
    filter = Attr('OrganizationID').eq(organization_id)
    result = DB_utils.query_index(trace_id, Tables.PM_CHECK_HISTORY,
                                  PROJECT_INDEX, key_conditions, filter, False)
    if convert_response:
        result = common_utils.convert_list_response(trace_id, result,
                                                    RESPONSE_HISTORY)
    return common_utils.response(result, pm_logger)
示例#9
0
def query_organization_index(trace_id,
                             organization_id,
                             project_id,
                             filter_expression=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'OrganizationID': {
            'AttributeValueList': [organization_id],
            'ComparisonOperator': 'EQ'
        },
        'ProjectID': {
            'AttributeValueList': [project_id],
            'ComparisonOperator': 'EQ'
        }
    }
    result = DB_utils.query_index(trace_id, Tables.PM_ASSESSMENT_ITEMS,
                                  ORGANIZATION_INDEX, key_conditions,
                                  filter_expression)
    return common_utils.response(result, pm_logger)
def query_webhook_index(trace_id,
                        webhook_path,
                        filter_expression=None,
                        convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'WebhookPath': {
            'AttributeValueList': [webhook_path],
            'ComparisonOperator': 'EQ'
        }
    }

    result = DB_utils.query_index(trace_id, Tables.PM_SECURITY_CHECK_WEBHOOK,
                                  WEBHOOK_PATH_INDEX, key_conditions,
                                  filter_expression)
    if result and convert_response:
        result = common_utils.convert_list_response(
            trace_id, result, RESPONSE_SECURITY_CHECK_WEBHOOK)

    return common_utils.response(result, pm_logger)
示例#11
0
def query_filter_account_refine_code(trace_id,
                                     account_refine_code,
                                     group_filter=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'AccountRefineCode': {
            'AttributeValueList': [account_refine_code],
            'ComparisonOperator': 'EQ'
        }
    }
    if common_utils.is_null(group_filter) is False:
        key_conditions['CheckItemCode'] = {
            'AttributeValueList': [CommonConst.GROUP_FILTER_TEMPLATE.format(group_filter)],
            'ComparisonOperator': 'BEGINS_WITH'
        }

    result = DB_utils.query_index(trace_id, Tables.PM_ASSESSMENT_ITEMS,
                                  ACCOUNT_REFINE_INDEX, key_conditions,
                                  None)
    return common_utils.response(result, pm_logger)
示例#12
0
def query_list_reports_project_index(trace_id,
                                     project_id,
                                     filter_expression=None,
                                     convert_response=None,
                                     scan_index_forward=True):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'ProjectID': {
            'AttributeValueList': [project_id],
            'ComparisonOperator': 'EQ'
        }
    }
    result = DB_utils.query_index(trace_id, Tables.PM_REPORTS, PROJECT_INDEX,
                                  key_conditions, filter_expression,
                                  scan_index_forward)

    if convert_response:
        result = common_utils.convert_list_response(trace_id, result,
                                                    RESPONSE_REPORT)

    return common_utils.response(result, pm_logger)
def query_awscoop_project_index(trace_id,
                                project_id,
                                filter_expression=None,
                                convert_response=None,
                                aws_account=None,
                                is_cw_logger=False):
    if (is_cw_logger):
        logger = common_utils.begin_cw_logger(trace_id, __name__,
                                              inspect.currentframe())
    else:
        logger = common_utils.begin_logger(trace_id, __name__,
                                           inspect.currentframe())
    key_conditions = {
        'ProjectID': {
            'AttributeValueList': [project_id],
            'ComparisonOperator': 'EQ'
        }
    }
    if aws_account is not None:
        key_conditions['AWSAccount'] = {
            'AttributeValueList': [aws_account],
            'ComparisonOperator': 'EQ'
        }
    result = DB_utils.query_index(trace_id,
                                  Tables.PM_AWSACCOUNTCOOPS,
                                  PROJECT_INDEX,
                                  key_conditions,
                                  filter_expression,
                                  is_cw_logger=is_cw_logger)

    if convert_response:
        result = common_utils.convert_list_response(trace_id,
                                                    result,
                                                    RESPONSE_AWSCOOPS,
                                                    RESPONSE_REQUIRED,
                                                    is_cw_logger=is_cw_logger)
    return common_utils.response(result, logger)