@@ -7,28 +7,31 @@ public protocol TopicsAPI {
77 /// Gets the configuration of a topic.
88 ///
99 /// - parameter `topicId`: Name of the topic
10+ /// `topicProject`: Name of the project that owns the topic. If not provided, the default project will be used.
1011 /// - returns: If successful, the response body contains an instance of `Topic`.
11- func get( topicId: String ) -> EventLoopFuture < GoogleCloudPubSubTopic >
12+ func get( topicId: String , topicProject : String ? ) -> EventLoopFuture < GoogleCloudPubSubTopic >
1213
1314 /// Lists matching topics.
1415 ///
1516 /// - parameter `pageSize`: Maximum number of topics to return.
1617 /// `pageToken`: The value returned by the last ListTopicsResponse; indicates that this is a
1718 /// continuation of a prior topics.list call, and that the system should return the next page of data
19+ /// `topicProject`: Name of the project that owns the topic. If not provided, the default project will be used.
1820 /// - returns: Returns a list of topics and the `nextPageToken`
19- func list( pageSize: Int ? , pageToken: String ? ) -> EventLoopFuture < GooglePubSubListTopicResponse >
21+ func list( pageSize: Int ? , pageToken: String ? , topicProject : String ? ) -> EventLoopFuture < GooglePubSubListTopicResponse >
2022
2123 /// Adds one or more messages to the topic.
2224 ///
23- /// - parameter `topidId`: Name of the topic
25+ /// - parameter `topicId`: Name of the topic
26+ /// `topicProject`: Name of the project that owns the topic. If not provided, the default project will be used.
2427 /// `data`: Data to be passed in the message
2528 /// `attributes`: Attributes for this message
2629 /// `orderingKey`: Identifies related messages for which publish order should be respected
2730 /// - returns: Returns an array of `messageId`. `MessageId` is the server-assigned ID of each published message, in the same order as the messages in the request. IDs are guaranteed to be unique within the topic.
28- func publish( topicId: String , data: String , attributes: [ String : String ] ? , orderingKey: String ? ) -> EventLoopFuture < GoogleCloudPublishResponse >
31+ func publish( topicId: String , topicProject : String ? , data: String , attributes: [ String : String ] ? , orderingKey: String ? ) -> EventLoopFuture < GoogleCloudPublishResponse >
2932
3033 /// Lists the names of the attached subscriptions on this topic.
31- func getSubscriptionsList( topicId: String , pageSize: Int ? , pageToken: String ? ) -> EventLoopFuture < GooglePubSubTopicSubscriptionListResponse >
34+ func getSubscriptionsList( topicId: String , topicProject : String ? , pageSize: Int ? , pageToken: String ? ) -> EventLoopFuture < GooglePubSubTopicSubscriptionListResponse >
3235}
3336
3437public final class GoogleCloudPubSubTopicsAPI : TopicsAPI {
@@ -42,27 +45,27 @@ public final class GoogleCloudPubSubTopicsAPI: TopicsAPI {
4245 self . endpoint = endpoint
4346 }
4447
45- public func get( topicId: String ) -> EventLoopFuture < GoogleCloudPubSubTopic > {
46- return request. send ( method: . GET, path: " \( endpoint) /v1/projects/ \( request. project) /topics/ \( topicId) " )
48+ public func get( topicId: String , topicProject : String ? = nil ) -> EventLoopFuture < GoogleCloudPubSubTopic > {
49+ return request. send ( method: . GET, path: " \( endpoint) /v1/projects/ \( topicProject ?? request. project) /topics/ \( topicId) " )
4750 }
4851
49- public func list( pageSize: Int ? , pageToken: String ? ) -> EventLoopFuture < GooglePubSubListTopicResponse > {
52+ public func list( pageSize: Int ? , pageToken: String ? , topicProject : String ? = nil ) -> EventLoopFuture < GooglePubSubListTopicResponse > {
5053 var query = " pageSize= \( pageSize ?? 10 ) "
5154 if let pageToken = pageToken {
5255 query. append ( contentsOf: " &pageToken= \( pageToken) " )
5356 }
5457
5558 return request. send ( method: . GET,
56- path: " \( endpoint) /v1/projects/ \( request. project) /topics " ,
59+ path: " \( endpoint) /v1/projects/ \( topicProject ?? request. project) /topics " ,
5760 query: query)
5861 }
5962
60- public func publish( topicId: String , data: String , attributes: [ String : String ] ? , orderingKey: String ? ) -> EventLoopFuture < GoogleCloudPublishResponse > {
63+ public func publish( topicId: String , topicProject : String ? = nil , data: String , attributes: [ String : String ] ? , orderingKey: String ? ) -> EventLoopFuture < GoogleCloudPublishResponse > {
6164 do {
6265 let message = GoogleCloudPubSubMessage ( data: data, attributes: attributes, orderingKey: orderingKey)
6366 let publishRequest = GoogleCloudPublishRequest ( messages: [ message] )
6467 let body = try HTTPClient . Body. data ( encoder. encode ( publishRequest) )
65- let path = " \( endpoint) /v1/projects/ \( request. project) /topics/ \( topicId) :publish "
68+ let path = " \( endpoint) /v1/projects/ \( topicProject ?? request. project) /topics/ \( topicId) :publish "
6669
6770 print ( " <<<--- Publish on: \( path) ---> " )
6871
@@ -74,14 +77,14 @@ public final class GoogleCloudPubSubTopicsAPI: TopicsAPI {
7477 }
7578 }
7679
77- public func getSubscriptionsList( topicId: String , pageSize: Int ? , pageToken: String ? ) -> EventLoopFuture < GooglePubSubTopicSubscriptionListResponse > {
80+ public func getSubscriptionsList( topicId: String , topicProject : String ? = nil , pageSize: Int ? , pageToken: String ? ) -> EventLoopFuture < GooglePubSubTopicSubscriptionListResponse > {
7881 var query = " pageSize= \( pageSize ?? 10 ) "
7982 if let pageToken = pageToken {
8083 query. append ( contentsOf: " &pageToken= \( pageToken) " )
8184 }
8285
8386 return request. send ( method: . GET,
84- path: " \( endpoint) /v1/projects/ \( request. project) /topics/subscriptions " ,
87+ path: " \( endpoint) /v1/projects/ \( topicProject ?? request. project) /topics/subscriptions " ,
8588 query: query)
8689 }
8790}
0 commit comments