Exemple #1
0
 def post(self, request):
     try:
         for key in request.POST:
             print(key)
             value = request.POST[key]
             print(value)
         param = {
             'id':                   request.POST.get('id'),
             'instance_name':        request.POST.get('instance_name'),
             'instance_type':        request.POST.get('instance_type'),
             'ip_address':           request.POST.get('ip_address'),
             'description':          request.POST.get('description'),
             'created_date':         request.POST.get('created_date'),
             'modified_date':        request.POST.get('modified_date'),
             'is_active':            request.POST.get('is_active'),
         }
         print(param)
         if param['id']:
             insf_driver = InstanceFunction()
             update_obj = insf_driver.update(**param)
             if update_obj:
                 serializer = custom_serialize_instance(update_obj)
                 return response_data_with_page(serializer)
         raise V1Exception("Error update instance")
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #2
0
 def get(self, request):
     try:
         url = "https://api.bitbucket.org/2.0/repositories/dzonesvn/services-content-manager/refs/branches"
         result = branches.serizalization_branches(url)
         return response_data_with_page(result)
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #3
0
 def get(self, request):
     try:
         PF_driver = projects.ProjectsFunction(settings.BITBUCKET_TEAM)
         result = PF_driver.get_projects_from_bitbucket()
         return response_data_with_page(result)
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #4
0
 def get(self, request):
     try:
         url = "https://api.bitbucket.org/1.0/group-privileges/dzonesvn"
         result = group_privileges.serizalization_group_privileges(url)
         return response_data_with_page(result)
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #5
0
 def get(self, request):
     try:
         itf_driver = InstanceTypesFunction()
         data = itf_driver.get_all()
         if not data:
             return response_message("Data is empty !!!")
         serializer = InstanceTypeWithName(data, many=True)
         return response_data_with_page(serializer.data)
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #6
0
 def get(self, request):
     try:
         # url = settings.BITBUCKET_URL + '/' + settings.BITBUCKET_VER + \
         # '/repositories/' + settings.BITBUCKET_TEAM
         # url = settings.BITBUCKET_URL + '/' + settings.BITBUCKET_VER + \
         #     '/teams/' + settings.BITBUCKET_TEAM + '/projects/'
         # demo lay thu mot project
         url = "https://api.bitbucket.org/2.0/repositories/dzonesvn?q=project.key=\"VSN\""
         result = repo.serizalization_reponame(url)
         return response_data_with_page(result)
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #7
0
 def get(self, request):
     try:
         insf_driver = InstanceFunction()
         data = insf_driver.get()
         if not data:
             return response_message("Data is empty !!!")
         paging = Paging()
         response_paging = paging.paginate_queryset(data, request)
         # serializer = InstanceList(response_paging, many=True)
         serializer = custom_serialize_instance(response_paging)
         print(serializer)
         data_response = paging.get_data_response(serializer)
         return response_data_with_page(data_response)
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #8
0
 def post(self, request):
     try:
         param = {
             'type_instances': request.POST.get('type_instances'),
             'type_instances_name': request.POST.get('type_instances_name'),
             'created_date': request.POST.get('created_date'),
             'modified_date': request.POST.get('modified_date'),
             'is_active': request.POST.get('is_active'),
         }
         if param['type_instances']:
             itf_driver = InstanceTypesFunction()
             create_obj = itf_driver.create(**param)
             if create_obj:
                 serializer = InstanceTypeList(create_obj)
                 return response_data_with_page(serializer.data)
             return response_message("Success")
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #9
0
 def post(self, request):
     try:
         param = {
             'instance_name':        request.POST.get('instance_name'),
             'ip_address':           request.POST.get('ip_address'),
             'description':          request.POST.get('description'),
             'instance_type':        request.POST.get('instance_type'),
             'created_date':         request.POST.get('created_date'),
             'modified_date':        request.POST.get('modified_date'),
             'is_active':            request.POST.get('is_active'),
         }
         if param['ip_address'] and param['instance_type']:
             insf_driver = InstanceFunction()
             create_obj = insf_driver.create(**param)
             if create_obj:
                 serializer = InstanceList(create_obj)
                 return response_data_with_page(serializer.data)
         raise V1Exception("Error create instance")
     except Exception as ex:
         print(ex)
         raise V1Exception("Error")
Exemple #10
0
    def get(self, request):
        for key in request.GET:
            print(key)
            value = request.GET[key]
            print(value)
        try:
            page = request.GET.get('page')
        except Exception as ex:
            page = 1
        try:
            itf_driver = InstanceTypesFunction()
            data = itf_driver.get_all()
            if not data:
                return response_message("Data is empty !!!")
            paging = Paging()
            response_paging = paging.paginate_queryset(data, request)
            serializer = InstanceTypeList(response_paging, many=True)

            data_response = paging.get_data_response(serializer.data)
            return response_data_with_page(data_response)
        except Exception as ex:
            print(ex)
            raise V1Exception("Error")