@@ -76,6 +76,7 @@ public Dataset apply(DatasetInfo datasetInfo) {
7676 private final ExternalDatasetReference externalDatasetReference ;
7777 private final String storageBillingModel ;
7878 private final Long maxTimeTravelHours ;
79+ private final Annotations resourceTags ;
7980
8081 /** A builder for {@code DatasetInfo} objects. */
8182 public abstract static class Builder {
@@ -184,6 +185,19 @@ public abstract Builder setDefaultEncryptionConfiguration(
184185 */
185186 public abstract Builder setDefaultCollation (String defaultCollation );
186187
188+ /**
189+ * Optional. The <a href="https://cloud.google.com/bigquery/docs/tags">tags</a> attached to this
190+ * dataset. Tag keys are globally unique. Tag key is expected to be in the namespaced format,
191+ * for example "123456789012/environment" where 123456789012 is the ID of the parent
192+ * organization or project resource for this tag key. Tag value is expected to be the short
193+ * name, for example "Production".
194+ *
195+ * @see <a href="https://cloud.google.com/iam/docs/tags-access-control#definitions">Tag
196+ * definitions</a> for more details.
197+ * @param resourceTags resourceTags or {@code null} for none
198+ */
199+ public abstract Builder setResourceTags (Map <String , String > resourceTags );
200+
187201 /** Creates a {@code DatasetInfo} object. */
188202 public abstract DatasetInfo build ();
189203 }
@@ -208,6 +222,7 @@ static final class BuilderImpl extends Builder {
208222 private ExternalDatasetReference externalDatasetReference ;
209223 private String storageBillingModel ;
210224 private Long maxTimeTravelHours ;
225+ private Annotations resourceTags = Annotations .ZERO ;
211226
212227 BuilderImpl () {}
213228
@@ -230,6 +245,7 @@ static final class BuilderImpl extends Builder {
230245 this .externalDatasetReference = datasetInfo .externalDatasetReference ;
231246 this .storageBillingModel = datasetInfo .storageBillingModel ;
232247 this .maxTimeTravelHours = datasetInfo .maxTimeTravelHours ;
248+ this .resourceTags = datasetInfo .resourceTags ;
233249 }
234250
235251 BuilderImpl (com .google .api .services .bigquery .model .Dataset datasetPb ) {
@@ -270,6 +286,7 @@ public Acl apply(Dataset.Access accessPb) {
270286 }
271287 this .storageBillingModel = datasetPb .getStorageBillingModel ();
272288 this .maxTimeTravelHours = datasetPb .getMaxTimeTravelHours ();
289+ this .resourceTags = Annotations .fromPb (datasetPb .getResourceTags ());
273290 }
274291
275292 @ Override
@@ -388,6 +405,12 @@ public Builder setMaxTimeTravelHours(Long maxTimeTravelHours) {
388405 return this ;
389406 }
390407
408+ @ Override
409+ public Builder setResourceTags (Map <String , String > resourceTags ) {
410+ this .resourceTags = Annotations .fromUser (resourceTags );
411+ return this ;
412+ }
413+
391414 @ Override
392415 public DatasetInfo build () {
393416 return new DatasetInfo (this );
@@ -413,6 +436,7 @@ public DatasetInfo build() {
413436 externalDatasetReference = builder .externalDatasetReference ;
414437 storageBillingModel = builder .storageBillingModel ;
415438 maxTimeTravelHours = builder .maxTimeTravelHours ;
439+ resourceTags = builder .resourceTags ;
416440 }
417441
418442 /** Returns the dataset identity. */
@@ -554,6 +578,21 @@ public Long getMaxTimeTravelHours() {
554578 return maxTimeTravelHours ;
555579 }
556580
581+ /**
582+ * Optional. The <a href="https://cloud.google.com/bigquery/docs/tags">tags</a> attached to this
583+ * dataset. Tag keys are globally unique. Tag key is expected to be in the namespaced format, for
584+ * example "123456789012/environment" where 123456789012 is the ID of the parent organization or
585+ * project resource for this tag key. Tag value is expected to be the short name, for example
586+ * "Production".
587+ *
588+ * @see <a href="https://cloud.google.com/iam/docs/tags-access-control#definitions">Tag
589+ * definitions</a> for more details.
590+ * @return value or {@code null} for none
591+ */
592+ public Map <String , String > getResourceTags () {
593+ return resourceTags .userMap ();
594+ }
595+
557596 /**
558597 * Returns information about the external metadata storage where the dataset is defined. Filled
559598 * out when the dataset type is EXTERNAL.
@@ -588,6 +627,7 @@ public String toString() {
588627 .add ("externalDatasetReference" , externalDatasetReference )
589628 .add ("storageBillingModel" , storageBillingModel )
590629 .add ("maxTimeTravelHours" , maxTimeTravelHours )
630+ .add ("resourceTags" , resourceTags )
591631 .toString ();
592632 }
593633
@@ -675,6 +715,7 @@ public Dataset.Access apply(Acl acl) {
675715 if (maxTimeTravelHours != null ) {
676716 datasetPb .setMaxTimeTravelHours (maxTimeTravelHours );
677717 }
718+ datasetPb .setResourceTags (resourceTags .toPb ());
678719 return datasetPb ;
679720 }
680721
0 commit comments