// 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";

message Scope {
  // public_id is the used to access the Scope via an API
  // @inject_tag: gorm:"primary_key"
  string public_id = 1;

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

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

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

  // Type of scope
  string type = 5;

  // parent_id is the id (primary key in the Scope aggregate) of scope's parent
  // @inject_tag: `gorm:"default:0"`
  string parent_id = 6;

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

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

  // primary_auth_method_id specifies which auth method will be used as a
  // source for account information for users within the scope.  This auth
  // method will also be designated as the auth method which can autovivify
  // users.
  // @inject_tag: `gorm:"default:null"`
  string primary_auth_method_id = 20 [(custom_options.v1.mask_mapping) = {
    this: "PrimaryAuthMethodId"
    that: "primary_auth_method_id"
  }];
}

message ScopePolicyStoragePolicy {
  // scope_id of the ScopePolicyStoragePolicy
  // @inject_tag: gorm:"primary_key"
  string scope_id = 10;

  // storage_policy_id of the ScopePolicyStoragePolicy
  // @inject_tag: `gorm:"default:null"`
  string storage_policy_id = 20;
}
