Search in sources :

Example 1 with GenerateAccessTokenResponse

use of com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse in project gapic-generator-java by googleapis.

the class AsyncGenerateAccessToken method asyncGenerateAccessToken.

public static void asyncGenerateAccessToken() throws Exception {
    // It may require modifications to work in your environment.
    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();
    }
}
Also used : ArrayList(java.util.ArrayList) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) GenerateAccessTokenResponse(com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse) GenerateAccessTokenRequest(com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest)

Example 2 with GenerateAccessTokenResponse

use of com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse in project gapic-generator-java by googleapis.

the class SyncGenerateAccessTokenServiceaccountnameListstringListstringDuration method syncGenerateAccessTokenServiceaccountnameListstringListstringDuration.

public static void syncGenerateAccessTokenServiceaccountnameListstringListstringDuration() throws Exception {
    // It may require modifications to work in your environment.
    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);
    }
}
Also used : ArrayList(java.util.ArrayList) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) ServiceAccountName(com.google.cloud.iam.credentials.v1.ServiceAccountName) Duration(com.google.protobuf.Duration) GenerateAccessTokenResponse(com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse)

Example 3 with GenerateAccessTokenResponse

use of com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse in project gapic-generator-java by googleapis.

the class SyncGenerateAccessTokenStringListstringListstringDuration method syncGenerateAccessTokenStringListstringListstringDuration.

public static void syncGenerateAccessTokenStringListstringListstringDuration() throws Exception {
    // It may require modifications to work in your environment.
    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);
    }
}
Also used : ArrayList(java.util.ArrayList) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) Duration(com.google.protobuf.Duration) GenerateAccessTokenResponse(com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse)

Aggregations

GenerateAccessTokenResponse (com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse)3 IamCredentialsClient (com.google.cloud.iam.credentials.v1.IamCredentialsClient)3 ArrayList (java.util.ArrayList)3 Duration (com.google.protobuf.Duration)2 GenerateAccessTokenRequest (com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest)1 ServiceAccountName (com.google.cloud.iam.credentials.v1.ServiceAccountName)1