Skip to content

Commit 7e1817e

Browse files
committed
work in progress
1 parent f22030b commit 7e1817e

4 files changed

Lines changed: 78 additions & 48 deletions

File tree

src/main/java/com/google/gcloud/storage/Bucket.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/main/java/com/google/gcloud/storage/BucketImpl.java

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/java/com/google/gcloud/storage/BucketInfo.java

Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,89 @@
1616

1717
package com.google.gcloud.storage;
1818

19+
import com.google.api.services.storage.model.Bucket;
20+
import com.google.common.base.MoreObjects;
21+
import com.google.common.collect.ImmutableList;
22+
23+
import java.util.List;
24+
1925
public final class BucketInfo {
2026

2127
private final String id;
2228
private final String name;
29+
private final String etag;
2330
private final long createTime;
2431
private final long metageneration;
2532
private final Cors cors;
26-
private final Acl acl;
27-
private final Acl defaultAcl;
33+
private final ImmutableList<Acl> acl;
34+
private final ImmutableList<Acl> defaultAcl;
35+
private final Location location;
36+
private final StorageClass storageClass;
2837

2938
public enum StorageClass {
3039
DURABLE_REDUCED_AVAILABILITY,
3140
STANDARD
3241
}
3342

43+
public enum Location {
44+
US, EU, ASIA
45+
}
46+
3447
public final static class Builder {
3548

3649
private final String id;
3750
private final String name;
38-
private final long createTime;
39-
private final long metageneration;
51+
private StorageClass storageClass;
52+
private Location location;
53+
private String etag;
54+
private Long createTime;
55+
private Long metageneration;
4056
private Cors cors;
41-
private Acl acl;
42-
private Acl defaultAcl;
57+
private Iterable<Acl> acl;
58+
private Iterable<Acl> defaultAcl;
4359

44-
Builder(String id, String name, long createTime, long metageneration) {
60+
Builder(String id, String name) {
4561
this.id = id;
4662
this.name = name;
63+
}
64+
65+
public Builder storageClass(StorageClass storageClass) {
66+
this.storageClass = storageClass;
67+
return this;
68+
}
69+
70+
public Builder location(Location location) {
71+
this.location = location;
72+
return this;
73+
}
74+
75+
Builder etag(String etag) {
76+
this.etag = etag;
77+
return this;
78+
}
79+
80+
Builder createTime(Long createTime) {
4781
this.createTime = createTime;
82+
return this;
83+
}
84+
85+
Builder metageneration(Long metageneration) {
4886
this.metageneration = metageneration;
87+
return this;
4988
}
5089

51-
public Builder cors(Cors cors) {
90+
Builder cors(Cors cors) {
5291
this.cors = cors;
5392
return this;
5493
}
5594

56-
public Builder acl(Acl acl) {
57-
this.acl = acl;
95+
public Builder acl(Iterable<Acl> acl) {
96+
this.acl = ImmutableList.copyOf(acl);
5897
return this;
5998
}
6099

61-
public Builder defaultAcl(Acl defaultAcl) {
62-
this.defaultAcl = defaultAcl;
100+
public Builder defaultAcl(Iterable<Acl> acl) {
101+
this.defaultAcl = ImmutableList.copyOf(acl);
63102
return this;
64103
}
65104

@@ -71,11 +110,14 @@ public BucketInfo build() {
71110
private BucketInfo(Builder builder) {
72111
id = builder.id;
73112
name = builder.name;
74-
createTime = builder.createTime;
75-
metageneration = builder.metageneration;
113+
etag = builder.etag;
114+
createTime = MoreObjects.firstNonNull(builder.createTime, 0L);
115+
metageneration = MoreObjects.firstNonNull(builder.metageneration, 0L);
116+
location = builder.location;
117+
storageClass = builder.storageClass;
76118
cors = builder.cors;
77-
acl = builder.acl;
78-
defaultAcl = builder.defaultAcl;
119+
acl = ImmutableList.copyOf(builder.acl);
120+
defaultAcl = ImmutableList.copyOf(builder.defaultAcl);
79121
}
80122

81123
public String id() {
@@ -90,19 +132,31 @@ public Cors cors() {
90132
return cors;
91133
}
92134

93-
public Acl acl() {
135+
public List<Acl> acl() {
94136
return acl;
95137
}
96138

97-
public Acl defaultObjectAcl() {
139+
public List<Acl> defaultObjectAcl() {
98140
return defaultAcl;
99141
}
100142

101143
public Builder toBuilder() {
102-
return builder(id, name, createTime, metageneration).cors(cors).acl(acl).defaultAcl(defaultAcl);
144+
return new Builder(id, name)
145+
.createTime(createTime)
146+
.etag(etag)
147+
.metageneration(metageneration)
148+
.cors(cors)
149+
.acl(acl)
150+
.defaultAcl(defaultAcl)
151+
.location(location)
152+
.storageClass(storageClass);
153+
}
154+
155+
void fromPb(Bucket bucket) {
156+
103157
}
104158

105-
public static Builder builder(String id, String name, long createTime, long metageneration) {
106-
return new Builder(id, name, createTime, metageneration);
159+
Bucket toPb() {
160+
return n
107161
}
108162
}

src/main/java/com/google/gcloud/storage/StorageServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.gcloud.storage;
1818

19+
import com.google.api.services.storage.model.Bucket;
1920
import com.google.common.base.Function;
2021
import com.google.common.collect.Iterables;
2122
import com.google.gcloud.BaseService;
@@ -33,7 +34,7 @@ final class StorageServiceImpl extends BaseService<StorageServiceOptions> implem
3334
}
3435

3536
@Override
36-
public Iterable<Bucket> listBuckets() {
37+
public Iterable<BucketInfo> listBuckets() {
3738
try {
3839
return Iterables.transform(storageRpc.buckets(),
3940
new Function<com.google.api.services.storage.model.Bucket, Bucket>() {
@@ -47,7 +48,7 @@ public Iterable<Bucket> listBuckets() {
4748
}
4849

4950
@Override
50-
public Bucket getBucket(String bucket) {
51+
public BucketInfo getBucket(String bucket) {
5152
try {
5253
return new BucketImpl(this, storageRpc.bucket(bucket));
5354
} catch (IOException ex) {

0 commit comments

Comments
 (0)