syntax = "proto3";

package confidence.auth.v1;

import "google/protobuf/descriptor.proto";

option java_multiple_files = true;
option java_outer_classname = "AuthProto";
option java_package = "com.spotify.confidence.commons.v1";


enum Permission {
  UNKNOWN_PERMISSION = 0;

  // workflows
  READ_WORKFLOWS   = 1 [(scope) = "read:workflows"];
  LIST_WORKFLOWS   = 2 [(scope) = "list:workflows"];
  CREATE_WORKFLOWS = 3 [(scope) = "create:workflows"];
  UPDATE_WORKFLOWS = 4 [(scope) = "update:workflows"];

  // workflow instances
  READ_WORKFLOW_INSTANCES   = 10 [(scope) = "read:workflowinstances"];
  LIST_WORKFLOW_INSTANCES   = 11 [(scope) = "list:workflowinstances"];
  CREATE_WORKFLOW_INSTANCES = 12 [(scope) = "create:workflowinstances"];
  UPDATE_WORKFLOW_INSTANCES = 13 [(scope) = "update:workflowinstances"];

  // checks
  READ_CHECKS   = 20 [(scope) = "read:checks"];
  LIST_CHECKS   = 21 [(scope) = "list:checks"];
  CREATE_CHECKS = 22 [(scope) = "create:checks"];
  UPDATE_CHECKS = 23 [(scope) = "update:checks"];

  // flags
  READ_FLAGS =   30 [(scope) = "read:flags"];
  LIST_FLAGS =   31 [(scope) = "list:flags"];
  CREATE_FLAGS = 32 [(scope) = "create:flags"];
  UPDATE_FLAGS = 33 [(scope) = "update:flags"];

  // segments
  READ_SEGMENTS =   40 [(scope) = "read:segments"];
  LIST_SEGMENTS =   41 [(scope) = "list:segments"];
  CREATE_SEGMENTS = 42 [(scope) = "create:segments"];
  UPDATE_SEGMENTS = 43 [(scope) = "update:segments"];

  // clients
  READ_CLIENTS =   50 [(scope) = "read:clients"];
  LIST_CLIENTS =   51 [(scope) = "list:clients"];
  CREATE_CLIENTS = 52 [(scope) = "create:clients"];
  UPDATE_CLIENTS = 53 [(scope) = "update:clients"];

  // client credentials
  READ_CLIENT_CREDENTIALS =   60 [(scope) = "read:clientcredentials"];
  LIST_CLIENT_CREDENTIALS =   61 [(scope) = "list:clientcredentials"];
  CREATE_CLIENT_CREDENTIALS = 62 [(scope) = "create:clientcredentials"];
  UPDATE_CLIENT_CREDENTIALS = 63 [(scope) = "update:clientcredentials"];

  // entities
  READ_ENTITIES =   70 [(scope) = "read:entities"];
  LIST_ENTITIES =   71 [(scope) = "list:entities"];
  CREATE_ENTITIES = 72 [(scope) = "create:entities"];
  UPDATE_ENTITIES = 73 [(scope) = "update:entities"];
  DELETE_ENTITIES = 74 [(scope) = "delete:entities"];

  // fact tables
  READ_FACT_TABLES =   80 [(scope) = "read:facttables"];
  LIST_FACT_TABLES =   81 [(scope) = "list:facttables"];
  CREATE_FACT_TABLES = 82 [(scope) = "create:facttables"];
  UPDATE_FACT_TABLES = 83 [(scope) = "update:facttables"];
  DELETE_FACT_TABLES = 84 [(scope) = "delete:facttables"];

  // assignment tables
  READ_ASSIGNMENT_TABLES =   90 [(scope) = "read:assignmenttables"];
  LIST_ASSIGNMENT_TABLES =   91 [(scope) = "list:assignmenttables"];
  CREATE_ASSIGNMENT_TABLES = 92 [(scope) = "create:assignmenttables"];
  UPDATE_ASSIGNMENT_TABLES = 93 [(scope) = "update:assignmenttables"];
  DELETE_ASSIGNMENT_TABLES = 94 [(scope) = "delete:assignmenttables"];

