| Files | R Documentation |
R6 Class representing Files resource.
sevenbridges2::Resource -> Files
URLList of URL endpoints for this resource.
new()Create new Files resource object.
Files$new(...)
...Other response arguments.
query()This call returns a list of files and subdirectories in a
specified project or directory within a project, with specified
properties that you can access. The project or directory whose contents
you want to list is specified as a query parameter in the call. Further
properties to filter by can also be specified as query parameters.
Note that this call lists both files and subdirectories in the
specified project or directory within a project, but not the contents
of the subdirectories.
To list the contents of a subdirectory, make a new call
and specify the subdirectory ID as the parent parameter.
For more details, see our
API documentation.
Files$query(
project = NULL,
parent = NULL,
name = NULL,
metadata = NULL,
origin = NULL,
tag = NULL,
limit = getOption("sevenbridges2")$limit,
offset = getOption("sevenbridges2")$offset,
...
)projectProject identifier (ID) as string or a Project object. Project should not be used together with parent. If parent is used, the call will list the content of the specified folder, within the project to which the folder belongs. If project is used, the call will list the content at the root of the project's files.
parentThe parent folder identifier as string or a File object
which must be of type FOLDER.
Should not be used together with project.
If parent is used, the call will list the content of the specified
folder, within the project to which the folder belongs.
If project is used, the call will list the content at the root of
the project's files.
nameName of the file. List files with this name. Note that the name must be an exact complete string for the results to match. Multiple names can be represented as a vector.
metadataList file with this metadata field values. List only files that have the specified value in metadata field. Different metadata fields are represented as a named list. You can also define multiple instances of the same metadata field.
originTask object. List only files produced by task.
tagFilters the files based on the specified tag(s). Each tag must be an exact, complete match, for the results to match. Tags may include spaces. Multiple tags should be provided as a vector of strings. The method will return files that have any of the specified tags.
limitThe maximum number of collection items to return
for a single request. Minimum value is 1.
The maximum value is 100 and the default value is 50.
This is a pagination-specific attribute.
offsetThe zero-based starting index in the entire collection
of the first item to return. The default value is 0.
This is a pagination-specific attribute.
...Other arguments that can be passed to core api() function
as 'fields', etc.
Collection of File objects.
\dontrun{
files_object <- Files$new(auth = auth)
# Query files in a project
files_object$query(project = project)
}
get()This call returns a single File object with its details. The call returns the file's name, its tags, and all of its metadata. Files are specified by their IDs, which you can obtain by making the API call to list all files in a project.
Files$get(id, ...)
idThe file ID.
...Other arguments that can be passed to core api() function
as 'fields', etc.
File object.
\dontrun{
files_object <- Files$new(auth = auth)
# Get file using id
files_object$get(id = id)
}
delete()This call removes a file from the Seven Bridges Platform.
Files are specified by their IDs, which you can obtain by using
Files$query() to list files or by getting a single file
using Files$get().
Files$delete(file, ...)
fileFile object or file ID.
...Other arguments that can be passed to core api() function
as 'fields', etc.
\dontrun{
files_object <- Files$new(auth = auth)
# Delete a file
files_object$delete(file = file)
}
copy()Copy file/files to the specified project. This call allows
you to copy files between projects. Unlike the call to copy a file
between projects, this call lets you batch the copy operation and copy
a list of files at a time.
More information can be found here
here.
Files$copy(files, destination_project)
filesThe list of files' IDs or list of File object to copy.
destination_projectProject object or project ID. where you want to copy files into.
\dontrun{
files_object <- Files$new(auth = auth)
# Copy files to a project
files_object$copy(
file = file,
destination_project = project
)
}
create_folder()A method for creating a new folder. It allows you to create
a new folder on the Platform within the root folder of a specified
project or the provided parent folder. Remember that you should provide
either the destination project (as the project parameter) or the
destination folder (as the parent parameter), not both.
More information you may find
here.
Files$create_folder(name, parent = NULL, project = NULL)
nameThe name of the folder you are about to create.
parentThe ID of the parent destination folder or a File
object which must be of type FOLDER.
projectThe ID of the destination project, or a Project object.
\dontrun{
files_object <- Files$new(auth = auth)
# Create folder in a project
files_object$create_folder(
name = name,
project = project
)
}
bulk_delete()This method facilitates bulk file deletion. It accepts
either a list of File objects or a list containing
files' IDs.
Files$bulk_delete(files)
filesEither a list of File objects or a list
of strings (IDs) representing the files you intend to delete.
None. The function only displays the IDs of the deleted files in the console.
\dontrun{
# Delete two files by providing their IDs
a$files$bulk_delete(files = list("file_1_ID", "file_2_ID"))
}
\dontrun{
# Delete two files by providing a list of File objects
a$files$bulk_delete(files = list(File_Object_1, File_Object_2))
}
bulk_get()This call returns the details of multiple specified files, including file names and file metadata. The maximum number of files you can retrieve the details for per call is 100.
Files$bulk_get(files)
filesA list of File objects or list of strings
(IDs) of the files you are querying for details.
Collection (list of File objects).
\dontrun{
# Get details of multiple files
a$files$bulk_get(
files = list("file_1_ID", "file_2_ID")
)
}
bulk_update()A method that sets new information for specified files, replacing all existing information and erasing omitted parameters.
Files$bulk_update(files)
filesList of File objects.
For each of the specified files, the call sets a new name,
new tags, and metadata.
When editing fields in the File objects you wish to
update, keep the following in mind:
The name field should be a string representing the new name of
the file.
The metadata field should be a named list of key-value pairs.
The keys and values should be strings.
The tags field should be an unnamed list of values.
The maximum number of files you can update the details for per call is 100.
Collection (list of File objects).
\dontrun{
# Update details of multiple files
a$files$bulk_update(
files = list(File_Object_1, File_Object_2)
)
}
bulk_edit()This method modifies the existing information for specified files or adds new information while preserving omitted parameters.
Files$bulk_edit(files)
filesList of File objects.
For each of the specified files, the call edits its name,
tags, and metadata.
When editing fields in the File objects you wish to
update, keep the following in mind:
The name field should be a string representing the new name of
the file.
The metadata field should be a named list of key-value pairs.
The keys and values should be strings.
The tags field should be an unnamed list of values.
The maximum number of files you can update the details for per call is 100.
Collection (list of File objects).
\dontrun{
# Edit details of multiple files
a$files$bulk_edit(
files = list(File_Object_1, File_Object_2)
)
}
async_bulk_copy()This call lets you perform a bulk copy of files and folders. Any underlying folder structure will be preserved. You can copy:
to a folder within the same project,
to another project,
to a folder in another project.
Files$async_bulk_copy(items)
itemsNested list of elements containing information about each file/folder to be copied. For each element, you must provide:
file - The ID of the file or folder you are copying.
Copying the project root folder is not allowed.
Use the API call for listing all files to obtain the ID.
parent - The ID of the folder you are copying files to.
It should not be used together with project. If project is
used, the items will be imported to the root of the project
files. If parent is used, the import will take place into the
specified folder, within the project to which the folder belongs.
project - The project you are copying the file to.
It should not be used together with parent. If parent is
used, the import will take place into the specified folder,
within the project to which the folder belongs. If project is
used, the items will be imported to the root of the project
files.
name - Enter the new name for the file if you want to
rename it in the destination folder.
Example of the list:
items <- list(
list(
file = '<file-id-1>',
parent = '<folder-id>'
),
list(
file = '<file-id-2>',
project = '<project-id-1>',
name = 'copied_file.txt'
),
list(
file = '<file-id-3>',
parent = '<parent-id-2>',
name = 'copied_file2.txt'
)
)
Read more on how to perform async copy action on multiple files.
AsyncJob object.
\dontrun{
# Copy multiple files
a$files$async_bulk_copy(
items = list(
list(
file = '<file-id-1>',
parent = '<folder-id>'
),
list(
file = '<file-id-2>',
project = '<project-id-1>',
name = 'copied_file.txt'
),
list(
file = '<file-id-3>',
parent = '<parent-id-2>',
name = 'copied_file2.txt'
)
)
)
}
async_bulk_delete()This call lets you perform an asynchronous bulk deletion of files or folders. Deleting folders which aren't empty is allowed.
Files$async_bulk_delete(items)
itemsList of File objects (both file or folder type) or list
of IDs of files/folders you want to delete.
Read more on how to perform async delete action on multiple files.
AsyncJob object.
\dontrun{
# Delete multiple files
a$files$async_bulk_delete(
items = list(file_obj1, file_obj2, "<folder-id-string>", "<file-id>")
)
}
async_bulk_move()This call lets you perform a bulk move operation of files and folders. You can move:
to a root project folder,
to a subfolder within the same project or a different project.
Files$async_bulk_move(items)
itemsNested list of elements containing information about each file/folder to be moved. For each element, you must provide:
file - The ID of the file or folder you are moving. Use the
API call for listing all files or folders to obtain the ID.
parent - The ID of the folder you are moving the files to,
which should not be used along with project. If project is
used, the items will be imported to the root of the project files.
If parent is used, the import will take place into the
specified folder, within the project to which the folder belongs.
project - The project you are moving the files to. It
should not be used together with parent. If parent is used,
the import will take place into the specified folder, within the
project to which the folder belongs. If project is used, the
items will be imported to the root of the project files.
name - Enter the new name for the file or folder if you
want to rename at the destination.
Example of the list:
items <- list(
list(
file = '<file-id-1>',
parent = '<folder-id>'
),
list(
file = '<file-id-2>',
project = '<project-id-1>',
name = 'moved_file.txt'
),
list(
file = '<file-id-3>',
parent = '<parent-id-2>',
name = 'moved_file2.txt'
)
)
Read more on how to perform async move action on multiple files.
Rules for moving files and folders:
The file ID is preserved after the move.
The folder ID is changed after the move.
The destination must be an existing folder.
If the target folder contains a folder with the same name, the contents of both folders will be merged.
If a file with the same name already exists, the source file will be automatically renamed (by adding a numeric prefix).
You need to have WRITE permissions for both source and destination folders.
AsyncJob object.
\dontrun{
# Move multiple files
a$files$async_bulk_move(
items = list(
list(
file = '<file-id-1>',
parent = '<folder-id>'
),
list(
file = '<file-id-2>',
project = '<project-id-1>',
name = 'moved_file.txt'
),
list(
file = '<file-id-3>',
parent = '<parent-id-2>',
name = 'moved_file2.txt'
)
)
)
}
async_get_copy_job()This call retrieves the details of an asynchronous bulk copy job. This information will be available for up to a month after the job has been completed.
Files$async_get_copy_job(job_id)
job_idThe ID of the copy job you are querying. This ID can be found within the API response for the call for copying files. The function also accepts an AsyncJob object and extracts the ID.
AsyncJob object.
\dontrun{
# Get details of an async copy job
a$files$async_get_copy_job(job_id = "job-id")
}
async_get_delete_job()This call retrieves the details of an asynchronous bulk deletion job. This information will be available for up to a month after the job has been completed.
Files$async_get_delete_job(job_id)
job_idThe ID of the delete job you are querying. This ID can be found within the API response for the call for deleting files. The function also accepts an AsyncJob object and extracts the ID.
AsyncJob object.
\dontrun{
# Get details of an async delete job
a$files$async_get_delete_job(job_id = "job-id")
}
async_get_move_job()This call retrieves the details of an asynchronous bulk move job. This information will be available for up to a month after the job has been completed.
Files$async_get_move_job(job_id)
job_idThe ID of the move job you are querying. This ID can be found within the API response for the call for moving files. The function also accepts an AsyncJob object and extracts the ID.
An AsyncJob object containing details of the move
job.
\dontrun{
# Get details of an async move job
a$files$async_get_move_job(job_id = "job-id")
}
async_list_file_jobs()This call retrieves the details for all asynchronous bulk jobs you have started. This information will be available for up to a month after the job has been completed.
Files$async_list_file_jobs(
limit = getOption("sevenbridges2")$limit,
offset = getOption("sevenbridges2")$offset
)limitThe maximum number of collection items to return
for a single request. Minimum value is 1.
The maximum value is 100 and the default value is 50.
This is a pagination-specific attribute.
offsetThe zero-based starting index in the entire collection
of the first item to return. The default value is 0.
This is a pagination-specific attribute.
A Collection object containing a list of
AsyncJob objects.
\dontrun{
# Get details of the first 5 async jobs
a$files$async_list_file_jobs(limit = 5)
}
clone()The objects of this class are cloneable with this method.
Files$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `Files$query`
## ------------------------------------------------
## Not run:
files_object <- Files$new(auth = auth)
# Query files in a project
files_object$query(project = project)
## End(Not run)
## ------------------------------------------------
## Method `Files$get`
## ------------------------------------------------
## Not run:
files_object <- Files$new(auth = auth)
# Get file using id
files_object$get(id = id)
## End(Not run)
## ------------------------------------------------
## Method `Files$delete`
## ------------------------------------------------
## Not run:
files_object <- Files$new(auth = auth)
# Delete a file
files_object$delete(file = file)
## End(Not run)
## ------------------------------------------------
## Method `Files$copy`
## ------------------------------------------------
## Not run:
files_object <- Files$new(auth = auth)
# Copy files to a project
files_object$copy(
file = file,
destination_project = project
)
## End(Not run)
## ------------------------------------------------
## Method `Files$create_folder`
## ------------------------------------------------
## Not run:
files_object <- Files$new(auth = auth)
# Create folder in a project
files_object$create_folder(
name = name,
project = project
)
## End(Not run)
## ------------------------------------------------
## Method `Files$bulk_delete`
## ------------------------------------------------
## Not run:
# Delete two files by providing their IDs
a$files$bulk_delete(files = list("file_1_ID", "file_2_ID"))
## End(Not run)
## Not run:
# Delete two files by providing a list of File objects
a$files$bulk_delete(files = list(File_Object_1, File_Object_2))
## End(Not run)
## ------------------------------------------------
## Method `Files$bulk_get`
## ------------------------------------------------
## Not run:
# Get details of multiple files
a$files$bulk_get(
files = list("file_1_ID", "file_2_ID")
)
## End(Not run)
## ------------------------------------------------
## Method `Files$bulk_update`
## ------------------------------------------------
## Not run:
# Update details of multiple files
a$files$bulk_update(
files = list(File_Object_1, File_Object_2)
)
## End(Not run)
## ------------------------------------------------
## Method `Files$bulk_edit`
## ------------------------------------------------
## Not run:
# Edit details of multiple files
a$files$bulk_edit(
files = list(File_Object_1, File_Object_2)
)
## End(Not run)
## ------------------------------------------------
## Method `Files$async_bulk_copy`
## ------------------------------------------------
## Not run:
# Copy multiple files
a$files$async_bulk_copy(
items = list(
list(
file = '<file-id-1>',
parent = '<folder-id>'
),
list(
file = '<file-id-2>',
project = '<project-id-1>',
name = 'copied_file.txt'
),
list(
file = '<file-id-3>',
parent = '<parent-id-2>',
name = 'copied_file2.txt'
)
)
)
## End(Not run)
## ------------------------------------------------
## Method `Files$async_bulk_delete`
## ------------------------------------------------
## Not run:
# Delete multiple files
a$files$async_bulk_delete(
items = list(file_obj1, file_obj2, "<folder-id-string>", "<file-id>")
)
## End(Not run)
## ------------------------------------------------
## Method `Files$async_bulk_move`
## ------------------------------------------------
## Not run:
# Move multiple files
a$files$async_bulk_move(
items = list(
list(
file = '<file-id-1>',
parent = '<folder-id>'
),
list(
file = '<file-id-2>',
project = '<project-id-1>',
name = 'moved_file.txt'
),
list(
file = '<file-id-3>',
parent = '<parent-id-2>',
name = 'moved_file2.txt'
)
)
)
## End(Not run)
## ------------------------------------------------
## Method `Files$async_get_copy_job`
## ------------------------------------------------
## Not run:
# Get details of an async copy job
a$files$async_get_copy_job(job_id = "job-id")
## End(Not run)
## ------------------------------------------------
## Method `Files$async_get_delete_job`
## ------------------------------------------------
## Not run:
# Get details of an async delete job
a$files$async_get_delete_job(job_id = "job-id")
## End(Not run)
## ------------------------------------------------
## Method `Files$async_get_move_job`
## ------------------------------------------------
## Not run:
# Get details of an async move job
a$files$async_get_move_job(job_id = "job-id")
## End(Not run)
## ------------------------------------------------
## Method `Files$async_list_file_jobs`
## ------------------------------------------------
## Not run:
# Get details of the first 5 async jobs
a$files$async_list_file_jobs(limit = 5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.