Skip to content
Permalink
Browse files
feat: generate sample code in the Java microgenerator (#349)
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/83d27b1b-599d-4795-9959-95d65d1baad5/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 356341083
Source-Link: googleapis/googleapis@8d8c008
  • Loading branch information
yoshi-automation committed Feb 9, 2021
1 parent cb66cfa commit af4157904ed08555a286f57011b11efc0aeac8a0
@@ -42,6 +42,17 @@
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
* List<String> delegates = new ArrayList<>();
* List<String> scope = new ArrayList<>();
* Duration lifetime = Duration.newBuilder().build();
* GenerateAccessTokenResponse response =
* iamCredentialsClient.generateAccessToken(name, delegates, scope, lifetime);
* }
* }</pre>
*
* <p>Note: close() needs to be called on the IamCredentialsClient object to clean up resources such
* as threads. In the example above, try-with-resources is used, which automatically calls close().
*
@@ -145,6 +156,19 @@ public IamCredentialsStub getStub() {
/**
* Generates an OAuth 2.0 access token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
* List<String> delegates = new ArrayList<>();
* List<String> scope = new ArrayList<>();
* Duration lifetime = Duration.newBuilder().build();
* GenerateAccessTokenResponse response =
* iamCredentialsClient.generateAccessToken(name, delegates, scope, lifetime);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -181,6 +205,19 @@ public final GenerateAccessTokenResponse generateAccessToken(
/**
* Generates an OAuth 2.0 access token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* String name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString();
* List<String> delegates = new ArrayList<>();
* List<String> scope = new ArrayList<>();
* Duration lifetime = Duration.newBuilder().build();
* GenerateAccessTokenResponse response =
* iamCredentialsClient.generateAccessToken(name, delegates, scope, lifetime);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -217,6 +254,21 @@ public final GenerateAccessTokenResponse generateAccessToken(
/**
* Generates an OAuth 2.0 access token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* GenerateAccessTokenRequest request =
* GenerateAccessTokenRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .addAllScope(new ArrayList<String>())
* .setLifetime(Duration.newBuilder().build())
* .build();
* GenerateAccessTokenResponse response = iamCredentialsClient.generateAccessToken(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -229,6 +281,22 @@ public final GenerateAccessTokenResponse generateAccessToken(GenerateAccessToken
* Generates an OAuth 2.0 access token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* GenerateAccessTokenRequest request =
* GenerateAccessTokenRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .addAllScope(new ArrayList<String>())
* .setLifetime(Duration.newBuilder().build())
* .build();
* ApiFuture<GenerateAccessTokenResponse> future =
* iamCredentialsClient.generateAccessTokenCallable().futureCall(request);
* // Do something.
* GenerateAccessTokenResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GenerateAccessTokenRequest, GenerateAccessTokenResponse>
generateAccessTokenCallable() {
@@ -239,6 +307,19 @@ public final GenerateAccessTokenResponse generateAccessToken(GenerateAccessToken
/**
* Generates an OpenID Connect ID token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
* List<String> delegates = new ArrayList<>();
* String audience = "audience975628804";
* boolean includeEmail = true;
* GenerateIdTokenResponse response =
* iamCredentialsClient.generateIdToken(name, delegates, audience, includeEmail);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -273,6 +354,19 @@ public final GenerateIdTokenResponse generateIdToken(
/**
* Generates an OpenID Connect ID token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* String name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString();
* List<String> delegates = new ArrayList<>();
* String audience = "audience975628804";
* boolean includeEmail = true;
* GenerateIdTokenResponse response =
* iamCredentialsClient.generateIdToken(name, delegates, audience, includeEmail);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -307,6 +401,21 @@ public final GenerateIdTokenResponse generateIdToken(
/**
* Generates an OpenID Connect ID token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* GenerateIdTokenRequest request =
* GenerateIdTokenRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .setAudience("audience975628804")
* .setIncludeEmail(true)
* .build();
* GenerateIdTokenResponse response = iamCredentialsClient.generateIdToken(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -319,6 +428,22 @@ public final GenerateIdTokenResponse generateIdToken(GenerateIdTokenRequest requ
* Generates an OpenID Connect ID token for a service account.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* GenerateIdTokenRequest request =
* GenerateIdTokenRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .setAudience("audience975628804")
* .setIncludeEmail(true)
* .build();
* ApiFuture<GenerateIdTokenResponse> future =
* iamCredentialsClient.generateIdTokenCallable().futureCall(request);
* // Do something.
* GenerateIdTokenResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GenerateIdTokenRequest, GenerateIdTokenResponse>
generateIdTokenCallable() {
@@ -329,6 +454,17 @@ public final GenerateIdTokenResponse generateIdToken(GenerateIdTokenRequest requ
/**
* Signs a blob using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
* List<String> delegates = new ArrayList<>();
* ByteString payload = ByteString.EMPTY;
* SignBlobResponse response = iamCredentialsClient.signBlob(name, delegates, payload);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -359,6 +495,17 @@ public final SignBlobResponse signBlob(
/**
* Signs a blob using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* String name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString();
* List<String> delegates = new ArrayList<>();
* ByteString payload = ByteString.EMPTY;
* SignBlobResponse response = iamCredentialsClient.signBlob(name, delegates, payload);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -388,6 +535,20 @@ public final SignBlobResponse signBlob(String name, List<String> delegates, Byte
/**
* Signs a blob using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* SignBlobRequest request =
* SignBlobRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .setPayload(ByteString.EMPTY)
* .build();
* SignBlobResponse response = iamCredentialsClient.signBlob(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -400,6 +561,21 @@ public final SignBlobResponse signBlob(SignBlobRequest request) {
* Signs a blob using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* SignBlobRequest request =
* SignBlobRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .setPayload(ByteString.EMPTY)
* .build();
* ApiFuture<SignBlobResponse> future =
* iamCredentialsClient.signBlobCallable().futureCall(request);
* // Do something.
* SignBlobResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SignBlobRequest, SignBlobResponse> signBlobCallable() {
return stub.signBlobCallable();
@@ -409,6 +585,17 @@ public final UnaryCallable<SignBlobRequest, SignBlobResponse> signBlobCallable()
/**
* Signs a JWT using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
* List<String> delegates = new ArrayList<>();
* String payload = "payload-786701938";
* SignJwtResponse response = iamCredentialsClient.signJwt(name, delegates, payload);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -439,6 +626,17 @@ public final SignJwtResponse signJwt(
/**
* Signs a JWT using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* String name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString();
* List<String> delegates = new ArrayList<>();
* String payload = "payload-786701938";
* SignJwtResponse response = iamCredentialsClient.signJwt(name, delegates, payload);
* }
* }</pre>
*
* @param name Required. The resource name of the service account for which the credentials are
* requested, in the following format:
* `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is
@@ -468,6 +666,20 @@ public final SignJwtResponse signJwt(String name, List<String> delegates, String
/**
* Signs a JWT using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* SignJwtRequest request =
* SignJwtRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .setPayload("payload-786701938")
* .build();
* SignJwtResponse response = iamCredentialsClient.signJwt(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -480,6 +692,21 @@ public final SignJwtResponse signJwt(SignJwtRequest request) {
* Signs a JWT using a service account's system-managed private key.
*
* <p>Sample code:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* SignJwtRequest request =
* SignJwtRequest.newBuilder()
* .setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString())
* .addAllDelegates(new ArrayList<String>())
* .setPayload("payload-786701938")
* .build();
* ApiFuture<SignJwtResponse> future =
* iamCredentialsClient.signJwtCallable().futureCall(request);
* // Do something.
* SignJwtResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SignJwtRequest, SignJwtResponse> signJwtCallable() {
return stub.signJwtCallable();
@@ -29,6 +29,17 @@
* self-signed JSON Web Tokens (JWTs), and more.
*
* <p>Sample for IamCredentialsClient:
*
* <pre>{@code
* try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
* ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
* List<String> delegates = new ArrayList<>();
* List<String> scope = new ArrayList<>();
* Duration lifetime = Duration.newBuilder().build();
* GenerateAccessTokenResponse response =
* iamCredentialsClient.generateAccessToken(name, delegates, scope, lifetime);
* }
* }</pre>
*/
@Generated("by gapic-generator-java")
package com.google.cloud.iam.credentials.v1;
@@ -4,15 +4,15 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/java-iamcredentials.git",
"sha": "c0d9424500f8e8def1cedd123cc56012f86020b1"
"sha": "cb66cfad97863983d5fb35a122c9925e7d06908b"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3",
"internalRef": "350949863"
"sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb",
"internalRef": "356341083"
}
},
{

0 comments on commit af41579

Please sign in to comment.