Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

The nextcloud client is the root object to access the remote api of the nextcloud server.

Hierarchy

  • Client

Index

Constructors

constructor

  • Creates a new instance of a nextcloud client.
    Use the server to provide server connectivity information to the client.
    (The FakeServer is only used for testing and code coverage)

    If the server is not provided the client tries to find the connectivity information in the environment.
    If a VCAP_SERVICES environment variable is available, the client tries to find a service with the name "nextcloud" in the user-provides-services section.
    If no VCAP_SERVICES are available, the client uses the following variables from the envirnonment for the connectivity:

    • NEXTCLOUD_URL - the url of the nextcloud server
    • NEXTCLOUD_USERNAME - the user name
    • NEXTCLOUD_PASSWORD - the application password

    Parameters

    • Optional server: Server | FakeServer

      optional server information to connection to a nextcloud server

    Returns Client

Properties

Static webDavUrlPath

webDavUrlPath: string = "/remote.php/webdav"

Methods

addCommentToFile

  • addCommentToFile(fileId: number, comment: string): Promise<void>
  • adds a comment to a file

    Parameters

    • fileId: number

      the id of the file

    • comment: string

      the comment to be added to the file

    Returns Promise<void>

addTagToFile

  • addTagToFile(fileId: number, tagName: string): Promise<void>
  • adds a tag to a file or folder if the tag does not exist, it is automatically created if the tag is created, the user must have damin privileges

    throws

    Error

    Parameters

    • fileId: number

      the id of the file

    • tagName: string

      the name of the tag

    Returns Promise<void>

    nothing

addUserToMemberUserGroup

  • addUserToMemberUserGroup(id: string, userGroupId: string): Promise<void>
  • adds a user to a group as member

    throws

    {UserNotFoundError}

    throws

    {UserGroupDoesNotExistError}

    throws

    {InsufficientPrivilegesError}

    throws

    {OperationFailedError}

    Parameters

    • id: string

      string the user id

    • userGroupId: string

      string the user group id

    Returns Promise<void>

createFile

  • createFile(fileName: string, data: Buffer | ReadableStream): Promise<File>
  • create a new file of overwrites an existing file

    Parameters

    • fileName: string

      the file name /folder1/folder2/filename.txt

    • data: Buffer | ReadableStream

      the buffer object

    Returns Promise<File>

createFolder

  • createFolder(folderName: string): Promise<Folder>
  • creates a folder and all parent folders in the path if they do not exist

    Parameters

    • folderName: string

      name of the folder /folder/subfolder/subfolder

    Returns Promise<Folder>

    a folder object

createShare

createTag

  • createTag(tagName: string): Promise<Tag>
  • creates a new tag, if not already existing this function will fail with http 403 if the user does not have admin privileges

    Parameters

    • tagName: string

      the name of the tag

    Returns Promise<Tag>

    tagId

createUser

  • createUser(options: { email?: undefined | string; id: string; password?: undefined | string }): Promise<User>
  • creates a new user with email or password

    throws

    UserAlreadyExistsError

    throws

    {UserNotFoundError}

    throws

    UserUpdateError

    Parameters

    • options: { email?: undefined | string; id: string; password?: undefined | string }
      • Optional email?: undefined | string
      • id: string
      • Optional password?: undefined | string

    Returns Promise<User>

    User

createUserGroup

  • createUserGroup(id: string): Promise<UserGroup>
  • create a new user group

    async
    throws

    {UserGroupAlreadyExistsError}

    Parameters

    • id: string

      user group id

    Returns Promise<UserGroup>

deleteAllTags

  • deleteAllTags(): Promise<void>
  • deletes all visible assignable tags

    throws

    Error

    Returns Promise<void>

deleteFile

  • deleteFile(fileName: string): Promise<void>
  • deletes a file

    Parameters

    • fileName: string

      name of folder "/f1/f2/f3/x.txt"

    Returns Promise<void>

deleteFolder

  • deleteFolder(folderName: string): Promise<void>
  • deletes a folder

    Parameters

    • folderName: string

      name of folder "/f1/f2/f3"

    Returns Promise<void>

deleteShare

  • deleteShare(shareId: string): Promise<any>
  • get share information

    Parameters

    • shareId: string

    Returns Promise<any>

deleteTag

  • deleteTag(tagId: number): Promise<void>
  • deletes the tag by id this function will fail with http 403 if the user does not have admin privileges

    Parameters

    • tagId: number

      the id of the tag like "/remote.php/dav/systemtags/234"

    Returns Promise<void>

deleteUser

  • deleteUser(id: string): Promise<void>
  • deletes the user

    throws

    {UserNotFoundError}

    Parameters

    • id: string

      string the user id

    Returns Promise<void>

deleteUserGroup

  • deleteUserGroup(id: string): Promise<void>
  • deletes an existing user group

    throws

    {UserGroupDowsNotExistError}

    throws

    {UserGroupDeletionFailedError}

    Parameters

    • id: string

      string

    Returns Promise<void>

