Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubsub: docs: correct links & add options.pushEndpoint #1745

Merged
merged 2 commits into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/pubsub/src/iam.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ util.inherits(IAM, common.GrpcService);
*
* @param {function} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request.
* @param {object} callback.policy - The [policy](https://cloud.google.com/pubsub/reference/rest/Shared.Types/Policy).
* @param {object} callback.policy - The [policy](https://cloud.google.com/pubsub/docs/reference/rest/Shared.Types/Policy).
* @param {object} callback.apiResponse - The full API response.
*
* @resource [Topics: getIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/getIamPolicy}
* @resource [Subscriptions: getIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/getIamPolicy}
* @resource [Topics: getIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/getIamPolicy}
* @resource [Subscriptions: getIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/getIamPolicy}
*
* @example
* topic.iam.getPolicy(function(err, policy, apiResponse) {});
Expand Down Expand Up @@ -126,7 +126,7 @@ IAM.prototype.getPolicy = function(callback) {
*
* @throws {Error} If no policy is provided.
*
* @param {object} policy - The [policy](https://cloud.google.com/pubsub/reference/rest/Shared.Types/Policy).
* @param {object} policy - The [policy](https://cloud.google.com/pubsub/docs/reference/rest/Shared.Types/Policy).
* @param {array=} policy.bindings - Bindings associate members with roles.
* @param {object[]=} policy.rules - Rules to be applied to the policy.
* @param {string=} policy.etag - Etags are used to perform a read-modify-write.
Expand All @@ -135,9 +135,9 @@ IAM.prototype.getPolicy = function(callback) {
* @param {object} callback.policy - The updated policy.
* @param {object} callback.apiResponse - The full API response.
*
* @resource [Topics: setIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/setIamPolicy}
* @resource [Subscriptions: setIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/setIamPolicy}
* @resource [Policy]{@link https://cloud.google.com/pubsub/reference/rest/Shared.Types/Policy}
* @resource [Topics: setIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/setIamPolicy}
* @resource [Subscriptions: setIamPolicy API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/setIamPolicy}
* @resource [Policy]{@link https://cloud.google.com/pubsub/docs/reference/rest/Shared.Types/Policy}
*
* @example
* var myPolicy = {
Expand Down Expand Up @@ -193,8 +193,8 @@ IAM.prototype.setPolicy = function(policy, callback) {
* is allowed
* @param {object} callback.apiResponse - The full API response.
*
* @resource [Topics: testIamPermissions API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/testIamPermissions}
* @resource [Subscriptions: testIamPermissions API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/testIamPermissions}
* @resource [Topics: testIamPermissions API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/testIamPermissions}
* @resource [Subscriptions: testIamPermissions API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/testIamPermissions}
* @resource [Permissions Reference]{@link https://cloud.google.com/pubsub/access_control#permissions}
*
* @example
Expand Down
25 changes: 15 additions & 10 deletions packages/pubsub/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ util.inherits(PubSub, common.GrpcService);
/**
* Create a topic with the given name.
*
* @resource [Topics: create API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/create}
* @resource [Topics: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/create}
*
* @param {string} name - Name of the topic.
* @param {function=} callback - The callback function.
Expand Down Expand Up @@ -145,7 +145,7 @@ PubSub.prototype.createTopic = function(name, callback) {
*
* To get subscriptions for a topic, see {module:pubsub/topic}.
*
* @resource [Subscriptions: list API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/list}
* @resource [Subscriptions: list API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/list}
*
* @param {object=} options - Configuration object.
* @param {boolean} options.autoPaginate - Have pagination handled
Expand Down Expand Up @@ -287,7 +287,7 @@ PubSub.prototype.getSubscriptionsStream =
* Get a list of the topics registered to your project. You may optionally
* provide a query object as the first argument to customize the response.
*
* @resource [Topics: list API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/list}
* @resource [Topics: list API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list}
*
* @param {object=} query - Query object.
* @param {boolean} options.autoPaginate - Have pagination handled
Expand Down Expand Up @@ -407,13 +407,9 @@ PubSub.prototype.getTopics = function(query, callback) {
PubSub.prototype.getTopicsStream = common.paginator.streamify('getTopics');

/**
* Create a subscription to a topic. You may optionally provide an object to
* customize the subscription.
* Create a subscription to a topic.
*
* Your provided callback will be invoked with an error object if an API error
* occurred or a {module:pubsub/subscription} object.
*
* @resource [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/create}
* @resource [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create}
*
* @throws {Error} If a Topic instance or topic name is not provided.
* @throws {Error} If a subName is not provided.
Expand All @@ -422,7 +418,7 @@ PubSub.prototype.getTopicsStream = common.paginator.streamify('getTopics');
* subscription to.
* @param {string} subName - The name of the subscription.
* @param {object=} options - See a
* [Subscription resource](https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions)
* [Subscription resource](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions)
* @param {number} options.ackDeadlineSeconds - The maximum time after receiving
* a message that you must ack a message before it is redelivered.
* @param {boolean} options.autoAck - Automatically acknowledge the message once
Expand All @@ -433,6 +429,8 @@ PubSub.prototype.getTopicsStream = common.paginator.streamify('getTopics');
* messages. (default: 10)
* @param {number} options.maxInProgress - Maximum messages to consume
* simultaneously.
* @param {string} options.pushEndpoint - A URL to a custom endpoint that
* messages should be pushed to.
* @param {boolean} options.reuseExisting - If the subscription already exists,
* reuse it. The options of the existing subscription are not changed. If
* false, attempting to create a subscription that already exists will fail.
Expand Down Expand Up @@ -504,10 +502,17 @@ PubSub.prototype.subscribe = function(topic, subName, options, callback) {
name: subscription.name
});

if (reqOpts.pushEndpoint) {
reqOpts.pushConfig = {
pushEndpoint: reqOpts.pushEndpoint
};
}

delete reqOpts.autoAck;
delete reqOpts.encoding;
delete reqOpts.interval;
delete reqOpts.maxInProgress;
delete reqOpts.pushEndpoint;
delete reqOpts.reuseExisting;
delete reqOpts.timeout;

Expand Down
10 changes: 5 additions & 5 deletions packages/pubsub/src/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function Subscription(pubsub, options) {
/**
* Get the metadata for the subscription.
*
* @resource [Subscriptions: get API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/get}
* @resource [Subscriptions: get API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/get}
*
* @param {function} callback - The callback function.
* @param {?error} callback.err - An error returned while making this
Expand Down Expand Up @@ -378,7 +378,7 @@ Subscription.formatName_ = function(projectId, name) {
* Acknowledge to the backend that the message was retrieved. You must provide
* either a single ackId or an array of ackIds.
*
* @resource [Subscriptions: acknowledge API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/acknowledge}
* @resource [Subscriptions: acknowledge API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/acknowledge}
*
* @throws {Error} If at least one ackId is not provided.
*
Expand Down Expand Up @@ -467,7 +467,7 @@ Subscription.prototype.decorateMessage_ = function(message) {
* Delete the subscription. Pull requests from the current subscription will be
* errored once unsubscription is complete.
*
* @resource [Subscriptions: delete API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/delete}
* @resource [Subscriptions: delete API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/delete}
*
* @param {function=} callback - The callback function.
* @param {?error} callback.err - An error returned while making this
Expand Down Expand Up @@ -522,7 +522,7 @@ Subscription.prototype.delete = function(callback) {
*
* @todo Should not be racing with other pull.
*
* @resource [Subscriptions: pull API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/pull}
* @resource [Subscriptions: pull API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull}
*
* @param {object=} options - Configuration object.
* @param {number} options.maxResults - Limit the amount of messages pulled.
Expand Down Expand Up @@ -634,7 +634,7 @@ Subscription.prototype.pull = function(options, callback) {
* to make the message available for redelivery if the processing was
* interrupted.
*
* @resource [Subscriptions: modifyAckDeadline API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/modifyAckDeadline}
* @resource [Subscriptions: modifyAckDeadline API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline}
*
* @param {object} options - The configuration object.
* @param {string|string[]} options.ackIds - The ack id(s) to change.
Expand Down
25 changes: 12 additions & 13 deletions packages/pubsub/src/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function Topic(pubsub, name) {
/**
* Delete the topic. This will not delete subscriptions to this topic.
*
* @resource [Topics: delete API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/delete}
* @resource [Topics: delete API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/delete}
*
* @param {function=} callback - The callback function.
*
Expand Down Expand Up @@ -150,7 +150,7 @@ function Topic(pubsub, name) {
/**
* Get the official representation of this topic from the API.
*
* @resource [Topics: get API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/get}
* @resource [Topics: get API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/get}
*
* @param {function} callback - The callback function.
* @param {?error} callback.err - An error returned while making this
Expand Down Expand Up @@ -266,7 +266,7 @@ Topic.formatName_ = function(projectId, name) {
* Your provided callback will be invoked with an error object if an API error
* occurred or an array of {module:pubsub/subscription} objects.
*
* @resource [Subscriptions: list API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics.subscriptions/list}
* @resource [Subscriptions: list API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics.subscriptions/list}
*
* @param {object=} options - Configuration object.
* @param {boolean} options.autoPaginate - Have pagination handled
Expand Down Expand Up @@ -359,7 +359,7 @@ Topic.prototype.getSubscriptionsStream = function(options) {
* Publish the provided message or array of messages. On success, an array of
* messageIds is returned in the response.
*
* @resource [Topics: publish API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/publish}
* @resource [Topics: publish API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/publish}
*
* @throws {Error} If no message is provided.
*
Expand Down Expand Up @@ -475,26 +475,25 @@ Topic.prototype.publish = function(messages, options, callback) {
};

/**
* Create a subscription to this topic. You may optionally provide an object to
* customize the subscription.
* Create a subscription to this topic.
*
* Your provided callback will be invoked with an error object if an API error
* occurred or a {module:pubsub/subscription} object.
*
* @resource [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/create}
* @resource [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create}
*
* @param {string} subName - The name of the subscription.
* @param {object=} options - Configuration object.
* @param {number=} options.ackDeadlineSeconds - The maximum time after
* @param {object=} options - See a
* [Subscription resource](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions)
* @param {number} options.ackDeadlineSeconds - The maximum time after
* receiving a message that you must ack a message before it is redelivered.
* @param {boolean=} options.autoAck - Automatically acknowledge the message
* once it's pulled. (default: false)
* @param {string} options.encoding - When pulling for messages, this type is
* used when converting a message's data to a string. (default: 'utf-8')
* @param {number=} options.interval - Interval in milliseconds to check for new
* @param {number} options.interval - Interval in milliseconds to check for new
* messages. (default: 10)
* @param {number} options.maxInProgress - Maximum messages to consume
* simultaneously.
* @param {string} options.pushEndpoint - A URL to a custom endpoint that
* messages should be pushed to.
* @param {boolean=} options.reuseExisting - If the subscription already exists,
* reuse it. The options of the existing subscription are not changed. If
* false, attempting to create a subscription that already exists will fail.
Expand Down
11 changes: 7 additions & 4 deletions packages/pubsub/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,22 +572,25 @@ describe('PubSub', function() {
encoding: 'utf-8',
interval: 3,
maxInProgress: 5,
pushConfig: {
pushEndpoint: 'https://domain/push'
},
pushEndpoint: 'https://domain/push',
reuseExisting: false,
timeout: 30000
};

var expectedBody = extend({
topic: TOPIC_NAME,
name: SUB_NAME
}, options);
}, options, {
pushConfig: {
pushEndpoint: options.pushEndpoint
}
});

delete expectedBody.autoAck;
delete expectedBody.encoding;
delete expectedBody.interval;
delete expectedBody.maxInProgress;
delete expectedBody.pushEndpoint;
delete expectedBody.reuseExisting;
delete expectedBody.timeout;

Expand Down