nextcloud-node-client
Version:
Nextcloud client API for node.js TypeScript applications
374 lines (373 loc) • 10.7 kB
TypeScript
import Client, { UserGroup } from "./client";
export declare enum UserProperty {
email = "email",
quota = "quota",
displayName = "displayname",
phone = "phone",
address = "address",
website = "website",
twitter = "twitter",
password = "password",
language = "language",
locale = "locale"
}
export interface IUserOptionsQuota {
"free"?: number;
"used": number;
"total"?: number;
"relative": number;
"quota": number;
}
export interface IUserQuotaUserFriendly {
"free"?: string;
"used": string;
"total"?: string;
"quota": string;
"relative": string;
}
export interface IUserOptions {
"enabled": boolean;
"lastLogin"?: Date;
"subadminGroups": string[];
"memberGroups": string[];
"quota": IUserOptionsQuota;
"email": string;
"displayName": string;
"phone": string;
"address": string;
"website": string;
"twitter": string;
"language": string;
"locale": string;
}
/**
* The user class represents a user in nextcloud.
* async getGroups
* async isDisabled
* async getLastLogin
* async getEmail
* getId
* async getDisplayName
*/
export default class User {
private memento?;
private client;
readonly id: string;
/**
* the conscructor of the user
* should only me invoked by the Client
* @constructor
* @param {Client} client
* @param {string} id the user id
* @param {IUserOptions} options optional options
*/
constructor(client: Client, id: string, options?: IUserOptions);
/**
* returns true if the user is enabled
* @async
* @returns {Promise<boolean>} true if the user is enabled
* @throws {UserNotFoundError}
*/
isEnabled(): Promise<boolean>;
/**
* disables the user
* @async
* @returns {Promise<void>}
* @throws {UserNotFoundError}
*/
disable(): Promise<void>;
/**
* enables the user
* @async
* @returns {Promise<void>}
* @throws {UserNotFoundError}
*/
enable(): Promise<void>;
/**
* get the last login date or null if the user has not been logged in yet
* @async
* @returns {Promise<Date | null>} last login date or null if the user has not been logged in yet
* @throws {UserNotFoundError}
*/
getLastLogin(): Promise<Date | null>;
/**
* returns the display name
* @async
* @returns {Promise<string>} display name
* @throws {UserNotFoundError}
*/
getDisplayName(): Promise<string>;
/**
* set the display name
* @async
* @param {string} value the display name
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setDisplayName(value: string): Promise<void>;
/**
* returns information on quota, usage and available space
* @async
* @returns {Promise<IUserOptionsQuota>}
* @throws {UserNotFoundError}
*/
getQuota(): Promise<IUserOptionsQuota>;
/**
* returns information on quota, usage and available space in a user friendly format
* @async
* @returns {Promise<IUserQuotaUserFriendly>}
* @throws {UserNotFoundError}
*/
getQuotaUserFriendly(): Promise<IUserQuotaUserFriendly>;
/**
* sets the quota limit of the user
* @async
* @param {string} value the quota string like "1 GB", "100 MB"
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setQuota(value: string): Promise<void>;
/**
* returns the email address
* @async
* @returns {Promise<string>} email adress
* @throws {UserNotFoundError}
*/
getEmail(): Promise<string>;
/**
* set the email address
* @async
* @param {string} value the email address
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setEmail(value: string): Promise<void>;
/**
* returns the phone number
* @async
* @returns {Promise<string>} phone number
* @throws {UserNotFoundError}
*/
getPhone(): Promise<string>;
/**
* set phone number
* @async
* @param {string} value the phone number
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setPhone(value: string): Promise<void>;
/**
* returns the phone number
* @async
* @returns {Promise<string>} address
* @throws {UserNotFoundError}
*/
getAddress(): Promise<string>;
/**
* set the address
* @async
* @param {string} value the address
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setAddress(value: string): Promise<void>;
/**
* returns the website
* @async
* @returns {Promise<string>} website
* @throws {UserNotFoundError}
*/
getWebsite(): Promise<string>;
/**
* set the website
* @async
* @param {string} value the website
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setWebsite(value: string): Promise<void>;
/**
* returns the twitter handle
* @async
* @returns {Promise<string>} twitter handle
* @throws {UserNotFoundError}
*/
getTwitter(): Promise<string>;
/**
* set the twitter handle
* @async
* @param {string} value the twitter handle
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setTwitter(value: string): Promise<void>;
/**
* returns the langauge code
* @async
* @returns {Promise<string>} language code
* @throws {UserNotFoundError}
*/
getLanguage(): Promise<string>;
/**
* set the language code like EN, DE, FR...
* @async
* @param {string} value the language code
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setLanguage(value: string): Promise<void>;
/**
* returns the locale
* @async
* @returns {Promise<string>} locale
* @throws {UserNotFoundError}
*/
getLocale(): Promise<string>;
/**
* set the locale like EN, DE, FR...
* @async
* @param {string} value the locale
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setLocale(value: string): Promise<void>;
/**
* set the password
* @async
* @param {string} value the password
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserUpdateError}
*/
setPassword(value: string): Promise<void>;
/**
* resends the welcome email
* @async
* @returns {Promise<void>}
* @throws {UserResendWelcomeEmailError}
*/
resendWelcomeEmail(): Promise<void>;
/**
* returns a list of user groups where the user is member
* @async
* @returns {Promise<UserGroup[]} a list of user groups where the user is member
* @throws {UserNotFoundError}
*/
getMemberUserGroups(): Promise<UserGroup[]>;
/**
* returns a list of user group ids where the user is member
* @async
* @returns {Promise<string[]} a list of user group ids where the user is member
* @throws {UserNotFoundError}
*/
getMemberUserGroupIds(): Promise<string[]>;
/**
* adds the user to a user group as member
* @async
* @param {UserGroup} userGroup the user group
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserGroupDoesNotExistError}
* @throws {InsufficientPrivilegesError}
* @throws {OperationFailedError}
*/
addToMemberUserGroup(userGroup: UserGroup): Promise<void>;
/**
* remove the user from a user group as member
* @async
* @param {UserGroup} userGroup the user group
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserGroupDoesNotExistError}
* @throws {InsufficientPrivilegesError}
* @throws {OperationFailedError}
*/
removeFromMemberUserGroup(userGroup: UserGroup): Promise<void>;
/**
* true if the user is a superadmin
* @async
* @returns {Promise<boolean>} true if the user is a superadmin
* @throws {UserNotFoundError}
*/
isSuperAdmin(): Promise<boolean>;
/**
* promote user to super admin
* @async
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserGroupDoesNotExistError}
* @throws {InsufficientPrivilegesError}
* @throws {OperationFailedError}
*/
promoteToSuperAdmin(): Promise<void>;
/**
* demote user from being a super admin
* @async
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserGroupDoesNotExistError}
* @throws {InsufficientPrivilegesError}
* @throws {OperationFailedError}
*/
demoteFromSuperAdmin(): Promise<void>;
/**
* returns a list of user groups where the user is subadmin
* @async
* @returns {Promise<UserGroup[]} a list of user groups where the user is subadmin
* @throws {UserNotFoundError}
*/
getSubadminUserGroups(): Promise<UserGroup[]>;
/**
* returns a list of user group ids where the user is subadmin
* @async
* @returns {Promise<string[]} a list of user group ids where the user is subadmin
* @throws {UserNotFoundError}
*/
getSubadminUserGroupIds(): Promise<string[]>;
/**
* promote the user to be a subadmin of the user group
* @async
* @param {UserGroup} userGroup the user group
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserGroupDoesNotExistError}
* @throws {InsufficientPrivilegesError}
* @throws {OperationFailedError}
*/
promoteToUserGroupSubadmin(userGroup: UserGroup): Promise<void>;
/**
* demote the user from beeing a subadmin of the user group
* @async
* @param {UserGroup} userGroup the user group
* @returns {Promise<void>}
* @throws {UserNotFoundError}
* @throws {UserGroupDoesNotExistError}
* @throws {InsufficientPrivilegesError}
* @throws {OperationFailedError}
*/
demoteFromSubadminUserGroup(userGroup: UserGroup): Promise<void>;
/**
* deletes a user
* @async
* @returns {Promise<void>}
* @throws {UserNotFoundError}
*/
delete(): Promise<void>;
/**
* returns the user data
* @async
* @returns {Promise<IUserOptions>}
* @throws {UserNotFoundError}
*/
private getUserData;
}