Skip to content
requests.py 76.2 KiB
Newer Older
    def query_context_source_registration_subscriptions(kwargs) -> str:
lopezaguilar's avatar
lopezaguilar committed
        expected_parameters = ['context', 'limit', 'page', 'accept']

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Query Context Source Registration Subscriptions"
        for key, value in kwargs.items():
            match key:
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'limit':
                    response = f"{response} and\n    Query Parameter: limit set to '{value}'"
                case 'page':
                    response = f"{response} and\n    Query Parameter: page set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def query_temporal_representation_of_entities(kwargs) -> str:
        # This function is a little bit special because we have a number of parameters not always defined and not always
        # in the same position, so we make a different analysis to extract the values
        expected_parameters = ['context', 'entity_types', 'entity_ids', 'entity_id_pattern',
                               'ngsild_query', 'csf', 'georel', 'geometry',
                               'coordinates', 'geoproperty', 'timerel', 'timeAt',

        result = [x for x in kwargs if x not in expected_parameters]
lopezaguilar's avatar
lopezaguilar committed
        response = "Query Temporal Representation of Entities"
        for key, value in kwargs.items():
            match key:
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'entity_types':
                    response = f"{response} and\n    Query Parameter: entity_types set to '{value}'"
                case 'entity_ids':
                    response = f"{response} and\n    Query Parameter: entity_ids set to '{value}'"
                case 'entity_id_pattern':
                    response = f"{response} and\n    Query Parameter: entity_id_pattern set to '{value}'"
                case 'ngsild_query':
                    response = f"{response} and\n    Query Parameter: ngsild_query set to '{value}'"
                case 'csf':
                    response = f"{response} and\n    Query Parameter: csf set to '{value}'"
                case 'georel':
                    response = f"{response} and\n    Query Parameter: georel set to '{value}'"
                case 'geometry':
                    response = f"{response} and\n    Query Parameter: geometry set to '{value}'"
                case 'coordinates':
                    response = f"{response} and\n    Query Parameter: coordinates set to '{value}'"
                case 'geoproperty':
                    response = f"{response} and\n    Query Parameter: geoproperty set to '{value}'"
                case 'timerel':
                    response = f"{response} and\n    Query Parameter: timerel set to '{value}'"
                case 'timeAt':
                    response = f"{response} and\n    Query Parameter: timeAt set to '{value}'"
                case 'attrs':
                    response = f"{response} and\n    Query Parameter: attrs set to '{value}'"
                case 'limit':
                    response = f"{response} and\n    Query Parameter: limit set to '{value}'"
                case 'lastN':
                    value = re.search(pattern=r'\d+', string=value).group()
                    response = f"{response} and\n    Query Parameter: lastN set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                case 'options':
                    response = f"{response} and\n    Query Parameter: options set to '{value}'"

            # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response
lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def retrieve_temporal_representation_of_entity(kwargs) -> str:
        expected_parameters = ['temporal_entity_representation_id', 'attrs', 'options',
                               'context', 'timerel', 'timeAt', 'endTimeAt', 'lastN', 'accept',
                               'aggrMethods', 'aggrPeriodDuration']
lopezaguilar's avatar
lopezaguilar committed
        result = [x for x in kwargs if x not in expected_parameters]
        response = "Retrieve Temporal Representation of Entity"
        for key, value in kwargs.items():
            match key:
                case 'temporal_entity_representation_id':
                    response = f"{response} and\n    Query Parameter: id set to '{value}'"
                case 'attrs':
                    response = f"{response} and\n    Query Parameter: attrs set to '{value}'"
                case 'options':
                    response = f"{response} and\n    Query Parameter: options set to '{value}'"
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'timerel':
                    response = f"{response} and\n    Query Parameter: timerel set to '{value}'"
                case 'timeAt':
                    response = f"{response} and\n    Query Parameter: timeAt set to '{value}'"
                case 'endTimeAt':
                    response = f"{response} and\n    Query Parameter: endTimeAt set to '{value}'"
                case 'lastN':
                    value = re.search(pattern=r'\d+', string=value).group()
                    response = f"{response} and\n    Query Parameter: lastN set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                case 'aggrMethods':
                    response = f"{response} and\n    Query Parameter: aggrMethods set to '{value}'"
                case 'aggrPeriodDuration':
                    response = f"{response} and\n    Query Parameter: aggrPeriodDuration set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def retrieve_attribute(kwargs) -> str:
        if 'attribute_name' in kwargs:
            return f"Retrieve Attribute with attributeName set to '{kwargs['attribute_name']}'"

    @staticmethod
    def retrieve_entity_type(kwargs) -> str:
        result = "Retrieve Entity Type"
        if 'type' in kwargs:
            result = f"{result}, with type set to '{kwargs['type']}'"

        if 'context' in kwargs and kwargs['context'] != '':
            result = f"{result}, with Header['Link'] containing '{kwargs['context']}'"

        if 'type' not in kwargs or 'context' not in kwargs:
            raise Exception(f"ERROR, expected type or context attributes, received '{kwargs}'")

        return result

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def query_entities(kwargs) -> str:
lopezaguilar's avatar
lopezaguilar committed
        expected_parameters = ['entity_ids', 'entity_types', 'accept',
                               'attrs', 'context', 'geoproperty',
                               'options', 'limit', 'entity_id_pattern',
                               'scopeq', 'georel', 'coordinates', 'geometry', 'count' , 'q']
lopezaguilar's avatar
lopezaguilar committed
        result = [x for x in kwargs if x not in expected_parameters]
        response = "Get Entities Request:"
        for key, value in kwargs.items():
            match key:
                case 'entity_ids':
                    response = f"{response} and\n    Query Parameter: entity_ids set to '{value}'"
                case 'entity_types':
                    response = f"{response} and\n    Query Parameter: entity_types set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                case 'attrs':
                    response = f"{response} and\n    Query Parameter: attrs set to '{value}'"
                case 'context':
                    response = (f"{response} and\n    Query Parameter: Link set to "
                                f"'<${value}>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'")
                case 'geoproperty':
                    response = f"{response} and\n    Query Parameter: geoproperty set to '{value}'"
                case 'options':
                    response = f"{response} and\n    Query Parameter: options set to '{value}'"
                case 'limit':
                    response = f"{response} and\n    Query Parameter: limit set to '{value}'"
                case 'entity_id_pattern':
                    response = f"{response} and\n    Query Parameter: entity_id_pattern set to '{value}'"
                case 'scopeq':
                    response = f"{response} and\n    Query Parameter: scopeq set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'georel':
                    response = f"{response} and\n    Query Parameter: georel set to '{value}'"
                case 'coordinates':
                    response = f"{response} and\n    Query Parameter: coordinates set to '{value}'"
                case 'geometry':
                    response = f"{response} and\n    Query Parameter: geometry set to '{value}'"
                case 'count':
                    response = f"{response} and\n    Query Parameter: count set to '{value}'"
                case 'q':
                    response = f"{response} and\n    Query Parameter: q set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")
