syntax = "proto3";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/iam/v1/iam_policy.proto";
import "google/iam/v1/policy.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/type/date.proto";

package animeshon.identity.v1alpha1;

option go_package = "github.com/animeapis/go-genproto/identity/v1alpha1;identity";
option java_package = "com.animeshon.identity.v1alpha1";
option java_multiple_files = true;
option ruby_package = "Animeshon::Identity::v1Alpha1";

service Identity {
  option (google.api.default_host) = "identity.animeapis.com";

  rpc GetUserProfile(GetUserProfileRequest) returns (UserProfile) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=users/*}:profile"
    };
  }

  rpc GetUser(GetUserRequest) returns (User) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=users/*}"
    };
  }

  rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {
    option (google.api.http) = {
      get: "/v1alpha1/users"
    };
  }

  rpc CreateUser(CreateUserRequest) returns (User) {
    option (google.api.http) = {
      post: "/v1alpha1/users"
      body: "*"
    };
  }

  rpc UpdateUser(UpdateUserRequest) returns (User) {
    option (google.api.http) = {
      patch: "/v1alpha1/{user.name=users/*}"
      body: "*"
    };
  }

  rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1alpha1/{name=users/*}"
    };
  }

  rpc GetUserSettings(GetUserSettingsRequest) returns (UserSettings) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=users/*}:settings"
    };
  }

  rpc UpdateUserSettings(UpdateUserSettingsRequest) returns (UserSettings) {
    option (google.api.http) = {
      patch: "/v1alpha1/{settings.name=users/*}:settings"
      body: "*"
    };
  }

  rpc GetUserNotifications(GetUserNotificationsRequest) returns (UserNotifications) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=users/*}:notifications"
    };
  }

  rpc UpdateUserNotifications(UpdateUserNotificationsRequest) returns (UserNotifications) {
    option (google.api.http) = {
      patch: "/v1alpha1/{notifications.name=users/*}:notifications"
      body: "*"
    };
  }

  rpc GetUserDefaults(GetUserDefaultsRequest) returns (UserDefaults) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=users/*}:defaults"
    };
  }

  rpc GetGroup(GetGroupRequest) returns (Group) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=groups/*}"
    };
  }

  rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) {
    option (google.api.http) = {
      get: "/v1alpha1/groups"
    };
  }

  rpc CreateGroup(CreateGroupRequest) returns (Group) {
    option (google.api.http) = {
      post: "/v1alpha1/groups"
      body: "*"
    };
  }

  rpc UpdateGroup(UpdateGroupRequest) returns (Group) {
    option (google.api.http) = {
      patch: "/v1alpha1/{group.name=groups/*}"
      body: "*"
    };
  }

  rpc DeleteGroup(DeleteGroupRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1alpha1/{name=groups/*}"
    };
  }
}

enum Gender {
  // Not specified.
  GENDER_UNSPECIFIED = 0;

  // Male.
  MALE = 1;

  // Female.
  FEMALE = 2;

  // Any other non-binary gender.
  OTHER = 3;
}

// This message is returned only when a user wants to fetch information about
// another user and the amount of information returned is greatly reduced to
// ensure that personal and confidential information is never disclosed by
// accident to other users. The user profile is read-only.
message UserProfile {
  // The resource name of the user.
  string name = 1;

  // The profile image of the user.
  string profile_image = 2;

  // The banner image of the user.
  string banner_image = 3;

  // The public username of the user.
  string username = 4;

  // The public discriminator of the user.
  string discriminator = 5;

  // The birthday of the user, this value is hidden for private profiles.
  google.type.Date birthday = 6;

  // The gender of the user, this value is hidden for private profiles.
  Gender gender = 7;
}

message User {
  // The resource name of the user.
  string name = 1;

  // The uuid that identifies the user during the authentication flow.
  string uuid = 2 [(google.api.field_behavior) = IMMUTABLE];

  // The public username of the user.
  string username = 3;

  // The public discriminator of the user.
  string discriminator = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The primary email address of the user.
  string primary_email = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Whether the primary email address has been verified.
  bool primary_email_verified = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The given name of the user.
  string given_name = 7;

  // The family name of the user.
  string family_name = 8;

  // The name of the user.
  string display_name = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The country where the user is located at, must be a valid ISO-3166 code.
  string country_code = 10;

  // The locale preferred by the user, must be a valid BCP-47 code.
  string locale = 11;

  // The fallback locale preferred by the user, must be a valid BCP-47 code.
  // The only allowed values are eng, jpn, and jpn-Latn (romaji).
  string locale_fallback = 12;

  // The birthday defined by the user, this value is used to determine whether
  // the user should be allowed to access explicit and sensitive content.
  google.type.Date birthday = 13;

  // The gender of the user.
  Gender gender = 14;

  // The profile image of the user.
  string profile_image = 15;

  // The banner image of the user.
  string banner_image = 16;
}

message UserSettings {
  enum Visibility {
    // Not specified.
    VISIBILITY_UNSPECIFIED = 0;

    // Public.
    PUBLIC = 1;

    // Private.
    PRIVATE = 2;
  }

  // The resource name of the user.
  string name = 1;

  // A private user will only have the username, discriminator, profile image
  // and banner image public.
  Visibility profile_visibility = 2;

  // Whether the user choose to see explicit content during navigation. 
  bool show_explicit_content = 3;

  // Whether the user has enabled the developer mode.
  bool enable_developer_mode = 4;
}

message UserDefaults {
  // The system-managed album dedicated to user profile images.
  string album_profile = 1 [(google.api.field_behavior) = REQUIRED];

  // The system-managed album dedicated to user banner images.
  string album_banner = 2 [(google.api.field_behavior) = REQUIRED];

  // The system-managed playlist dedicated to user liked content.
  string playlist_liked = 3 [(google.api.field_behavior) = REQUIRED];

  // The system-managed playlist dedicated to user saved for later content.
  string playlist_later = 4 [(google.api.field_behavior) = REQUIRED];
}

message UserNotifications {
  // The resource name of the user.
  string name = 1;
}

message Group {
  // The resource name of the group.
  string name = 1;

  // The list of members of the group. Groups might include other groups.
  repeated string members = 2;

  // An etag for concurrency control, ignored during creation.
  bytes etag = 3;
}

message GetUserProfileRequest {
  // The name of the user to retrieve the profile from.
  string name = 1;
}

message GetUserRequest {
  // The name of the user to retrieve.
  string name = 1;
}

message ListUsersRequest {
  // If unspecified, server will pick an appropriate default.
  int32 page_size = 1;

  // The value returned from the previous call.
  string page_token = 2;

  // A filter to be applied to results.
  string filter = 3;
}

message ListUsersResponse {
  // The list of users.
  repeated User users = 1;

  // A token to retrieve next page of results.
  string next_page_token = 2;
}

message CreateUserRequest {
  // The user to create.
  User user = 1;
}

message UpdateUserRequest {
  // The user to update.
  User user = 1 [(google.api.field_behavior) = REQUIRED];

  // The field mask to determine which fields are to be updated. If empty, the
  // server will assume all fields are to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

message DeleteUserRequest {
  // The name of the user to delete.
  string name = 1;
}

message GetUserSettingsRequest {
  // The name of the user to retrieve the settings from.
  string name = 1 [(google.api.field_behavior) = REQUIRED];
}

message UpdateUserSettingsRequest {
  // The user settings to update.
  UserSettings settings = 1 [(google.api.field_behavior) = REQUIRED];

  // The field mask to determine which fields are to be updated. If empty, the
  // server will assume all fields are to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

message GetUserNotificationsRequest {
  // The name of the user to retrieve the notifications from.
  string name = 1 [(google.api.field_behavior) = REQUIRED];
}

message UpdateUserNotificationsRequest {
  // The user notifications to update.
  UserNotifications notifications = 1 [(google.api.field_behavior) = REQUIRED];

  // The field mask to determine which fields are to be updated. If empty, the
  // server will assume all fields are to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

message GetUserDefaultsRequest {
  // The name of the user to retrieve the defaults from.
  string name = 1 [(google.api.field_behavior) = REQUIRED];
}

message GetGroupRequest {
  // The name of the group to retrieve.
  string name = 1;
}

message ListGroupsRequest {
  // If unspecified, server will pick an appropriate default.
  int32 page_size = 1;

  // The value returned from the previous call.
  string page_token = 2;

  // A filter to be applied to results.
  string filter = 3;
}

message ListGroupsResponse {
  // The list of groups.
  repeated Group groups = 1;

  // A token to retrieve next page of results.
  string next_page_token = 2;
}

message CreateGroupRequest {
  // The group to create.
  Group group = 1;
}

message UpdateGroupRequest {
  // The group to update.
  Group group = 1 [(google.api.field_behavior) = REQUIRED];

  // The field mask to determine which fields are to be updated. If empty, the
  // server will assume all fields are to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

message DeleteGroupRequest {
  // The name of the group to delete.
  string name = 1;
}
