use of com.google.cloud.pubsub.v1.TopicAdminClient in project java-docs-samples by GoogleCloudPlatform.
the class ManagerIT method testGetIam.
@Test
public void testGetIam() throws Exception {
topic = DeviceRegistryExample.createIotTopic(PROJECT_ID, TOPIC_ID);
DeviceRegistryExample.createRegistry(CLOUD_REGION, PROJECT_ID, REGISTRY_ID, TOPIC_ID);
DeviceRegistryExample.getIamPermissions(PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
String got = bout.toString();
Assert.assertTrue(got.contains("ETAG"));
DeviceRegistryExample.deleteRegistry(CLOUD_REGION, PROJECT_ID, REGISTRY_ID);
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
topicAdminClient.deleteTopic(topic.getNameAsTopicName());
}
}
use of com.google.cloud.pubsub.v1.TopicAdminClient in project java-docs-samples by GoogleCloudPlatform.
the class ManagerIT method testCreateDeleteEsDevice.
@Test
public void testCreateDeleteEsDevice() throws Exception {
final String deviceName = "es-device";
topic = DeviceRegistryExample.createIotTopic(PROJECT_ID, TOPIC_ID);
DeviceRegistryExample.createRegistry(CLOUD_REGION, PROJECT_ID, REGISTRY_ID, TOPIC_ID);
DeviceRegistryExample.createDeviceWithEs256(deviceName, ES_PATH, PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
DeviceRegistryExample.getDeviceStates(deviceName, PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
String got = bout.toString();
Assert.assertTrue(got.contains("Created device: {"));
DeviceRegistryExample.deleteDevice(deviceName, PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
DeviceRegistryExample.deleteRegistry(CLOUD_REGION, PROJECT_ID, REGISTRY_ID);
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
topicAdminClient.deleteTopic(topic.getNameAsTopicName());
}
}
use of com.google.cloud.pubsub.v1.TopicAdminClient in project java-docs-samples by GoogleCloudPlatform.
the class ManagerIT method testCreateListDevices.
@Test
public void testCreateListDevices() throws Exception {
final String deviceName = "rsa-device";
topic = DeviceRegistryExample.createIotTopic(PROJECT_ID, TOPIC_ID);
DeviceRegistryExample.createRegistry(CLOUD_REGION, PROJECT_ID, REGISTRY_ID, TOPIC_ID);
DeviceRegistryExample.createDeviceWithRs256(deviceName, RSA_PATH, PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
DeviceRegistryExample.listDevices(PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
String got = bout.toString();
Assert.assertTrue(got.contains("Created device: {"));
Assert.assertTrue(got.contains("Found"));
DeviceRegistryExample.deleteDevice(deviceName, PROJECT_ID, CLOUD_REGION, REGISTRY_ID);
DeviceRegistryExample.deleteRegistry(CLOUD_REGION, PROJECT_ID, REGISTRY_ID);
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
topicAdminClient.deleteTopic(topic.getNameAsTopicName());
}
}
use of com.google.cloud.pubsub.v1.TopicAdminClient in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientSnippets method getTopic.
/** Example of getting a topic. */
public Topic getTopic(String topicId) throws Exception {
// [START pubsub_get_topic]
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
TopicName topicName = TopicName.create(projectId, topicId);
Topic topic = topicAdminClient.getTopic(topicName);
return topic;
}
// [END pubsub_get_topic]
}
use of com.google.cloud.pubsub.v1.TopicAdminClient in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientSnippets method listTopics.
/** Example of listing topics. */
public ListTopicsPagedResponse listTopics() throws Exception {
// [START pubsub_list_topics]
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
ListTopicsRequest listTopicsRequest = ListTopicsRequest.newBuilder().setProjectWithProjectName(ProjectName.create(projectId)).build();
ListTopicsPagedResponse response = topicAdminClient.listTopics(listTopicsRequest);
Iterable<Topic> topics = response.iterateAll();
for (Topic topic : topics) {
// do something with the topic
}
return response;
}
// [END pubsub_list_topics]
}
Aggregations