class AutomationClientResource {

  @Timed @ExceptionMetered
  @POST
  @Consumes(APPLICATION_JSON)
  public ClientDetailResponse createClient(
      @Auth AutomationClient automationClient,
      @Valid CreateClientRequest clientRequest) {

    Optional<Client> client = clientDAO.getClientByName(clientRequest.name);
    if (client.isPresent()) {
      logger.info("Automation ({}) - Client {} already exists", automationClient.getName(),
          clientRequest.name);
      throw new ConflictException("Client name already exists.");
    }

    long id = clientDAO.createClient(clientRequest.name, automationClient.getName(), "", null);
    client = clientDAO.getClientById(id);

    if (client.isPresent()) {
      Map<String, String> extraInfo = new HashMap<>();
      extraInfo.put("deprecated", "true");
      auditLog.recordEvent(
          new Event(Instant.now(), EventTag.CLIENT_CREATE, automationClient.getName(),
              client.get().getName(), extraInfo));
    }

    return ClientDetailResponse.fromClient(client.get(), ImmutableList.of(), ImmutableList.of());
  }

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

}