syntax = "proto2";
package rockpaperscissors;
option go_package = "proto";

message GitHubRepository {
  optional string host = 1 [default = "git-aws.internal.justin.tv"];
  optional string name = 2;
}

message SourceRepository {
  oneof repository {
    GitHubRepository github_repository = 1;
  }
  optional string description = 2;
}

message SourceFilePath {
  optional SourceRepository repository = 1;
  optional string path = 2;
}

message GitHubIssues {
  optional GitHubRepository repository = 1;
  repeated string label = 2;
}

message JiraProject {
  optional string host = 1;
  optional string project = 2;
  repeated string component = 3;
  repeated string label = 4;
}

message IssueTracker {
  optional string description = 1;
  oneof tracker {
    GitHubIssues github_issues = 2;
    JiraProject jira_project = 3;
  }
  repeated string assignee = 4;
}

message GitHubPullRequest {
  optional GitHubRepository repository = 1;
  optional string upstream_branch = 2 [default = "master"];
}

message Differential {
  optional string host = 1 [default = "phabricator.internal.justin.tv"];
}

message CodeReview {
  optional string description = 1;
  repeated string reviewer = 2;
  oneof review_system {
    GitHubPullRequest github_pull_request = 3;
    Differential differential = 4;
  }
}

message SkadiDeployment {
  optional string host = 1 [default = "clean-deploy.internal.justin.tv"];
  optional string branch = 2;
  optional string environment = 3;
}

message Deployment {
  optional string description = 1;
  oneof deployment {
    SkadiDeployment skadi = 2;
  }
}

message JenkinsJob {
  optional string host = 1 [default = "jenkins.internal.justin.tv"];
  optional string name = 2;
  message Parameter {
    optional string name = 1;
    optional string value = 2;
  }
  repeated Parameter parameters = 3;
}

message BuildService {
  optional string description = 1;
  oneof service {
    JenkinsJob jenkins_job = 2;
  }
}

message Rollbar {
  // In Rollbar, projects are created within an Account. All of Twitch uses
  // the "Twitch" account.
  optional string account = 1 [default = "Twitch"];
  optional string project = 2;
}

message PagerDuty {
  // In PagerDuty, services are created within an Organization. An Organization
  // is identified by it's "site-name". For Twitch, our site-name is
  // "twitchoncall". Services are identified by their ID. You can find the ID
  // for your service from the URL of the PagerDuty page for it and it will be
  // something like "PCHR9O8".
  optional string site_name = 1 [default = "twitchoncall"];
  optional string service_id = 2;
}

message Link {
  optional string name = 1;
  optional string url = 2;

  enum Type {
    OTHER = 0;
    DOCUMENTATION = 1;
    DESIGN_DOC = 2;
    WIKI = 3;
  }
  optional Type type = 3;
}

message ProjectMetadata {
  optional string project_id = 1;
  optional string project_name = 2;

  // Automatically updated by RockPaperScissors blueprint ingest
  optional double last_update_timestamp = 3;
  optional SourceFilePath blueprint_location = 4;

  // Where does the code live?
  repeated SourceRepository source_repositories = 5;

  // Who is the major contact point for the project.
  repeated string tech_lead = 6;

  // Email address to reach the team/project/developers.
  optional string developer_email_list = 7;

  // Other contributors/developers that work on the project.
  repeated string developer = 8;

  // Where are bugs filed?
  repeated IssueTracker issue_tracker = 9;

  // How should code be reviewed?
  repeated CodeReview code_review = 10;

  // Where/How are deployments made?
  repeated Deployment deployment = 11;

  // What team is this project a part of.
  optional string team_name = 12;

  // Whether this project has been "archived" to be hidden in lists.
  optional bool archived = 13;

  // Where/how this project gets built.
  repeated BuildService build_service = 14;

  // If this project reports problems to a Rollbar project.
  optional Rollbar rollbar = 15;

  // If this project has a PagerDuty service associated with it.
  optional PagerDuty pagerduty = 16;

  // What org is this project a part of.
  optional string org_name = 17;

  // Documentation and other links.
  repeated Link links = 18;
}
