# Google Cloud Pub/Sub API . projects . subscriptions

## Instance Methods

Acknowledges the messages associated with the ack tokens in the AcknowledgeRequest. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.

Creates a subscription to a given topic for a given subscriber. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic.

Deletes an existing subscription. All pending messages in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription, or its topic unless the same topic is specified.

Gets the configuration details of a subscription.

Lists matching subscriptions.

Retrieves the next page of results.

Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted.

Modifies the PushConfig for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty PushConfig) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the PushConfig.

Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return UNAVAILABLE if there are too many concurrent pull requests pending for the given subscription.

### Method Details

`acknowledge(subscription, body)`

    Acknowledges the messages associated with the ack tokens in the AcknowledgeRequest. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.

    Args:
      subscription: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
        "ackIds": [
          "A String",
        ],
      }

    Returns:
      An object of the form:

        {
      }

`create(name, body)`

    Creates a subscription to a given topic for a given subscriber. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic.

    Args:
      name: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
      "ackDeadlineSeconds": 42,
      "topic": "A String",
      "pushConfig": {
        "attributes": {
          "a_key": "A String",
        },
        "pushEndpoint": "A String",
      },
      "name": "A String",
    }

    Returns:
      An object of the form:

        {
        "ackDeadlineSeconds": 42,
        "topic": "A String",
        "pushConfig": {
          "attributes": {
            "a_key": "A String",
          },
          "pushEndpoint": "A String",
        },
        "name": "A String",
      }

`delete(subscription)`

    Deletes an existing subscription. All pending messages in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription, or its topic unless the same topic is specified.

    Args:
      subscription: string, A parameter (required)

    Returns:
      An object of the form:

        {
      }

`get(subscription)`

    Gets the configuration details of a subscription.

    Args:
      subscription: string, A parameter (required)

    Returns:
      An object of the form:

        {
        "ackDeadlineSeconds": 42,
        "topic": "A String",
        "pushConfig": {
          "attributes": {
            "a_key": "A String",
          },
          "pushEndpoint": "A String",
        },
        "name": "A String",
      }

`list(project, pageSize=None, pageToken=None)`

    Lists matching subscriptions.

    Args:
      project: string, A parameter (required)
      pageSize: integer, A parameter
      pageToken: string, A parameter

    Returns:
      An object of the form:

        {
        "nextPageToken": "A String",
        "subscriptions": [
          {
            "ackDeadlineSeconds": 42,
            "topic": "A String",
            "pushConfig": {
              "attributes": {
                "a_key": "A String",
              },
              "pushEndpoint": "A String",
            },
            "name": "A String",
          },
        ],
      }

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

`modifyAckDeadline(subscription, body)`

    Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted.

    Args:
      subscription: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
        "ackDeadlineSeconds": 42,
        "ackId": "A String",
      }

    Returns:
      An object of the form:

        {
      }

`modifyPushConfig(subscription, body)`

    Modifies the PushConfig for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty PushConfig) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the PushConfig.

    Args:
      subscription: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
        "pushConfig": {
          "attributes": {
            "a_key": "A String",
          },
          "pushEndpoint": "A String",
        },
      }

    Returns:
      An object of the form:

        {
      }

`pull(subscription, body)`

    Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return UNAVAILABLE if there are too many concurrent pull requests pending for the given subscription.

    Args:
      subscription: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
        "returnImmediately": True or False,
        "maxMessages": 42,
      }

    Returns:
      An object of the form:

        {
        "receivedMessages": [
          {
            "ackId": "A String",
            "message": {
              "attributes": {
                "a_key": "A String",
              },
              "data": "A String",
              "messageId": "A String",
            },
          },
        ],
      }