googleapis / google-cloud-python

Google Cloud Client Library for Python
https://googleapis.github.io/google-cloud-python/
Apache License 2.0
4.8k stars 1.51k forks source link

Pubsub example on front page fails if topic does not already exist #1082

Closed Michael0x2a closed 9 years ago

Michael0x2a commented 9 years ago

The pubsub example throws an exception if the specified topic does not already exist. Example:

>>> from gcloud import pubsub
>>> client = pubsub.Client(project=MY_PROJECT_ID)
>>> topic = client.topic('my-new-custom-topic')
>>> topic.publish('Ping!')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/topic.py", line 186, in publish
    method='POST', path='%s:publish' % (self.path,), data=data)
  File "/usr/local/lib/python2.7/dist-packages/gcloud/connection.py", line 419, in api_request
    error_info=method + ' ' + url)
gcloud.exceptions.NotFound: 404 Resource not found (resource=my-custom-topic). (POST https://pubsub.googleapis.com/v1/projects/lee-cloud/topics/my-custom-topic:publish)

The code sample will resume working if you create the topic and re-run the sample, but it would be nice if the code sample included a line or two demonstrating how to create a topic if it doesn't exist.

dhermes commented 9 years ago

What page is this from?

Michael0x2a commented 9 years ago

Whoops, sorry -- at the bottom of https://cloud.google.com/python/ if you click "Publish messages and subscribe to Pub/Sub topics".

theacodes commented 9 years ago

Assign this to me, Danny. I guess we need to call out specifically that users should create their topic beforehand.

(fwiw, I don't like these samples on the python landing page...)

On Mon, Aug 24, 2015 at 4:00 PM Michael Lee notifications@github.com wrote:

Whoops, sorry -- at the bottom of https://cloud.google.com/python/ if you click "Publish messages and subscribe to Pub/Sub topics".

— Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/gcloud-python/issues/1082#issuecomment-134405974 .

dhermes commented 9 years ago

/cc @jonparrott

UPDATE: Jinx!

dhermes commented 9 years ago

@jonparrott I can't assign to someone outside the org. Are you not a part of GoogleCloudPlatform? If not, why not?

theacodes commented 9 years ago

I am, but our repos are divided into teams. I'm not part of the team that's on this repo (perhaps I should be?)

On Mon, Aug 24, 2015 at 4:02 PM Danny Hermes notifications@github.com wrote:

@jonparrott https://github.com/jonparrott I can't assign to someone outside the org. Are you not a part of GoogleCloudPlatform? If not, why not?

— Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/gcloud-python/issues/1082#issuecomment-134406235 .

dhermes commented 9 years ago

What are the implications? We can chat on Hangouts if it's easier / less public.

theacodes commented 9 years ago

Nothing that I'm aware of. Summoning @elibixby who has admin rights to GoogleCloudPlatform.

elibixby commented 9 years ago

Unfortunately right a team has a level of permissions, a set of repos and a set of members, and everyone on the team has the same level of permissions for all the repos of the team.... It's a really bad permissions model, and we're moving to the new one Sept 22nd, until then, make your team choice accordingly =)

theacodes commented 9 years ago

I'm tracking this via an internal bug now, as it's unclear whether we should instruct new users to create projects, enable billing, etc, or just remove these code samples.

dhermes commented 9 years ago

Shall I close this issue?

theacodes commented 9 years ago

Sure - it's not an issue with this library.