Ejemplo n.º 1
0
    def post(self):
        args = self.parser.parse_args()  # need to exists for input payload validation
        status = 'failure'
        host_identifier = args['host_identifier']
        add_tags = args['add_tags'].split(',')
        remove_tags = args['remove_tags'].split(',')
        node = dao.get_node_by_host_identifier(host_identifier)
        if not node:
            message = 'Invalid host identifier. This node does not exist'
        else:
            if add_tags:
                add_tags = create_tags(*add_tags)
                for add_tag in add_tags:
                    if not add_tag in node.tags:
                        node.tags.append(add_tag)

            if remove_tags:
                remove_tags = get_tags(*remove_tags)
                for remove_tag in remove_tags:
                    if remove_tag in node.tags:
                        node.tags.remove(remove_tag)

            node.save()
            status = 'success'
            message = 'Successfully modified the tag(s)'

        return marshal(respcls(message,status), parentwrapper.common_response_wrapper, skip_none=True)
Ejemplo n.º 2
0
    def post(self):
        args = self.parser.parse_args(
        )  # need to exists for input payload validation

        query_id = args['query_id']
        status = 'failure'
        message = None

        add_tags = args['add_tags'].split(',')
        remove_tags = args['remove_tags'].split(',')
        if not (add_tags or remove_tags):
            message = 'Please provide tags'
        else:
            query = dao.get_query_by_id(query_id)
            if not query:
                message = 'Invalid query id. Query with this id does not exist'
            else:
                if add_tags:
                    add_tags = create_tags(*add_tags)
                    for add_tag in add_tags:
                        if not add_tag in query.tags:
                            query.tags.append(add_tag)

                if remove_tags:
                    remove_tags = get_tags(*remove_tags)
                    for remove_tag in remove_tags:
                        if remove_tag in query.tags:
                            query.tags.remove(remove_tag)
                query.save()
                status = 'success'
                message = 'Successfully modified the tag(s)'
        return marshal(respcls(message, status),
                       parentwrapper.common_response_wrapper,
                       skip_none=True)
Ejemplo n.º 3
0
    def post(self):
        args = self.parser.parse_args(
        )  # need to exists for input payload validation
        pack_id = args['pack_id']
        status = 'failure'
        message = None

        add_tags = args['add_tags'].split(',')
        remove_tags = args['remove_tags'].split(',')

        pack = dao.get_pack_by_id(pack_id)
        if not pack:
            message = 'Invalid pack id. Pack with this id does not exist'
        else:
            if add_tags:
                add_tags = create_tags(*add_tags)
                for add_tag in add_tags:
                    if not add_tag in pack.tags:
                        pack.tags.append(add_tag)

            if remove_tags:
                remove_tags = get_tags(*remove_tags)
                for remove_tag in remove_tags:
                    if remove_tag in pack.tags:
                        pack.tags.remove(remove_tag)

            pack.save()
            status = 'success'
            message = 'Successfully modified the tag(s)'

        return marshal(respcls(message, status),
                       parentwrapper.common_response_wrapper,
                       skip_none=True)