Class HttpStorageRpc (2.14.0)

public class HttpStorageRpc implements StorageRpc

Inheritance

java.lang.Object > HttpStorageRpc

Implements

StorageRpc

Static Fields

DEFAULT_PROJECTION

public static final String DEFAULT_PROJECTION
Field Value
Type Description
String

NO_ACL_PROJECTION

public static final String NO_ACL_PROJECTION
Field Value
Type Description
String

Constructors

HttpStorageRpc(StorageOptions options)

public HttpStorageRpc(StorageOptions options)
Parameter
Name Description
options StorageOptions

HttpStorageRpc(StorageOptions options, JsonFactory jsonFactory)

public HttpStorageRpc(StorageOptions options, JsonFactory jsonFactory)
Parameters
Name Description
options StorageOptions
jsonFactory com.google.api.client.json.JsonFactory

Methods

compose(Iterable<StorageObject> sources, StorageObject target, Map<StorageRpc.Option,?> targetOptions)

public StorageObject compose(Iterable<StorageObject> sources, StorageObject target, Map<StorageRpc.Option,?> targetOptions)

Sends a compose request.

Parameters
Name Description
sources Iterable<com.google.api.services.storage.model.StorageObject>
target com.google.api.services.storage.model.StorageObject
targetOptions Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.StorageObject

continueRewrite(StorageRpc.RewriteResponse previousResponse)

public StorageRpc.RewriteResponse continueRewrite(StorageRpc.RewriteResponse previousResponse)

Continues rewriting on an already open rewrite channel.

Parameter
Name Description
previousResponse StorageRpc.RewriteResponse
Returns
Type Description
StorageRpc.RewriteResponse

create(Bucket bucket, Map<StorageRpc.Option,?> options)

public Bucket create(Bucket bucket, Map<StorageRpc.Option,?> options)

Creates a new bucket.

Parameters
Name Description
bucket com.google.api.services.storage.model.Bucket
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.Bucket

create(StorageObject storageObject, InputStream content, Map<StorageRpc.Option,?> options)

public StorageObject create(StorageObject storageObject, InputStream content, Map<StorageRpc.Option,?> options)

Creates a new storage object.

Parameters
Name Description
storageObject com.google.api.services.storage.model.StorageObject
content InputStream
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.StorageObject

createAcl(BucketAccessControl acl, Map<StorageRpc.Option,?> options)

public BucketAccessControl createAcl(BucketAccessControl acl, Map<StorageRpc.Option,?> options)

Creates a new ACL entry on the specified bucket.

Parameters
Name Description
acl com.google.api.services.storage.model.BucketAccessControl
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.BucketAccessControl

createAcl(ObjectAccessControl acl)

public ObjectAccessControl createAcl(ObjectAccessControl acl)

Creates a new ACL entry on the specified object.

Parameter
Name Description
acl com.google.api.services.storage.model.ObjectAccessControl
Returns
Type Description
com.google.api.services.storage.model.ObjectAccessControl

createBatch()

public RpcBatch createBatch()

Creates an empty batch.

Returns
Type Description
RpcBatch

createDefaultAcl(ObjectAccessControl acl)

public ObjectAccessControl createDefaultAcl(ObjectAccessControl acl)

Creates a new default object ACL entry on the specified bucket.

Parameter
Name Description
acl com.google.api.services.storage.model.ObjectAccessControl
Returns
Type Description
com.google.api.services.storage.model.ObjectAccessControl

createHmacKey(String serviceAccountEmail, Map<StorageRpc.Option,?> options)

public HmacKey createHmacKey(String serviceAccountEmail, Map<StorageRpc.Option,?> options)

Creates a new HMAC key for the provided service account email.

Parameters
Name Description
serviceAccountEmail String
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.HmacKey

createNotification(String bucket, Notification notification)

public Notification createNotification(String bucket, Notification notification)

Creates the notification for a given bucket.

Parameters
Name Description
bucket String
notification com.google.api.services.storage.model.Notification
Returns
Type Description
com.google.api.services.storage.model.Notification

delete(Bucket bucket, Map<StorageRpc.Option,?> options)

public boolean delete(Bucket bucket, Map<StorageRpc.Option,?> options)

Deletes the requested bucket.

Parameters
Name Description
bucket com.google.api.services.storage.model.Bucket
options Map<Option,?>
Returns
Type Description
boolean

delete(StorageObject blob, Map<StorageRpc.Option,?> options)

public boolean delete(StorageObject blob, Map<StorageRpc.Option,?> options)

Deletes the requested storage object.

