async def inactivate( name: str, current_user: dict = Depends(get_current_user), service: ApplicationService = Depends(get_application_service)): try: await service.inactivate(name, current_user) return ok() except ValueError as e: return bad_request(str(e))
async def put(name: str, schema: ApplicationRequestSchema, current_user: dict = Depends(get_current_user), service: ApplicationService = Depends(get_application_service)): try: await service.update(schema.__dict__, name, current_user) return ok() except ValueError as e: return bad_request(str(e))
async def delete( name: str, email: str, current_user: dict = Depends(get_current_user), service: ApplicationService = Depends(get_application_service)): try: await service.remove_user(name, email, current_user) return ok() except ValueError as e: return bad_request(str(e))
async def patch( name: str, schema: ApplicationFeatureRequestSchema, current_user: dict = Depends(get_current_user), service: ApplicationService = Depends(get_application_service)): try: await service.add_feature(name, schema.__dict__, current_user) except ValueError as e: return bad_request(str(e)) else: return ok()
async def patch( schema: UserChangePasswordSchema, service: UserService = Depends(get_user_service), current_user: dict = Depends(get_current_user), ): try: await service.change_password(current_user["email"], schema.new_password, schema.confirm_password) return ok() except ValueError as e: return bad_request(str(e))
async def activate( name: str, environment: str, feature_name: str, current_user: dict = Depends(get_current_user), service: ApplicationService = Depends(get_application_service)): try: await service.activate_feature(name, environment, feature_name, current_user) except ValueError as e: return bad_request(str(e)) else: return ok()