class MtasApiServiceImpl implements MtasApiService {

    @Override
    public ResponseEntity<Mta> getMta(String spaceGuid, String mtaId) {
        List<DeployedMta> mtas = deployedMtaDetector.detectDeployedMtasByName(mtaId, getCloudFoundryClient(spaceGuid));

        if (mtas.isEmpty()) {
            throw new NotFoundException(Messages.MTA_NOT_FOUND, mtaId);
        }

        if (mtas.size() != 1) {
            throw new ConflictException(Messages.MTA_SEARCH_NOT_UNIQUE_BY_NAME, mtaId);
        }

        return ResponseEntity.ok()
                             .body(getMta(mtas.get(0)));
    }

}