FoldersModule

public class FoldersModule

Provides Folder management.

  • Get information about a folder.

    Declaration

    Swift

    public func get(
        folderId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder on which to retrieve information.

    fields

    Comma-separated list of fields to include in the response.

    completion

    Returns a full folder object or an error.

  • Gets all of the files, folders, or web links contained within a folder.

    Declaration

    Swift

    public func listItems(
        folderId: String,
        usemarker: Bool? = nil,
        marker: String? = nil,
        offset: Int? = nil,
        limit: Int? = nil,
        sort: FolderItemsOrderBy? = nil,
        direction: OrderDirection? = nil,
        fields: [String]? = nil
    ) -> PagingIterator<FolderItem>

    Parameters

    folderId

    The ID of the folder on which to retrieve information.

    usemarker

    This specifies whether you would like to use marker-based or offset-based paging. You can only use one or the other. Marker-based paging is the preferred method and is most performant. If not specified, this endpoint defaults to using offset-based paging. This parameter is unique to Get Folder Items to retain backwards compatibility for this endpoint. This parameter is required for both the first and subsequent calls to use marked-based paging.

    marker

    The position marker at which to begin the response. See marker-based paging for details. This parameter cannot be used simultaneously with the ‘offset’ parameter.

    offset

    The offset of the item at which to begin the response. See offset-based paging for details. This parameter cannot be used simultaneously with the ‘marker’ parameter.

    limit

    The maximum number of items to return. The default is 100 and the maximum is 1,000.

    sort

    This can be id, name, or date. This parameter is not yet supported for marker- based paging on folder 0.

    direction

    This can be ASC or DESC.

    fields

    Comma-separated list of fields to include in the response.

  • Create a new folder.

    Declaration

    Swift

    public func create(
        name: String,
        parentId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    name

    The desired name for the folder. Box supports folder names of 255 characters or less. Names containing non-printable ASCII characters, “/” or “\”, names with trailing spaces, and the special names “.” and “..” are also not allowed.

    parentId

    The ID of the parent folder.

    fields

    Comma-separated list of fields to include in the response.

    completion

    Returns a full folder object or an error if the parentId is invalid or if a name collision occurs.

  • Update a folder.

    Declaration

    Swift

    public func update(
        folderId: String,
        name: String? = nil,
        description: String? = nil,
        parentId: String? = nil,
        sharedLink: NullableParameter<SharedLinkData>? = nil,
        folderUploadEmailAccess: FolderUploadEmailAccess? = nil,
        tags: [String]? = nil,
        canNonOwnersInvite: Bool? = nil,
        isCollaborationRestrictedToEnterprise: Bool? = nil,
        collections: [String]? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the file to update

    name

    The name of the folder.

    description

    The description of the folder.

    parentId

    The ID of the parent folder

    sharedLink

    Shared links provide direct, read-only access to folder on Box using a URL.

    folderUploadEmailAccess

    Can be open or collaborators

    tags

    Array of tags to be added or replaced to the folder

    canNonOwnersInvite

    If this parameter is set to false, only folder owners and co-owners can send collaborator invites

    isCollaborationRestrictedToEnterprise

    Whether to restrict future collaborations to within the enterprise. Does not affect existing collaborations.

    fields

    Comma-separated list of fields to include in the response.

    completion

    The updated folder is returned if the name is valid. Errors generally occur only if there is a name collision.

  • Delete a folder or move a folder to the trash. The recursive parameter must be included in order to delete folders that aren’t empty. Depending on the enterprise settings for this user, the item will either be actually deleted from Box or moved to the trash.

    Declaration

    Swift

    public func delete(
        folderId: String,
        recursive: Bool? = nil,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderId

    The ID of the file to delete.

    recursive

    Whether to delete this folder if it has items inside of it.

    completion

    An empty response will be returned upon successful deletion. An error is thrown if the folder is not empty and the ‘recursive’ parameter is not included.

  • Used to create a copy of a folder in another folder. The original version of the folder will not be altered.

    Declaration

    Swift

    public func copy(
        folderId: String,
        destinationFolderID: String,
        name: String? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder that will be copy.

    destinationFolderID

    The ID of the destination folder

    name

    An optional new name for the folder

    fields

    Comma-separated list of fields to include in the response.

    completion

    Returns a full folder object or an error if the parentId is invalid or if a name collision occurs.

  • Use this to get a list of all the collaborations on a folder i.e. all of the users that have access to that folder.

    Declaration

    Swift

    public func listCollaborations(
        folderId: String,
        fields: [String]? = nil
    ) -> PagingIterator<Collaboration>

    Parameters

    folderId

    The ID of the folder on which to retrieve collaborations.

    fields

    Comma-separated list of fields to include in the response.

  • Add folder to favorites

    Declaration

    Swift

    public func addToFavorites(
        folderId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    fields

    Comma-separated list of folder fields to include in the response.

    completion

    Returns the updated folder or an error

  • Add folder to particular collection

    Declaration

    Swift

    public func addToCollection(
        folderId: String,
        collectionId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    collectionId

    The ID of the collection

    fields

    Comma-separated list of folder fields to include in the response.

    completion

    Returns the updated folder or an error

  • Remove folder from favorites

    Declaration

    Swift

    public func removeFromFavorites(
        folderId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    fields

    Comma-separated list of folder fields to include in the response.

    completion

    Returns the updated folder or an error

  • Remove folder from particular collection

    Declaration

    Swift

    public func removeFromCollection(
        folderId: String,
        collectionId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    collectionId

    The ID of the collection

    fields

    Comma-separated list of folder fields to include in the response.

    completion

    Returns the updated folder or an error

  • Gets folder with updated shared link

    Declaration

    Swift

    public func getSharedLink(
        forFolder folderId: String,
        completion: @escaping Callback<SharedLink>
    )

    Parameters

    folderId

    The ID of the folder

    completion

    Returns a standard SharedLink object or an error

  • Creates or updates shared link for a folder

    Declaration

    Swift

    public func setSharedLink(
        forFolder folderId: String,
        access: SharedLinkAccess? = nil,
        unsharedAt: NullableParameter<Date>? = nil,
        vanityName: NullableParameter<String>? = nil,
        password: NullableParameter<String>? = nil,
        canDownload: Bool? = nil,
        completion: @escaping Callback<SharedLink>
    )

    Parameters

    folderId

    The ID of the folder

    access

    The level of access. If you omit this field then the access level will be set to the default access level specified by the enterprise admin

    unsharedAt

    The date-time that this link will become disabled. This field can only be set by users with paid accounts

    vanityName

    The custom name of a shared link, as used in the vanityUrl field. It should be between 12 and 30 characters. This field can contains only letters, numbers, and hyphens.

    password

    The password required to access the shared link. Set to .null to remove the password

    canDownload

    Whether the shared link allows downloads. Applies to any items in the folder

    completion

    Returns a standard SharedLink object or an error

  • Removes shared link for a folder

    Declaration

    Swift

    public func deleteSharedLink(
        forFolder folderId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderId

    The ID of the folder

    completion

    Returns an empty response or an error

  • Retrieves the watermark on a specified folder.

    Declaration

    Swift

    public func getWatermark(
        folderId: String,
        completion: @escaping Callback<Watermark>
    )

    Parameters

    folderId

    The id of the folder to retrieve the watermark from.

    completion

    Returns a watermark object or an error.

  • Apply or update the watermark on a specified folder.

    Declaration

    Swift

    public func applyWatermark(
        folderId: String,
        completion: @escaping Callback<Watermark>
    )

    Parameters

    folderId

    The id of the folder to update the watermark for.

    completion

    Returns a watermark object or an error.

  • Remove the watermark from a specified folder.

    Declaration

    Swift

    public func removeWatermark(
        folderId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderId

    The id of the folder to remove the watermark from.

    completion

    Returns an empty response or an error.

  • Get all of the locks on a folder.

    Declaration

    Swift

    public func listLocks(
        folderId: String
    ) -> PagingIterator<FolderLock>

    Parameters

    folderId

    The ID of the folder on which to retrieve folder locks.

    completion

    Returns all of the locks on the folder, or an error if the request is unsuccessful.

  • Creates a folder lock on a folder, preventing it from being moved and/or deleted.

    Declaration

    Swift

    public func createLock(
        folderId: String,
        completion: @escaping Callback<FolderLock>
    )

    Parameters

    folderId

    The ID of the folder to apply the lock to.

    completion

    Returns a folder lock object or an error if the request is unsuccessful.

  • Remove the specified folder lock.

    Declaration

    Swift

    public func deleteLock(
        folderLockId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderLockId

    The id of the folder lock to remove.

    completion

    Returns an empty response or an error.

  • get(folderId:fields:) Asynchronous

    Get information about a folder.

    Throws

    BoxSDKError if the parentId is invalid or if a name collision occurs.

    Declaration

    Swift

    func get(
        folderId: String,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the folder on which to retrieve information.

    fields

    Comma-separated list of fields to include in the response.

    Return Value

    Folder object

  • Create a new folder.

    Throws

    A BoxSDKError if the parentId is invalid or if a name collision occurs.

    Declaration

    Swift

    func create(
        name: String,
        parentId: String,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    name

    The desired name for the folder. Box supports folder names of 255 characters or less. Names containing non-printable ASCII characters, “/” or “\”, names with trailing spaces, and the special names “.” and “..” are also not allowed.

    parentId

    The ID of the parent folder.

    fields

    Comma-separated list of fields to include in the response.

    Return Value

    A full folder object.

  • Update a folder.

    Throws

    A BoxSDKError if the parentId is invalid or if a name collision occurs.

    Declaration

    Swift

    func update(
        folderId: String,
        name: String? = nil,
        description: String? = nil,
        parentId: String? = nil,
        sharedLink: NullableParameter<SharedLinkData>? = nil,
        folderUploadEmailAccess: FolderUploadEmailAccess? = nil,
        tags: [String]? = nil,
        canNonOwnersInvite: Bool? = nil,
        isCollaborationRestrictedToEnterprise: Bool? = nil,
        collections: [String]? = nil,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the file to update

    name

    The name of the folder.

    description

    The description of the folder.

    parentId

    The ID of the parent folder

    sharedLink

    Shared links provide direct, read-only access to folder on Box using a URL.

    folderUploadEmailAccess

    Can be open or collaborators

    tags

    Array of tags to be added or replaced to the folder

    canNonOwnersInvite

    If this parameter is set to false, only folder owners and co-owners can send collaborator invites

    isCollaborationRestrictedToEnterprise

    Whether to restrict future collaborations to within the enterprise. Does not affect existing collaborations.

    fields

    Comma-separated list of fields to include in the response.

    Return Value

    The updated folder is returned if the name is valid.

  • Delete a folder or move a folder to the trash. The recursive parameter must be included in order to delete folders that aren’t empty. Depending on the enterprise settings for this user, the item will either be actually deleted from Box or moved to the trash.

    Throws

    A BoxSDKError if the folder is not empty and the ‘recursive’ parameter is not included.

    Declaration

    Swift

    func delete(folderId: String, recursive: Bool? = nil) async throws

    Parameters

    folderId

    The ID of the file to delete.

    recursive

    Whether to delete this folder if it has items inside of it.

    Return Value

    An empty response will be returned upon successful deletion.

  • Create a copy of a folder in another folder. The original version of the folder will not be altered.

    Throws

    A BoxSDKError if a name collision occurs.

    Declaration

    Swift

    func copy(
        folderId: String,
        destinationFolderId: String,
        name: String? = nil,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the folder that will be copy.

    destinationFolderId

    The ID of the destination folder

    name

    An optional new name for the folder

    fields

    Comma-separated list of fields to include in the response.

    Return Value

    The full folder object.

  • Add folder to favorites

    Throws

    BoxSDKError.

    Declaration

    Swift

    func addToFavorites(
        folderId: String,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the folder

    fields

    Comma-separated list of folder fields to include in the response.

    Return Value

    The updated folder.

  • Add folder to particular collection

    Throws

    BoxSDKError

    Declaration

    Swift

    func addToCollection(
        folderId: String,
        collectionId: String,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the folder

    fields

    Comma-separated list of folder fields to include in the response.

    Return Value

    The updated folder or an error

  • Remove folder from favorites

    Throws

    BoxSDKError

    Declaration

    Swift

    func removeFromFavorites(
        folderId: String,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the folder

    fields

    Comma-separated list of folder fields to include in the response.

    Return Value

    The updated folder or an error

  • Remove folder from particular collection

    Throws

    BoxSDKError

    Declaration

    Swift

    func removeFromCollection(
        folderId: String,
        collectionId: String,
        fields: [String]? = nil
    ) async throws -> Folder

    Parameters

    folderId

    The ID of the folder

    collectionId

    The ID of the collection

    fields

    Comma-separated list of folder fields to include in the response.

    Return Value

    The updated folder

  • Gets folder with updated shared link

    Throws

    BoxSDKError

    Declaration

    Swift

    func getSharedLink(forFolder folderId: String) async throws -> SharedLink

    Parameters

    folderId

    The ID of the folder

    Return Value

    The SharedLink object

  • Creates or updates shared link for a folder

    Throws

    BoxSDKError

    Declaration

    Swift

    func setSharedLink(
        forFolder folderId: String,
        access: SharedLinkAccess? = nil,
        unsharedAt: NullableParameter<Date>? = nil,
        vanityName: NullableParameter<String>? = nil,
        password: NullableParameter<String>? = nil,
        canDownload: Bool? = nil
    ) async throws -> SharedLink

    Parameters

    folderId

    The ID of the folder

    access

    The level of access. If you omit this field then the access level will be set to the default access level specified by the enterprise admin

    unsharedAt

    The date-time that this link will become disabled. This field can only be set by users with paid accounts

    vanityName

    The custom name of a shared link, as used in the vanityUrl field. It should be between 12 and 30 characters. This field can contains only letters, numbers, and hyphens.

    password

    The password required to access the shared link. Set to .null to remove the password

    canDownload

    Whether the shared link allows downloads. Applies to any items in the folder

    Return Value

    The SharedLink object

  • Removes shared link for a folder

    Throws

    BoxSDKError

    Declaration

    Swift

    func deleteSharedLink(forFolder folderId: String) async throws

    Parameters

    folderId

    The ID of the folder

  • Retrieves the watermark on a specified folder.

    Throws

    BoxSDKError

    Declaration

    Swift

    func getWatermark(folderId: String) async throws -> Watermark

    Parameters

    folderId

    The id of the folder to retrieve the watermark from.

    Return Value

    The Watermark object.

  • Apply or update the watermark on a specified folder.

    Throws

    BoxSDKError

    Declaration

    Swift

    func applyWatermark(folderId: String) async throws -> Watermark

    Parameters

    folderId

    The id of the folder to update the watermark for.

    Return Value

    The Watermark object.

  • Remove the watermark from a specified folder.

    Throws

    BoxSDKError

    Declaration

    Swift

    func removeWatermark(folderId: String) async throws

    Parameters

    folderId

    The id of the folder to remove the watermark from.

  • createLock(folderId:) Asynchronous

    Creates a folder lock on a folder, preventing it from being moved and/or deleted.

    Throws

    BoxSDKError

    Declaration

    Swift

    func createLock(folderId: String) async throws -> FolderLock

    Parameters

    folderId

    The ID of the folder to apply the lock to.

    Return Value

    The Folder lock object

  • Remove the specified folder lock.

    Throws

    BoxSDKError

    Declaration

    Swift

    func deleteLock(folderLockId: String) async throws

    Parameters

    folderLockId

    The id of the folder lock to remove.