lopezaguilar's avatar
lopezaguilar committed
        return response

    def query_entities_via_post(kwargs) -> str:
lopezaguilar's avatar
lopezaguilar committed
        expected_parameters = ['entity_id', 'entity_type', 'content_type', 'accept',
                               'attrs', 'entity_id_pattern', 'geometry_property']
lopezaguilar's avatar
lopezaguilar committed

        if 'content_type' not in kwargs:
lopezaguilar's avatar
lopezaguilar committed
            kwargs['content_type'] = 'application/json'

        if 'accept' not in kwargs:
            kwargs['accept'] = 'application/json'
lopezaguilar's avatar
lopezaguilar committed

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Get Entities Via POST Request:"
        for key, value in kwargs.items():
            match key:
lopezaguilar's avatar
lopezaguilar committed
                case 'entity_id':
lopezaguilar's avatar
lopezaguilar committed
                    response = f"{response} and\n    Query Parameter: entity_ids set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'entity_type':
lopezaguilar's avatar
lopezaguilar committed
                    response = f"{response} and\n    Query Parameter: entity_types set to '{value}'"
                case 'content_type':
                    response = f"{response} and\n    Query Parameter: content_type set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'attrs':
                    response = f"{response} and\n    Query Parameter: attrs set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'geometry_property':
