Search in sources :

Example 1 with ApiKeyDTO

use of com.nexblocks.authguard.api.dto.entities.ApiKeyDTO in project AuthGuard by AuthGuard.

the class ApiKeysRoute method getById.

@Override
public void getById(final Context context) {
    final String apiKeyId = context.pathParam("id");
    final Optional<ApiKeyDTO> apiKey = apiKeysService.getById(apiKeyId).map(restMapper::toDTO);
    if (apiKey.isPresent()) {
        context.status(200).json(apiKey.get());
    } else {
        context.status(404).json(new Error(ErrorCode.API_KEY_DOES_NOT_EXIST.getCode(), "API key does not exist"));
    }
}
Also used : Error(com.nexblocks.authguard.api.dto.entities.Error) ApiKeyDTO(com.nexblocks.authguard.api.dto.entities.ApiKeyDTO)

Example 2 with ApiKeyDTO

use of com.nexblocks.authguard.api.dto.entities.ApiKeyDTO in project AuthGuard by AuthGuard.

the class ApiKeysRoute method deleteById.

@Override
public void deleteById(final Context context) {
    final String apiKeyId = context.pathParam("id");
    final Optional<ApiKeyDTO> apiKey = apiKeysService.delete(apiKeyId).map(restMapper::toDTO);
    if (apiKey.isPresent()) {
        context.status(200).json(apiKey.get());
    } else {
        context.status(404).json(new Error(ErrorCode.API_KEY_DOES_NOT_EXIST.getCode(), "API key does not exist"));
    }
}
Also used : Error(com.nexblocks.authguard.api.dto.entities.Error) ApiKeyDTO(com.nexblocks.authguard.api.dto.entities.ApiKeyDTO)

Aggregations

ApiKeyDTO (com.nexblocks.authguard.api.dto.entities.ApiKeyDTO)2 Error (com.nexblocks.authguard.api.dto.entities.Error)2