// SonarQube, open source software quality management tool.
// Copyright (C) 2008-2016 SonarSource
// mailto:contact AT sonarsource DOT com
//
// SonarQube is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// SonarQube is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

syntax = "proto2";

package sonarqube.ws.users;

import "ws-commons.proto";

option java_package = "org.sonarqube.ws";
option java_outer_classname = "Users";
option optimize_for = SPEED;

// WS api/users/search
message SearchWsResponse {
  optional sonarqube.ws.commons.Paging paging = 1;
  repeated User users = 2;

  message User {
    optional string login = 1;
    optional string name = 2;
    optional bool active = 3;
    optional string email = 4;
    optional ScmAccounts scmAccounts = 5;
    optional Groups groups = 6;
    optional int32 tokensCount = 7;
    optional bool local = 8;
    optional string externalIdentity = 9;
    optional string externalProvider = 10;
    optional string avatar = 11;
    optional string lastConnectionDate = 12;
    optional bool managed = 13;
    optional string sonarLintLastConnectionDate = 14;
  }

  message Groups {
    repeated string groups = 1;
  }

  message ScmAccounts {
    repeated string scmAccounts = 1;
  }
}

// WS api/users/identity_providers
message IdentityProvidersWsResponse {
  repeated IdentityProvider identityProviders = 1;
}

message IdentityProvider {
  optional string key = 1;
  optional string name = 2;
  optional string iconPath = 3;
  optional string backgroundColor = 4;
  optional string helpMessage = 5;
}

message CreateWsResponse {
  optional User user = 1;

  message User {
    optional string login = 1;
    optional string name = 2;
    optional string email = 3;
    repeated string scmAccounts = 4;
    optional bool active = 5;
    optional bool local = 6;
  }
}

// WS api/users/groups
message GroupsWsResponse {
  optional sonarqube.ws.commons.Paging paging = 1;
  repeated Group groups = 2;

  message Group {
    optional string id = 1;
    optional string name = 2;
    optional string description = 3;
    optional bool selected = 4;
    optional bool default = 5;
  }
}

// WS api/users/current
message CurrentWsResponse {
  optional bool isLoggedIn = 1;
  optional string login = 2;
  optional string name = 3;
  optional string email = 4;
  optional bool local = 5;
  optional string externalIdentity = 6;
  optional string externalProvider = 7;
  repeated string scmAccounts = 8;
  repeated string groups = 9;
  optional Permissions permissions = 10;
  reserved 11; // showOnboardingTutorial removed
  optional string avatar = 12;
  optional Homepage homepage = 13;
  reserved 15; // settings removed
  optional bool usingSonarLintConnectedMode = 16;
  reserved 17; // sonarLintAdSeen removed
  map<string,bool> dismissedNotices = 18;

  message Permissions {
    repeated string global = 1;
  }

  enum HomepageType {
    PROJECT = 1;
    PROJECTS = 2;
    ISSUES = 3;
    PORTFOLIO = 4;
    PORTFOLIOS = 5;
    APPLICATION = 6;
  }

  message Homepage {
    optional HomepageType type = 1;
    optional string component = 2;
    optional string branch = 3;
  }

  message Setting {
    optional string key = 1;
    optional string value = 2;
  }
}
