1

Could someone walk me through setting an IAM policy in node.js using gcloud's pubsub?

I've looked through this page: https://developers.google.com/gmail/api/guides/push

And based on what I understood, I've saved this file as a .json:

POST "https://pubsub.googleapis.com/v1beta2/projects/gmail_push_project/topics/gmail_push_topic:setIamPolicy"
Content-type: application/json

{
  "policy": {
    "bindings": [{
      "role": "roles/pubsub.publisher",
      "members": ["serviceAccount:gmail-api-push@system.gserviceaccount.com"],
    }],
  }
}

And then, after creating a topic and subscribing to it, I've made this call in my .js script: pubsub.projects.topics.setIamPolicy('pubsub_policy.json');, however, I'm getting an error cannot read property "topics" of undefined.

Thanks for your help!

Sekoul
  • 1,361
  • 2
  • 14
  • 30

2 Answers2

2

Unfortunately this is not supported yet. However, we're preparing to launch such API calls with a new set of documentation shortly (in weeks). Also all the APIs are public now so that gcloud-node developers can actually start implementing, so I filed an issue at: https://github.com/GoogleCloudPlatform/gcloud-node/issues/758

As a short-term workaround, you can use the API explorer, or if you need to do it dynamically, you should be able to use the following library: https://developers.google.com/api-client-library/javascript/?hl=en

Takashi Matsuo
  • 3,406
  • 16
  • 25
  • thank you for the answer and for filing the issue. I fixed this with API explorer - for anyone seeing this later, just search for `setiampolicy` on API explorer and fill in according to guide here: https://developers.google.com/gmail/api/guides/push – Sekoul Jul 30 '15 at 14:43
2

As of v0.19.0 IAM methods are supported, you can find the documentation for them on the official gcloud-node docs.

callmehiphop
  • 636
  • 5
  • 10