Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add withAppProfileId to BigtableIO Read and Write #28864

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,25 @@ public Read withTableId(String tableId) {
return withTableId(StaticValueProvider.of(tableId));
}

/**
* Returns a new {@link BigtableIO.Read} that will read using the specified app profile id.
*
* <p>Does not modify this object.
*/
public Read withAppProfileId(ValueProvider<String> appProfileId) {
BigtableConfig config = getBigtableConfig();
return toBuilder().setBigtableConfig(config.withAppProfileId(appProfileId)).build();
}

/**
* Returns a new {@link BigtableIO.Read} that will read using the specified app profile id.
*
* <p>Does not modify this object.
*/
public Read withAppProfileId(String appProfileId) {
return withAppProfileId(StaticValueProvider.of(appProfileId));
}

/**
* WARNING: Should be used only to specify additional parameters for connection to the Cloud
* Bigtable, instanceId and projectId should be provided over {@link #withInstanceId} and {@link
Expand Down Expand Up @@ -837,6 +856,31 @@ public Write withTableId(String tableId) {
return withTableId(StaticValueProvider.of(tableId));
}

/**
* Returns a new {@link BigtableIO.Write} that will write using the specified app profile id.
*
* <p>Remember that in order to use single-row transactions, this must use a single-cluster
* routing policy.
*
* <p>Does not modify this object.
*/
public Write withAppProfileId(ValueProvider<String> appProfileId) {
BigtableConfig config = getBigtableConfig();
return toBuilder().setBigtableConfig(config.withAppProfileId(appProfileId)).build();
}

/**
* Returns a new {@link BigtableIO.Write} that will write using the specified app profile id.
*
* <p>Remember that in order to use single-row transactions, this must use a single-cluster
* routing policy.
*
* <p>Does not modify this object.
*/
public Write withAppProfileId(String appProfileId) {
return withAppProfileId(StaticValueProvider.of(appProfileId));
}

/**
* WARNING: Should be used only to specify additional parameters for connection to the Cloud
* Bigtable, instanceId and projectId should be provided over {@link #withInstanceId} and {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,13 @@ public void testReadBuildsCorrectly() {
.withTableId("table")
.withInstanceId("instance")
.withProjectId("project")
.withAppProfileId("app-profile")
.withBigtableOptionsConfigurator(PORT_CONFIGURATOR);
assertEquals("options_project", read.getBigtableOptions().getProjectId());
assertEquals("options_instance", read.getBigtableOptions().getInstanceId());
assertEquals("instance", read.getBigtableConfig().getInstanceId().get());
assertEquals("project", read.getBigtableConfig().getProjectId().get());
assertEquals("app-profile", read.getBigtableConfig().getAppProfileId().get());
assertEquals("table", read.getTableId());
assertEquals(PORT_CONFIGURATOR, read.getBigtableConfig().getBigtableOptionsConfigurator());
}
Expand Down Expand Up @@ -373,12 +375,14 @@ public void testWriteBuildsCorrectly() {
.withBigtableOptions(BIGTABLE_OPTIONS)
.withTableId("table")
.withInstanceId("instance")
.withProjectId("project");
.withProjectId("project")
.withAppProfileId("app-profile");
assertEquals("table", write.getBigtableWriteOptions().getTableId().get());
assertEquals("options_project", write.getBigtableOptions().getProjectId());
assertEquals("options_instance", write.getBigtableOptions().getInstanceId());
assertEquals("instance", write.getBigtableConfig().getInstanceId().get());
assertEquals("project", write.getBigtableConfig().getProjectId().get());
assertEquals("app-profile", write.getBigtableConfig().getAppProfileId().get());
}

@Test
Expand Down
Loading