def serviceList(self): # We look for services for this authenticator groups. User is logged in in just 1 authenticator, so his groups must coincide with those assigned to ds from uds.web.util.services import getServicesData self._request.user = self._user return Connection.result(result=getServicesData(self._request))
def serviceList(self): # We look for services for this authenticator groups. User is logged in in just 1 authenticator, so his groups must coincide with those assigned to ds from uds.web.util.services import getServicesData # Ensure user is present on request, used by web views methods self._request.user = self._user return Connection.result(result=getServicesData(typing.cast(ExtendedHttpRequestWithUser, self._request)))
def action(request: 'ExtendedHttpRequestWithUser', idService: str, actionString: str) -> HttpResponse: userService = userServiceManager().locateUserService(request.user, idService, create=False) response: typing.Any = None rebuild: bool = False if userService: if (actionString == 'release' and userService.deployed_service.allow_users_remove): rebuild = True log.doLog( userService.deployed_service, log.INFO, "Removing User Service {} as requested by {} from {}".format( userService.friendly_name, request.user.pretty_name, request.ip), log.WEB, ) userServiceManager().requestLogoff(userService) userService.release() elif (actionString == 'reset' and userService.deployed_service.allow_users_reset and userService.deployed_service.service.getType().canReset): rebuild = True log.doLog( userService.deployed_service, log.INFO, "Reseting User Service {} as requested by {} from {}".format( userService.friendly_name, request.user.pretty_name, request.ip), log.WEB, ) # userServiceManager().requestLogoff(userService) userServiceManager().reset(userService) if rebuild: # Rebuild services data, but return only "this" service for v in services.getServicesData(request)['services']: if v['id'] == idService: response = v break return HttpResponse(json.dumps(response), content_type="application/json")
def action(request, idService, action): logger.debug('ID Service: {}'.format(idService)) userService = userServiceManager().locateUserService(request.user, idService, create=False) logger.debug('UserService: >{}<'.format(userService)) response = None rebuild = False if userService: if action == 'release' and userService.deployed_service.allow_users_remove: rebuild = True log.doLog( userService.deployed_service, log.INFO, "Removing User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip), log.WEB ) userServiceManager().requestLogoff(userService) userService.release() elif (action == 'reset' and userService.deployed_service.allow_users_reset and userService.deployed_service.service.getType().canReset): rebuild = True log.doLog( userService.deployed_service, log.INFO, "Reseting User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip), log.WEB ) # userServiceManager().requestLogoff(userService) userServiceManager().reset(userService) if rebuild: # Rebuild services data, but return only "this" service for v in services.getServicesData(request)['services']: logger.debug('{} ==? {}'.format(v['id'], idService)) if v['id'] == idService: response = v break return HttpResponse(json.dumps(response), content_type="application/json")
def action(request, idService, action): userService = userServiceManager().locateUserService(request.user, idService, create=False) response = None rebuild = False if userService: if action == 'release' and userService.deployed_service.allow_users_remove: rebuild = True log.doLog( userService.deployed_service, log.INFO, "Removing User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip), log.WEB ) userServiceManager().requestLogoff(userService) userService.release() elif (action == 'reset' and userService.deployed_service.allow_users_reset and userService.deployed_service.service.getType().canReset): rebuild = True log.doLog( userService.deployed_service, log.INFO, "Reseting User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip), log.WEB ) # userServiceManager().requestLogoff(userService) userServiceManager().reset(userService) if rebuild: # Rebuild services data, but return only "this" service for v in services.getServicesData(request)['services']: logger.debug('{} ==? {}'.format(v['id'], idService)) if v['id'] == idService: response = v break return HttpResponse(json.dumps(response), content_type="application/json")
def servicesData(request): data = getServicesData(request) return HttpResponse(content=json.dumps(data), content_type='application/json')
def servicesData(request: HttpRequest) -> HttpResponse: return JsonResponse(getServicesData(request))
def servicesData(request: ExtendedHttpRequestWithUser) -> HttpResponse: return JsonResponse(getServicesData(request))
def servicesData(request): return JsonResponse(getServicesData(request))