Skip to content

Commit

Permalink
fix: generator setting incorrect name/class for sample due to region …
Browse files Browse the repository at this point in the history
…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]
```
  • Loading branch information
jinseopkim0 authored Oct 16, 2024
1 parent 5a0e254 commit 771bd0e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static Sample composeTransportSample(
RegionTag.builder()
.setServiceName(service.name())
.setRpcName(rpcName)
.setOverloadDisambiguation("setCredentialsProvider")
.setOverloadDisambiguation("useHttpJsonTransport")
.build();
return Sample.builder().setBody(sampleBody).setRegionTag(regionTag).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

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

// [START apigeeconnect_v1_generated_ConnectionService_Create_SetCredentialsProvider1_sync]
// [START apigeeconnect_v1_generated_ConnectionService_Create_UseHttpJsonTransport_sync]
import com.google.cloud.apigeeconnect.v1.ConnectionServiceClient;
import com.google.cloud.apigeeconnect.v1.ConnectionServiceSettings;

public class SyncCreateSetCredentialsProvider1 {
public class SyncCreateUseHttpJsonTransport {

public static void main(String[] args) throws Exception {
syncCreateSetCredentialsProvider1();
syncCreateUseHttpJsonTransport();
}

public static void syncCreateSetCredentialsProvider1() throws Exception {
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.
Expand All @@ -38,4 +38,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
ConnectionServiceClient.create(connectionServiceSettings);
}
}
// [END apigeeconnect_v1_generated_ConnectionService_Create_SetCredentialsProvider1_sync]
// [END apigeeconnect_v1_generated_ConnectionService_Create_UseHttpJsonTransport_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

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

// [START cloudasset_v1_generated_AssetService_Create_SetCredentialsProvider1_sync]
// [START cloudasset_v1_generated_AssetService_Create_UseHttpJsonTransport_sync]
import com.google.cloud.asset.v1.AssetServiceClient;
import com.google.cloud.asset.v1.AssetServiceSettings;

public class SyncCreateSetCredentialsProvider1 {
public class SyncCreateUseHttpJsonTransport {

public static void main(String[] args) throws Exception {
syncCreateSetCredentialsProvider1();
syncCreateUseHttpJsonTransport();
}

public static void syncCreateSetCredentialsProvider1() throws Exception {
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.
Expand All @@ -36,4 +36,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings);
}
}
// [END cloudasset_v1_generated_AssetService_Create_SetCredentialsProvider1_sync]
// [END cloudasset_v1_generated_AssetService_Create_UseHttpJsonTransport_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

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

// [START iamcredentials_v1_generated_IAMCredentials_Create_SetCredentialsProvider1_sync]
// [START iamcredentials_v1_generated_IAMCredentials_Create_UseHttpJsonTransport_sync]
import com.google.cloud.iam.credentials.v1.IamCredentialsClient;
import com.google.cloud.iam.credentials.v1.IamCredentialsSettings;

public class SyncCreateSetCredentialsProvider1 {
public class SyncCreateUseHttpJsonTransport {

public static void main(String[] args) throws Exception {
syncCreateSetCredentialsProvider1();
syncCreateUseHttpJsonTransport();
}

public static void syncCreateSetCredentialsProvider1() throws Exception {
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.
Expand All @@ -37,4 +37,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create(iamCredentialsSettings);
}
}
// [END iamcredentials_v1_generated_IAMCredentials_Create_SetCredentialsProvider1_sync]
// [END iamcredentials_v1_generated_IAMCredentials_Create_UseHttpJsonTransport_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

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

// [START example_v1_generated_LibraryService_Create_SetCredentialsProvider1_sync]
// [START example_v1_generated_LibraryService_Create_UseHttpJsonTransport_sync]
import com.google.cloud.example.library.v1.LibraryServiceClient;
import com.google.cloud.example.library.v1.LibraryServiceSettings;

public class SyncCreateSetCredentialsProvider1 {
public class SyncCreateUseHttpJsonTransport {

public static void main(String[] args) throws Exception {
syncCreateSetCredentialsProvider1();
syncCreateUseHttpJsonTransport();
}

public static void syncCreateSetCredentialsProvider1() throws Exception {
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.
Expand All @@ -37,4 +37,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
LibraryServiceClient libraryServiceClient = LibraryServiceClient.create(libraryServiceSettings);
}
}
// [END example_v1_generated_LibraryService_Create_SetCredentialsProvider1_sync]
// [END example_v1_generated_LibraryService_Create_UseHttpJsonTransport_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

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

// [START redis_v1beta1_generated_CloudRedis_Create_SetCredentialsProvider1_sync]
// [START redis_v1beta1_generated_CloudRedis_Create_UseHttpJsonTransport_sync]
import com.google.cloud.redis.v1beta1.CloudRedisClient;
import com.google.cloud.redis.v1beta1.CloudRedisSettings;

public class SyncCreateSetCredentialsProvider1 {
public class SyncCreateUseHttpJsonTransport {

public static void main(String[] args) throws Exception {
syncCreateSetCredentialsProvider1();
syncCreateUseHttpJsonTransport();
}

public static void syncCreateSetCredentialsProvider1() throws Exception {
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.
Expand All @@ -36,4 +36,4 @@ public static void syncCreateSetCredentialsProvider1() throws Exception {
CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
}
}
// [END redis_v1beta1_generated_CloudRedis_Create_SetCredentialsProvider1_sync]
// [END redis_v1beta1_generated_CloudRedis_Create_UseHttpJsonTransport_sync]

0 comments on commit 771bd0e

Please sign in to comment.