  // dimension tables
  READ_DIMENSION_TABLES =   100 [(scope) = "read:dimensiontables"];
  LIST_DIMENSION_TABLES =   101 [(scope) = "list:dimensiontables"];
  CREATE_DIMENSION_TABLES = 102 [(scope) = "create:dimensiontables"];
  UPDATE_DIMENSION_TABLES = 103 [(scope) = "update:dimensiontables"];
  DELETE_DIMENSION_TABLES = 104 [(scope) = "delete:dimensiontables"];

  // metrics
  READ_METRICS =   110 [(scope) = "read:metrics"];
  LIST_METRICS =   111 [(scope) = "list:metrics"];
  CREATE_METRICS = 112 [(scope) = "create:metrics"];
  UPDATE_METRICS = 113 [(scope) = "update:metrics"];
  DELETE_METRICS = 114 [(scope) = "delete:metrics"];

  // scheduled metric calculations
  READ_SCHEDULED_METRIC_CALCULATIONS =   120 [(scope) = "read:scheduledmetriccalculations"];
  LIST_SCHEDULED_METRIC_CALCULATIONS =   121 [(scope) = "list:scheduledmetriccalculations"];
  CREATE_SCHEDULED_METRIC_CALCULATIONS = 122 [(scope) = "create:scheduledmetriccalculations"];
  UPDATE_SCHEDULED_METRIC_CALCULATIONS = 123 [(scope) = "update:scheduledmetriccalculations"];

  // metric calculations
  READ_METRIC_CALCULATIONS =   130 [(scope) = "read:metriccalculations"];
  LIST_METRIC_CALCULATIONS =   131 [(scope) = "list:metriccalculations"];
  CREATE_METRIC_CALCULATIONS = 132 [(scope) = "create:metriccalculations"];
  UPDATE_METRIC_CALCULATIONS = 133 [(scope) = "update:metriccalculations"];

  // exposure tables
  READ_EXPOSURE_TABLES =   140 [(scope) = "read:exposuretables"];
  LIST_EXPOSURE_TABLES =   141 [(scope) = "list:exposuretables"];
  CREATE_EXPOSURE_TABLES = 142 [(scope) = "create:exposuretables"];
  UPDATE_EXPOSURE_TABLES = 143 [(scope) = "update:exposuretables"];

  // sql jobs
  READ_SQL_JOBS =   150 [(scope) = "read:sqljobs"];
  LIST_SQL_JOBS =   151 [(scope) = "list:sqljobs"];
  CREATE_SQL_JOBS = 152 [(scope) = "create:sqljobs"];
  UPDATE_SQL_JOBS = 153 [(scope) = "update:sqljobs"];

  // metrics query
  PREVIEW_SQL_QUERY = 160 [(scope) = "preview:sqlquery"];

  // event types
  LIST_EVENT_TYPES =   170 [(scope) = "list:eventtypes"];
  READ_EVENT_TYPES =   171 [(scope) = "read:eventtypes"];

  // connections
  READ_CONNECTIONS =   180 [(scope) = "read:connections"];
  LIST_CONNECTIONS =   181 [(scope) = "list:connections"];
  CREATE_CONNECTIONS = 182 [(scope) = "create:connections"];
  UPDATE_CONNECTIONS = 183 [(scope) = "update:connections"];

  // scheduled exposure calculations
  READ_SCHEDULED_EXPOSURE_CALCULATIONS =   190 [(scope) = "read:scheduledexposurecalculations"];
  LIST_SCHEDULED_EXPOSURE_CALCULATIONS =   191 [(scope) = "list:scheduledexposurecalculations"];
  CREATE_SCHEDULED_EXPOSURE_CALCULATIONS = 192 [(scope) = "create:scheduledexposurecalculations"];
  UPDATE_SCHEDULED_EXPOSURE_CALCULATIONS = 193 [(scope) = "update:scheduledexposurecalculations"];

  // operations
  READ_OPERATIONS =   200 [(scope) = "read:operations"];
  LIST_OPERATIONS =   201 [(scope) = "list:operations"];
  CREATE_OPERATIONS = 202 [(scope) = "create:operations"];
  UPDATE_OPERATIONS = 203 [(scope) = "update:operations"];