Parameters
Name Description
blob com.google.api.services.storage.model.StorageObject
options Map<Option,?>
Returns
Type Description
boolean

deleteAcl(String bucket, String object, Long generation, String entity)

public boolean deleteAcl(String bucket, String object, Long generation, String entity)

Deletes the ACL entry for the specified entity on the specified object.

Parameters
Name Description
bucket String
object String
generation Long
entity String
Returns
Type Description
boolean

deleteAcl(String bucket, String entity, Map<StorageRpc.Option,?> options)

public boolean deleteAcl(String bucket, String entity, Map<StorageRpc.Option,?> options)

Deletes the ACL entry for the specified entity on the specified bucket.

Parameters
Name Description
bucket String
entity String
options Map<Option,?>
Returns
Type Description
boolean

deleteDefaultAcl(String bucket, String entity)

public boolean deleteDefaultAcl(String bucket, String entity)

Deletes the default object ACL entry for the specified entity on the specified bucket.

Parameters
Name Description
bucket String
entity String
Returns
Type Description
boolean

deleteHmacKey(HmacKeyMetadata hmacKeyMetadata, Map<StorageRpc.Option,?> options)

public void deleteHmacKey(HmacKeyMetadata hmacKeyMetadata, Map<StorageRpc.Option,?> options)

Deletes the HMAC key associated with the provided metadata object.

Parameters
Name Description
hmacKeyMetadata com.google.api.services.storage.model.HmacKeyMetadata
options Map<Option,?>

deleteNotification(String bucket, String notification)

public boolean deleteNotification(String bucket, String notification)

Deletes the notification with the specified id on the bucket.

Parameters
Name Description
bucket String
notification String
Returns
Type Description
boolean

get(Bucket bucket, Map<StorageRpc.Option,?> options)

public Bucket get(Bucket bucket, Map<StorageRpc.Option,?> options)

Returns the requested bucket or null if not found.

Parameters
Name Description
bucket com.google.api.services.storage.model.Bucket
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.Bucket

get(StorageObject object, Map<StorageRpc.Option,?> options)

public StorageObject get(StorageObject object, Map<StorageRpc.Option,?> options)

Returns the requested storage object or null if not found.

Parameters
Name Description
object com.google.api.services.storage.model.StorageObject
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.StorageObject

getAcl(String bucket, String object, Long generation, String entity)

public ObjectAccessControl getAcl(String bucket, String object, Long generation, String entity)

Returns the ACL entry for the specified entity on the specified object or null if not found.

Parameters
Name Description
bucket String
object String
generation Long
entity String
Returns
Type Description
com.google.api.services.storage.model.ObjectAccessControl

getAcl(String bucket, String entity, Map<StorageRpc.Option,?> options)

public BucketAccessControl getAcl(String bucket, String entity, Map<StorageRpc.Option,?> options)

Returns the ACL entry for the specified entity on the specified bucket or null if not found.

Parameters
Name Description
bucket String
entity String
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.BucketAccessControl

getCurrentUploadOffset(String uploadId)

public long getCurrentUploadOffset(String uploadId)

Requests current byte offset from Cloud Storage API. Used to recover from a failure in some bytes were committed successfully to the open resumable session.

Parameter
Name Description
uploadId String
Returns
Type Description
long

getDefaultAcl(String bucket, String entity)

public ObjectAccessControl getDefaultAcl(String bucket, String entity)

Returns the default object ACL entry for the specified entity on the specified bucket or null if not found.

Parameters
Name Description
bucket String
entity String
Returns
Type Description
com.google.api.services.storage.model.ObjectAccessControl

getHmacKey(String accessId, Map<StorageRpc.Option,?> options)

public HmacKeyMetadata getHmacKey(String accessId, Map<StorageRpc.Option,?> options)

Returns the HMAC key associated with the provided access id.

Parameters
Name Description
accessId String
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.HmacKeyMetadata

getIamPolicy(String bucket, Map<StorageRpc.Option,?> options)

public Policy getIamPolicy(String bucket, Map<StorageRpc.Option,?> options)

Returns the IAM policy for the specified bucket.

Parameters
Name Description
bucket String
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.Policy

getNotification(String bucket, String notification)

public Notification getNotification(String bucket, String notification)

Gets the notification with the specified id.

Parameters
Name Description
bucket String
notification String
Returns
Type Description
com.google.api.services.storage.model.Notification

getServiceAccount(String projectId)

public ServiceAccount getServiceAccount(String projectId)

Returns the service account associated with the given project.

Parameter
Name Description
projectId String
Returns
Type Description
com.google.api.services.storage.model.ServiceAccount

