@@ -103,6 +103,7 @@ public com.google.api.services.storage.model.Bucket apply(BucketInfo bucketInfo)
103103 private final IamConfiguration iamConfiguration ;
104104 private final String locationType ;
105105 private final Logging logging ;
106+ private final CustomPlacementConfig customPlacementConfig ;
106107
107108 private static final Logger log = Logger .getLogger (BucketInfo .class .getName ());
108109
@@ -328,6 +329,76 @@ public IamConfiguration build() {
328329 }
329330 }
330331
332+ /**
333+ * The bucket's custom placement configuration for Custom Dual Regions. If using `location` is
334+ * also required.
335+ */
336+ public static class CustomPlacementConfig implements Serializable {
337+
338+ private static final long serialVersionUID = -3172255903331692127L ;
339+ private List <String > dataLocations ;
340+
341+ @ Override
342+ public boolean equals (Object o ) {
343+ if (this == o ) return true ;
344+ if (o == null || getClass () != o .getClass ()) {
345+ return false ;
346+ }
347+ CustomPlacementConfig other = (CustomPlacementConfig ) o ;
348+ return Objects .equals (toPb (), other .toPb ());
349+ }
350+
351+ @ Override
352+ public int hashCode () {
353+ return Objects .hashCode (dataLocations );
354+ }
355+
356+ public static Builder newBuilder () {
357+ return new Builder ();
358+ }
359+
360+ public Builder toBuilder () {
361+ Builder builder = new Builder ();
362+ builder .dataLocations = dataLocations ;
363+ return builder ;
364+ }
365+
366+ public List <String > getDataLocations () {
367+ return dataLocations ;
368+ }
369+
370+ Bucket .CustomPlacementConfig toPb () {
371+ Bucket .CustomPlacementConfig customPlacementConfig = null ;
372+ if (dataLocations != null ) {
373+ customPlacementConfig = new Bucket .CustomPlacementConfig ();
374+ customPlacementConfig .setDataLocations (dataLocations );
375+ }
376+ return customPlacementConfig ;
377+ }
378+
379+ static CustomPlacementConfig fromPb (Bucket .CustomPlacementConfig customPlacementConfig ) {
380+ return newBuilder ().setDataLocations (customPlacementConfig .getDataLocations ()).build ();
381+ }
382+
383+ private CustomPlacementConfig (Builder builder ) {
384+ this .dataLocations = builder .dataLocations ;
385+ }
386+
387+ public static class Builder {
388+ private List <String > dataLocations ;
389+
390+ /** A list of regions for custom placement configurations. */
391+ public Builder setDataLocations (List <String > dataLocations ) {
392+ this .dataLocations = dataLocations != null ? ImmutableList .copyOf (dataLocations ) : null ;
393+ return this ;
394+ }
395+
396+ public CustomPlacementConfig build () {
397+ return new CustomPlacementConfig (this );
398+ }
399+ }
400+ }
401+
331402 /**
332403 * The bucket's logging configuration, which defines the destination bucket and optional name
333404 * prefix for the current bucket's logs.
@@ -1361,6 +1432,8 @@ public abstract static class Builder {
13611432
13621433 public abstract Builder setLogging (Logging logging );
13631434
1435+ public abstract Builder setCustomPlacementConfig (CustomPlacementConfig customPlacementConfig );
1436+
13641437 /** Creates a {@code BucketInfo} object. */
13651438 public abstract BucketInfo build ();
13661439 }
@@ -1396,6 +1469,7 @@ static final class BuilderImpl extends Builder {
13961469 private IamConfiguration iamConfiguration ;
13971470 private String locationType ;
13981471 private Logging logging ;
1472+ private CustomPlacementConfig customPlacementConfig ;
13991473
14001474 BuilderImpl (String name ) {
14011475 this .name = name ;
@@ -1431,6 +1505,7 @@ static final class BuilderImpl extends Builder {
14311505 iamConfiguration = bucketInfo .iamConfiguration ;
14321506 locationType = bucketInfo .locationType ;
14331507 logging = bucketInfo .logging ;
1508+ customPlacementConfig = bucketInfo .customPlacementConfig ;
14341509 }
14351510
14361511 @ Override
@@ -1626,6 +1701,12 @@ public Builder setLogging(Logging logging) {
16261701 return this ;
16271702 }
16281703
1704+ @ Override
1705+ public Builder setCustomPlacementConfig (CustomPlacementConfig customPlacementConfig ) {
1706+ this .customPlacementConfig = customPlacementConfig != null ? customPlacementConfig : null ;
1707+ return this ;
1708+ }
1709+
16291710 @ Override
16301711 Builder setLocationType (String locationType ) {
16311712 this .locationType = locationType ;
@@ -1669,6 +1750,7 @@ public BucketInfo build() {
16691750 iamConfiguration = builder .iamConfiguration ;
16701751 locationType = builder .locationType ;
16711752 logging = builder .logging ;
1753+ customPlacementConfig = builder .customPlacementConfig ;
16721754 }
16731755
16741756 /** Returns the service-generated id for the bucket. */
@@ -1792,7 +1874,8 @@ public Long getMetageneration() {
17921874
17931875 /**
17941876 * Returns the bucket's location. Data for blobs in the bucket resides in physical storage within
1795- * this region or regions.
1877+ * this region or regions. If specifying more than one region `customPlacementConfig` should be
1878+ * set in conjunction.
17961879 *
17971880 * @see <a href="https://cloud.google.com/storage/docs/bucket-locations">Bucket Locations</a>
17981881 */
@@ -1945,6 +2028,11 @@ public Logging getLogging() {
19452028 return logging ;
19462029 }
19472030
2031+ /** Returns the Custom Placement Configuration */
2032+ public CustomPlacementConfig getCustomPlacementConfig () {
2033+ return customPlacementConfig ;
2034+ }
2035+
19482036 /** Returns a builder for the current bucket. */
19492037 public Builder toBuilder () {
19502038 return new BuilderImpl (this );
@@ -2118,6 +2206,9 @@ public Rule apply(LifecycleRule lifecycleRule) {
21182206 if (logging != null ) {
21192207 bucketPb .setLogging (logging .toPb ());
21202208 }
2209+ if (customPlacementConfig != null ) {
2210+ bucketPb .setCustomPlacementConfig (customPlacementConfig .toPb ());
2211+ }
21212212 return bucketPb ;
21222213 }
21232214
@@ -2258,6 +2349,10 @@ public DeleteRule apply(Rule rule) {
22582349 if (logging != null ) {
22592350 builder .setLogging (Logging .fromPb (logging ));
22602351 }
2352+ Bucket .CustomPlacementConfig customPlacementConfig = bucketPb .getCustomPlacementConfig ();
2353+ if (customPlacementConfig != null ) {
2354+ builder .setCustomPlacementConfig (CustomPlacementConfig .fromPb (customPlacementConfig ));
2355+ }
22612356 return builder .build ();
22622357 }
22632358}
0 commit comments