public Policy getSubscriptionPolicy ( String subscriptionId ) throws Exception { // [START pubsub_get_subscription_policy] try ( SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient . create ( ) ) { ProjectSubscriptionName subscriptionName = ProjectSubscriptionName . of ( projectId , subscriptionId ) ; Policy policy = subscriptionAdminClient . getIamPolicy ( subscriptionName . toString ( ) ) ; if ( policy == null ) { // subscription was not found } return policy ; } // [END pubsub_get_subscription_policy] }
Example of getting a subscription policy .