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

[CHANGE ME] Re-generated to pick up changes in the API or client library generator. #321

Closed
wants to merge 1 commit into from
Closed
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
92 changes: 92 additions & 0 deletions smoke-test/publisher_smoke_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('PublisherSmokeTest', () => {
if (!process.env.GCLOUD_PROJECT) {
throw new Error("Usage: GCLOUD_PROJECT=<project_id> node #{$0}");
}
const projectId = process.env.GCLOUD_PROJECT;

it('successfully makes a call to the service using promises', done => {
const pubsub = require('../src');

const client = new pubsub.v1.PublisherClient({
// optional auth parameters.
});

// Iterate over all elements.
const formattedProject = client.projectPath(projectId);

client.listTopics({project: formattedProject})
.then(responses => {
const resources = responses[0];
for (let i = 0; i < resources.length; i += 1) {
console.log(resources[i]);
}
})
.then(done)
.catch(done);
});

it('successfully makes a call to the service using callbacks', done => {
const pubsub = require('../src');

const client = new pubsub.v1.PublisherClient({
// optional auth parameters.
});

// Or obtain the paged response.
const formattedProject = client.projectPath(projectId);


const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (let i = 0; i < resources.length; i += 1) {
console.log(resources[i]);
}
if (nextRequest) {
// Fetch the next page.
return client.listTopics(nextRequest, options).then(callback);
}
}
client.listTopics({project: formattedProject}, options)
.then(callback)
.then(done)
.catch(done);
});

it('successfully makes a call to the service using streaming', done => {
const pubsub = require('../src');

const client = new pubsub.v1.PublisherClient({
// optional auth parameters.
});

const formattedProject = client.projectPath(projectId);
client.listTopicsStream({project: formattedProject})
.on('data', element => {
console.log(element);
})
.on('error', done)
.on('end', done);
});
});
58 changes: 25 additions & 33 deletions src/v1/publisher_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class PublisherClient {
topicPathTemplate: new gax.PathTemplate(
'projects/{project}/topics/{topic}'
),
projectPathTemplate: new gax.PathTemplate('projects/{project}'),
projectPathTemplate: new gax.PathTemplate(
'projects/{project}'
),
};

// Some of the methods on this service return "paged" results,
Expand All @@ -129,36 +131,25 @@ class PublisherClient {
};
let protoFilesRoot = new gax.GoogleProtoFilesRoot();
protoFilesRoot = protobuf.loadSync(
path.join(
__dirname,
'..',
'..',
'protos',
'google/iam/v1/iam_policy.proto'
),
path.join(__dirname, '..', '..', 'protos', 'google/iam/v1/iam_policy.proto'),
protoFilesRoot
);
protoFilesRoot = protobuf.loadSync(
path.join(
__dirname,
'..',
'..',
'protos',
'google/pubsub/v1/pubsub.proto'
),
path.join(__dirname, '..', '..', 'protos', 'google/pubsub/v1/pubsub.proto'),
protoFilesRoot
);


// Some methods on this API support automatically batching
// requests; denote this.
this._descriptors.batching = {
publish: new gax.BundleDescriptor(
'messages',
['topic'],
[
'topic',
],
'messageIds',
gax.createByteLengthFunction(
protoFilesRoot.lookup('google.pubsub.v1.PubsubMessage')
)
gax.createByteLengthFunction(protoFilesRoot.lookup('google.pubsub.v1.PubsubMessage'))
),
};

Expand Down Expand Up @@ -199,8 +190,7 @@ class PublisherClient {
}
),
defaults[methodName],
this._descriptors.page[methodName] ||
this._descriptors.batching[methodName]
this._descriptors.page[methodName] || this._descriptors.batching[methodName]
);
}

Expand Down Expand Up @@ -232,8 +222,7 @@ class PublisherClient {
}
),
defaults[methodName],
this._descriptors.page[methodName] ||
this._descriptors.batching[methodName]
this._descriptors.page[methodName] || this._descriptors.batching[methodName]
);
}
}
Expand Down Expand Up @@ -658,7 +647,7 @@ class PublisherClient {
request,
options
);
}
};

/**
* Lists the names of the subscriptions on this topic.
Expand Down Expand Up @@ -752,11 +741,7 @@ class PublisherClient {
}
options = options || {};

return this._innerApiCalls.listTopicSubscriptions(
request,
options,
callback
);
return this._innerApiCalls.listTopicSubscriptions(request, options, callback);
}

/**
Expand Down Expand Up @@ -813,7 +798,7 @@ class PublisherClient {
request,
options
);
}
};

/**
* Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
Expand Down Expand Up @@ -1067,7 +1052,9 @@ class PublisherClient {
* @returns {String} - A string representing the project.
*/
matchProjectFromTopicName(topicName) {
return this._pathTemplates.topicPathTemplate.match(topicName).project;
return this._pathTemplates.topicPathTemplate
.match(topicName)
.project;
}

