class GoogleStorageLifecycleFeature implements Lifecycle {

    @Override
    public void setConfiguration(final Path file, final LifecycleConfiguration configuration) throws BackgroundException {
        final Path container = containerService.getContainer(file);
        try {
            if(configuration.getTransition() != null || configuration.getExpiration() != null) {
                final Bucket.Lifecycle config = new Bucket.Lifecycle();
                // Unique identifier for the rule. The value cannot be longer than 255 characters. When you specify an empty prefix, the rule applies to all objects in the bucket
                final List<Bucket.Lifecycle.Rule> rules = new ArrayList<>();
                if(configuration.getTransition() != null) {
                    rules.add(new Bucket.Lifecycle.Rule().setCondition(new Bucket.Lifecycle.Rule.Condition().setIsLive(true).setAge(configuration.getTransition()))
                        .setAction(new Bucket.Lifecycle.Rule.Action().setType("SetStorageClass").setStorageClass(configuration.getStorageClass())));
                }
                if(configuration.getExpiration() != null) {
                    rules.add(new Bucket.Lifecycle.Rule().setCondition(new Bucket.Lifecycle.Rule.Condition().setIsLive(true).setAge(configuration.getExpiration()))
                        .setAction(new Bucket.Lifecycle.Rule.Action().setType("Delete")));
                }
                session.getClient().buckets().patch(container.getName(), new Bucket().setLifecycle(
                    config.setRule(rules))).execute();
            }
            else {
                // Empty lifecycle configuration
                session.getClient().buckets().patch(container.getName(), new Bucket().setLifecycle(new Bucket.Lifecycle().setRule(Collections.emptyList()))).execute();
            }
        }
        catch(IOException e) {
            throw new GoogleStorageExceptionMappingService().map("Failure to write attributes of {0}", e, container);
        }
    }

    public  GoogleStorageLifecycleFeature(final GoogleStorageSession session);

}