  // data warehouse
  READ_DATA_WAREHOUSES =   210 [(scope) = "read:datawarehouses"];
  LIST_DATA_WAREHOUSES =   211 [(scope) = "list:datawarehouses"];
  CREATE_DATA_WAREHOUSES = 212 [(scope) = "create:datawarehouses"];
  UPDATE_DATA_WAREHOUSES = 213 [(scope) = "update:datawarehouses"];

  // users
  READ_USERS =   220 [(scope) = "read:users"];
  LIST_USERS =   221 [(scope) = "list:users"];
  CREATE_USERS = 222 [(scope) = "create:users"];
  UPDATE_USERS = 223 [(scope) = "update:users"];

  // roles
  READ_ROLES =   230 [(scope) = "read:roles"];
  LIST_ROLES =   231 [(scope) = "list:roles"];
  CREATE_ROLES = 232 [(scope) = "create:roles"];
  UPDATE_ROLES = 233 [(scope) = "update:roles"];

  // api clients
  READ_API_CLIENTS =   240 [(scope) = "read:apiclients"];
  LIST_API_CLIENTS =   241 [(scope) = "list:apiclients"];
  CREATE_API_CLIENTS = 242 [(scope) = "create:apiclients"];
  UPDATE_API_CLIENTS = 243 [(scope) = "update:apiclients"];
  DELETE_API_CLIENTS = 244 [(scope) = "delete:apiclients"];

  // events
  LIST_EVENTS = 250 [(scope) = "list:events"];
  READ_EVENTS = 251 [(scope) = "read:events"];

  READ_CLIENT_SCHEMA = 260 [(scope) = "read:clientschema"];

  // event ingestion
  READ_EVENT_DEFINITIONS =   270 [(scope) = "read:eventdefinitions"];
  LIST_EVENT_DEFINITIONS =   271 [(scope) = "list:eventdefinitions"];
  CREATE_EVENT_DEFINITIONS = 272 [(scope) = "create:eventdefinitions"];
  UPDATE_EVENT_DEFINITIONS = 273 [(scope) = "update:eventdefinitions"];
  DELETE_EVENT_DEFINITIONS = 274 [(scope) = "delete:eventdefinitions"];

  // billing skus
  READ_SKUS = 280 [(scope) = "read:skus"];
  LIST_SKUS = 281 [(scope) = "list:skus"];

  // usage reports
  READ_USAGE_REPORTS = 290 [(scope) = "read:usagereports"];

  // user invitations
  READ_USER_INVITATIONS =   300 [(scope) = "read:userinvitations"];
  LIST_USER_INVITATIONS =   301 [(scope) = "list:userinvitations"];
  CREATE_USER_INVITATIONS = 302 [(scope) = "create:userinvitations"];
  DELETE_USER_INVITATIONS = 304 [(scope) = "delete:userinvitations"];

  // user invitations
  READ_OAUTH_APPS =   310 [(scope) = "read:oauthapps"];
  LIST_OAUTH_APPS =   311 [(scope) = "list:oauthapps"];
  CREATE_OAUTH_APPS = 312 [(scope) = "create:oauthapps"];
  UPDATE_OAUTH_APPS = 313 [(scope) = "update:oauthapps"];
  DELETE_OAUTH_APPS = 314 [(scope) = "delete:oauthapps"];

  // workflow secrets
  READ_WORKFLOW_SECRETS = 320 [(scope) = "read:workflowsecrets"];
  LIST_WORKFLOW_SECRETS = 321 [(scope) = "list:workflowsecrets"];
  CREATE_WORKFLOW_SECRETS = 322 [(scope) = "create:workflowsecrets"];
  UPDATE_WORKFLOW_SECRETS = 323 [(scope) = "update:workflowsecrets"];
  DELETE_WORKFLOW_SECRETS = 324 [(scope) = "delete:workflowsecrets"];

  // workflow logs
  LIST_WORKFLOW_LOGS = 330 [(scope) = "list:workflowlogs"];
  READ_WORKFLOW_LOGS = 331 [(scope) = "read:workflowlogs"];

