/**
 * This file is part of the CernVM File System.
 */

#ifndef CVMFS_REPOSITORY_TAG_H_
#define CVMFS_REPOSITORY_TAG_H_

#include <ctime>
#include <string>

class RepositoryTag {
 public:
  RepositoryTag() : name_(""), description_(""), auto_tag_threshold_(0) { }
  RepositoryTag(const std::string &name, const std::string &description);

  void SetName(const std::string &name) { name_ = name; }
  void SetDescription(const std::string &description) {
    description_ = description;
  }
  // Unix timestamp: auto-generated tags older than this are removed on commit.
  // 0 disables the cleanup. The publisher resolves CVMFS_AUTO_TAG_TIMESPAN to
  // an absolute timestamp before sending it to the gateway, so no human-readable
  // date string ever needs to be parsed on the (untrusted) receiver side.
  void SetAutoTagThreshold(time_t threshold) {
    auto_tag_threshold_ = threshold;
  }

  bool HasGenericName();
  void SetGenericName();

  // True if `name` is a full auto-generated tag name, i.e. "generic-<ISO8601>"
  // or "generic_<n>-<ISO8601>" (e.g. "generic-2024-01-01T00:00:00.000Z").
  // Unlike HasGenericName(), this also requires the timestamp shape, so it does
  // not match user tags such as "generic-release". Used to decide which tags
  // the auto-tag cleanup is allowed to delete.
  static bool IsAutoGeneratedName(const std::string &name);

  std::string name() const { return name_; }
  std::string description() const { return description_; }
  time_t auto_tag_threshold() const { return auto_tag_threshold_; }

 private:
  std::string name_;
  std::string description_;
  time_t auto_tag_threshold_;
};

#endif  // CVMFS_REPOSITORY_TAG_H_
