syntax = "proto3";

import "proto/context.proto";
import "proto/grp.proto";
import "proto/user_id.proto";

package user;

message GetUserRequest {
  context.RequestContext request_context = 2;

  user_id.UserId user_id = 1;
}

message GetUserResponse {
  user_id.DisplayUser display_user = 1;

  // The groups this user is a member of.
  repeated grp.Group user_group = 2;

  // The ID of the user's currently selected group to be displayed in the UI.
  //
  // In most cases, this will match the group_id in the original request
  // context, which should be populated from client preferences. However, if the
  // user no longer has access to the group or if no group_id was set, this will
  // be set to one of the group IDs in user_group as a fallback. If user_group
  // is empty, this will also be empty.
  string selected_group_id = 3;

  // List of BuildBuddyService RPC names that the user is allowed to perform
  // for their currently selected group.
  repeated string allowed_rpc = 4;

  // User-specific Github token (if linked).
  string github_token = 5;
}

message CreateUserRequest {
  // User sub ID is inferred from the (required) side-channel token.
  // UserID (buildbuddy) is generated.
  // Other values (like name, etc) will have initial values that are pulled
  // from the authentication provider response.
}

message CreateUserResponse {
  user_id.DisplayUser display_user = 1;
}
