package org.twonote.rgwadmin4j.model;

import com.google.gson.annotations.SerializedName;

import java.util.Optional;

/** Represents the sub-user information. */
public class SubUser {
  /** id : rgwAdmin4jTest-6eed8682-c533-4364-bd36-684e3a9f32c7:qqqqq permissions : full-control */
  private String id;

  @SerializedName("permissions")
  private Permission permission;

  /**
   * Get sub-user ID
   *
   * <p>Note that it will be in the absolute form, i.e., [USER_ID]:[SUB_USER_ID]
   *
   * @return sub-user ID
   */
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  /**
   * Get access permission of the sub-user.
   *
   * <p>Note that the sub-user may not have any permission.
   *
   * @return The permission.
   */
  public Optional<Permission> getPermission() {
    return Optional.ofNullable(permission);
  }

  public void setPermission(Permission permission) {
    this.permission = permission;
  }

  /**
   * Access permission for sub-user.
   */
  public enum Permission {
    @SerializedName("read")
    READ,

    @SerializedName("write")
    WRITE,

    @SerializedName("readwrite")
    READ_WRITE,

    @SerializedName(
        value = "full",
        alternate = {"full-control"}
    )
    FULL;

    @Override
    public String toString() {
      return super.toString().toLowerCase();
    }
  }
}
@@ -614,24 +614,169 @@
  = id;%0A  %7D%0A%0A
+  public String getParentUserId() %7B%0A    return id.split(%22:%22)%5B0%5D;%0A  %7D%0A%0A  public String getRelativeSubUserId() %7B%0A    return id.split(%22:%22)%5B1%5D;%0A  %7D%0A%0A
   /**%0A   * G

Add helper method in subuser model