list(String bucket, Map<StorageRpc.Option,?> options)

public Tuple<String,Iterable<StorageObject>> list(String bucket, Map<StorageRpc.Option,?> options)

Lists the bucket's blobs.

Parameters
Name Description
bucket String
options Map<Option,?>
Returns
Type Description
com.google.cloud.Tuple<String,Iterable<com.google.api.services.storage.model.StorageObject>>

list(Map<StorageRpc.Option,?> options)

public Tuple<String,Iterable<Bucket>> list(Map<StorageRpc.Option,?> options)

Lists the project's buckets.

Parameter
Name Description
options Map<Option,?>
Returns
Type Description
com.google.cloud.Tuple<String,Iterable<com.google.api.services.storage.model.Bucket>>

listAcls(String bucket, String object, Long generation)

public List<ObjectAccessControl> listAcls(String bucket, String object, Long generation)

Lists the ACL entries for the provided object.

Parameters
Name Description
bucket String
object String
generation Long
Returns
Type Description
List<com.google.api.services.storage.model.ObjectAccessControl>

listAcls(String bucket, Map<StorageRpc.Option,?> options)

public List<BucketAccessControl> listAcls(String bucket, Map<StorageRpc.Option,?> options)

Lists the ACL entries for the provided bucket.

Parameters
Name Description
bucket String
options Map<Option,?>
Returns
Type Description
List<com.google.api.services.storage.model.BucketAccessControl>

listDefaultAcls(String bucket)

public List<ObjectAccessControl> listDefaultAcls(String bucket)

Lists the default object ACL entries for the provided bucket.

Parameter
Name Description
bucket String
Returns
Type Description
List<com.google.api.services.storage.model.ObjectAccessControl>

listHmacKeys(Map<StorageRpc.Option,?> options)

public Tuple<String,Iterable<HmacKeyMetadata>> listHmacKeys(Map<StorageRpc.Option,?> options)

Lists the HMAC keys for the provided service account email.

Parameter
Name Description
options Map<Option,?>
Returns
Type Description
com.google.cloud.Tuple<String,Iterable<com.google.api.services.storage.model.HmacKeyMetadata>>

listNotifications(String bucket)

public List<Notification> listNotifications(String bucket)

Retrieves the list of notifications associated with the bucket.

Parameter
Name Description
bucket String
Returns
Type Description
List<com.google.api.services.storage.model.Notification>

load(StorageObject from, Map<StorageRpc.Option,?> options)

public byte[] load(StorageObject from, Map<StorageRpc.Option,?> options)

Reads all the bytes from a storage object.

Parameters
Name Description
from com.google.api.services.storage.model.StorageObject
options Map<Option,?>
Returns
Type Description
byte[]

lockRetentionPolicy(Bucket bucket, Map<StorageRpc.Option,?> options)

public Bucket lockRetentionPolicy(Bucket bucket, Map<StorageRpc.Option,?> options)

Lock retention policy for the provided bucket.

Parameters
Name Description
bucket com.google.api.services.storage.model.Bucket
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.Bucket

open(StorageObject object, Map<StorageRpc.Option,?> options)

public String open(StorageObject object, Map<StorageRpc.Option,?> options)

Opens a resumable upload channel for a given storage object.

Parameters
Name Description
object com.google.api.services.storage.model.StorageObject
options Map<Option,?>
Returns
Type Description
String

open(String signedURL)

public String open(String signedURL)

Opens a resumable upload channel for a given signedURL.

Parameter
Name Description
signedURL String
Returns
Type Description
String

openRewrite(StorageRpc.RewriteRequest rewriteRequest)

public StorageRpc.RewriteResponse openRewrite(StorageRpc.RewriteRequest rewriteRequest)

Sends a rewrite request to open a rewrite channel.

Parameter
Name Description
rewriteRequest StorageRpc.RewriteRequest
Returns
Type Description
StorageRpc.RewriteResponse

patch(Bucket bucket, Map<StorageRpc.Option,?> options)

public Bucket patch(Bucket bucket, Map<StorageRpc.Option,?> options)

Updates bucket information.

Parameters
Name Description
bucket com.google.api.services.storage.model.Bucket
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.Bucket

patch(StorageObject storageObject, Map<StorageRpc.Option,?> options)

public StorageObject patch(StorageObject storageObject, Map<StorageRpc.Option,?> options)

Updates the storage object's information. Original metadata are merged with metadata in the provided storageObject.

Parameters
Name Description
storageObject com.google.api.services.storage.model.StorageObject
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.StorageObject

patchAcl(BucketAccessControl acl, Map<StorageRpc.Option,?> options)

