public class InMemoryGoogleCloudStorage extends Object implements GoogleCloudStorage
GoogleCloudStorage.ListPage<T>MAX_COMPOSE_OBJECTS, MAX_RESULTS_UNLIMITED, PATH_DELIMITER| Constructor and Description |
|---|
InMemoryGoogleCloudStorage() |
InMemoryGoogleCloudStorage(GoogleCloudStorageOptions storageOptions) |
InMemoryGoogleCloudStorage(GoogleCloudStorageOptions storageOptions,
com.google.api.client.util.Clock clock) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases resources used by this instance.
|
void |
compose(String bucketName,
List<String> sources,
String destination,
String contentType)
Composes inputs into a single GCS object.
|
GoogleCloudStorageItemInfo |
composeObjects(List<StorageResourceId> sources,
StorageResourceId destination,
CreateObjectOptions options)
Composes inputs into a single GCS object.
|
void |
copy(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames)
Copies metadata of the given objects.
|
WritableByteChannel |
create(StorageResourceId resourceId,
CreateObjectOptions options)
Creates and opens an object for writing.
|
void |
createBucket(String bucketName,
CreateBucketOptions options)
Creates a bucket.
|
void |
createEmptyObject(StorageResourceId resourceId)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObject(StorageResourceId resourceId,
CreateObjectOptions options)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObjects(List<StorageResourceId> resourceIds)
Creates a list of empty objects; see
GoogleCloudStorage.createEmptyObject(StorageResourceId) for the
single-item version of this method. |
void |
createEmptyObjects(List<StorageResourceId> resourceIds,
CreateObjectOptions options)
Creates a list of empty objects; see
GoogleCloudStorage.createEmptyObject(StorageResourceId) for the
single-item version of this method. |
void |
deleteBuckets(List<String> bucketNames)
Deletes a list of buckets.
|
void |
deleteFolders(List<FolderInfo> folders)
Deletes the given folder resources.
|
void |
deleteObjects(List<StorageResourceId> fullObjectNames)
Deletes the given objects.
|
static GoogleCloudStorageOptions |
getInMemoryGoogleCloudStorageOptions() |
GoogleCloudStorageItemInfo |
getItemInfo(StorageResourceId resourceId)
Gets information about an object or a bucket.
|
List<GoogleCloudStorageItemInfo> |
getItemInfos(List<StorageResourceId> resourceIds)
Gets information about multiple objects and/or buckets.
|
GoogleCloudStorageOptions |
getOptions()
Retrieve the options that were used to create this GoogleCloudStorage.
|
boolean |
isHnBucket(URI src)
Checks if
resourceId belongs to a Hierarchical namespace enabled bucket. |
List<GoogleCloudStorageItemInfo> |
listBucketInfo()
Gets a list of GoogleCloudStorageItemInfo for all buckets of this project.
|
List<String> |
listBucketNames()
Gets a list of names of buckets in this project.
|
GoogleCloudStorage.ListPage<FolderInfo> |
listFolderInfoForPrefixPage(String bucketName,
String objectNamePrefix,
ListFolderOptions listFolderOptions,
String pageToken)
Returns the list of folder resources.
|
List<GoogleCloudStorageItemInfo> |
listObjectInfo(String bucketName,
String objectNamePrefix,
ListObjectOptions listOptions)
Lists
GoogleCloudStorageItemInfo of objects contained in the given bucket and whose
names begin with the given prefix. |
GoogleCloudStorage.ListPage<GoogleCloudStorageItemInfo> |
listObjectInfoPage(String bucketName,
String objectNamePrefix,
ListObjectOptions listOptions,
String pageToken)
The same semantics as
GoogleCloudStorage.listObjectInfo(java.lang.String, java.lang.String), but returns only result of single list request
(1 page). |
SeekableByteChannel |
open(StorageResourceId resourceId,
GoogleCloudStorageReadOptions readOptions)
Opens an object for reading.
|
void |
renameHnFolder(URI src,
URI dst)
Renames
src to dst using the rename LRO API. |
List<GoogleCloudStorageItemInfo> |
updateItems(List<UpdatableItemInfo> itemInfoList)
Attempt to update metadata of the objects referenced within the passed itemInfo objects.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcopy, create, createBucket, listObjectInfo, listObjectInfoPage, openpublic InMemoryGoogleCloudStorage()
public InMemoryGoogleCloudStorage(GoogleCloudStorageOptions storageOptions)
public InMemoryGoogleCloudStorage(GoogleCloudStorageOptions storageOptions, com.google.api.client.util.Clock clock)
public static GoogleCloudStorageOptions getInMemoryGoogleCloudStorageOptions()
public GoogleCloudStorageOptions getOptions()
GoogleCloudStoragegetOptions in interface GoogleCloudStoragepublic WritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStorageresourceId
contains a known generationId or a generationId of 0, it is used instead of any "overwrite"
settings in the provided CreateObjectOptions (overwrite will only succeed if the
provided generationId matches the existing object, where a generationId of 0 indicates no
existing object expected).create in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - Options to use when creating the objectIOException - on IO errorpublic void createBucket(String bucketName, CreateBucketOptions options) throws IOException
GoogleCloudStoragecreateBucket in interface GoogleCloudStoragebucketName - name of the bucket to createoptions - options to use when creating bucketIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId) throws IOException
GoogleCloudStorageGoogleCloudStorage.create(StorageResourceId) for the behavior if StorageResourceId.getGenerationId() is
explicitly set.createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStorageGoogleCloudStorage.create(StorageResourceId) for the behavior if StorageResourceId.getGenerationId() is
explicitly set.createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - options to use when creating the objectIOException - on IO errorpublic void createEmptyObjects(List<StorageResourceId> resourceIds) throws IOException
GoogleCloudStorageGoogleCloudStorage.createEmptyObject(StorageResourceId) for the
single-item version of this method. Implementations may use different flow than the single-item
version for greater efficiency. See GoogleCloudStorage.create(StorageResourceId) for the behavior if
StorageResourceId.getGenerationId() is explicitly set.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic void createEmptyObjects(List<StorageResourceId> resourceIds, CreateObjectOptions options) throws IOException
GoogleCloudStorageGoogleCloudStorage.createEmptyObject(StorageResourceId) for the
single-item version of this method. Implementations may use different flow than the single-item
version for greater efficiency. See GoogleCloudStorage.create(StorageResourceId) for the behavior if
StorageResourceId.getGenerationId() is explicitly set.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic SeekableByteChannel open(StorageResourceId resourceId, GoogleCloudStorageReadOptions readOptions) throws IOException
GoogleCloudStorageopen in interface GoogleCloudStorageresourceId - identifies a StorageObjectreadOptions - Fine-grained options for behaviors of retries, buffering, etc.FileNotFoundException - if the given object does not existIOException - if object exists but cannot be openedpublic void deleteBuckets(List<String> bucketNames) throws IOException
GoogleCloudStoragedeleteBuckets in interface GoogleCloudStoragebucketNames - name of the buckets to deleteFileNotFoundException - if the given bucket does not existIOException - on IO errorpublic void deleteObjects(List<StorageResourceId> fullObjectNames) throws IOException
GoogleCloudStoragedeleteObjects in interface GoogleCloudStoragefullObjectNames - names of objects to delete with their respective bucketNames.FileNotFoundException - if the given object does not existIOException - if object exists but cannot be deletedpublic void deleteFolders(List<FolderInfo> folders) throws IOException
GoogleCloudStoragedeleteFolders in interface GoogleCloudStoragefolders - names of folder resources to deleteIOException - if folder exists but cannot be deletedpublic void copy(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames) throws IOException
GoogleCloudStoragecopy in interface GoogleCloudStoragesrcBucketName - name of the bucket containing the objects to copysrcObjectNames - names of the objects to copydstBucketName - name of the bucket to copy todstObjectNames - names of the objects after copyFileNotFoundException - if the source object or the destination bucket does not
existIOException - in all other error casespublic List<String> listBucketNames() throws IOException
GoogleCloudStoragelistBucketNames in interface GoogleCloudStorageIOExceptionpublic List<GoogleCloudStorageItemInfo> listBucketInfo() throws IOException
GoogleCloudStoragelistBucketInfo in interface GoogleCloudStorageIOExceptionpublic GoogleCloudStorage.ListPage<GoogleCloudStorageItemInfo> listObjectInfoPage(String bucketName, String objectNamePrefix, ListObjectOptions listOptions, String pageToken) throws IOException
GoogleCloudStorageGoogleCloudStorage.listObjectInfo(java.lang.String, java.lang.String), but returns only result of single list request
(1 page).listObjectInfoPage in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desiredlistOptions - options to use when listing objectspageToken - the page tokenGoogleCloudStorage.ListPage object with listed GoogleCloudStorageItemInfos and next page
token if anyIOException - on IO errorpublic GoogleCloudStorage.ListPage<FolderInfo> listFolderInfoForPrefixPage(String bucketName, String objectNamePrefix, ListFolderOptions listFolderOptions, String pageToken) throws IOException
GoogleCloudStoragelistFolderInfoForPrefixPage in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - folder resource name prefixlistFolderOptions - options to use when listing folder resourcespageToken - the page tokenGoogleCloudStorage.ListPage folder resources with listed FoldersIOException - on IO errorpublic List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix, ListObjectOptions listOptions) throws IOException
GoogleCloudStorageGoogleCloudStorageItemInfo of objects contained in the given bucket and whose
names begin with the given prefix.
Note: Although GCS does not implement a file system, it treats objects that contain a
delimiter (ListObjectOptions.getDelimiter()) as different from other objects when
listing objects. This will be clearer with an example.
Consider a bucket with objects: o1, d1/, d1/o1, d1/o2
prefix == null and delimiter == /, we get: d1/, o1
With prefix == null and delimiter == null, we get: o1, d1/, d1/o1, d1/o2
Thus when delimiter is null, the entire key name is considered an opaque string,
otherwise only the part up to the first delimiter is considered.
listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desiredlistOptions - options to use when listing objectsIOException - on IO errorpublic void renameHnFolder(URI src, URI dst) throws IOException
GoogleCloudStoragesrc to dst using the rename LRO API. This should be called only on an
Hierarchical namespace enabled bucket.renameHnFolder in interface GoogleCloudStoragesrc - source pathdst - destination pathIOExceptionpublic boolean isHnBucket(URI src) throws IOException
GoogleCloudStorageresourceId belongs to a Hierarchical namespace enabled bucket. This takes a
path and not the bucket name since the caller may not have permission to query the bucket.isHnBucket in interface GoogleCloudStoragesrc - Path for which the check need to be performedIOExceptionpublic GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException
GoogleCloudStoragegetItemInfo in interface GoogleCloudStorageresourceId - identifies either root, a Bucket, or a StorageObjectIOException - on IO errorpublic List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds) throws IOException
GoogleCloudStoragegetItemInfos in interface GoogleCloudStorageresourceIds - names of the GCS StorageObjects or Buckets for which to retrieve info.IOException - on IO errorpublic List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList) throws IOException
GoogleCloudStorageupdateItems in interface GoogleCloudStorageIOException - on IO errorpublic void close()
GoogleCloudStorageclose in interface GoogleCloudStoragepublic void compose(String bucketName, List<String> sources, String destination, String contentType) throws IOException
GoogleCloudStoragecompose in interface GoogleCloudStoragebucketName - name of the bucket containing the sources and the destinationsources - names of the objects to be composeddestination - name of the resulting objectcontentType - content-type of composed objectIOException - if the Compose operation was unsuccessfulpublic GoogleCloudStorageItemInfo composeObjects(List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options) throws IOException
GoogleCloudStorageoptions. Overwrite semantics for the destination object will follow the
same semantics as GoogleCloudStorage.create(StorageResourceId, CreateObjectOptions). See GoogleCloudStorage.create(StorageResourceId) for the behavior if StorageResourceId.getGenerationId() is
explicitly set. The bucket must be the same for all sources and the destination.composeObjects in interface GoogleCloudStorageIOExceptionCopyright © 2024. All rights reserved.