|
16 | 16 | package com.google.cloud.bigtable.admin.v2.models; |
17 | 17 |
|
18 | 18 | import com.google.api.core.InternalApi; |
| 19 | +import com.google.bigtable.admin.v2.AppProfile.DataBoostIsolationReadOnly; |
19 | 20 | import com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny; |
20 | 21 | import com.google.bigtable.admin.v2.AppProfile.Priority; |
21 | 22 | import com.google.bigtable.admin.v2.AppProfile.StandardIsolation; |
@@ -81,6 +82,8 @@ public RoutingPolicy getPolicy() { |
81 | 82 | public IsolationPolicy getIsolationPolicy() { |
82 | 83 | if (proto.hasStandardIsolation()) { |
83 | 84 | return new StandardIsolationPolicy(proto.getStandardIsolation()); |
| 85 | + } else if (proto.hasDataBoostIsolationReadOnly()) { |
| 86 | + return new DataBoostIsolationReadOnlyPolicy(proto.getDataBoostIsolationReadOnly()); |
84 | 87 | } else { |
85 | 88 | // Should never happen because the constructor verifies that one must exist. |
86 | 89 | throw new IllegalStateException(); |
@@ -409,4 +412,108 @@ public int hashCode() { |
409 | 412 | return Objects.hashCode(proto); |
410 | 413 | } |
411 | 414 | } |
| 415 | + |
| 416 | + /** Compute Billing Owner specifies how usage should be accounted when using Data Boost. */ |
| 417 | + public static enum ComputeBillingOwner { |
| 418 | + UNSPECIFIED(DataBoostIsolationReadOnly.ComputeBillingOwner.COMPUTE_BILLING_OWNER_UNSPECIFIED), |
| 419 | + HOST_PAYS(DataBoostIsolationReadOnly.ComputeBillingOwner.HOST_PAYS); |
| 420 | + |
| 421 | + private final com.google.bigtable.admin.v2.AppProfile.DataBoostIsolationReadOnly |
| 422 | + .ComputeBillingOwner |
| 423 | + proto; |
| 424 | + |
| 425 | + /** |
| 426 | + * Wraps the protobuf. This method is considered an internal implementation detail and not meant |
| 427 | + * to be used by applications. |
| 428 | + */ |
| 429 | + @InternalApi |
| 430 | + public static ComputeBillingOwner fromProto( |
| 431 | + com.google.bigtable.admin.v2.AppProfile.DataBoostIsolationReadOnly.ComputeBillingOwner |
| 432 | + proto) { |
| 433 | + Preconditions.checkNotNull(proto); |
| 434 | + |
| 435 | + for (ComputeBillingOwner owner : values()) { |
| 436 | + if (owner.proto.equals(proto)) { |
| 437 | + return owner; |
| 438 | + } |
| 439 | + } |
| 440 | + |
| 441 | + throw new IllegalArgumentException("Unknown billing owner: " + proto); |
| 442 | + } |
| 443 | + |
| 444 | + /** |
| 445 | + * Creates the request protobuf. This method is considered an internal implementation detail and |
| 446 | + * not meant to be used by applications. |
| 447 | + */ |
| 448 | + @InternalApi |
| 449 | + public DataBoostIsolationReadOnly.ComputeBillingOwner toProto() { |
| 450 | + return proto; |
| 451 | + } |
| 452 | + |
| 453 | + ComputeBillingOwner(DataBoostIsolationReadOnly.ComputeBillingOwner proto) { |
| 454 | + this.proto = proto; |
| 455 | + } |
| 456 | + } |
| 457 | + |
| 458 | + /** |
| 459 | + * A Data Boost Read Only {@link IsolationPolicy} for running high-throughput read traffic on your |
| 460 | + * Bigtable data without affecting application traffic. |
| 461 | + */ |
| 462 | + public static class DataBoostIsolationReadOnlyPolicy implements IsolationPolicy { |
| 463 | + private final DataBoostIsolationReadOnly proto; |
| 464 | + |
| 465 | + DataBoostIsolationReadOnlyPolicy(DataBoostIsolationReadOnly proto) { |
| 466 | + this.proto = proto; |
| 467 | + } |
| 468 | + |
| 469 | + /** |
| 470 | + * Creates a new instance of {@link DataBoostIsolationReadOnlyPolicy} with specified {@link |
| 471 | + * ComputeBillingOwner}. |
| 472 | + */ |
| 473 | + public static DataBoostIsolationReadOnlyPolicy of(ComputeBillingOwner billingOwner) { |
| 474 | + return new DataBoostIsolationReadOnlyPolicy( |
| 475 | + DataBoostIsolationReadOnly.newBuilder() |
| 476 | + .setComputeBillingOwner(billingOwner.toProto()) |
| 477 | + .build()); |
| 478 | + } |
| 479 | + |
| 480 | + /** Creates a new instance of {@link DataBoostIsolationReadOnlyPolicy}. */ |
| 481 | + public static DataBoostIsolationReadOnlyPolicy of() { |
| 482 | + return new DataBoostIsolationReadOnlyPolicy(DataBoostIsolationReadOnly.getDefaultInstance()); |
| 483 | + } |
| 484 | + |
| 485 | + /** |
| 486 | + * Gets the {@link ComputeBillingOwner} on the current {@link DataBoostIsolationReadOnlyPolicy} |
| 487 | + * instance. |
| 488 | + */ |
| 489 | + public ComputeBillingOwner getComputeBillingOwner() { |
| 490 | + return ComputeBillingOwner.fromProto(proto.getComputeBillingOwner()); |
| 491 | + } |
| 492 | + |
| 493 | + /** |
| 494 | + * Creates the request protobuf. This method is considered an internal implementation detail and |
| 495 | + * not meant to be used by applications. |
| 496 | + */ |
| 497 | + @InternalApi |
| 498 | + public DataBoostIsolationReadOnly toProto() { |
| 499 | + return proto; |
| 500 | + } |
| 501 | + |
| 502 | + @Override |
| 503 | + public boolean equals(Object o) { |
| 504 | + if (this == o) { |
| 505 | + return true; |
| 506 | + } |
| 507 | + if (o == null || getClass() != o.getClass()) { |
| 508 | + return false; |
| 509 | + } |
| 510 | + DataBoostIsolationReadOnlyPolicy that = (DataBoostIsolationReadOnlyPolicy) o; |
| 511 | + return Objects.equal(proto, that.proto); |
| 512 | + } |
| 513 | + |
| 514 | + @Override |
| 515 | + public int hashCode() { |
| 516 | + return Objects.hashCode(proto); |
| 517 | + } |
| 518 | + } |
412 | 519 | } |
0 commit comments