  // exposure calculations
  READ_EXPOSURE_CALCULATIONS =   340 [(scope) = "read:exposurecalculations"];
  LIST_EXPOSURE_CALCULATIONS =   341 [(scope) = "list:exposurecalculations"];
  CREATE_EXPOSURE_CALCULATIONS = 342 [(scope) = "create:exposurecalculations"];
  UPDATE_EXPOSURE_CALCULATIONS = 343 [(scope) = "update:exposurecalculations"];

  // crypto keys
  READ_CRYPTO_KEYS = 350 [(scope) = "read:cryptokeys"];
  LIST_CRYPTO_KEYS = 351 [(scope) = "list:cryptokeys"];
  CREATE_CRYPTO_KEYS = 352 [(scope) = "create:cryptokeys"];
  DELETE_CRYPTO_KEYS = 353 [(scope) = "delete:cryptokeys"];

  // resolve info
  CREATE_RESOLVE_INFO = 360 [(scope) = "create:resolveinfo"];

  // flag assigned
  CREATE_FLAG_ASSIGNED = 370 [(scope) = "create:flagassigned"];

  // stats
  STATS_TEST_HYPOTHESIS = 380 [(scope) = "stats:testhypothesis"];
  STATS_RUN_ANALYSIS = 381 [(scope) = "stats:runanalysis"];
  STATS_RUN_EXPLORATORY_ANALYSIS = 382 [(scope) = "stats:runexploratoryanalysis"];
  STATS_RUN_POWER_ANALYSIS = 383 [(scope) = "stats:runpoweranalysis"];

  // Subgroup
  READ_SUBGROUP_ANALYSES = 390 [(scope) = "read:subgroupanalyses"];
  LIST_SUBGROUP_ANALYSES = 391 [(scope) = "list:subgroupanalyses"];
  CREATE_SUBGROUP_ANALYSES = 392 [(scope) = "create:subgroupanalyses"];
  DELETE_SUBGROUP_ANALYSES = 393 [(scope) = "delete:subgroupanalyses"];

  // Materialized segments
  READ_MATERIALIZED_SEGMENTS = 400 [(scope) = "read:materializedsegments"];
  LIST_MATERIALIZED_SEGMENTS = 401 [(scope) = "list:materializedsegments"];
  CREATE_MATERIALIZED_SEGMENTS = 402 [(scope) = "create:materializedsegments"];
  DELETE_MATERIALIZED_SEGMENTS = 403 [(scope) = "delete:materializedsegments"];
  UPDATE_MATERIALIZED_SEGMENTS = 404 [(scope) = "update:materializedsegments"];

  // groups
  READ_GROUPS =   410 [(scope) = "read:groups"];
  LIST_GROUPS =   411 [(scope) = "list:groups"];
  CREATE_GROUPS = 412 [(scope) = "create:groups"];
  UPDATE_GROUPS = 413 [(scope) = "update:groups"];
  DELETE_GROUPS = 414 [(scope) = "delete:groups"];

  // images
  READ_IMAGES =   420 [(scope) = "read:images"];
  LIST_IMAGES =   421 [(scope) = "list:images"];
  CREATE_IMAGES = 422 [(scope) = "create:images"];
  UPDATE_IMAGES = 423 [(scope) = "update:images"];
  DELETE_IMAGES = 424 [(scope) = "delete:images"];

  // surfaces
  READ_SURFACES =   430 [(scope) = "read:surfaces"];
  LIST_SURFACES =   431 [(scope) = "list:surfaces"];
  CREATE_SURFACES = 432 [(scope) = "create:surfaces"];
  UPDATE_SURFACES = 433 [(scope) = "update:surfaces"];
  DELETE_SURFACES = 434 [(scope) = "delete:surfaces"];
}

message Authorization {
  repeated Permission required_permission = 1;
  bool disable_authorization = 2;
  bool allow_empty_permissions = 3;
  string object_field = 4;
  string required_relation = 5;
  bool allow_basic_auth = 6;
}

extend google.protobuf.MethodOptions {
  Authorization auth = 4399225;
}

extend google.protobuf.EnumValueOptions {
  string scope = 4399294;
}