/**
Expand All @@ -1078,7 +1065,9 @@ class PublisherClient {
* @returns {String} - A string representing the topic.
*/
matchTopicFromTopicName(topicName) {
return this._pathTemplates.topicPathTemplate.match(topicName).topic;
return this._pathTemplates.topicPathTemplate
.match(topicName)
.topic;
}

/**
Expand All @@ -1089,8 +1078,11 @@ class PublisherClient {
* @returns {String} - A string representing the project.
*/
matchProjectFromProjectName(projectName) {
return this._pathTemplates.projectPathTemplate.match(projectName).project;
return this._pathTemplates.projectPathTemplate
.match(projectName)
.project;
}
}


module.exports = PublisherClient;
4 changes: 0 additions & 4 deletions src/v1/publisher_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"http_get": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": [],
"one_plus_delivery": [
"ABORTED",
Expand Down
40 changes: 26 additions & 14 deletions src/v1/subscriber_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ class SubscriberClient {
topicPathTemplate: new gax.PathTemplate(
'projects/{project}/topics/{topic}'
),
projectPathTemplate: new gax.PathTemplate('projects/{project}'),
projectPathTemplate: new gax.PathTemplate(
'projects/{project}'
),
snapshotPathTemplate: new gax.PathTemplate(
'projects/{project}/snapshots/{snapshot}'
),
Expand Down Expand Up @@ -177,8 +179,7 @@ class SubscriberClient {
}
),
defaults[methodName],
this._descriptors.page[methodName] ||
this._descriptors.stream[methodName]
this._descriptors.page[methodName] || this._descriptors.stream[methodName]
);
}

Expand Down Expand Up @@ -218,8 +219,7 @@ class SubscriberClient {
}
),
defaults[methodName],
this._descriptors.page[methodName] ||
this._descriptors.stream[methodName]
this._descriptors.page[methodName] || this._descriptors.stream[methodName]
);
}

Expand Down Expand Up @@ -664,7 +664,7 @@ class SubscriberClient {
request,
options
);
}
};

/**
* Deletes an existing subscription. All messages retained in the subscription
Expand Down Expand Up @@ -1137,7 +1137,7 @@ class SubscriberClient {
request,
options
);
}
};

/**
* Creates a snapshot from the requested subscription.<br><br>
Expand Down Expand Up @@ -1644,7 +1644,8 @@ class SubscriberClient {
* @returns {String} - A string representing the project.
*/
matchProjectFromSubscriptionName(subscriptionName) {
return this._pathTemplates.subscriptionPathTemplate.match(subscriptionName)
return this._pathTemplates.subscriptionPathTemplate
.match(subscriptionName)
.project;
}

Expand All @@ -1656,7 +1657,8 @@ class SubscriberClient {
* @returns {String} - A string representing the subscription.
*/
matchSubscriptionFromSubscriptionName(subscriptionName) {
return this._pathTemplates.subscriptionPathTemplate.match(subscriptionName)
return this._pathTemplates.subscriptionPathTemplate
.match(subscriptionName)
.subscription;
}

Expand All @@ -1668,7 +1670,9 @@ class SubscriberClient {
* @returns {String} - A string representing the project.
*/
matchProjectFromTopicName(topicName) {
return this._pathTemplates.topicPathTemplate.match(topicName).project;
return this._pathTemplates.topicPathTemplate
.match(topicName)
.project;
}

/**
Expand All @@ -1679,7 +1683,9 @@ class SubscriberClient {
* @returns {String} - A string representing the topic.
*/
matchTopicFromTopicName(topicName) {
return this._pathTemplates.topicPathTemplate.match(topicName).topic;
return this._pathTemplates.topicPathTemplate
.match(topicName)
.topic;
}

/**
Expand All @@ -1690,7 +1696,9 @@ class SubscriberClient {
* @returns {String} - A string representing the project.
*/
matchProjectFromProjectName(projectName) {
return this._pathTemplates.projectPathTemplate.match(projectName).project;
return this._pathTemplates.projectPathTemplate
.match(projectName)
.project;
}

/**
Expand All @@ -1701,7 +1709,9 @@ class SubscriberClient {
* @returns {String} - A string representing the project.
*/
matchProjectFromSnapshotName(snapshotName) {
return this._pathTemplates.snapshotPathTemplate.match(snapshotName).project;
return this._pathTemplates.snapshotPathTemplate
.match(snapshotName)
.project;
}

/**
Expand All @@ -1712,9 +1722,11 @@ class SubscriberClient {
* @returns {String} - A string representing the snapshot.
*/
matchSnapshotFromSnapshotName(snapshotName) {
return this._pathTemplates.snapshotPathTemplate.match(snapshotName)
return this._pathTemplates.snapshotPathTemplate
.match(snapshotName)
.snapshot;
}
}


module.exports = SubscriberClient;
4 changes: 0 additions & 4 deletions src/v1/subscriber_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"RESOURCE_EXHAUSTED",
"UNAVAILABLE"
],
"http_get": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": []
},
"retry_params": {
Expand Down
Loading