/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

syntax = "proto3";

option java_multiple_files = true;
package org.apache.custos.core.user.profile.api;


enum UserStatus {
  ACTIVE = 0;
  CONFIRMED = 1;
  APPROVED = 2;
  DELETED = 3;
  DUPLICATE = 4;
  GRACE_PERIOD = 5;
  INVITED = 6;
  DENIED = 7;
  PENDING = 8;
  PENDING_APPROVAL = 9;
  PENDING_CONFIRMATION = 10;
  SUSPENDED = 11;
  DECLINED = 12;
  EXPIRED = 13;
}

enum DefaultGroupMembershipTypes {
  OWNER = 0;
  ADMIN = 1;
  MEMBER = 2;
}

enum UserTypes {
  END_USER = 0;
  COMMUNITY = 1;
}

message UserProfile {
  string username = 1;
  string email = 2;
  string first_name = 3;
  string last_name = 4;
  int64 created_at = 5;
  UserStatus status = 6;
  repeated UserAttribute attributes = 7;
  repeated string client_roles = 8;
  repeated string realm_roles = 9;
  int64 last_modified_at = 10;
  UserTypes type = 11;
  string membership_type = 12;
}

message UserProfileRequest {
  int64 tenantId = 1;
  UserProfile profile = 2;
  string performed_by = 3;
  string client_id = 4;
  int32 offset=5;
  int32 limit=6;
}

message UserAttribute {
  int64 id = 1;
  string key = 2;
  repeated string values = 3;
}

message GetAllUserProfilesResponse {
  repeated UserProfile profiles = 1;
}

message GetUpdateAuditTrailRequest {
  int64 tenantId = 1;
  string username = 2;
}

message UserProfileAttributeUpdateMetadata {
  string updated_attribute = 1;
  string updated_attribute_value = 2;
  string updated_by = 3;
  string updated_at = 4;
}

message UserProfileStatusUpdateMetadata {
  UserStatus updated_status = 1;
  string updated_by = 2;
  string updated_at = 3;
}

message GetUpdateAuditTrailResponse {
  repeated UserProfileAttributeUpdateMetadata attribute_audit = 1;
  repeated UserProfileStatusUpdateMetadata status_audit = 2;
}

message GroupRequest {
  int64 tenant_id = 1;
  Group group = 2;
  string performed_by = 3;
  string client_id = 4;
  string membership_type = 5;
  string id = 6;
  string client_sec =7;
  int32 offset =8;
  int32 limit=9;
}

message GetAllGroupsResponse {
  repeated Group groups = 1;
}

message Group {
  string id = 1;
  string name = 2;
  repeated string realm_roles = 3;
  repeated string client_roles = 4;
  string parent_id = 5;
  int64 created_time = 6;
  int64 last_modified_time = 7;
  repeated GroupAttribute attributes = 8;
  string description = 9;
  string owner_id = 10;
  int32 total_members = 11;
  string requester_role = 12;
}

message GroupAttribute {
  int64 id = 1;
  string key = 2;
  repeated string value = 3;
}

message GroupMembership {
  int64 tenant_id = 1;
  string group_id = 2;
  string username = 3;
  string type = 4;
  string clientId = 5;
  string clientSec = 6;
}

message GroupToGroupMembership {
  int64 tenant_id = 1;
  string parent_id = 2;
  string child_id = 3;
  string client_id = 4;
}

message Status {
  bool status = 1;
}

message UserGroupMembershipTypeRequest {
  string type = 1;
  int64 tenant_id = 2;
  string client_id = 3;
}
