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

syntax = "proto3";

package controller.storage.iam.store.v1;

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

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

// OrgRole represent roles that are created at an org scope
message OrgRole {
  // public_id is used to access the Role via an API
  // @inject_tag: gorm:"primary_key"
  string public_id = 1;

  // scope id for the role
  // @inject_tag: `gorm:"default:null"`
  string scope_id = 2;

  // name is the optional friendly name used to
  // access the Role via an API
  // @inject_tag: `gorm:"default:null"`
  string name = 3 [(custom_options.v1.mask_mapping) = {
    this: "name"
    that: "name"
  }];

  // description of the role
  // @inject_tag: `gorm:"default:null"`
  string description = 4 [(custom_options.v1.mask_mapping) = {
    this: "description"
    that: "description"
  }];

  // control if this role is granted access to its role scope
  // @inject_tag: `gorm:"default:false"`
  bool grant_this_role_scope = 5;

  // control type of grant scope granted to this role ['descendant', 'children', 'individual']
  // @inject_tag: `gorm:"default:null"`
  string grant_scope = 6;

  // timestamp when grant_this_role_scope was last updated
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp grant_this_role_scope_update_time = 7;

  // timestamp when grant_scope was last updated
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp grant_scope_update_time = 8;

  // create_time from the RDBMS
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 9;

  // update_time from the RDBMS
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp update_time = 10;

  // version allows optimistic locking of the role when modifying the role
  // itself and when modifying dependent items like principal roles.
  // @inject_tag: `gorm:"default:null"`
  uint32 version = 11;
}
