# Class ArtifactController

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

@RestController public class ArtifactController extends Object
Controller handling artifact-related API endpoints.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ArtifactController(BaseArtifactService artifactService)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.springframework.http.ResponseEntity<Void>`
  `deleteArtifact(String appName, String userId, String sessionId, String artifactName)`
  Deletes an artifact and all its versions.
  `List<String>`
  `listArtifactNames(String appName, String userId, String sessionId)`
  Lists the names of all artifacts associated with a session.
  `List<Integer>`
  `listArtifactVersions(String appName, String userId, String sessionId, String artifactName)`
  Lists the available versions for a specific artifact.
  `com.google.genai.types.Part`
  `loadArtifact(String appName, String userId, String sessionId, String artifactName, Integer version)`
  Loads the latest or a specific version of an artifact associated with a session.
  `com.google.genai.types.Part`
  `loadArtifactVersion(String appName, String userId, String sessionId, String artifactName, int versionId)`
  Loads a specific version of an artifact.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ArtifactController

    @Autowired public ArtifactController(BaseArtifactService artifactService)

- ## Method Details

  - ### loadArtifact

    @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}") public com.google.genai.types.Part loadArtifact(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName, @RequestParam(required=false) Integer version)
    Loads the latest or a specific version of an artifact associated with a session.
    Parameters:
      `appName` - The application name.
      `userId` - The user ID.
      `sessionId` - The session ID.
      `artifactName` - The name of the artifact.
      `version` - Optional specific version number. If null, loads the latest.
    Returns:
      The artifact content as a Part object.
    Throws:
      `org.springframework.web.server.ResponseStatusException` - if the artifact is not found (NOT_FOUND).

  - ### loadArtifactVersion

    @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}/versions/{versionId}") public com.google.genai.types.Part loadArtifactVersion(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName, @PathVariable int versionId)
    Loads a specific version of an artifact.
    Parameters:
      `appName` - The application name.
      `userId` - The user ID.
      `sessionId` - The session ID.
      `artifactName` - The name of the artifact.
      `versionId` - The specific version number.
    Returns:
      The artifact content as a Part object.
    Throws:
      `org.springframework.web.server.ResponseStatusException` - if the artifact version is not found (NOT_FOUND).

  - ### listArtifactNames

    @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts") public List<String> listArtifactNames(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId)
    Lists the names of all artifacts associated with a session.
    Parameters:
      `appName` - The application name.
      `userId` - The user ID.
      `sessionId` - The session ID.
    Returns:
      A list of artifact names.

  - ### listArtifactVersions

    @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}/versions") public List<Integer> listArtifactVersions(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName)
    Lists the available versions for a specific artifact.
    Parameters:
      `appName` - The application name.
      `userId` - The user ID.
      `sessionId` - The session ID.
      `artifactName` - The name of the artifact.
    Returns:
      A list of version numbers (integers).

  - ### deleteArtifact

    @DeleteMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}") public org.springframework.http.ResponseEntity<Void> deleteArtifact(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName)
    Deletes an artifact and all its versions.
    Parameters:
      `appName` - The application name.
      `userId` - The user ID.
      `sessionId` - The session ID.
      `artifactName` - The name of the artifact to delete.
    Returns:
      A ResponseEntity with status NO_CONTENT on success.
    Throws:
      `org.springframework.web.server.ResponseStatusException` - if deletion fails (INTERNAL_SERVER_ERROR).