Search in sources :

Example 1 with Versioning

use of com.google.api.services.storage.model.Bucket.Versioning in project google-cloud-java by GoogleCloudPlatform.

the class BucketInfo method toPb.

com.google.api.services.storage.model.Bucket toPb() {
    com.google.api.services.storage.model.Bucket bucketPb = new com.google.api.services.storage.model.Bucket();
    bucketPb.setId(generatedId);
    bucketPb.setName(name);
    bucketPb.setEtag(etag);
    if (createTime != null) {
        bucketPb.setTimeCreated(new DateTime(createTime));
    }
    if (metageneration != null) {
        bucketPb.setMetageneration(metageneration);
    }
    if (location != null) {
        bucketPb.setLocation(location);
    }
    if (storageClass != null) {
        bucketPb.setStorageClass(storageClass.toString());
    }
    if (cors != null) {
        bucketPb.setCors(transform(cors, Cors.TO_PB_FUNCTION));
    }
    if (acl != null) {
        bucketPb.setAcl(transform(acl, new Function<Acl, BucketAccessControl>() {

            @Override
            public BucketAccessControl apply(Acl acl) {
                return acl.toBucketPb();
            }
        }));
    }
    if (defaultAcl != null) {
        bucketPb.setDefaultObjectAcl(transform(defaultAcl, new Function<Acl, ObjectAccessControl>() {

            @Override
            public ObjectAccessControl apply(Acl acl) {
                return acl.toObjectPb();
            }
        }));
    }
    if (owner != null) {
        bucketPb.setOwner(new Owner().setEntity(owner.toPb()));
    }
    bucketPb.setSelfLink(selfLink);
    if (versioningEnabled != null) {
        bucketPb.setVersioning(new Versioning().setEnabled(versioningEnabled));
    }
    if (indexPage != null || notFoundPage != null) {
        Website website = new Website();
        website.setMainPageSuffix(indexPage);
        website.setNotFoundPage(notFoundPage);
        bucketPb.setWebsite(website);
    }
    if (deleteRules != null) {
        Lifecycle lifecycle = new Lifecycle();
        lifecycle.setRule(transform(deleteRules, new Function<DeleteRule, Rule>() {

            @Override
            public Rule apply(DeleteRule deleteRule) {
                return deleteRule.toPb();
            }
        }));
        bucketPb.setLifecycle(lifecycle);
    }
    return bucketPb;
}
Also used : Owner(com.google.api.services.storage.model.Bucket.Owner) Lifecycle(com.google.api.services.storage.model.Bucket.Lifecycle) Website(com.google.api.services.storage.model.Bucket.Website) DateTime(com.google.api.client.util.DateTime) Function(com.google.common.base.Function) Versioning(com.google.api.services.storage.model.Bucket.Versioning)

Aggregations

DateTime (com.google.api.client.util.DateTime)1 Lifecycle (com.google.api.services.storage.model.Bucket.Lifecycle)1 Owner (com.google.api.services.storage.model.Bucket.Owner)1 Versioning (com.google.api.services.storage.model.Bucket.Versioning)1 Website (com.google.api.services.storage.model.Bucket.Website)1 Function (com.google.common.base.Function)1