// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1

syntax = "proto3";

// Package store provides protobufs for storing types in the static host
// package.
package controller.storage.host.static.store.v1;

import "controller/custom_options/v1/options.proto";
import "controller/storage/timestamp/v1/timestamp.proto";

option go_package = "github.com/hashicorp/boundary/internal/host/static/store;store";

message HostCatalog {
  // public_is is a surrogate key suitable for use in a public API.
  // @inject_tag: `gorm:"primary_key"`
  string public_id = 1;

  // The create_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 2;

  // The update_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp update_time = 3;

  // name is optional. If set, it must be unique within project_id.
  // @inject_tag: `gorm:"default:null"`
  string name = 4 [(custom_options.v1.mask_mapping) = {
    this: "name"
    that: "name"
  }];

  // description is optional.
  // @inject_tag: `gorm:"default:null"`
  string description = 5 [(custom_options.v1.mask_mapping) = {
    this: "description"
    that: "description"
  }];

  // The project_id of the owning scope and must be set.
  // @inject_tag: `gorm:"not_null"`
  string project_id = 6;

  // version allows optimistic locking of the resource
  // @inject_tag: `gorm:"default:null"`
  uint32 version = 7;
}

message Host {
  // public_is is a surrogate key suitable for use in a public API.
  // @inject_tag: `gorm:"primary_key"`
  string public_id = 1;

  // The create_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 2;

  // The update_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp update_time = 3;

  // name is optional. If set, it must be unique within
  // catalog_id.
  // @inject_tag: `gorm:"default:null"`
  string name = 4 [(custom_options.v1.mask_mapping) = {
    this: "name"
    that: "name"
  }];

  // description is optional.
  // @inject_tag: `gorm:"default:null"`
  string description = 5 [(custom_options.v1.mask_mapping) = {
    this: "description"
    that: "description"
  }];

  // catalog_id is the public_id of the owning
  // static_host_catalog and must be set.
  // @inject_tag: `gorm:"not_null"`
  string catalog_id = 6;

  // address is the IP Address or DNS name of the host. It must be set and
  // it must be unique within catalog_id.
  // @inject_tag: `gorm:"default:null"`
  string address = 7 [(custom_options.v1.mask_mapping) = {
    this: "address"
    that: "attributes.address"
  }];

  // version allows optimistic locking of the resource
  // @inject_tag: `gorm:"default:null"`
  uint32 version = 8;
}

message HostSet {
  // public_is is a surrogate key suitable for use in a public API.
  // @inject_tag: `gorm:"primary_key"`
  string public_id = 1;

  // The create_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 2;

  // The update_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp update_time = 3;

  // name is optional. If set, it must be unique within
  // catalog_id.
  // @inject_tag: `gorm:"default:null"`
  string name = 4 [(custom_options.v1.mask_mapping) = {
    this: "name"
    that: "name"
  }];

  // description is optional.
  // @inject_tag: `gorm:"default:null"`
  string description = 5 [(custom_options.v1.mask_mapping) = {
    this: "description"
    that: "description"
  }];

  // catalog_id is the public_id of the owning
  // static_host_catalog and must be set.
  // @inject_tag: `gorm:"not_null"`
  string catalog_id = 6;

  // version allows optimistic locking of the resource
  // @inject_tag: `gorm:"default:null"`
  uint32 version = 7;
}

message HostSetMember {
  // @inject_tag: `gorm:"primary_key"`
  string host_id = 1;

  // @inject_tag: `gorm:"primary_key"`
  string set_id = 2;

  // @inject_tag: `gorm:"default:null"`
  string catalog_id = 3;
}

// These fields are not implemented yet on the host set.  They are captured
// here for the purpose of identifying the mask maps which are on the top level
// api set resource but aren't present in the static host set storage.
message UnimplementedSetFields {
  repeated string preferred_endpoints = 11 [(custom_options.v1.mask_mapping) = {
    this: "PreferredEndpoints"
    that: "preferred_endpoints"
  }];
  int32 sync_interval_seconds = 22 [(custom_options.v1.mask_mapping) = {
    this: "SyncIntervalSeconds"
    that: "sync_interval_seconds"
  }];
}

// These fields are not implemented yet on the host catalog. They are captured
// here for the purpose of identifying the mask maps which are on the top level
// api catalog resource but aren't present in the static host catalog storage.
message UnimplementedCatalogFields {
  string worker_filter = 11 [(custom_options.v1.mask_mapping) = {
    this: "WorkerFilter"
    that: "worker_filter"
  }];
}
