Skip to content

Commit 771bd0e

Browse files
authored
fix: generator setting incorrect name/class for sample due to region tag (2nd attempt) (#3293)
Fixes #1272 Tested by following instructions https://github.com/googleapis/sdk-platform-java/blob/main/gapic-generator-java/DEVELOPMENT.md#running-the-plugin-under-googleapis-with-local-gapic-generator-java Ran ``` bazelisk build //google/cloud/tpu/v2:google-cloud-tpu-v2-java ``` Generated samples, included new google-cloud-tpu-v2-java/samples/snippets/generated/com/google/cloud/tpu/v2/tpu/create/SyncCreateUseHttpJsonTransport.java ``` /* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.cloud.tpu.v2.samples; // [START tpu_v2_generated_Tpu_Create_UseHttpJsonTransport_sync] import com.google.cloud.tpu.v2.TpuClient; import com.google.cloud.tpu.v2.TpuSettings; public class SyncCreateUseHttpJsonTransport { public static void main(String[] args) throws Exception { syncCreateUseHttpJsonTransport(); } public static void syncCreateUseHttpJsonTransport() throws Exception { // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library TpuSettings tpuSettings = TpuSettings.newHttpJsonBuilder().build(); TpuClient tpuClient = TpuClient.create(tpuSettings); } } // [END tpu_v2_generated_Tpu_Create_UseHttpJsonTransport_sync] ```
1 parent 5a0e254 commit 771bd0e

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public static Sample composeTransportSample(
338338
RegionTag.builder()
339339
.setServiceName(service.name())
340340
.setRpcName(rpcName)
341-
.setOverloadDisambiguation("setCredentialsProvider")
341+
.setOverloadDisambiguation("useHttpJsonTransport")
342342
.build();
343343
return Sample.builder().setBody(sampleBody).setRegionTag(regionTag).build();
344344
}
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
package com.google.cloud.apigeeconnect.v1.samples;
1818

19-
// [START apigeeconnect_v1_generated_ConnectionService_Create_SetCredentialsProvider1_sync]
19+
// [START apigeeconnect_v1_generated_ConnectionService_Create_UseHttpJsonTransport_sync]
2020
import com.google.cloud.apigeeconnect.v1.ConnectionServiceClient;
2121
import com.google.cloud.apigeeconnect.v1.ConnectionServiceSettings;
2222

23-
public class SyncCreateSetCredentialsProvider1 {
23+
public class SyncCreateUseHttpJsonTransport {
2424

2525
public static void main(String[] args) throws Exception {
26-
syncCreateSetCredentialsProvider1();
26+
syncCreateUseHttpJsonTransport();
2727
}
2828

29-
public static void syncCreateSetCredentialsProvider1() throws Exception {
29+
public static void syncCreateUseHttpJsonTransport() throws Exception {
3030
// This snippet has been automatically generated and should be regarded as a code template only.
3131
// It will require modifications to work:
3232
// - It may require correct/in-range values for request initialization.
@@ -38,4 +38,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
3838
ConnectionServiceClient.create(connectionServiceSettings);
3939
}
4040
}
41-
// [END apigeeconnect_v1_generated_ConnectionService_Create_SetCredentialsProvider1_sync]
41+
// [END apigeeconnect_v1_generated_ConnectionService_Create_UseHttpJsonTransport_sync]
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
package com.google.cloud.asset.v1.samples;
1818

19-
// [START cloudasset_v1_generated_AssetService_Create_SetCredentialsProvider1_sync]
19+
// [START cloudasset_v1_generated_AssetService_Create_UseHttpJsonTransport_sync]
2020
import com.google.cloud.asset.v1.AssetServiceClient;
2121
import com.google.cloud.asset.v1.AssetServiceSettings;
2222

23-
public class SyncCreateSetCredentialsProvider1 {
23+
public class SyncCreateUseHttpJsonTransport {
2424

2525
public static void main(String[] args) throws Exception {
26-
syncCreateSetCredentialsProvider1();
26+
syncCreateUseHttpJsonTransport();
2727
}
2828

29-
public static void syncCreateSetCredentialsProvider1() throws Exception {
29+
public static void syncCreateUseHttpJsonTransport() throws Exception {
3030
// This snippet has been automatically generated and should be regarded as a code template only.
3131
// It will require modifications to work:
3232
// - It may require correct/in-range values for request initialization.
@@ -36,4 +36,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
3636
AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings);
3737
}
3838
}
39-
// [END cloudasset_v1_generated_AssetService_Create_SetCredentialsProvider1_sync]
39+
// [END cloudasset_v1_generated_AssetService_Create_UseHttpJsonTransport_sync]
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
package com.google.cloud.iam.credentials.v1.samples;
1818

19-
// [START iamcredentials_v1_generated_IAMCredentials_Create_SetCredentialsProvider1_sync]
19+
// [START iamcredentials_v1_generated_IAMCredentials_Create_UseHttpJsonTransport_sync]
2020
import com.google.cloud.iam.credentials.v1.IamCredentialsClient;
2121
import com.google.cloud.iam.credentials.v1.IamCredentialsSettings;
2222

23-
public class SyncCreateSetCredentialsProvider1 {
23+
public class SyncCreateUseHttpJsonTransport {
2424

2525
public static void main(String[] args) throws Exception {
26-
syncCreateSetCredentialsProvider1();
26+
syncCreateUseHttpJsonTransport();
2727
}
2828

29-
public static void syncCreateSetCredentialsProvider1() throws Exception {
29+
public static void syncCreateUseHttpJsonTransport() throws Exception {
3030
// This snippet has been automatically generated and should be regarded as a code template only.
3131
// It will require modifications to work:
3232
// - It may require correct/in-range values for request initialization.
@@ -37,4 +37,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
3737
IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create(iamCredentialsSettings);
3838
}
3939
}
40-
// [END iamcredentials_v1_generated_IAMCredentials_Create_SetCredentialsProvider1_sync]
40+
// [END iamcredentials_v1_generated_IAMCredentials_Create_UseHttpJsonTransport_sync]
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
package com.google.cloud.example.library.v1.samples;
1818

19-
// [START example_v1_generated_LibraryService_Create_SetCredentialsProvider1_sync]
19+
// [START example_v1_generated_LibraryService_Create_UseHttpJsonTransport_sync]
2020
import com.google.cloud.example.library.v1.LibraryServiceClient;
2121
import com.google.cloud.example.library.v1.LibraryServiceSettings;
2222

23-
public class SyncCreateSetCredentialsProvider1 {
23+
public class SyncCreateUseHttpJsonTransport {
2424

2525
public static void main(String[] args) throws Exception {
26-
syncCreateSetCredentialsProvider1();
26+
syncCreateUseHttpJsonTransport();
2727
}
2828

29-
public static void syncCreateSetCredentialsProvider1() throws Exception {
29+
public static void syncCreateUseHttpJsonTransport() throws Exception {
3030
// This snippet has been automatically generated and should be regarded as a code template only.
3131
// It will require modifications to work:
3232
// - It may require correct/in-range values for request initialization.
@@ -37,4 +37,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
3737
LibraryServiceClient libraryServiceClient = LibraryServiceClient.create(libraryServiceSettings);
3838
}
3939
}
40-
// [END example_v1_generated_LibraryService_Create_SetCredentialsProvider1_sync]
40+
// [END example_v1_generated_LibraryService_Create_UseHttpJsonTransport_sync]
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
package com.google.cloud.redis.v1beta1.samples;
1818

19-
// [START redis_v1beta1_generated_CloudRedis_Create_SetCredentialsProvider1_sync]
19+
// [START redis_v1beta1_generated_CloudRedis_Create_UseHttpJsonTransport_sync]
2020
import com.google.cloud.redis.v1beta1.CloudRedisClient;
2121
import com.google.cloud.redis.v1beta1.CloudRedisSettings;
2222

23-
public class SyncCreateSetCredentialsProvider1 {
23+
public class SyncCreateUseHttpJsonTransport {
2424

2525
public static void main(String[] args) throws Exception {
26-
syncCreateSetCredentialsProvider1();
26+
syncCreateUseHttpJsonTransport();
2727
}
2828

29-
public static void syncCreateSetCredentialsProvider1() throws Exception {
29+
public static void syncCreateUseHttpJsonTransport() throws Exception {
3030
// This snippet has been automatically generated and should be regarded as a code template only.
3131
// It will require modifications to work:
3232
// - It may require correct/in-range values for request initialization.
@@ -36,4 +36,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
3636
CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
3737
}
3838
}
39-
// [END redis_v1beta1_generated_CloudRedis_Create_SetCredentialsProvider1_sync]
39+
// [END redis_v1beta1_generated_CloudRedis_Create_UseHttpJsonTransport_sync]

0 commit comments

Comments
 (0)