# Cloud Pub/Sub API - Class Google::Cloud::PubSub::Project (v3.3.0)

3.3.0 (latest) 3.2.1 3.1.1 3.0.3 2.23.0 2.22.0 2.21.0 2.20.0 2.19.0 2.18.1 2.17.0 2.16.0 2.15.5 2.14.0 2.12.1 2.11.0 2.10.0 2.9.2 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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Publisher "Google::Cloud::PubSub::Publisher (class)").
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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Subscriber "Google::Cloud::PubSub::Subscriber (class)"). [Message](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Message "Google::Cloud::PubSub::Message (class)") is a combination of data and
attributes that a publisher sends to a topic and is eventually delivered
to subscribers.

See [Google::Cloud#pubsub](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud#Google__Cloud_pubsub_instance_ "Google::Cloud#pubsub (method)")

## Inherits

- Object

## Example

```ruby
require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new

publisher = pubsub.publisher "my-topic"
publisher.publish "task completed"
```

## Methods

### #iam

    def iam() -> Google::Iam::V1::IAMPolicy::Client

Retrieve a client specific for Iam Policy related functions.
**Returns**

- (Google::Iam::V1::IAMPolicy::Client)

### #project

    def project()

**Alias Of** : [#project_id](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Project#Google__Cloud__PubSub__Project_project_id_instance_) The Pub/Sub project connected to.
**Example**

```ruby
require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new(
  project_id: "my-project",
  credentials: "/path/to/keyfile.json"
)

pubsub.project_id #=> "my-project"
```

### #project_id

    def project_id()

**Aliases**

- [#project](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Project#Google__Cloud__PubSub__Project_project_instance_)
The Pub/Sub project connected to.
**Example**

```ruby
require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new(
  project_id: "my-project",
  credentials: "/path/to/keyfile.json"
)

pubsub.project_id #=> "my-project"
```

### #project_path

    def project_path(project_name: nil)

Returns a fully-qualified project path in the form of
`projects/{project_id}`
**Parameter**

- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.

### #publisher

    def publisher(topic_name, project: nil, async: nil, skip_lookup: nil) -> Google::Cloud::PubSub::Publisher

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`.
- **async** (Hash) *(defaults to: nil)* --- A hash of values to configure the topic's [AsyncPublisher](https://docs.cloud.google.com/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](https://docs.cloud.google.com/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.
- **skip_lookup** (Boolean) *(defaults to: nil)* --- Optionally create a [Publisher](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Publisher "Google::Cloud::PubSub::Publisher (class)") object without verifying the topic 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`.
**Returns**

- ([Google::Cloud::PubSub::Publisher](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Publisher))

### #schema_path

    def schema_path(schema_name, project_name: nil)

Returns a fully-qualified schema path in the form of
`projects/{project_id}/schemas/{schema_name}`
**Parameters**

- **schema_name** (String) --- A schema name.
- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.

### #schemas

    def schemas() -> Google::Cloud::PubSub::V1::SchemaService::Client

Retrieve a client for managing schemas.
**Returns**

- (Google::Cloud::PubSub::V1::SchemaService::Client)

### #snapshot_path

    def snapshot_path(snapshot_name, project_name: nil)

Returns a fully-qualified snapshot path in the form of
`projects/{project_id}/snapshots/{snapshot_name}`
**Parameters**

- **snapshot_name** (String) --- A snapshot name.
- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.

### #subscriber

    def subscriber(subscription_name, project: nil, skip_lookup: nil) -> Google::Cloud::PubSub::Subscriber, nil

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`.
**Returns**

- ([Google::Cloud::PubSub::Subscriber](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-Subscriber), nil) --- Returns `nil` if the subscription does not exist.

### #subscription_admin

    def subscription_admin() -> Google::Cloud::PubSub::SubscriptionAdmin::Client

Retrieve a client for managing subscriptions.
**Returns**

- ([Google::Cloud::PubSub::SubscriptionAdmin::Client](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-SubscriptionAdmin-Client))

### #subscription_path

    def subscription_path(subscription_name, project_name: nil)

Returns a fully-qualified subscription path in the form of
`projects/{project_id}/subscriptions/{subscription_name}`
**Parameters**

- **subscription_name** (String) --- A subscription name.
- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.

### #topic_admin

    def topic_admin() -> Google::Cloud::PubSub::TopicAdmin::Client

Retrieve a client for managing topics.
**Returns**

- ([Google::Cloud::PubSub::TopicAdmin::Client](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-TopicAdmin-Client))

### #topic_path

    def topic_path(topic_name, project_name: nil)

Returns a fully-qualified topic path in the form of
`projects/{project_id}/topics/{topic_name}`
**Parameters**

- **topic_name** (String) --- A topic name.
- **project_name** (String) *(defaults to: nil)* --- A project name. Optional. If provided, this will be used in place of the default `project_id`.

### #universe_domain

    def universe_domain() -> String

The universe domain the client is connected to
**Returns**

- (String)