def query_key(trace_id,
              organization_id,
              notify_code,
              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 = {"OrganizationID": organization_id, "NotifyCode": notify_code}
    result = DB_utils.query_key(trace_id,
                                Tables.PM_ORG_NOTIFY_MAIL_DESTINATIONS,
                                key,
                                is_cw_logger=is_cw_logger)
    if result and convert_response:
        result = common_utils.convert_response(
            trace_id,
            result,
            RESPONSE_ORG_NOTIFY_MAIL_DESTINATIONS,
            is_cw_logger=is_cw_logger)
        result['destinations'] = common_utils.convert_list_response(
            trace_id,
            result['destinations'],
            RESPONSE_DESTINATIONS,
            is_cw_logger=is_cw_logger)
    return common_utils.response(result, logger)
def query_key(trace_id, exclusion_resource_id, convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key = {"ExclusionResourceID": exclusion_resource_id}
    result = DB_utils.query_key(trace_id, Tables.PM_EXCLUSION_RESOURCES, key)
    if result is not None and convert_response:
        result = common_utils.convert_response(trace_id, result,
                                               RESPONSE_EXCLUSION_RESOURCES)
    return common_utils.response(result, pm_logger)
Beispiel #3
0
def query_key(trace_id, apply_id, convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key = {"ApplyID": apply_id}
    result = DB_utils.query_key(trace_id, Tables.PM_EMAIL_CHANGE_APPLY, key)
    if convert_response:
        result = common_utils.convert_response(trace_id, result,
                                               RESPONSE_EMAIL_CHANGE_APPLY)
    return common_utils.response(result, pm_logger)
Beispiel #4
0
def query_key(trace_id, assessment_item_id, convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key = {"AssessmentItemID": assessment_item_id}
    result = DB_utils.query_key(trace_id, Tables.PM_ASSESSMENT_ITEMS, key)
    if result is not None and convert_response:
        result = common_utils.convert_response(
            trace_id, result, RESPONSE_ASSESSMENT)
    return common_utils.response(result, pm_logger)
def get_affiliation(user_id, organization_id, convert_response=None):
    pm_logger = common_utils.begin_logger(user_id, __name__,
                                          inspect.currentframe())
    key = {"UserID": user_id, "OrganizationID": organization_id}
    result = DB_utils.query_key(user_id, Tables.PM_AFFILIATION, key)

    if result and convert_response:
        result = common_utils.convert_response(user_id, result,
                                               RESPONSE_AFFILIATION)
    return common_utils.response(result, pm_logger)
Beispiel #6
0
def query_report(trace_id, report_id, convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key = {"ReportID": report_id}
    result = DB_utils.query_key(trace_id, Tables.PM_REPORTS, key)
    if convert_response:
        result = common_utils.convert_response(trace_id, result,
                                               RESPONSE_REPORT)

    return common_utils.response(result, pm_logger)
def query_key(user_id, convert_response=None):
    pm_logger = common_utils.begin_logger(user_id, __name__,
                                          inspect.currentframe())
    key = {"UserID": user_id}
    result = DB_utils.query_key(user_id, Tables.PM_USER_ATTRIBUTE, key)

    if result and convert_response:
        result = common_utils.convert_response(user_id, result,
                                               RESPONSE_USER_ATTRIBUTE)
    # return user
    return common_utils.response(result, pm_logger)
def query_key(trace_id,
              security_check_webhook_id,
              filter_expression=None,
              convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key = {'SecurityCheckWebhookID': security_check_webhook_id}
    result = DB_utils.query_key(trace_id, Tables.PM_SECURITY_CHECK_WEBHOOK,
                                key)
    if result and convert_response:
        result = common_utils.convert_response(
            trace_id, result, RESPONSE_SECURITY_CHECK_WEBHOOK)

    return common_utils.response(result, pm_logger)
Beispiel #9
0
def query_key(trace_id,
              exclusion_item_id,
              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 = {"ExclusionItemID": exclusion_item_id}
    result = DB_utils.query_key(trace_id, Tables.PM_EXCLUSION_ITEMS, key)
    if result is not None and convert_response:
        result = common_utils.convert_response(trace_id, result,
                                               RESPONSE_EXCLUSION)
    return common_utils.response(result, logger)
def get_check_history_by_status(trace_id,
                                check_history_id,
                                check_status,
                                convert_response=None):
    pm_logger = common_utils.begin_logger(trace_id, __name__,
                                          inspect.currentframe())
    key_conditions = {
        'CheckHistoryID': {
            'AttributeValueList': [check_history_id],
            'ComparisonOperator': 'EQ'
        }
    }
    filter = Attr('CheckStatus').eq(check_status)
    result = DB_utils.query(trace_id, Tables.PM_CHECK_HISTORY, key_conditions,
                            filter)
    if convert_response:
        result = common_utils.convert_response(trace_id, result,
                                               RESPONSE_HISTORY)
    return common_utils.response(result, pm_logger)
def query_key(trace_id,
              check_history_id,
              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 = {"CheckHistoryID": check_history_id}
    result = DB_utils.query_key(trace_id,
                                Tables.PM_CHECK_HISTORY,
                                key,
                                is_cw_logger=is_cw_logger)
    if convert_response:
        result = common_utils.convert_response(trace_id,
                                               result,
                                               RESPONSE_HISTORY,
                                               is_cw_logger=is_cw_logger)
    return common_utils.response(result, logger)
Beispiel #12
0
def query_report_job_def_key(trace_id,
                             code,
                             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 = {"Code": code}
    result = DB_utils.query_key(trace_id,
                                Tables.PM_BATCH_JOB_DEFS,
                                key,
                                is_cw_logger=is_cw_logger)

    if convert_response:
        result = common_utils.convert_response(trace_id,
                                               result,
                                               RESPONSE_REPORT_JOB_DEF,
                                               is_cw_logger=is_cw_logger)
    return common_utils.response(result, logger)
def get_organization(trace_id,
                     organization_id,
                     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 = {"OrganizationID": organization_id}

    result = DB_utils.query_key(trace_id,
                                Tables.PM_ORGANIZATIONS,
                                key,
                                is_cw_logger=is_cw_logger)
    if result and convert_response:
        result = common_utils.convert_response(trace_id,
                                               result,
                                               RESPONSE_ORGANIZATION,
                                               is_cw_logger=is_cw_logger)

    return common_utils.response(result, logger)
def query_awscoop_coop_key(trace_id,
                           coop_id,
                           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 = {"CoopID": coop_id}
    result = DB_utils.query_key(trace_id,
                                Tables.PM_AWSACCOUNTCOOPS,
                                key,
                                is_cw_logger=is_cw_logger)

    if convert_response:
        result = common_utils.convert_response(trace_id,
                                               result,
                                               RESPONSE_AWSCOOPS,
                                               RESPONSE_REQUIRED,
                                               is_cw_logger=is_cw_logger)

    return common_utils.response(result, logger)