Exemplo n.º 1
0
def call_elastic_search_to_update_tag(existing_tags):
    try:
        elastic_search_dict = {}
        elastic_search_metadata = elastic_search_dict["metadata"] = {}
        elastic_search_metadata["tags"] = existing_tags
        # Call to elastic_search to update
        index_obj = ElasticSearchCreateAsset(elastic_search_dict)
        elastic_obj = Elastic()
        res = elastic_obj.update_data(index_obj)
        return res
    except:
        return "Error while updating tags"
Exemplo n.º 2
0
 def put(self, request):
     pk = request.data.get("id")
     parent = request.data.get('parent')
     try:
         UUID(pk, version=4)
     except ValueError:
         return Response({"message": "invalid id"},
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     if parent is not None:
         try:
             UUID(parent, version=4)
         except ValueError:
             return Response({"message": "invalid parent_id"},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     inst = Folders.objects.get(id=pk)
     ser = FolderSerializer(inst, data=request.data)
     if ser.is_valid():
         ser.save()
         folder_es_obj = CreateFolders(ser.data)
         elastic_utils_obj = Elastic()
         elastic_utils_obj.update_data(folder_es_obj)
         return Response(ser.data)
     return Response(ser.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 3
0
def call_elastic_search_to_update(response_asset):
    try:
        elastic_search_dict = {}
        elastic_search_metadata = elastic_search_dict["metadata"] = {}
        elastic_search_dict["folder_id"] = response_asset['folder_id']
        elastic_search_dict["id"] = response_asset['id']
        elastic_search_dict["name"] = response_asset['asset_name']
        elastic_search_dict["asset_path"] = response_asset['asset_path']
        elastic_search_dict["thumbnail_path"] = response_asset['thumbnail']
        elastic_search_metadata["status"] = "pending"
        elastic_search_metadata["activate_on"] = response_asset['activate_on']
        elastic_search_metadata["expire_on"] = response_asset['expire_on']
        # elastic_search_metadata["tags"] = existing_tags
        # Call to elastic_search to update
        index_obj = ElasticSearchCreateAsset(elastic_search_dict)
        elastic_obj = Elastic()
        res = elastic_obj.update_data(index_obj)
        return res
    except Exception:
        return "Error while updating"