类:SessionController

java.lang.Object
com.google.adk.web.controller.SessionController

@RestController public class SessionController extends Object
控制器负责处理与会话相关的 API 端点。
  • 构造函数详细信息

    • SessionController

      @Autowired public SessionController(BaseSessionService sessionService)
  • 方法详细信息(Method Details)

    • getSession

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}") public Session getSession(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId)
      根据会话 ID 检索特定的会话。
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      Returns:
      The requested Session object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if the session is not found.
    • listSessions

      @GetMapping("/apps/{appName}/users/{userId}/sessions") public List<Session> listSessions(@PathVariable String appName, @PathVariable String userId)
      列出给定应用程序和用户的所有非评估会话(即那些不属于评估流程的会话)。
      Parameters:
      appName - The name of the application.
      userId - The ID of the user.
      Returns:
      A list of sessions, excluding those used for evaluation.
    • createSessionWithId

      @PostMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}") public Session createSessionWithId(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @RequestBody(required=false) SessionRequest body)
      根据客户端提供的特定 ID,创建一个新的会话。
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The desired session ID.
      Returns:
      The newly created Session object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if a session with the given ID already exists (BAD_REQUEST) or if creation fails (INTERNAL_SERVER_ERROR).
    • createSession

      @PostMapping("/apps/{appName}/users/{userId}/sessions") public Session createSession(@PathVariable String appName, @PathVariable String userId, @RequestBody(required=false) SessionRequest body)
      创建一个新的会话,该会话的 ID 由服务自动生成。
      Parameters:
      appName - The application name.
      userId - The user ID.
      Returns:
      The newly created Session object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if creation fails (INTERNAL_SERVER_ERROR).
    • deleteSession

      @DeleteMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}") public org.springframework.http.ResponseEntity<Void> deleteSession(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId)
      删除特定的会话。
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID to delete.
      Returns:
      A ResponseEntity with status NO_CONTENT on success.
      Throws:
      org.springframework.web.server.ResponseStatusException - if deletion fails (INTERNAL_SERVER_ERROR).