demoteUserFromSubadminUserGroup

  • demoteUserFromSubadminUserGroup(id: string, userGroupId: string): Promise<void>
  • Removes the subadmin rights for the user specified from the group specified

    throws

    {InsufficientPrivilegesError}

    throws

    {OperationFailedError}

    Parameters

    • id: string

      string the user id

    • userGroupId: string

      string the user group id

    Returns Promise<void>

disableUser

  • disableUser(id: string): Promise<void>
  • disables the user

    throws

    {UserNotFoundError}

    Parameters

    • id: string

      string the user id

    Returns Promise<void>

enableUser

  • enableUser(id: string): Promise<void>
  • enables the user

    throws

    {UserNotFoundError}

    Parameters

    • id: string

      string the user id

    Returns Promise<void>

getAppInfos

  • getAppInfos(appName: string): Promise<object>

getApps

  • getApps(): Promise<string[]>

getContent

  • getContent(fileName: string): Promise<Buffer>
  • returns the content of a file

    Parameters

    • fileName: string

      name of the file /d1/file1.txt

    Returns Promise<Buffer>

    Buffer with file content

getFile

  • getFile(fileName: string): Promise<File | null>
  • returns a nextcloud file object

    Parameters

    • fileName: string

      the full file name /folder1/folder2/file.pdf

    Returns Promise<File | null>

getFileComments

  • getFileComments(fileId: number, top?: undefined | number, skip?: undefined | number): Promise<string[]>
  • returns comments of a file / folder

    throws

    Exception

    Parameters

    • fileId: number

      the id of the file / folder

    • Optional top: undefined | number

      number of comments to return

    • Optional skip: undefined | number

      the offset

    Returns Promise<string[]>

    array of comment strings

getFileId

  • getFileId(fileUrl: string): Promise<number>
  • returns the id of the file or -1 of not found

    Parameters

    • fileUrl: string

    Returns Promise<number>

    id of the file or -1 if not found

getFileSystemElementByTags

  • returns an array of file system objects that have all given tags assigned (AND)

    async

    Parameters

    • tags: Tag[]

      array of tags

    Returns Promise<FileSystemElement[]>

    returns an array of file system objects

getFiles

  • get files of a folder

    Parameters

    • folderName: string

      Name of the folder like "/company/branches/germany"

    • Optional options: FolderGetFilesOptions

      options for filtering and paging

    Returns Promise<File[]>

    array of file objects

getFolder

  • getFolder(folderName: string): Promise<Folder | null>
  • get a folder object from a path string

    Parameters

    • folderName: string

      Name of the folder like "/company/branches/germany"

    Returns Promise<Folder | null>

    null if the folder does not exist or an folder object

getFolderContents

  • getFolderContents(folderName: string): Promise<any[]>

getLink

  • getLink(fileName: string): string
  • returns the link to a file for downloading

    Parameters

    • fileName: string

      name of the file /folder1/folder1.txt

    Returns string

    url

getNotifications

  • getNotifications(): Promise<object[]>

getQuota

getRootFolder

getShare

  • getShare(shareId: string): Promise<any>
  • get share information

    Parameters

    • shareId: string

    Returns Promise<any>

getSubFolders

  • getSubFolders(folderName: string): Promise<Folder[]>
  • get a array of folders from a folder path string

    Parameters

    • folderName: string

      Name of the folder like "/company/branches/germany"

    Returns Promise<Folder[]>

    array of folder objects

getSystemBasicData

getSystemInfo

getTagById

  • getTagById(tagId: number): Promise<Tag | null>
  • returns a tag identified by the id or null if not found

    Parameters

    • tagId: number

      the id of the tag

    Returns Promise<Tag | null>

    tag or null

getTagByName

  • getTagByName(tagName: string): Promise<Tag | null>
  • returns a tag identified by the name or null if not found

    Parameters

    • tagName: string

      the name of the tag

    Returns Promise<Tag | null>

    tag or null

getTags

  • getTags(): Promise<Tag[]>

getTagsOfFile

  • getTagsOfFile(fileId: number): Promise<Map<string, number>>
  • returns the list of tag names and the tag ids

    Parameters

    • fileId: number

      the id of the file

    Returns Promise<Map<string, number>>

getUILink

  • getUILink(fileId: number): string
  • returns the url to the file in the nextcloud UI

    Parameters

    • fileId: number

      the id of the file

    Returns string

getUpdateNotifications

  • getUpdateNotifications(version: string): Promise<object>

getUser

  • getUser(id: string): Promise<User | null>
  • returns a user or null if not found

    Parameters

    • id: string

      string

    Returns Promise<User | null>

    User | null

