Class AbstractBucketLifecycleManager

  • All Implemented Interfaces:
    ExtensionPoint, Describable<AbstractUpload>, Serializable
    Direct Known Subclasses:
    ExpiringBucketLifecycleManager

    public abstract class AbstractBucketLifecycleManager
    extends AbstractUpload
    This extension point may be implemented to surface the object lifecycle options available on cloud storage buckets. Generally the expectation is that the UI will ask for the bucket, and surface some additional UI for capturing the lifecycle features of the plugin.

    This is done by implementing these two overrides:

    • checkBucket: Validated the annotations on a pre-existing bucket, returning it if they are satisfactory, and throwing a InvalidAnnotationException if we must update it.
    • decorateBucket: Annotates either a new or existing bucket with the lifecycle features of the plugin.
    NOTE: This extends AbstractUpload, but isn't really an upload. You could reason about it as an empty upload to a bucket with special bucket annotation properties.

    TODO(mattmoor): We should factor out a common AbstractStorageOperation base class that this and AbstractUpload can share. The current entrypoint is benign enough (see "perform").

    See Also:
    ExpiringBucketLifecycleManager, Serialized Form
    • Constructor Detail

      • AbstractBucketLifecycleManager

        public AbstractBucketLifecycleManager​(String bucket,
                                              @Nullable
                                              UploadModule module)
        Constructs the base bucket OLM plugin from the bucket name and module.
        Parameters:
        bucket - GCS Bucket in which to alter the time to live.
        module - Helper class methods to use for execution.
    • Method Detail

      • getOrCreateBucket

        protected com.google.api.services.storage.model.Bucket getOrCreateBucket​(com.google.api.services.storage.Storage service,
                                                                                 com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
                                                                                 com.google.jenkins.plugins.util.Executor executor,
                                                                                 String bucketName)
                                                                          throws UploadException
        This overrides the core implementation to provide additional hooks for decorating storage objects with lifecycle annotations.
        Overrides:
        getOrCreateBucket in class AbstractUpload
        Parameters:
        credentials - The credentials with which to fetch/create the bucket
        bucketName - The top-level bucket name to ensure exists
        service - Handle to the GCS API.
        executor - Helper class to make calls to the GCS API.
        Returns:
        an instance of the named bucket, created or retrieved.
        Throws:
        UploadException - if any issues are encountered
      • checkBucket

        protected abstract com.google.api.services.storage.model.Bucket checkBucket​(com.google.api.services.storage.model.Bucket bucket)
                                                                             throws InvalidAnnotationException
        This is intended to be an identity function that throws when the input is not adequately annotated.
        Parameters:
        bucket - the pre-existing bucket whose annotations to validate.
        Returns:
        The bucket that was validated.
        Throws:
        InvalidAnnotationException - if not annotated properly.
      • decorateBucket

        protected abstract com.google.api.services.storage.model.Bucket decorateBucket​(com.google.api.services.storage.model.Bucket bucket)
        A hook by which extensions may annotate a new or existing bucket.
        Parameters:
        bucket - The bucket to annotate and return.
        Returns:
        The bucket to annotate and return.