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
ConstructorsConstructorDescriptionCredentialController(CredentialService credentialService) Constructs a new CredentialController. -
Method Summary
Modifier and TypeMethodDescriptionai.nervemind.common.dto.CredentialDTOCreate a new credential.voidDeletes a credential.List<ai.nervemind.common.dto.CredentialDTO> findAll()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.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 a credential.
-
Constructor Details
-
CredentialController
Constructs a new CredentialController.- Parameters:
credentialService- the credential service to use
-
-
Method Details
-
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 updaterequest- Map containing updated properties- Returns:
- the updated credential metadata
-
delete
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 uploadcontent- Optional raw text content- Returns:
- summary of the import operation
-