Example #1
0
def validate_name_request(location, entity_type, request_action):
    # Raise error if location is invalid
    if location not in ValidLocations.list():
        raise ValueError('Invalid location provided')

    # Raise error if request_action is invalid
    if request_action not in AnalysisRequestActions.list():
        raise ValueError('Invalid request action provided')

    # Throw any errors related to invalid entity_type or request_action for a location
    valid_location = location in [
        ValidLocations.CA_NOT_BC.value, ValidLocations.INTL.value
    ]
    valid_request_actions = [
        AnalysisRequestActions.NEW.value, AnalysisRequestActions.AML.value,
        AnalysisRequestActions.CHG.value, AnalysisRequestActions.ASSUMED.value,
        AnalysisRequestActions.REN.value, AnalysisRequestActions.REH.value
    ]

    if not valid_location:
        raise ValueError('Invalid location provided')

    if entity_type not in XproUnprotectedNameEntityTypes.list():
        raise ValueError('Invalid entity_type provided for an XPRO entity')

    if request_action not in valid_request_actions:
        raise Exception('Operation not currently supported')

    return True
def xpro_validate_name_request(location, entity_type, request_action):
    """Validate the params for xpro analysis."""
    errors = []

    # Check if location is invalid
    if location not in ValidLocations.list():
        errors.append('Invalid location provided')

    # Check if request_action is invalid
    if request_action not in AnalysisRequestActions.list():
        errors.append('Invalid request action provided')

    # Check validity for entity_type or request_action for a location
    valid_location = location in [
        ValidLocations.CA_NOT_BC.value, ValidLocations.INTL.value
    ]
    valid_request_actions = [
        AnalysisRequestActions.NEW.value, AnalysisRequestActions.AML.value,
        AnalysisRequestActions.CHG.value, AnalysisRequestActions.ASSUMED.value,
        AnalysisRequestActions.REN.value, AnalysisRequestActions.REH.value,
        AnalysisRequestActions.MVE.value
    ]

    if not valid_location:
        errors.append('Invalid location provided')

    if entity_type not in XproUnprotectedNameEntityTypes.list():
        errors.append('Invalid entity_type provided for an XPRO entity')

    if request_action not in valid_request_actions:
        errors.append('Operation not currently supported')

    return errors
Example #3
0
def validate_name_request(location, entity_type, request_action):
    # Raise error if location is invalid
    if location not in ValidLocations.list():
        raise ValueError('Invalid location provided')

    # Raise error if request_action is invalid
    if request_action not in AnalysisRequestActions.list():
        raise ValueError('Invalid request action provided')

    # Throw any errors related to invalid entity_type or request_action for a location
    if location == ValidLocations.CA_BC.value:
        is_protected = False
        is_unprotected = False

        # Determine what request actions are valid
        valid_request_actions = ()

        if entity_type in BCProtectedNameEntityTypes.list():
            is_protected = True
            valid_request_actions = (AnalysisRequestActions.NEW.value,
                                     AnalysisRequestActions.AML.value)

        elif entity_type in BCUnprotectedNameEntityTypes.list():
            is_unprotected = True
            valid_request_actions = (AnalysisRequestActions.NEW.value,
                                     AnalysisRequestActions.DBA.value)

        if is_protected and is_unprotected:
            raise ValueError(
                'An entity name cannot be both protected and unprotected')

        if is_protected and entity_type not in BCProtectedNameEntityTypes.list(
        ):
            raise ValueError(
                'Invalid entity_type provided for a protected BC entity name')

        if is_unprotected and entity_type not in BCUnprotectedNameEntityTypes.list(
        ):
            raise ValueError(
                'Invalid entity_type provided for an unprotected BC entity name'
            )

        if request_action not in valid_request_actions:
            raise Exception('Operation not currently supported')

    elif location in (ValidLocations.CA_NOT_BC.list(),
                      ValidLocations.INTL.list()):
        # If XPRO, nothing is protected (for now anyway)
        valid_request_actions = (AnalysisRequestActions.NEW.value,
                                 AnalysisRequestActions.DBA.value)

        if entity_type not in XproUnprotectedNameEntityTypes.list():
            raise ValueError('Invalid entity_type provided for an XPRO entity')

        if request_action not in valid_request_actions:
            raise Exception('Operation not currently supported')

    return True
