@@ -76,6 +76,7 @@ public Dataset apply(DatasetInfo datasetInfo) {
76
76
private final ExternalDatasetReference externalDatasetReference ;
77
77
private final String storageBillingModel ;
78
78
private final Long maxTimeTravelHours ;
79
+ private final Annotations resourceTags ;
79
80
80
81
/** A builder for {@code DatasetInfo} objects. */
81
82
public abstract static class Builder {
@@ -184,6 +185,19 @@ public abstract Builder setDefaultEncryptionConfiguration(
184
185
*/
185
186
public abstract Builder setDefaultCollation (String defaultCollation );
186
187
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
+
187
201
/** Creates a {@code DatasetInfo} object. */
188
202
public abstract DatasetInfo build ();
189
203
}
@@ -208,6 +222,7 @@ static final class BuilderImpl extends Builder {
208
222
private ExternalDatasetReference externalDatasetReference ;
209
223
private String storageBillingModel ;
210
224
private Long maxTimeTravelHours ;
225
+ private Annotations resourceTags = Annotations .ZERO ;
211
226
212
227
BuilderImpl () {}
213
228
@@ -230,6 +245,7 @@ static final class BuilderImpl extends Builder {
230
245
this .externalDatasetReference = datasetInfo .externalDatasetReference ;
231
246
this .storageBillingModel = datasetInfo .storageBillingModel ;
232
247
this .maxTimeTravelHours = datasetInfo .maxTimeTravelHours ;
248
+ this .resourceTags = datasetInfo .resourceTags ;
233
249
}
234
250
235
251
BuilderImpl (com .google .api .services .bigquery .model .Dataset datasetPb ) {
@@ -270,6 +286,7 @@ public Acl apply(Dataset.Access accessPb) {
270
286
}
271
287
this .storageBillingModel = datasetPb .getStorageBillingModel ();
272
288
this .maxTimeTravelHours = datasetPb .getMaxTimeTravelHours ();
289
+ this .resourceTags = Annotations .fromPb (datasetPb .getResourceTags ());
273
290
}
274
291
275
292
@ Override
@@ -388,6 +405,12 @@ public Builder setMaxTimeTravelHours(Long maxTimeTravelHours) {
388
405
return this ;
389
406
}
390
407
408
+ @ Override
409
+ public Builder setResourceTags (Map <String , String > resourceTags ) {
410
+ this .resourceTags = Annotations .fromUser (resourceTags );
411
+ return this ;
412
+ }
413
+
391
414
@ Override
392
415
public DatasetInfo build () {
393
416
return new DatasetInfo (this );
@@ -413,6 +436,7 @@ public DatasetInfo build() {
413
436
externalDatasetReference = builder .externalDatasetReference ;
414
437
storageBillingModel = builder .storageBillingModel ;
415
438
maxTimeTravelHours = builder .maxTimeTravelHours ;
439
+ resourceTags = builder .resourceTags ;
416
440
}
417
441
418
442
/** Returns the dataset identity. */
@@ -554,6 +578,21 @@ public Long getMaxTimeTravelHours() {
554
578
return maxTimeTravelHours ;
555
579
}
556
580
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
+
557
596
/**
558
597
* Returns information about the external metadata storage where the dataset is defined. Filled
559
598
* out when the dataset type is EXTERNAL.
@@ -588,6 +627,7 @@ public String toString() {
588
627
.add ("externalDatasetReference" , externalDatasetReference )
589
628
.add ("storageBillingModel" , storageBillingModel )
590
629
.add ("maxTimeTravelHours" , maxTimeTravelHours )
630
+ .add ("resourceTags" , resourceTags )
591
631
.toString ();
592
632
}
593
633
@@ -675,6 +715,7 @@ public Dataset.Access apply(Acl acl) {
675
715
if (maxTimeTravelHours != null ) {
676
716
datasetPb .setMaxTimeTravelHours (maxTimeTravelHours );
677
717
}
718
+ datasetPb .setResourceTags (resourceTags .toPb ());
678
719
return datasetPb ;
679
720
}
680
721
0 commit comments