use of com.google.cloud.datalabeling.v1beta1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method createGroupTest.
@Test
@SuppressWarnings("all")
public void createGroupTest() {
GroupName name2 = GroupName.create("[PROJECT]", "[GROUP]");
String displayName = "displayName1615086568";
GroupName parentName = GroupName.create("[PROJECT]", "[GROUP]");
String filter = "filter-1274492040";
boolean isCluster = false;
Group expectedResponse = Group.newBuilder().setNameWithGroupName(name2).setDisplayName(displayName).setParentNameWithGroupName(parentName).setFilter(filter).setIsCluster(isCluster).build();
mockGroupService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
Group group = Group.newBuilder().build();
Group actualResponse = client.createGroup(name, group);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateGroupRequest actualRequest = (CreateGroupRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(group, actualRequest.getGroup());
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method createGroupExceptionTest.
@Test
@SuppressWarnings("all")
public void createGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
Group group = Group.newBuilder().build();
client.createGroup(name, group);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project spring-cloud-gcp by spring-cloud.
the class SecretManagerTemplate method createSecretInternal.
/**
* Creates a new secret for the GCP Project.
*
* <p>
* Note that the {@link Secret} object does not contain the secret payload. You must
* create versions of the secret which stores the payload of the secret.
*/
private void createSecretInternal(String secretId, String projectId) {
ProjectName projectName = ProjectName.of(projectId);
Secret secret = Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.getDefaultInstance())).build();
CreateSecretRequest request = CreateSecretRequest.newBuilder().setParent(projectName.toString()).setSecretId(secretId).setSecret(secret).build();
this.secretManagerServiceClient.createSecret(request);
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project divolte-collector by divolte.
the class GoogleCloudPubSubSinkConfiguration method createTopic.
private static void createTopic(final String hostPort, final TransportChannelProvider channelProvider, final ProjectTopicName topic) {
final TopicAdminClient topicClient;
try {
final TopicAdminSettings topicAdminSettings = TopicAdminSettings.newBuilder().setTransportChannelProvider(channelProvider).setCredentialsProvider(NoCredentialsProvider.create()).build();
topicClient = TopicAdminClient.create(topicAdminSettings);
} catch (final IOException e) {
throw new UncheckedIOException(String.format("Error creating topic %s for pub/sub emulator %s", topic, hostPort), e);
}
final ProjectName project = ProjectName.of(topic.getProject());
if (Streams.stream(topicClient.listTopics(project).iterateAll()).map(Topic::getName).map(ProjectTopicName::parse).noneMatch(topic::equals)) {
logger.info("Initializing Pub/Sub emulator topic: {}", topic);
topicClient.createTopic(topic);
}
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project spring-cloud-config by spring-cloud.
the class GoogleSecretManagerV1AccessStrategy method getSecrets.
@Override
public List<Secret> getSecrets() {
// Build the parent name.
ProjectName project = ProjectName.of(getProjectId());
// Create the request.
ListSecretsRequest listSecretRequest = ListSecretsRequest.newBuilder().setParent(project.toString()).build();
// Get all secrets.
SecretManagerServiceClient.ListSecretsPagedResponse pagedListSecretResponse = client.listSecrets(listSecretRequest);
List<Secret> result = new ArrayList<Secret>();
pagedListSecretResponse.iterateAll().forEach(result::add);
// List all secrets.
return result;
}
Aggregations