# Cloud Pub/Sub API . topics

## Instance Methods

Creates the given topic with the given name.

Deletes the topic with the given name. All subscriptions to this topic are also deleted. Returns NOT_FOUND if the topic does not exist. After a topic is deleted, a new topic may be created with the same name.

Gets the configuration of a topic. Since the topic only has the name attribute, this method is only useful to check the existence of a topic. If other attributes are added in the future, they will be returned here.

Lists matching topics.

Retrieves the next page of results.

Adds a message to the topic. Returns NOT_FOUND if the topic does not exist.

### Method Details

`create(body)`

    Creates the given topic with the given name.

    Args:
      body: object, The request body. (required)
        The object takes the form of:

    { # A topic resource.
        "name": "A String", # Name of the topic.
      }

    Returns:
      An object of the form:

        { # A topic resource.
          "name": "A String", # Name of the topic.
        }

`delete(topic)`

    Deletes the topic with the given name. All subscriptions to this topic are also deleted. Returns NOT_FOUND if the topic does not exist. After a topic is deleted, a new topic may be created with the same name.

    Args:
      topic: string, Name of the topic to delete. (required)

`get(topic)`

    Gets the configuration of a topic. Since the topic only has the name attribute, this method is only useful to check the existence of a topic. If other attributes are added in the future, they will be returned here.

    Args:
      topic: string, The name of the topic to get. (required)

    Returns:
      An object of the form:

        { # A topic resource.
          "name": "A String", # Name of the topic.
        }

`list(pageToken=None, maxResults=None, query=None)`

    Lists matching topics.

    Args:
      pageToken: string, The value obtained in the last ListTopicsResponse for continuation.
      maxResults: integer, Maximum number of topics to return.
      query: string, A valid label query expression.

    Returns:
      An object of the form:

        {
        "nextPageToken": "A String", # If not empty, indicates that there are more topics that match the request, and this value should be passed to the next ListTopicsRequest to continue.
        "topic": [ # The resulting topics.
          { # A topic resource.
              "name": "A String", # Name of the topic.
            },
        ],
      }

`list_next(previous_request, previous_response)`

    Retrieves the next page of results.

    Args:
      previous_request: The request for the previous page. (required)
      previous_response: The response from the request for the previous page. (required)

    Returns:
      A request object that you can call 'execute()' on to request the next
      page. Returns None if there are no more items in the collection.

`publish(body)`

    Adds a message to the topic. Returns NOT_FOUND if the topic does not exist.

    Args:
      body: object, The request body. (required)
        The object takes the form of:

    {
        "topic": "A String", # The name of the topic for which the message is being added.
        "message": { # A message data and its labels. # The message to publish.
          "data": "A String", # The message payload.
          "label": [ # Optional list of labels for this message. Keys in this collection must be unique.
            { # A key-value pair applied to a given object.
              "numValue": "A String", # An integer value.
              "strValue": "A String", # A string value.
              "key": "A String", # The key of a label is a syntactically valid URL (as per RFC 1738) with the "scheme" and initial slashes omitted and with the additional restrictions noted below. Each key should be globally unique. The "host" portion is called the "namespace" and is not necessarily resolvable to a network endpoint. Instead, the namespace indicates what system or entity defines the semantics of the label. Namespaces do not restrict the set of objects to which a label may be associated.
                  #
                  # Keys are defined by the following grammar:
                  #
                  # key = hostname "/" kpath kpath = ksegment *[ "/" ksegment ] ksegment = alphadigit | *[ alphadigit | "-" | "_" | "." ]
                  #
                  # where "hostname" and "alphadigit" are defined as in RFC 1738.
                  #
                  # Example key: spanner.google.com/universe
            },
          ],
        },
      }