Class StorageClient

java.lang.Object
com.google.jenkins.plugins.storage.client.StorageClient

public class StorageClient extends Object
Client for communicating with the Google GCS API.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    StorageClient(com.google.api.services.storage.Storage storage)
    Constructs a new StorageClient instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Delete bucket from GCS with name bucket.
    com.google.api.services.storage.Storage.Buckets.Delete
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StorageClient

      public StorageClient(com.google.api.services.storage.Storage storage)
      Constructs a new StorageClient instance.
      Parameters:
      storage - The Storage instance this class will utilize for interacting with the GCS API.
  • Method Details

    • deleteFromBucket

      public void deleteFromBucket(String bucket, String pattern) throws IOException
      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

      public void deleteBucket(String bucket) throws IOException
      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.