getUserData

  • returns user data

    throws

    {UserNotFoundError}

    Parameters

    • id: string

      string the user id

    Returns Promise<IUserOptions>

    Promise user data

getUserGroup

  • getUserGroup(id: string): Promise<UserGroup | null>

getUserGroupIds

  • getUserGroupIds(search?: undefined | string, limit?: undefined | number, offset?: undefined | number): Promise<string[]>
  • returns a list of user groups

    throws

    QueryLimitError

    throws

    QueryOffsetError

    Parameters

    • Optional search: undefined | string

      string

    • Optional limit: undefined | number

      number

    • Optional offset: undefined | number

      number

    Returns Promise<string[]>

    list of user groups

getUserGroupMembers

  • getUserGroupMembers(id: string): Promise<string[]>
  • returns a list of user ids that are members of the user group

    throws

    [UserGroupDoesNotExistError}

    Parameters

    • id: string

      string

    Returns Promise<string[]>

    list of member user ids

getUserGroupSubadmins

  • getUserGroupSubadmins(id: string): Promise<string[]>
  • returns a list of user ids that are subadmins of the user group

    throws

    [UserGroupDoesNotExistError}

    Parameters

    • id: string

      string

    Returns Promise<string[]>

    list of subadmin user ids

getUserGroups

  • getUserGroups(search?: undefined | string, limit?: undefined | number, offset?: undefined | number): Promise<UserGroup[]>
  • returns a list of user groups

    throws

    QueryLimitError

    throws

    QueryOffsetError

    Parameters

    • Optional search: undefined | string

      string

    • Optional limit: undefined | number

      number

    • Optional offset: undefined | number

      number

    Returns Promise<UserGroup[]>

    list of user groups

getUsers

  • getUsers(search?: undefined | string, limit?: undefined | number, offset?: undefined | number): Promise<User[]>

moveFile

  • moveFile(sourceFileName: string, targetFileName: string): Promise<File>
  • renames the file or moves it to an other location

    Parameters

    • sourceFileName: string

      source file name

    • targetFileName: string

      target file name

    Returns Promise<File>

moveFolder

  • moveFolder(sourceFolderName: string, tarName: string): Promise<Folder>
  • renames the folder or moves it to an other location

    Parameters

    • sourceFolderName: string

      source folder name

    • tarName: string

      target folder name

    Returns Promise<Folder>

pipeContentStream

  • pipeContentStream(fileName: string, destination: WritableStream): Promise<void>
  • returns the content of a file

    Parameters

    • fileName: string

      name of the file /d1/file1.txt

    • destination: WritableStream

    Returns Promise<void>

    Buffer with file content

promoteUserToUserGroupSubadmin

  • promoteUserToUserGroupSubadmin(id: string, userGroupId: string): Promise<void>
  • promotes a user to a user group subadmin

    throws

    {UserNotFoundError}

    throws

    {UserGroupDoesNotExistError}

    throws

    {InsufficientPrivilegesError}

    throws

    {OperationFailedError}

    Parameters

    • id: string

      string the user id

    • userGroupId: string

      string the user group id

    Returns Promise<void>

removeTagOfFile

  • removeTagOfFile(fileId: number, tagId: number): Promise<void>
  • removes the tag from the file

    Parameters

    • fileId: number

      the file id

    • tagId: number

      the tag id

    Returns Promise<void>

removeUserFromMemberUserGroup

  • removeUserFromMemberUserGroup(id: string, userGroupId: string): Promise<void>
  • removes a user from a group as member

    throws

    {UserNotFoundError}

    throws

    {UserGroupDoesNotExistError}

    throws

    {InsufficientPrivilegesError}

    throws

    {OperationFailedError}

    Parameters

    • id: string

      string the user id

    • userGroupId: string

      string the user group id

    Returns Promise<void>

resendWelcomeEmail

  • resendWelcomeEmail(id: string): Promise<void>
  • resend the welcome email

    throws

    {UserResendWelcomeEmailError}

    Parameters

    • id: string

      user id

    Returns Promise<void>

sendNotificationToUser

  • sendNotificationToUser(userId: string, shortMessage: string, longMessage?: undefined | string): Promise<void>
  • Parameters

    • userId: string
    • shortMessage: string
    • Optional longMessage: undefined | string

    Returns Promise<void>

updateShare

  • updateShare(shareId: string, body: { password: string } | { expireDate: string } | { note: string }): Promise<void>
  • update a new share

    Parameters

    • shareId: string
    • body: { password: string } | { expireDate: string } | { note: string }

    Returns Promise<void>

updateUserProperty

  • updateUserProperty(id: string, property: UserProperty, value: string): Promise<void>
  • updates a user property

    async
    throws

    {UserNotFoundError}

    throws

    {UserUpdateError}

    Parameters

    • id: string

      user id

    • property: UserProperty

      property name

    • value: string

      property value

    Returns Promise<void>

upsertUsers

Generated using TypeDoc