public BucketAccessControl patchAcl(BucketAccessControl acl, Map<StorageRpc.Option,?> options)

Updates an ACL entry on the specified bucket.

Parameters
Name Description
acl com.google.api.services.storage.model.BucketAccessControl
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.BucketAccessControl

patchAcl(ObjectAccessControl acl)

public ObjectAccessControl patchAcl(ObjectAccessControl acl)

Updates an ACL entry on the specified object.

Parameter
Name Description
acl com.google.api.services.storage.model.ObjectAccessControl
Returns
Type Description
com.google.api.services.storage.model.ObjectAccessControl

patchDefaultAcl(ObjectAccessControl acl)

public ObjectAccessControl patchDefaultAcl(ObjectAccessControl acl)

Updates a default object ACL entry on the specified bucket.

Parameter
Name Description
acl com.google.api.services.storage.model.ObjectAccessControl
Returns
Type Description
com.google.api.services.storage.model.ObjectAccessControl

queryCompletedResumableUpload(String uploadId, long totalBytes)

public StorageObject queryCompletedResumableUpload(String uploadId, long totalBytes)

Attempts to retrieve the StorageObject from a completed resumable upload. When a resumable upload completes, the response will be the up-to-date StorageObject metadata. This up-to-date metadata can then be used to validate the total size of the object along with new generation and other information.

If for any reason, the response to the final PUT to a resumable upload is not received, this method can be used to query for the up-to-date StorageObject. If the upload is complete, this method can be used to access the StorageObject independently from any other liveness or conditional criteria requirements that are otherwise applicable when using #get(StorageObject, Map).

Parameters
Name Description
uploadId String
totalBytes long
Returns
Type Description
com.google.api.services.storage.model.StorageObject

read(StorageObject from, Map<StorageRpc.Option,?> options, long position, int bytes)

public Tuple<String,byte[]> read(StorageObject from, Map<StorageRpc.Option,?> options, long position, int bytes)

Reads the given amount of bytes from a storage object at the given position.

Parameters
Name Description
from com.google.api.services.storage.model.StorageObject
options Map<Option,?>
position long
bytes int
Returns
Type Description
com.google.cloud.Tuple<String,byte[]>

read(StorageObject from, Map<StorageRpc.Option,?> options, long position, OutputStream outputStream)

public long read(StorageObject from, Map<StorageRpc.Option,?> options, long position, OutputStream outputStream)

Reads all the bytes from a storage object at the given position in to outputstream using direct download.

Parameters
Name Description
from com.google.api.services.storage.model.StorageObject
options Map<Option,?>
position long
outputStream OutputStream
Returns
Type Description
long

setIamPolicy(String bucket, Policy policy, Map<StorageRpc.Option,?> options)

public Policy setIamPolicy(String bucket, Policy policy, Map<StorageRpc.Option,?> options)

Updates the IAM policy for the specified bucket.

Parameters
Name Description
bucket String
policy com.google.api.services.storage.model.Policy
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.Policy

testIamPermissions(String bucket, List<String> permissions, Map<StorageRpc.Option,?> options)

public TestIamPermissionsResponse testIamPermissions(String bucket, List<String> permissions, Map<StorageRpc.Option,?> options)

Tests whether the caller holds the specified permissions for the specified bucket.

Parameters
Name Description
bucket String
permissions List<String>
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.TestIamPermissionsResponse

updateHmacKey(HmacKeyMetadata hmacKeyMetadata, Map<StorageRpc.Option,?> options)

public HmacKeyMetadata updateHmacKey(HmacKeyMetadata hmacKeyMetadata, Map<StorageRpc.Option,?> options)

Updates an HMAC key for the provided metadata object and returns the updated object. Only updates the State field.

Parameters
Name Description
hmacKeyMetadata com.google.api.services.storage.model.HmacKeyMetadata
options Map<Option,?>
Returns
Type Description
com.google.api.services.storage.model.HmacKeyMetadata

write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, boolean last)

public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, boolean last)

Writes the provided bytes to a storage object at the provided location.

Parameters
Name Description
uploadId String
toWrite byte[]
toWriteOffset int
destOffset long
length int
last boolean

writeWithResponse(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, boolean last)

public StorageObject writeWithResponse(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, boolean last)

Writes the provided bytes to a storage object at the provided location. If last=true returns metadata of the updated object, otherwise returns null.

Parameters
Name Description
uploadId String
toWrite byte[]
toWriteOffset int
destOffset long
length int
last boolean
Returns
Type Description
com.google.api.services.storage.model.StorageObject