Class StorageClient
java.lang.Object
com.google.jenkins.plugins.storage.client.StorageClient
Client for communicating with the Google GCS API.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStorageClient
(com.google.api.services.storage.Storage storage) Constructs a newStorageClient
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteBucket
(String bucket) Delete bucket from GCS with name bucket.com.google.api.services.storage.Storage.Buckets.Delete
deleteBucketRequest
(String bucket) Helper method to return the delete request.void
deleteFromBucket
(String bucket, String pattern) Delete object matching pattern from Google Cloud Storage bucket of name bucket.com.google.api.services.storage.Storage.Objects.Delete
deleteFromBucketRequest
(String bucket, String pattern) Helper method to return the delete request.com.google.api.services.storage.model.StorageObject
uploadToBucket
(String pattern, String bucket, com.google.api.client.http.InputStreamContent content) Uploads item with path pattern to Google Cloud Storage bucket of name bucket.com.google.api.services.storage.Storage.Objects.Insert
uploadToBucketRequest
(String pattern, String bucket, com.google.api.client.http.InputStreamContent content) Helper method to return the insert request.
-
Constructor Details
-
StorageClient
public StorageClient(com.google.api.services.storage.Storage storage) Constructs a newStorageClient
instance.- Parameters:
storage
- TheStorage
instance this class will utilize for interacting with the GCS API.
-
-
Method Details
-
deleteFromBucket
Delete object matching pattern from Google Cloud Storage bucket of name bucket.- Parameters:
bucket
- GCS bucket to delete from.pattern
- Pattern to match object name to delete from bucket.- Throws:
IOException
- If there was an issue calling the GCS API.
-
deleteFromBucketRequest
public com.google.api.services.storage.Storage.Objects.Delete deleteFromBucketRequest(String bucket, String pattern) throws IOException Helper method to return the delete request.- Parameters:
bucket
- GCS bucket to delete from.pattern
- Pattern to match object name to delete from bucket.- Returns:
- Delete request.
- Throws:
IOException
- If there was an issue calling the GCS API.
-
uploadToBucket
public com.google.api.services.storage.model.StorageObject uploadToBucket(String pattern, String bucket, com.google.api.client.http.InputStreamContent content) throws IOException Uploads item with path pattern to Google Cloud Storage bucket of name bucket.- Parameters:
pattern
- Pattern to match object name to upload to bucket.bucket
- Name of the bucket to upload to.content
- InputStreamContent of desired file to upload.- Returns:
- The parsed HTTP response from the request.
- Throws:
IOException
- If there was an issue calling the GCS API.
-
uploadToBucketRequest
public com.google.api.services.storage.Storage.Objects.Insert uploadToBucketRequest(String pattern, String bucket, com.google.api.client.http.InputStreamContent content) throws IOException Helper method to return the insert request.- Parameters:
pattern
- Pattern to match object name to upload to bucket.bucket
- Name of the bucket to upload to.content
- InputStreamContent of desired file to upload.- Returns:
- Insert request.
- Throws:
IOException
- If there was an issue calling the GCS API.
-
deleteBucket
Delete bucket from GCS with name bucket. Bucket must be empty.- Parameters:
bucket
- Name of GCS bucket to delete.- Throws:
IOException
- If there was an issue calling the GCS API.
-
deleteBucketRequest
public com.google.api.services.storage.Storage.Buckets.Delete deleteBucketRequest(String bucket) throws IOException Helper method to return the delete request.- Parameters:
bucket
- Name of GCS bucket to delete.- Returns:
- Delete request.
- Throws:
IOException
- If there was an issue calling the GCS API.
-