class AutomationGroupResource {

  @Timed @ExceptionMetered
  @GET
  public Response getGroupByName(
      @Auth AutomationClient automationClient,
      @QueryParam("name") Optional<String> name) {
    if (name.isPresent()) {
      Group group = groupDAO.getGroup(name.get()).orElseThrow(NotFoundException::new);

      ImmutableList<Client> clients = ImmutableList.copyOf(aclDAO.getClientsFor(group));
      ImmutableList<SanitizedSecret> sanitizedSecrets =
          ImmutableList.copyOf(aclDAO.getSanitizedSecretsFor(group));
      return Response.ok()
          .entity(GroupDetailResponse.fromGroup(group, sanitizedSecrets, clients))
          .build();
    }

    ImmutableList<SanitizedSecret> emptySecrets = ImmutableList.of();
    ImmutableList<Client> emptyClients = ImmutableList.of();
    List<GroupDetailResponse> groups = groupDAO.getGroups().stream()
        .map((g) -> GroupDetailResponse.fromGroup(g, emptySecrets, emptyClients))
        .collect(toList());
    return Response.ok()
        .entity(groups)
        .build();
  }

  @Inject public  AutomationGroupResource(GroupDAOFactory groupDAOFactory, AclDAOFactory aclDAOFactory,
      AuditLog auditLog);
  @VisibleForTesting  AutomationGroupResource(GroupDAO groupDAO, AclDAO aclDAO, AuditLog auditLog);

}