type User {
  id: ID!
  username: String!
  "All albums owned by this user"
  albums: [Album!]! @isAdmin
  "Top level albums owned by this user"
  rootAlbums: [Album!]! @isAdmin
  "Whether or not the user has admin privileges"
  admin: Boolean!
}

"Supported language translations of the user interface"
enum LanguageTranslation {
  English,
  French,
  Italian,
  Swedish,
  Danish,
  Spanish,
  Polish,
  Ukrainian,
  German,
  Russian,
  TraditionalChinese,
  SimplifiedChinese,
  Portuguese,
  Basque,
  Turkish
}

"Preferences for regular users"
type UserPreferences {
  id: ID!
  language: LanguageTranslation
}

type AuthorizeResult {
  success: Boolean!

  "A textual status message describing the result, can be used to show an error message when `success` is false"
  status: String!
  "An access token used to authenticate new API requests as the newly authorized user. Is present when success is true"
  token: String
}


extend type Query {
  "List of registered users, must be admin to call"
  user(order: Ordering, paginate: Pagination): [User!]! @isAdmin

  "Information about the currently logged in user"
  myUser: User! @isAuthorized

  "User preferences for the logged in user"
  myUserPreferences: UserPreferences! @isAuthorized
}

extend type Mutation {
  "Authorizes a user and returns a token used to identify the new session"
  authorizeUser(username: String!, password: String!): AuthorizeResult!

  "Registers the initial user, can only be called if initialSetup from SiteInfo is true"
  initialSetupWizard(
    username: String!
    password: String!
    rootPath: String!
  ): AuthorizeResult

  "Update a user, fields left as `null` will not be changed"
  updateUser(
    id: ID!
    username: String
    password: String
    admin: Boolean
  ): User! @isAdmin
  "Create a new user"
  createUser(
    username: String!
    password: String
    admin: Boolean!
  ): User! @isAdmin
  "Delete an existing user"
  deleteUser(id: ID!): User! @isAdmin

  "Add a root path from where to look for media for the given user, specified by their user id."
  userAddRootPath(id: ID!, rootPath: String!): Album @isAdmin

  """
  Remove a root path from a user, specified by the id of the user and the top album representing the root path.
  This album was returned when creating the path using `userAddRootPath`.
  A list of root paths for a particular user can be retrived from the `User.rootAlbums` path.
  """
  userRemoveRootAlbum(userId: ID!, albumId: ID!): Album @isAdmin

  "Change user preferences for the logged in user"
  changeUserPreferences(language: String): UserPreferences! @isAuthorized
}
