use of com.google.api.services.iam.v1.model.CreateServiceAccountRequest in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudApiManager method createServiceAccount.
/**
* Creates a new {@link ServiceAccount} for the given {@link CloudProject} using the IAM API.
*/
private static ServiceAccount createServiceAccount(CredentialedUser user, String name, CloudProject cloudProject) throws IOException {
CreateServiceAccountRequest request = new CreateServiceAccountRequest();
ServiceAccount serviceAccount = new ServiceAccount();
serviceAccount.setDisplayName(name);
request.setServiceAccount(serviceAccount);
request.setAccountId(createServiceAccountId(name));
Iam iam = GoogleApiClientFactory.getInstance().getIamClient(user.getCredential());
return iam.projects().serviceAccounts().create(String.format(SERVICE_ACCOUNT_CREATE_REQUEST_PROJECT_FORMAT, cloudProject.projectId()), request).execute();
}
Aggregations