Class CredentialController

java.lang.Object
ai.nervemind.app.api.CredentialController

@RestController @RequestMapping("/api/credentials") public class CredentialController extends Object
REST API controller for credential management.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new CredentialController.
  • Method Summary

    Modifier and Type
    Method
    Description
    ai.nervemind.common.dto.CredentialDTO
    create(@Valid Map<String,Object> request)
    Create a new credential.
    void
    Deletes a credential.
    List<ai.nervemind.common.dto.CredentialDTO>
    Finds all credentials.
    org.springframework.http.ResponseEntity<ai.nervemind.common.dto.CredentialDTO>
    Finds a credential by ID.
    List<ai.nervemind.common.dto.CredentialDTO>
    findByType(ai.nervemind.common.enums.CredentialType type)
    Finds credentials by type.
    org.springframework.http.ResponseEntity<Map<String,Object>>
    importCredentials(org.springframework.web.multipart.MultipartFile file, String content)
    Import credentials from a .env formatted file or text content.
    org.springframework.http.ResponseEntity<ai.nervemind.common.dto.CredentialDTO>
    update(Long id, @Valid Map<String,Object> request)
    Update a credential.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CredentialController

      public CredentialController(CredentialService credentialService)
      Constructs a new CredentialController.
      Parameters:
      credentialService - the credential service to use
  • Method Details

    • findAll

      @GetMapping public List<ai.nervemind.common.dto.CredentialDTO> findAll()
      Finds all credentials.
      Returns:
      list of credentials
    • findById

      @GetMapping("/{id}") public org.springframework.http.ResponseEntity<ai.nervemind.common.dto.CredentialDTO> findById(@PathVariable Long id)
      Finds a credential by ID.
      Parameters:
      id - the credential ID
      Returns:
      the credential if found
    • findByType

      @GetMapping("/type/{type}") public List<ai.nervemind.common.dto.CredentialDTO> findByType(@PathVariable ai.nervemind.common.enums.CredentialType type)
      Finds credentials by type.
      Parameters:
      type - the credential type
      Returns:
      list of credentials
    • create

      @PostMapping @ResponseStatus(CREATED) public ai.nervemind.common.dto.CredentialDTO create(@Valid @RequestBody @Valid Map<String,Object> request)
      Create a new credential. Request body should contain: - name: Credential name - type: Credential type - data: The actual credential data (will be encrypted)
      Parameters:
      request - Map containing credential properties
      Returns:
      the created credential metadata
    • update

      @PutMapping("/{id}") public org.springframework.http.ResponseEntity<ai.nervemind.common.dto.CredentialDTO> update(@PathVariable Long id, @Valid @RequestBody @Valid Map<String,Object> request)
      Update a credential. Data field is optional - if not provided, only metadata is updated.
      Parameters:
      id - The ID of the credential to update
      request - Map containing updated properties
      Returns:
      the updated credential metadata
    • delete

      @DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void delete(@PathVariable Long id)
      Deletes a credential.
      Parameters:
      id - the credential ID
    • importCredentials

      @PostMapping("/import") public org.springframework.http.ResponseEntity<Map<String,Object>> importCredentials(@RequestParam(required=false) org.springframework.web.multipart.MultipartFile file, @RequestParam(required=false) String content)
      Import credentials from a .env formatted file or text content. Supports both file upload and raw text input. Returns a summary of the import operation.
      Parameters:
      file - Optional multipart file upload
      content - Optional raw text content
      Returns:
      summary of the import operation