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

syntax = "proto3";

package controller.storage.iam.store.v1;

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

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

message UserRole {
  // create_time from the RDBMS
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 1;

  // role_id is the role of this principal.
  // @inject_tag: gorm:"primary_key"
  string role_id = 2;

  // principal_id is the public_id of the user (which is the principal)
  // @inject_tag: gorm:"primary_key"
  string principal_id = 3;
}

message GroupRole {
  // create_time from the RDBMS
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 1;

  // role_id is the role of this principal.
  // @inject_tag: gorm:"primary_key"
  string role_id = 2;

  // principal_id is the public_id of the group (which is the principal)
  // @inject_tag: gorm:"primary_key"
  string principal_id = 3;
}

message ManagedGroupRole {
  // create_time from the RDBMS
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 1;

  // role_id is the role of this principal.
  // @inject_tag: gorm:"primary_key"
  string role_id = 2;

  // principal_id is the public_id of the managed group (which is the principal)
  // @inject_tag: gorm:"primary_key"
  string principal_id = 3;
}

message PrincipalRoleView {
  // create_time from the RDBMS
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 1;

  // role_id is the role of this principal.
  // @inject_tag: gorm:"primary_key"
  string role_id = 2;

  // Principal type (User or Group)
  string type = 3;

  // @inject_tag: gorm:"primary_key"
  string principal_id = 4;

  // principal_scope_id of the principal
  // @inject_tag: `gorm:"default:null"`
  string principal_scope_id = 5;

  // role_scope_id of the role
  // @inject_tag: `gorm:"default:null"`
  string role_scope_id = 6;

  // scoped_principal_id of the principal
  // @inject_tag: `gorm:"default:null"`
  string scoped_principal_id = 7;
}
