class AutomationClientResource {

  @Timed @ExceptionMetered
  @GET
  public Response findClient(
      @Auth AutomationClient automationClient,
      @QueryParam("name") Optional<String> name) {
    logger.info("Automation ({}) - Looking up a name {}", automationClient.getName(), name);

    if (name.isPresent()) {
      Client client = clientDAO.getClientByName(name.get()).orElseThrow(NotFoundException::new);
      ImmutableList<Group> groups = ImmutableList.copyOf(aclDAO.getGroupsFor(client));
      return Response.ok()
          .entity(ClientDetailResponse.fromClient(client, groups, ImmutableList.of()))
          .build();
    }

    List<ClientDetailResponse> clients = clientDAO.getClients().stream()
        .map(c -> ClientDetailResponse.fromClient(c, ImmutableList.copyOf(aclDAO.getGroupsFor(c)),
            ImmutableList.of()))
        .collect(toList());
    return Response.ok().entity(clients).build();
  }

  @Inject public  AutomationClientResource(ClientDAOFactory clientDAOFactory, AclDAOFactory aclDAOFactory,
      AuditLog auditLog);
  @VisibleForTesting  AutomationClientResource(ClientDAO clientDAO, AclDAO aclDAO,
      AuditLog auditLog);

}