Example #4
0
def validate_name_request(location, entity_type, request_action):
    """ Validates the name analysis request."""
    # Raise error if location is invalid
    if location not in ValidLocations.list():
        raise ValueError('Invalid location provided')

    # Raise error if request_action is invalid
    if request_action not in AnalysisRequestActions.list():
        raise ValueError('Invalid request action provided')

    # Throw any errors related to invalid entity_type or request_action for a location
    if location == ValidLocations.CA_BC.value:
        is_protected = False
        is_unprotected = False
        valid_request_actions = []

        if entity_type in BCProtectedNameEntityTypes.list():
            is_protected = True
            valid_request_actions = [
                AnalysisRequestActions.NEW.value,
                AnalysisRequestActions.CHG.value,
                AnalysisRequestActions.MVE.value
            ]
        elif entity_type in BCUnprotectedNameEntityTypes.list():
            is_unprotected = True
            valid_request_actions = (AnalysisRequestActions.NEW.value, AnalysisRequestActions.DBA.value)

        if is_protected and is_unprotected:
            raise ValueError('An entity name cannot be both protected and unprotected')

        if is_protected and entity_type not in BCProtectedNameEntityTypes.list():
            raise ValueError('Invalid entity_type provided for a protected BC entity name')

        if is_unprotected and entity_type not in BCUnprotectedNameEntityTypes.list():
            raise ValueError('Invalid entity_type provided for an unprotected BC entity name')

    else:
        valid_location = location in [ValidLocations.CA_NOT_BC.value, ValidLocations.INTL.value]
        valid_request_actions = [
            AnalysisRequestActions.NEW.value,
            AnalysisRequestActions.AML.value,
            AnalysisRequestActions.CHG.value,
            AnalysisRequestActions.ASSUMED.value,
            AnalysisRequestActions.REN.value,
            AnalysisRequestActions.REH.value
        ]

        if not valid_location:
            raise ValueError('Invalid location provided')

        if entity_type not in XproUnprotectedNameEntityTypes.list():
            raise ValueError('Invalid entity_type provided for an XPRO entity')

    if request_action not in valid_request_actions:
        raise Exception('Operation not currently supported')

    return True
def validate_name_request(location, entity_type, request_action):
    # Raise error if location is invalid
    if location not in ValidLocations.list():
        raise ValueError('Invalid location provided')

    # Raise error if request_action is invalid
    if request_action not in AnalysisRequestActions.list():
        raise ValueError('Invalid request action provided')

    # Throw any errors related to invalid entity_type or request_action for a location
    if location != ValidLocations.CA_BC.value:
        raise ValueError('Invalid location provided')

    is_protected = False
    is_unprotected = False
    valid_request_actions = []

    if entity_type in BCProtectedNameEntityTypes.list():
        is_protected = True
        valid_request_actions = [
            AnalysisRequestActions.NEW.value, AnalysisRequestActions.CHG.value,
            AnalysisRequestActions.MVE.value
        ]
    elif entity_type in BCUnprotectedNameEntityTypes.list():
        is_unprotected = True
        valid_request_actions = (AnalysisRequestActions.NEW.value,
                                 AnalysisRequestActions.DBA.value)

    if is_protected and is_unprotected:
        raise ValueError(
            'An entity name cannot be both protected and unprotected')

    if is_protected and entity_type not in BCProtectedNameEntityTypes.list():
        raise ValueError(
            'Invalid entity_type provided for a protected BC entity name')

    if is_unprotected and entity_type not in BCUnprotectedNameEntityTypes.list(
    ):
        raise ValueError(
            'Invalid entity_type provided for an unprotected BC entity name')

    if request_action not in valid_request_actions:
        raise Exception('Operation not currently supported')

    return True
def bc_validate_name_request(location, entity_type, request_action):
    """Validate the params for bc analysis."""
    errors = []
    # Check location is valid
    if location != ValidLocations.CA_BC.value:
        errors.append('Invalid location provided')

    # Check request_action is valid
    if request_action not in AnalysisRequestActions.list():
        errors.append('Invalid request action provided')

    is_protected = False
    is_unprotected = False
    valid_request_actions = []
    if entity_type in BCProtectedNameEntityTypes.list():
        is_protected = True
        valid_request_actions = [
            AnalysisRequestActions.NEW.value, AnalysisRequestActions.CHG.value,
            AnalysisRequestActions.MVE.value, AnalysisRequestActions.REH.value,
            AnalysisRequestActions.REN.value, AnalysisRequestActions.CNV.value,
            AnalysisRequestActions.AML.value
        ]
    # elif entity_type in BCUnprotectedNameEntityTypes.list():
    #     is_unprotected = True
    #     valid_request_actions = (AnalysisRequestActions.NEW.value, AnalysisRequestActions.DBA.value)

    if is_protected and is_unprotected:
        errors.append(
            'An entity name cannot be both protected and unprotected')

    if is_protected and entity_type not in BCProtectedNameEntityTypes.list():
        errors.append(
            'Invalid entity_type provided for a protected BC entity name')

    if is_unprotected and entity_type not in BCUnprotectedNameEntityTypes.list(
    ):
        errors.append(
            'Invalid entity_type provided for an unprotected BC entity name')

    if request_action not in valid_request_actions:
        errors.append('Operation not currently supported')

    return errors