Reference documentation and code samples for the Cloud Pub/Sub API class Google::Cloud::PubSub::Project.
Project
Represents the project that pubsub messages are pushed to and pulled
from.
V1::Topic is a named resource to which
messages are sent by using Publisher.
V1::Subscription is a named resource representing the stream
of messages from a single, specific topic, to be delivered to the
subscribing application via Subscriber. Message is a combination of data and
attributes that a publisher sends to a topic and is eventually delivered
to subscribers.
Retrieves a Publisher by topic name or full project path.
Parameters
topic_name (String) โ Name of a topic. The value can be a simple
topic ID (relative name) or a fully-qualified topic name.
project (String) (defaults to: nil) โ The alternate project ID can be specified here.
Optional. Not used if a fully-qualified topic name is provided
for topic_name.
Retrieves a Subscriber by subscription name or full project path.
Parameters
subscription_name (String) โ Name of a subscription. The value can
be a simple subscription ID (relative name) or a fully-qualified
subscription name.
project (String) (defaults to: nil) โ The alternate project ID can be specified here.
Optional. Not used if a fully-qualified topic name is provided
for topic_name.
skip_lookup (Boolean) (defaults to: nil) โ Optionally create a V1::Subscription
object without verifying the subscription resource exists on the Pub/Sub
service. Calls made on this object will raise errors if the service
resource does not exist. Default is false.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Cloud Pub/Sub API - Class Google::Cloud::PubSub::Project (v3.0.2)\n\nVersion latestkeyboard_arrow_down\n\n- [3.0.2 (latest)](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Project)\n- [3.0.1](/ruby/docs/reference/google-cloud-pubsub/3.0.1/Google-Cloud-PubSub-Project)\n- [2.23.0](/ruby/docs/reference/google-cloud-pubsub/2.23.0/Google-Cloud-PubSub-Project)\n- [2.22.0](/ruby/docs/reference/google-cloud-pubsub/2.22.0/Google-Cloud-PubSub-Project)\n- [2.21.0](/ruby/docs/reference/google-cloud-pubsub/2.21.0/Google-Cloud-PubSub-Project)\n- [2.20.0](/ruby/docs/reference/google-cloud-pubsub/2.20.0/Google-Cloud-PubSub-Project)\n- [2.19.0](/ruby/docs/reference/google-cloud-pubsub/2.19.0/Google-Cloud-PubSub-Project)\n- [2.18.1](/ruby/docs/reference/google-cloud-pubsub/2.18.1/Google-Cloud-PubSub-Project)\n- [2.17.0](/ruby/docs/reference/google-cloud-pubsub/2.17.0/Google-Cloud-PubSub-Project)\n- [2.16.0](/ruby/docs/reference/google-cloud-pubsub/2.16.0/Google-Cloud-PubSub-Project)\n- [2.15.5](/ruby/docs/reference/google-cloud-pubsub/2.15.5/Google-Cloud-PubSub-Project)\n- [2.14.0](/ruby/docs/reference/google-cloud-pubsub/2.14.0/Google-Cloud-PubSub-Project)\n- [2.12.1](/ruby/docs/reference/google-cloud-pubsub/2.12.1/Google-Cloud-PubSub-Project)\n- [2.11.0](/ruby/docs/reference/google-cloud-pubsub/2.11.0/Google-Cloud-PubSub-Project)\n- [2.10.0](/ruby/docs/reference/google-cloud-pubsub/2.10.0/Google-Cloud-PubSub-Project)\n- [2.9.2](/ruby/docs/reference/google-cloud-pubsub/2.9.2/Google-Cloud-PubSub-Project) \nReference documentation and code samples for the Cloud Pub/Sub API class Google::Cloud::PubSub::Project.\n\nProject\n-------\n\nRepresents the project that pubsub messages are pushed to and pulled\nfrom.\n\nV1::Topic is a named resource to which\nmessages are sent by using [Publisher](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Publisher \"Google::Cloud::PubSub::Publisher (class)\").\nV1::Subscription is a named resource representing the stream\nof messages from a single, specific topic, to be delivered to the\nsubscribing application via [Subscriber](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Subscriber \"Google::Cloud::PubSub::Subscriber (class)\"). [Message](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Message \"Google::Cloud::PubSub::Message (class)\") is a combination of data and\nattributes that a publisher sends to a topic and is eventually delivered\nto subscribers.\n\nSee [Google::Cloud#pubsub](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud#Google__Cloud_pubsub_instance_ \"Google::Cloud#pubsub (method)\") \n\nInherits\n--------\n\n- Object\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/pubsub\"\n\npubsub = Google::Cloud::PubSub.new\n\npublisher = pubsub.publisher \"my-topic\"\npublisher.publish \"task completed\"\n```\n\nMethods\n-------\n\n### #iam\n\n def iam() -\u003e Google::Iam::V1::IAMPolicy::Client\n\nRetrieve a client specific for Iam Policy related functions. \n**Returns**\n\n- (Google::Iam::V1::IAMPolicy::Client)\n\n### #project\n\n def project()\n\n**Alias Of** : [#project_id](./Google-Cloud-PubSub-Project#Google__Cloud__PubSub__Project_project_id_instance_) \nThe Pub/Sub project connected to.\n**Example** \n\n```ruby\nrequire \"google/cloud/pubsub\"\n\npubsub = Google::Cloud::PubSub.new(\n project_id: \"my-project\",\n credentials: \"/path/to/keyfile.json\"\n)\n\npubsub.project_id #=\u003e \"my-project\"\n```\n\n### #project_id\n\n def project_id()\n\n**Aliases**\n\n- [#project](./Google-Cloud-PubSub-Project#Google__Cloud__PubSub__Project_project_instance_) \nThe Pub/Sub project connected to.\n**Example** \n\n```ruby\nrequire \"google/cloud/pubsub\"\n\npubsub = Google::Cloud::PubSub.new(\n project_id: \"my-project\",\n credentials: \"/path/to/keyfile.json\"\n)\n\npubsub.project_id #=\u003e \"my-project\"\n```\n\n### #project_path\n\n def project_path(project_name: nil)\n\nReturns a fully-qualified project path in the form of\n`projects/{project_id}` \n**Parameter**\n\n- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.\n\n### #publisher\n\n def publisher(topic_name, project: nil, async: nil) -\u003e Google::Cloud::PubSub::Publisher\n\nRetrieves a Publisher by topic name or full project path. \n**Parameters**\n\n- **topic_name** (String) --- Name of a topic. The value can be a simple topic ID (relative name) or a fully-qualified topic name.\n- **project** (String) *(defaults to: nil)* --- The alternate project ID can be specified here. Optional. Not used if a fully-qualified topic name is provided for `topic_name`.\n- **async** (Hash) *(defaults to: nil)* --- A hash of values to configure the topic's [AsyncPublisher](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-AsyncPublisher \"Google::Cloud::PubSub::AsyncPublisher (class)\") that is created when [Google::Cloud::PubSub::Publisher#publish_async](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Publisher#Google__Cloud__PubSub__Publisher_publish_async_instance_ \"Google::Cloud::PubSub::Publisher#publish_async (method)\") is called. Optional. \n**Returns**\n\n- ([Google::Cloud::PubSub::Publisher](./Google-Cloud-PubSub-Publisher))\n\n### #schema_path\n\n def schema_path(schema_name, project_name: nil)\n\nReturns a fully-qualified schema path in the form of\n`projects/{project_id}/schemas/{schema_name}` \n**Parameters**\n\n- **schema_name** (String) --- A schema name.\n- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.\n\n### #schemas\n\n def schemas() -\u003e Google::Cloud::PubSub::V1::SchemaService::Client\n\nRetrieve a client for managing schemas. \n**Returns**\n\n- (Google::Cloud::PubSub::V1::SchemaService::Client)\n\n### #snapshot_path\n\n def snapshot_path(snapshot_name, project_name: nil)\n\nReturns a fully-qualified snapshot path in the form of\n`projects/{project_id}/snapshots/{snapshot_name}` \n**Parameters**\n\n- **snapshot_name** (String) --- A snapshot name.\n- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.\n\n### #subscriber\n\n def subscriber(subscription_name, project: nil, skip_lookup: nil) -\u003e Google::Cloud::PubSub::Subscriber, nil\n\nRetrieves a Subscriber by subscription name or full project path. \n**Parameters**\n\n- **subscription_name** (String) --- Name of a subscription. The value can be a simple subscription ID (relative name) or a fully-qualified subscription name.\n- **project** (String) *(defaults to: nil)* --- The alternate project ID can be specified here. Optional. Not used if a fully-qualified topic name is provided for `topic_name`.\n- **skip_lookup** (Boolean) *(defaults to: nil)* --- Optionally create a V1::Subscription object without verifying the subscription resource exists on the Pub/Sub service. Calls made on this object will raise errors if the service resource does not exist. Default is `false`. \n**Returns**\n\n- ([Google::Cloud::PubSub::Subscriber](./Google-Cloud-PubSub-Subscriber), nil) --- Returns `nil` if the subscription does not exist.\n\n### #subscription_admin\n\n def subscription_admin() -\u003e Google::Cloud::PubSub::SubscriptionAdmin::Client\n\nRetrieve a client for managing subscriptions. \n**Returns**\n\n- ([Google::Cloud::PubSub::SubscriptionAdmin::Client](./Google-Cloud-PubSub-SubscriptionAdmin-Client))\n\n### #subscription_path\n\n def subscription_path(subscription_name, project_name: nil)\n\nReturns a fully-qualified subscription path in the form of\n`projects/{project_id}/subscriptions/{subscription_name}` \n**Parameters**\n\n- **subscription_name** (String) --- A subscription name.\n- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.\n\n### #topic_admin\n\n def topic_admin() -\u003e Google::Cloud::PubSub::TopicAdmin::Client\n\nRetrieve a client for managing topics. \n**Returns**\n\n- ([Google::Cloud::PubSub::TopicAdmin::Client](./Google-Cloud-PubSub-TopicAdmin-Client))\n\n### #topic_path\n\n def topic_path(topic_name, project_name: nil)\n\nReturns a fully-qualified topic path in the form of\n`projects/{project_id}/topics/{topic_name}` \n**Parameters**\n\n- **topic_name** (String) --- A topic name.\n- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.\n\n### #universe_domain\n\n def universe_domain() -\u003e String\n\nThe universe domain the client is connected to \n**Returns**\n\n- (String)"]]