public Policy getTopicPolicy ( String topicId ) throws Exception { // [START pubsub_get_topic_policy] try ( TopicAdminClient topicAdminClient = TopicAdminClient . create ( ) ) { ProjectTopicName topicName = ProjectTopicName . of ( projectId , topicId ) ; Policy policy = topicAdminClient . getIamPolicy ( topicName . toString ( ) ) ; if ( policy == null ) { // topic iam policy was not found } return policy ; } // [END pubsub_get_topic_policy] }
Example of getting a topic policy .