lopezaguilar's avatar
lopezaguilar committed
                    response = f"{response} and\n    Query Parameter: geoproperty set to '{value}'"
                case 'entity_id_pattern':
                    response = f"{response} and\n    Query Parameter: entity_id_pattern set to '{value}'"
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    def query_temporal_representation_of_entities_via_post(kwargs) -> str:
        expected_parameters = ['query_file_name', 'content_type', 'context']

        if 'content_type' not in kwargs:
            kwargs['content_type'] = 'application/json'

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Query Temporal Representation of Entities Via POST Request:"
        for key, value in kwargs.items():
            match key:
                case 'query_file_name':
                    response = f"{response} and\n    Query Parameter: query_file_name set to '{value}'"
                case 'content_type':
                    response = f"{response} and\n    Query Parameter: content_type set to '{value}'"
                case 'context':
                    response = (f"{response} and\n    Query Parameter: Link set to "
                                f"'<${value}>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'")
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response
lopezaguilar's avatar
lopezaguilar committed

    @staticmethod
    def retrieve_entity_by_id(kwargs) -> str:
        expected_parameters = ['id', 'accept', 'context']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Request Retrieve Entity by Id'
        for key, value in kwargs.items():
            match key:
                case 'id':
                    response = f"{response} and\n    Query Parameter: id set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def delete_entity_by_id(kwargs) -> str:
        if 'id' in kwargs:
            return f"Delete Entity Request with id set to '{kwargs['id']}'"

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def delete_subscription(kwargs) -> str:
        if 'id' in kwargs:
            return f"Delete Subscription with id set to '{kwargs['id']}'"

    @staticmethod
    def query_subscriptions(kwargs) -> str:
        expected_parameters = ['context', 'limit', 'offset', 'accept']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Query Subscription Request with data:'
        for key, value in kwargs.items():
            match key:
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'limit':
                    response = f"{response} and\n    Query Parameter: limit set to '{value}'"
                case 'offset':
                    response = f"{response} and\n    Query Parameter: offset set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def retrieve_context_source_registration_subscription(kwargs) -> str:
        expected_parameters = ['subscription_id', 'context', 'accept']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Retrieve Context Source Registration Subscription with data:'
        for key, value in kwargs.items():
            match key:
                case 'subscription_id':
                    response = f"{response} and\n    Query Parameter: subscription id set to '{value}'"
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def delete_context_source_registration_with_return(kwargs) -> str:
        if 'id' in kwargs:
            return f"Delete Context Source Registration with id set to '{kwargs['id']}'"

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def update_context_source_registration(kwargs) -> str:
        if 'context_source_registration_id' in kwargs and 'update_fragment' in kwargs:
            return (f"Update Context Source Registration "
                    f"with CSR Id set to '{kwargs['context_source_registration_id']}' and "
                    f"subscription update fragment set to '{kwargs['update_fragment']}'")
        else:
            raise Exception(f"ERROR, expected 'context_source_registration_id' and 'update_fragment'"
                            f" but received: {kwargs}")

    @staticmethod
    def update_context_source_registration_from_file(kwargs) -> str:
        if 'context_source_registration_id' in kwargs and 'filename' in kwargs:
            return (f"Update Context Source Registration "
                    f"with CSR Id set to '{kwargs['context_source_registration_id']}' and "
                    f"subscription update from file '{kwargs['filename']}'")
        else:
            raise Exception(f"ERROR, expected 'context_source_registration_id' and 'update_fragment'"
                            f" but received: {kwargs}")

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def update_context_source_registration_subscription(kwargs) -> str:
        if 'subscription_id' in kwargs and 'subscription_update_fragment' in kwargs:
            return (f"Update Context Source Registration Subscription "
                    f"with subscription id set to '{kwargs['subscription_id']}' and "
                    f"subscription update fragment set to '{kwargs['subscription_update_fragment']}'")
        else:
            raise Exception(f"ERROR, expected 'subscription_id' and 'subscription_update_fragment' but received: {kwargs}")

    @staticmethod
    def update_context_source_registration_subscription_from_file(kwargs) -> str:
        if 'subscription_id' in kwargs and 'subscription_update_fragment' in kwargs:
            return (f"Update Context Source Registration Subscription from file "
                    f"with subscription id set to '{kwargs['subscription_id']}' and "
                    f"subscription update fragment set to '{kwargs['subscription_update_fragment']}'")
        else:
            raise Exception(f"ERROR, expected 'subscription_id' and 'subscription_update_fragment' but received: {kwargs}")

    @staticmethod
    def retrieve_context_source_registration(kwargs) -> str:
        expected_parameters = ['context_source_registration_id', 'context', 'accept']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Retrieve Context Source Registration with data:'
        for key, value in kwargs.items():
            match key:
                case 'context_source_registration_id':
                    response = f"{response} and\n    Query Parameter: context source registration id set to '{value}'"
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def query_context_source_registrations(kwargs) -> str:
        expected_parameters = ['context', 'id', 'type', 'idPattern', 'attrs',
lopezaguilar's avatar
lopezaguilar committed
                               'q', 'csf', 'georel', 'geometry',
                               'coordinates', 'geoproperty', 'timeproperty', 'timerel',
lopezaguilar's avatar
lopezaguilar committed

        # kwargs = {key: kwargs.get(key, '${EMPTY}') for key in expected_parameters}

lopezaguilar's avatar
lopezaguilar committed
        result = [x for x in kwargs if x not in expected_parameters]
        response = "Retrieve Temporal Representation of Entity"
        for key, value in kwargs.items():
            match key:
                case 'context':
                    response = f"{response} and\n    Query Parameter: context set to '{value}'"
                case 'id':
                    response = f"{response} and\n    Query Parameter: id set to '{value}'"
                case 'type':
                    response = f"{response} and\n    Query Parameter: type set to '{value}'"
                case 'attrs':
                    response = f"{response} and\n    Query Parameter: attrs set to '{value}'"
                case 'idPattern':
                    response = f"{response} and\n    Query Parameter: idPattern set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'q':
                    response = f"{response} and\n    Query Parameter: q set to '{value}'"
                case 'csf':
                    response = f"{response} and\n    Query Parameter: csf set to '{value}'"
                case 'georel':
                    response = f"{response} and\n    Query Parameter: georel set to '{value}'"
                case 'geometry':
                    response = f"{response} and\n    Query Parameter: geometry set to '{value}'"
                case 'coordinates':
                    response = f"{response} and\n    Query Parameter: coordinates set to '{value}'"
                case 'geoproperty':
                    response = f"{response} and\n    Query Parameter: geoproperty set to '{value}'"
                case 'timeproperty':
                    response = f"{response} and\n    Query Parameter: timeproperty set to '{value}'"
                case 'timerel':
                    response = f"{response} and\n    Query Parameter: timerel set to '{value}'"
                case 'timeAt':
                    response = f"{response} and\n    Query Parameter: timeAt set to '{value}'"
                case 'limit':
                    response = f"{response} and\n    Query Parameter: limit set to '{value}'"
                case 'offset':
                    response = f"{response} and\n    Query Parameter: offset set to '{value}'"
lopezaguilar's avatar
lopezaguilar committed
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def update_context_source_registration_with_return(kwargs) -> str:
        if 'id' in kwargs and 'filename' in kwargs and 'content' in kwargs:
            return (f"Update Context Source Registration with id set to '{kwargs['id']}' "
                    f"and registration update fragment set to '{kwargs['filename']}' "
                    f"and content-type set to '{kwargs['content']}'")

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def delete_temporal_representation_of_entity_with_returning_response(kwargs) -> str:
        if 'id' in kwargs:
            return f"Delete Temporal Representation Of Entity With Returning Response with id set to '{kwargs['id']}'"

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def retrieve_context_source_registration_subscription_2(kwargs) -> str:
        if 'id' in kwargs:
            return f"Retrieve Context Source Registration Subscription with id set to '{kwargs['id']}'"
        else:
            raise Exception(f"ERROR, expected 'id' but received: '{kwargs}'")

    @staticmethod
    def delete_context_source_registration_subscription(kwargs) -> str:
        if 'id' in kwargs:
            return f"Delete Context Source Registration Subscription with id set to '{kwargs['id']}'"
        else:
            raise Exception(f"ERROR, expected 'id' but received: '{kwargs}'")

    @staticmethod
    def create_context_source_registration_subscription(kwargs) -> str:
        if 'filename' in kwargs:
lopezaguilar's avatar
lopezaguilar committed
            return (f"Create Context Source Registration Subscription with filename set to '{kwargs['filename']}', "
                    f"accept set to '${{EMPTY}}', and content-type set to 'application/ld+json'")
lopezaguilar's avatar
lopezaguilar committed
        else:
            raise Exception(f"ERROR, expected 'filename' but received: '{kwargs}'")

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def append_attribute_to_temporal_entity(kwargs) -> str:
        expected_parameters = ['id', 'fragment_filename', 'content_type']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Append Attribute to Temporal Entity'
        for key, value in kwargs.items():
            match key:
                case 'id':
                    response = f"{response} and\n    Query Parameter: id set to '{value}'"
                case 'fragment_filename':
                    response = f"{response} and\n    Query Parameter: fragment_filename set to '{value}'"
                case 'content_type':
                    response = f"{response} and\n    Query Parameter: content_type set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

lopezaguilar's avatar
lopezaguilar committed
    @staticmethod
    def append_entity_attributes(kwargs) -> str:
        expected_parameters = ['id', 'fragment_filename', 'content_type']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Append Entity Attributes'
        for key, value in kwargs.items():
            match key:
                case 'id':
                    response = f"{response} and\n    Query Parameter: id set to '{value}'"
                case 'fragment_filename':
                    response = f"{response} and\n    Query Parameter: fragment_filename set to '{value}'"
                case 'content_type':
                    response = f"{response} and\n    Query Parameter: content_type set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    @staticmethod
    def update_entity_attributes(kwargs) -> str:
        expected_parameters = ['id', 'fragment_filename', 'content_type']

        result = [x for x in kwargs if x not in expected_parameters]
        response = 'Update Entity Attributes'
        for key, value in kwargs.items():
            match key:
                case 'id':
                    response = f"{response} and\n    Query Parameter: id set to '{value}'"
                case 'fragment_filename':
                    response = f"{response} and\n    Query Parameter: fragment_filename set to '{value}'"
                case 'content_type':
                    response = f"{response} and\n    Query Parameter: content_type set to '{value}'"
                # If an exact match is not confirmed, this last case will be used if provided
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")

        return response

    def get_value(self, params, param_position, param_key):
        data = [x for x in params if f'{param_key}=' in x]
        if len(data) == 1:
            # The name of the attribute is passed to the function in the form attribute=value
            data = data[0]
            data = data.split('=')
            if data[0] != param_key:
        elif len(data) == 0:
            # There is no attribute=something therefore we have to apply the position
            try:
                data = params[param_position]

                # Workaround
                if 'accept' in data and param_key != 'accept':
                    data = ''
            except IndexError:
                return ''
        return self.get_value_simple(data=data)

    def get_value_simple(self, data):
            value = self.variables[data]
            return value
        except KeyError:
            try:
                value = self.apiutils_variables[data]
                return value
            except KeyError:
                try:
                    value = self.config_file.get_variable(variable=data)
                    return value
                except KeyError:
lopezaguilar's avatar
lopezaguilar committed
                    try:
                        aux = self.template_params_value[self.name]
                        value = aux[data]
                        return value
                    except KeyError:
                        return data