sfprotostash 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sfprotostash"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Pre-generated Salesforce Pub/Sub API gRPC stubs"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"grpcio",
|
|
12
|
+
"protobuf",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[tool.hatch.build.targets.wheel]
|
|
16
|
+
packages = ["src/sfprotostash"]
|
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: pubsub_api.proto
|
|
5
|
+
# Protobuf Python Version: 6.33.5
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
6,
|
|
15
|
+
33,
|
|
16
|
+
5,
|
|
17
|
+
'',
|
|
18
|
+
'pubsub_api.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10pubsub_api.proto\x12\x0b\x65ventbus.v1\"\x83\x01\n\tTopicInfo\x12\x12\n\ntopic_name\x18\x01 \x01(\t\x12\x13\n\x0btenant_guid\x18\x02 \x01(\t\x12\x13\n\x0b\x63\x61n_publish\x18\x03 \x01(\x08\x12\x15\n\rcan_subscribe\x18\x04 \x01(\x08\x12\x11\n\tschema_id\x18\x05 \x01(\t\x12\x0e\n\x06rpc_id\x18\x06 \x01(\t\"\"\n\x0cTopicRequest\x12\x12\n\ntopic_name\x18\x01 \x01(\t\")\n\x0b\x45ventHeader\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"j\n\rProducerEvent\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tschema_id\x18\x02 \x01(\t\x12\x0f\n\x07payload\x18\x03 \x01(\x0c\x12)\n\x07headers\x18\x04 \x03(\x0b\x32\x18.eventbus.v1.EventHeader\"M\n\rConsumerEvent\x12)\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x1a.eventbus.v1.ProducerEvent\x12\x11\n\treplay_id\x18\x02 \x01(\x0c\"^\n\rPublishResult\x12\x11\n\treplay_id\x18\x01 \x01(\x0c\x12!\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x12.eventbus.v1.Error\x12\x17\n\x0f\x63orrelation_key\x18\x03 \x01(\t\":\n\x05\x45rror\x12$\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x16.eventbus.v1.ErrorCode\x12\x0b\n\x03msg\x18\x02 \x01(\t\"\x94\x01\n\x0c\x46\x65tchRequest\x12\x12\n\ntopic_name\x18\x01 \x01(\t\x12\x30\n\rreplay_preset\x18\x02 \x01(\x0e\x32\x19.eventbus.v1.ReplayPreset\x12\x11\n\treplay_id\x18\x03 \x01(\x0c\x12\x15\n\rnum_requested\x18\x04 \x01(\x05\x12\x14\n\x0c\x61uth_refresh\x18\x05 \x01(\t\"\x84\x01\n\rFetchResponse\x12*\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x1a.eventbus.v1.ConsumerEvent\x12\x18\n\x10latest_replay_id\x18\x02 \x01(\x0c\x12\x0e\n\x06rpc_id\x18\x03 \x01(\t\x12\x1d\n\x15pending_num_requested\x18\x04 \x01(\x05\"\"\n\rSchemaRequest\x12\x11\n\tschema_id\x18\x01 \x01(\t\"D\n\nSchemaInfo\x12\x13\n\x0bschema_json\x18\x01 \x01(\t\x12\x11\n\tschema_id\x18\x02 \x01(\t\x12\x0e\n\x06rpc_id\x18\x03 \x01(\t\"f\n\x0ePublishRequest\x12\x12\n\ntopic_name\x18\x01 \x01(\t\x12*\n\x06\x65vents\x18\x02 \x03(\x0b\x32\x1a.eventbus.v1.ProducerEvent\x12\x14\n\x0c\x61uth_refresh\x18\x03 \x01(\t\"a\n\x0fPublishResponse\x12+\n\x07results\x18\x01 \x03(\x0b\x32\x1a.eventbus.v1.PublishResult\x12\x11\n\tschema_id\x18\x02 \x01(\t\x12\x0e\n\x06rpc_id\x18\x03 \x01(\t\"\xb7\x01\n\x13ManagedFetchRequest\x12\x17\n\x0fsubscription_id\x18\x01 \x01(\t\x12\x16\n\x0e\x64\x65veloper_name\x18\x02 \x01(\t\x12\x15\n\rnum_requested\x18\x03 \x01(\x05\x12\x14\n\x0c\x61uth_refresh\x18\x04 \x01(\t\x12\x42\n\x18\x63ommit_replay_id_request\x18\x05 \x01(\x0b\x32 .eventbus.v1.CommitReplayRequest\"\xc7\x01\n\x14ManagedFetchResponse\x12*\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x1a.eventbus.v1.ConsumerEvent\x12\x18\n\x10latest_replay_id\x18\x02 \x01(\x0c\x12\x0e\n\x06rpc_id\x18\x03 \x01(\t\x12\x1d\n\x15pending_num_requested\x18\x04 \x01(\x05\x12:\n\x0f\x63ommit_response\x18\x05 \x01(\x0b\x32!.eventbus.v1.CommitReplayResponse\"C\n\x13\x43ommitReplayRequest\x12\x19\n\x11\x63ommit_request_id\x18\x01 \x01(\t\x12\x11\n\treplay_id\x18\x02 \x01(\x0c\"}\n\x14\x43ommitReplayResponse\x12\x19\n\x11\x63ommit_request_id\x18\x01 \x01(\t\x12\x11\n\treplay_id\x18\x02 \x01(\x0c\x12!\n\x05\x65rror\x18\x03 \x01(\x0b\x32\x12.eventbus.v1.Error\x12\x14\n\x0cprocess_time\x18\x04 \x01(\x03*1\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0b\n\x07PUBLISH\x10\x01\x12\n\n\x06\x43OMMIT\x10\x02*4\n\x0cReplayPreset\x12\n\n\x06LATEST\x10\x00\x12\x0c\n\x08\x45\x41RLIEST\x10\x01\x12\n\n\x06\x43USTOM\x10\x02\x32\xc4\x03\n\x06PubSub\x12\x46\n\tSubscribe\x12\x19.eventbus.v1.FetchRequest\x1a\x1a.eventbus.v1.FetchResponse(\x01\x30\x01\x12@\n\tGetSchema\x12\x1a.eventbus.v1.SchemaRequest\x1a\x17.eventbus.v1.SchemaInfo\x12=\n\x08GetTopic\x12\x19.eventbus.v1.TopicRequest\x1a\x16.eventbus.v1.TopicInfo\x12\x44\n\x07Publish\x12\x1b.eventbus.v1.PublishRequest\x1a\x1c.eventbus.v1.PublishResponse\x12N\n\rPublishStream\x12\x1b.eventbus.v1.PublishRequest\x1a\x1c.eventbus.v1.PublishResponse(\x01\x30\x01\x12[\n\x10ManagedSubscribe\x12 .eventbus.v1.ManagedFetchRequest\x1a!.eventbus.v1.ManagedFetchResponse(\x01\x30\x01\x42\x61\n com.salesforce.eventbus.protobufB\x0bPubSubProtoP\x01Z.github.com/developerforce/pub-sub-api/go/protob\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'pubsub_api_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
|
34
|
+
_globals['DESCRIPTOR']._serialized_options = b'\n com.salesforce.eventbus.protobufB\013PubSubProtoP\001Z.github.com/developerforce/pub-sub-api/go/proto'
|
|
35
|
+
_globals['_ERRORCODE']._serialized_start=1768
|
|
36
|
+
_globals['_ERRORCODE']._serialized_end=1817
|
|
37
|
+
_globals['_REPLAYPRESET']._serialized_start=1819
|
|
38
|
+
_globals['_REPLAYPRESET']._serialized_end=1871
|
|
39
|
+
_globals['_TOPICINFO']._serialized_start=34
|
|
40
|
+
_globals['_TOPICINFO']._serialized_end=165
|
|
41
|
+
_globals['_TOPICREQUEST']._serialized_start=167
|
|
42
|
+
_globals['_TOPICREQUEST']._serialized_end=201
|
|
43
|
+
_globals['_EVENTHEADER']._serialized_start=203
|
|
44
|
+
_globals['_EVENTHEADER']._serialized_end=244
|
|
45
|
+
_globals['_PRODUCEREVENT']._serialized_start=246
|
|
46
|
+
_globals['_PRODUCEREVENT']._serialized_end=352
|
|
47
|
+
_globals['_CONSUMEREVENT']._serialized_start=354
|
|
48
|
+
_globals['_CONSUMEREVENT']._serialized_end=431
|
|
49
|
+
_globals['_PUBLISHRESULT']._serialized_start=433
|
|
50
|
+
_globals['_PUBLISHRESULT']._serialized_end=527
|
|
51
|
+
_globals['_ERROR']._serialized_start=529
|
|
52
|
+
_globals['_ERROR']._serialized_end=587
|
|
53
|
+
_globals['_FETCHREQUEST']._serialized_start=590
|
|
54
|
+
_globals['_FETCHREQUEST']._serialized_end=738
|
|
55
|
+
_globals['_FETCHRESPONSE']._serialized_start=741
|
|
56
|
+
_globals['_FETCHRESPONSE']._serialized_end=873
|
|
57
|
+
_globals['_SCHEMAREQUEST']._serialized_start=875
|
|
58
|
+
_globals['_SCHEMAREQUEST']._serialized_end=909
|
|
59
|
+
_globals['_SCHEMAINFO']._serialized_start=911
|
|
60
|
+
_globals['_SCHEMAINFO']._serialized_end=979
|
|
61
|
+
_globals['_PUBLISHREQUEST']._serialized_start=981
|
|
62
|
+
_globals['_PUBLISHREQUEST']._serialized_end=1083
|
|
63
|
+
_globals['_PUBLISHRESPONSE']._serialized_start=1085
|
|
64
|
+
_globals['_PUBLISHRESPONSE']._serialized_end=1182
|
|
65
|
+
_globals['_MANAGEDFETCHREQUEST']._serialized_start=1185
|
|
66
|
+
_globals['_MANAGEDFETCHREQUEST']._serialized_end=1368
|
|
67
|
+
_globals['_MANAGEDFETCHRESPONSE']._serialized_start=1371
|
|
68
|
+
_globals['_MANAGEDFETCHRESPONSE']._serialized_end=1570
|
|
69
|
+
_globals['_COMMITREPLAYREQUEST']._serialized_start=1572
|
|
70
|
+
_globals['_COMMITREPLAYREQUEST']._serialized_end=1639
|
|
71
|
+
_globals['_COMMITREPLAYRESPONSE']._serialized_start=1641
|
|
72
|
+
_globals['_COMMITREPLAYRESPONSE']._serialized_end=1766
|
|
73
|
+
_globals['_PUBSUB']._serialized_start=1874
|
|
74
|
+
_globals['_PUBSUB']._serialized_end=2326
|
|
75
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from . import pubsub_api_pb2 as pubsub__api__pb2
|
|
7
|
+
|
|
8
|
+
GRPC_GENERATED_VERSION = '1.81.1'
|
|
9
|
+
GRPC_VERSION = grpc.__version__
|
|
10
|
+
_version_not_supported = False
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from grpc._utilities import first_version_is_lower
|
|
14
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
15
|
+
except ImportError:
|
|
16
|
+
_version_not_supported = True
|
|
17
|
+
|
|
18
|
+
if _version_not_supported:
|
|
19
|
+
raise RuntimeError(
|
|
20
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
21
|
+
+ ' but the generated code in pubsub_api_pb2_grpc.py depends on'
|
|
22
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
23
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
24
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class PubSubStub:
|
|
29
|
+
"""
|
|
30
|
+
The Pub/Sub API provides a single interface for publishing and subscribing to platform events, including real-time
|
|
31
|
+
event monitoring events, and change data capture events. The Pub/Sub API is a gRPC API that is based on HTTP/2.
|
|
32
|
+
|
|
33
|
+
A session token is needed to authenticate. Any of the Salesforce supported
|
|
34
|
+
OAuth flows can be used to obtain a session token:
|
|
35
|
+
https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_flows.htm&type=5
|
|
36
|
+
|
|
37
|
+
For each RPC, a client needs to pass authentication information
|
|
38
|
+
as metadata headers (https://www.grpc.io/docs/guides/concepts/#metadata) with their method call.
|
|
39
|
+
|
|
40
|
+
For Salesforce session token authentication, use:
|
|
41
|
+
accesstoken : access token
|
|
42
|
+
instanceurl : Salesforce instance URL
|
|
43
|
+
tenantid : tenant/org id of the client
|
|
44
|
+
|
|
45
|
+
StatusException is thrown in case of response failure for any request.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self, channel):
|
|
49
|
+
"""Constructor.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
channel: A grpc.Channel.
|
|
53
|
+
"""
|
|
54
|
+
self.Subscribe = channel.stream_stream(
|
|
55
|
+
'/eventbus.v1.PubSub/Subscribe',
|
|
56
|
+
request_serializer=pubsub__api__pb2.FetchRequest.SerializeToString,
|
|
57
|
+
response_deserializer=pubsub__api__pb2.FetchResponse.FromString,
|
|
58
|
+
_registered_method=True)
|
|
59
|
+
self.GetSchema = channel.unary_unary(
|
|
60
|
+
'/eventbus.v1.PubSub/GetSchema',
|
|
61
|
+
request_serializer=pubsub__api__pb2.SchemaRequest.SerializeToString,
|
|
62
|
+
response_deserializer=pubsub__api__pb2.SchemaInfo.FromString,
|
|
63
|
+
_registered_method=True)
|
|
64
|
+
self.GetTopic = channel.unary_unary(
|
|
65
|
+
'/eventbus.v1.PubSub/GetTopic',
|
|
66
|
+
request_serializer=pubsub__api__pb2.TopicRequest.SerializeToString,
|
|
67
|
+
response_deserializer=pubsub__api__pb2.TopicInfo.FromString,
|
|
68
|
+
_registered_method=True)
|
|
69
|
+
self.Publish = channel.unary_unary(
|
|
70
|
+
'/eventbus.v1.PubSub/Publish',
|
|
71
|
+
request_serializer=pubsub__api__pb2.PublishRequest.SerializeToString,
|
|
72
|
+
response_deserializer=pubsub__api__pb2.PublishResponse.FromString,
|
|
73
|
+
_registered_method=True)
|
|
74
|
+
self.PublishStream = channel.stream_stream(
|
|
75
|
+
'/eventbus.v1.PubSub/PublishStream',
|
|
76
|
+
request_serializer=pubsub__api__pb2.PublishRequest.SerializeToString,
|
|
77
|
+
response_deserializer=pubsub__api__pb2.PublishResponse.FromString,
|
|
78
|
+
_registered_method=True)
|
|
79
|
+
self.ManagedSubscribe = channel.stream_stream(
|
|
80
|
+
'/eventbus.v1.PubSub/ManagedSubscribe',
|
|
81
|
+
request_serializer=pubsub__api__pb2.ManagedFetchRequest.SerializeToString,
|
|
82
|
+
response_deserializer=pubsub__api__pb2.ManagedFetchResponse.FromString,
|
|
83
|
+
_registered_method=True)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class PubSubServicer:
|
|
87
|
+
"""
|
|
88
|
+
The Pub/Sub API provides a single interface for publishing and subscribing to platform events, including real-time
|
|
89
|
+
event monitoring events, and change data capture events. The Pub/Sub API is a gRPC API that is based on HTTP/2.
|
|
90
|
+
|
|
91
|
+
A session token is needed to authenticate. Any of the Salesforce supported
|
|
92
|
+
OAuth flows can be used to obtain a session token:
|
|
93
|
+
https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_flows.htm&type=5
|
|
94
|
+
|
|
95
|
+
For each RPC, a client needs to pass authentication information
|
|
96
|
+
as metadata headers (https://www.grpc.io/docs/guides/concepts/#metadata) with their method call.
|
|
97
|
+
|
|
98
|
+
For Salesforce session token authentication, use:
|
|
99
|
+
accesstoken : access token
|
|
100
|
+
instanceurl : Salesforce instance URL
|
|
101
|
+
tenantid : tenant/org id of the client
|
|
102
|
+
|
|
103
|
+
StatusException is thrown in case of response failure for any request.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
def Subscribe(self, request_iterator, context):
|
|
107
|
+
"""
|
|
108
|
+
Bidirectional streaming RPC to subscribe to a Topic. The subscription is pull-based. A client can request
|
|
109
|
+
for more events as it consumes events. This enables a client to handle flow control based on the client's processing speed.
|
|
110
|
+
|
|
111
|
+
Typical flow:
|
|
112
|
+
1. Client requests for X number of events via FetchRequest.
|
|
113
|
+
2. Server receives request and delivers events until X events are delivered to the client via one or more FetchResponse messages.
|
|
114
|
+
3. Client consumes the FetchResponse messages as they come.
|
|
115
|
+
4. Client issues new FetchRequest for Y more number of events. This request can
|
|
116
|
+
come before the server has delivered the earlier requested X number of events
|
|
117
|
+
so the client gets a continuous stream of events if any.
|
|
118
|
+
|
|
119
|
+
If a client requests more events before the server finishes the last
|
|
120
|
+
requested amount, the server appends the new amount to the current amount of
|
|
121
|
+
events it still needs to fetch and deliver.
|
|
122
|
+
|
|
123
|
+
A client can subscribe at any point in the stream by providing a replay option in the first FetchRequest.
|
|
124
|
+
The replay option is honored for the first FetchRequest received from a client. Any subsequent FetchRequests with a
|
|
125
|
+
new replay option are ignored. A client needs to call the Subscribe RPC again to restart the subscription
|
|
126
|
+
at a new point in the stream.
|
|
127
|
+
|
|
128
|
+
The first FetchRequest of the stream identifies the topic to subscribe to.
|
|
129
|
+
If any subsequent FetchRequest provides topic_name, it must match what
|
|
130
|
+
was provided in the first FetchRequest; otherwise, the RPC returns an error
|
|
131
|
+
with INVALID_ARGUMENT status.
|
|
132
|
+
"""
|
|
133
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
134
|
+
context.set_details('Method not implemented!')
|
|
135
|
+
raise NotImplementedError('Method not implemented!')
|
|
136
|
+
|
|
137
|
+
def GetSchema(self, request, context):
|
|
138
|
+
"""Get the event schema for a topic based on a schema ID.
|
|
139
|
+
"""
|
|
140
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
141
|
+
context.set_details('Method not implemented!')
|
|
142
|
+
raise NotImplementedError('Method not implemented!')
|
|
143
|
+
|
|
144
|
+
def GetTopic(self, request, context):
|
|
145
|
+
"""
|
|
146
|
+
Get the topic Information related to the specified topic.
|
|
147
|
+
"""
|
|
148
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
149
|
+
context.set_details('Method not implemented!')
|
|
150
|
+
raise NotImplementedError('Method not implemented!')
|
|
151
|
+
|
|
152
|
+
def Publish(self, request, context):
|
|
153
|
+
"""
|
|
154
|
+
Send a publish request to synchronously publish events to a topic.
|
|
155
|
+
"""
|
|
156
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
157
|
+
context.set_details('Method not implemented!')
|
|
158
|
+
raise NotImplementedError('Method not implemented!')
|
|
159
|
+
|
|
160
|
+
def PublishStream(self, request_iterator, context):
|
|
161
|
+
"""
|
|
162
|
+
Bidirectional Streaming RPC to publish events to the event bus.
|
|
163
|
+
PublishRequest contains the batch of events to publish.
|
|
164
|
+
|
|
165
|
+
The first PublishRequest of the stream identifies the topic to publish on.
|
|
166
|
+
If any subsequent PublishRequest provides topic_name, it must match what
|
|
167
|
+
was provided in the first PublishRequest; otherwise, the RPC returns an error
|
|
168
|
+
with INVALID_ARGUMENT status.
|
|
169
|
+
|
|
170
|
+
The server returns a PublishResponse for each PublishRequest when publish is
|
|
171
|
+
complete for the batch. A client does not have to wait for a PublishResponse
|
|
172
|
+
before sending a new PublishRequest, i.e. multiple publish batches can be queued
|
|
173
|
+
up, which allows for higher publish rate as a client can asynchronously
|
|
174
|
+
publish more events while publishes are still in flight on the server side.
|
|
175
|
+
|
|
176
|
+
PublishResponse holds a PublishResult for each event published that indicates success
|
|
177
|
+
or failure of the publish. A client can then retry the publish as needed before sending
|
|
178
|
+
more PublishRequests for new events to publish.
|
|
179
|
+
|
|
180
|
+
A client must send a valid publish request with one or more events every 70 seconds to hold on to the stream.
|
|
181
|
+
Otherwise, the server closes the stream and notifies the client. Once the client is notified of the stream closure,
|
|
182
|
+
it must make a new PublishStream call to resume publishing.
|
|
183
|
+
"""
|
|
184
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
185
|
+
context.set_details('Method not implemented!')
|
|
186
|
+
raise NotImplementedError('Method not implemented!')
|
|
187
|
+
|
|
188
|
+
def ManagedSubscribe(self, request_iterator, context):
|
|
189
|
+
"""
|
|
190
|
+
This feature is part of an open beta release and is subject to the applicable
|
|
191
|
+
Beta Services Terms provided at Agreements and Terms
|
|
192
|
+
(https://www.salesforce.com/company/legal/agreements/).
|
|
193
|
+
|
|
194
|
+
Same as Subscribe, but for Managed Subscription clients.
|
|
195
|
+
This feature is part of an open beta release.
|
|
196
|
+
"""
|
|
197
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
198
|
+
context.set_details('Method not implemented!')
|
|
199
|
+
raise NotImplementedError('Method not implemented!')
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def add_PubSubServicer_to_server(servicer, server):
|
|
203
|
+
rpc_method_handlers = {
|
|
204
|
+
'Subscribe': grpc.stream_stream_rpc_method_handler(
|
|
205
|
+
servicer.Subscribe,
|
|
206
|
+
request_deserializer=pubsub__api__pb2.FetchRequest.FromString,
|
|
207
|
+
response_serializer=pubsub__api__pb2.FetchResponse.SerializeToString,
|
|
208
|
+
),
|
|
209
|
+
'GetSchema': grpc.unary_unary_rpc_method_handler(
|
|
210
|
+
servicer.GetSchema,
|
|
211
|
+
request_deserializer=pubsub__api__pb2.SchemaRequest.FromString,
|
|
212
|
+
response_serializer=pubsub__api__pb2.SchemaInfo.SerializeToString,
|
|
213
|
+
),
|
|
214
|
+
'GetTopic': grpc.unary_unary_rpc_method_handler(
|
|
215
|
+
servicer.GetTopic,
|
|
216
|
+
request_deserializer=pubsub__api__pb2.TopicRequest.FromString,
|
|
217
|
+
response_serializer=pubsub__api__pb2.TopicInfo.SerializeToString,
|
|
218
|
+
),
|
|
219
|
+
'Publish': grpc.unary_unary_rpc_method_handler(
|
|
220
|
+
servicer.Publish,
|
|
221
|
+
request_deserializer=pubsub__api__pb2.PublishRequest.FromString,
|
|
222
|
+
response_serializer=pubsub__api__pb2.PublishResponse.SerializeToString,
|
|
223
|
+
),
|
|
224
|
+
'PublishStream': grpc.stream_stream_rpc_method_handler(
|
|
225
|
+
servicer.PublishStream,
|
|
226
|
+
request_deserializer=pubsub__api__pb2.PublishRequest.FromString,
|
|
227
|
+
response_serializer=pubsub__api__pb2.PublishResponse.SerializeToString,
|
|
228
|
+
),
|
|
229
|
+
'ManagedSubscribe': grpc.stream_stream_rpc_method_handler(
|
|
230
|
+
servicer.ManagedSubscribe,
|
|
231
|
+
request_deserializer=pubsub__api__pb2.ManagedFetchRequest.FromString,
|
|
232
|
+
response_serializer=pubsub__api__pb2.ManagedFetchResponse.SerializeToString,
|
|
233
|
+
),
|
|
234
|
+
}
|
|
235
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
236
|
+
'eventbus.v1.PubSub', rpc_method_handlers)
|
|
237
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
238
|
+
server.add_registered_method_handlers('eventbus.v1.PubSub', rpc_method_handlers)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# This class is part of an EXPERIMENTAL API.
|
|
242
|
+
class PubSub:
|
|
243
|
+
"""
|
|
244
|
+
The Pub/Sub API provides a single interface for publishing and subscribing to platform events, including real-time
|
|
245
|
+
event monitoring events, and change data capture events. The Pub/Sub API is a gRPC API that is based on HTTP/2.
|
|
246
|
+
|
|
247
|
+
A session token is needed to authenticate. Any of the Salesforce supported
|
|
248
|
+
OAuth flows can be used to obtain a session token:
|
|
249
|
+
https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_flows.htm&type=5
|
|
250
|
+
|
|
251
|
+
For each RPC, a client needs to pass authentication information
|
|
252
|
+
as metadata headers (https://www.grpc.io/docs/guides/concepts/#metadata) with their method call.
|
|
253
|
+
|
|
254
|
+
For Salesforce session token authentication, use:
|
|
255
|
+
accesstoken : access token
|
|
256
|
+
instanceurl : Salesforce instance URL
|
|
257
|
+
tenantid : tenant/org id of the client
|
|
258
|
+
|
|
259
|
+
StatusException is thrown in case of response failure for any request.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
@staticmethod
|
|
263
|
+
def Subscribe(request_iterator,
|
|
264
|
+
target,
|
|
265
|
+
options=(),
|
|
266
|
+
channel_credentials=None,
|
|
267
|
+
call_credentials=None,
|
|
268
|
+
insecure=False,
|
|
269
|
+
compression=None,
|
|
270
|
+
wait_for_ready=None,
|
|
271
|
+
timeout=None,
|
|
272
|
+
metadata=None):
|
|
273
|
+
return grpc.experimental.stream_stream(
|
|
274
|
+
request_iterator,
|
|
275
|
+
target,
|
|
276
|
+
'/eventbus.v1.PubSub/Subscribe',
|
|
277
|
+
pubsub__api__pb2.FetchRequest.SerializeToString,
|
|
278
|
+
pubsub__api__pb2.FetchResponse.FromString,
|
|
279
|
+
options,
|
|
280
|
+
channel_credentials,
|
|
281
|
+
insecure,
|
|
282
|
+
call_credentials,
|
|
283
|
+
compression,
|
|
284
|
+
wait_for_ready,
|
|
285
|
+
timeout,
|
|
286
|
+
metadata,
|
|
287
|
+
_registered_method=True)
|
|
288
|
+
|
|
289
|
+
@staticmethod
|
|
290
|
+
def GetSchema(request,
|
|
291
|
+
target,
|
|
292
|
+
options=(),
|
|
293
|
+
channel_credentials=None,
|
|
294
|
+
call_credentials=None,
|
|
295
|
+
insecure=False,
|
|
296
|
+
compression=None,
|
|
297
|
+
wait_for_ready=None,
|
|
298
|
+
timeout=None,
|
|
299
|
+
metadata=None):
|
|
300
|
+
return grpc.experimental.unary_unary(
|
|
301
|
+
request,
|
|
302
|
+
target,
|
|
303
|
+
'/eventbus.v1.PubSub/GetSchema',
|
|
304
|
+
pubsub__api__pb2.SchemaRequest.SerializeToString,
|
|
305
|
+
pubsub__api__pb2.SchemaInfo.FromString,
|
|
306
|
+
options,
|
|
307
|
+
channel_credentials,
|
|
308
|
+
insecure,
|
|
309
|
+
call_credentials,
|
|
310
|
+
compression,
|
|
311
|
+
wait_for_ready,
|
|
312
|
+
timeout,
|
|
313
|
+
metadata,
|
|
314
|
+
_registered_method=True)
|
|
315
|
+
|
|
316
|
+
@staticmethod
|
|
317
|
+
def GetTopic(request,
|
|
318
|
+
target,
|
|
319
|
+
options=(),
|
|
320
|
+
channel_credentials=None,
|
|
321
|
+
call_credentials=None,
|
|
322
|
+
insecure=False,
|
|
323
|
+
compression=None,
|
|
324
|
+
wait_for_ready=None,
|
|
325
|
+
timeout=None,
|
|
326
|
+
metadata=None):
|
|
327
|
+
return grpc.experimental.unary_unary(
|
|
328
|
+
request,
|
|
329
|
+
target,
|
|
330
|
+
'/eventbus.v1.PubSub/GetTopic',
|
|
331
|
+
pubsub__api__pb2.TopicRequest.SerializeToString,
|
|
332
|
+
pubsub__api__pb2.TopicInfo.FromString,
|
|
333
|
+
options,
|
|
334
|
+
channel_credentials,
|
|
335
|
+
insecure,
|
|
336
|
+
call_credentials,
|
|
337
|
+
compression,
|
|
338
|
+
wait_for_ready,
|
|
339
|
+
timeout,
|
|
340
|
+
metadata,
|
|
341
|
+
_registered_method=True)
|
|
342
|
+
|
|
343
|
+
@staticmethod
|
|
344
|
+
def Publish(request,
|
|
345
|
+
target,
|
|
346
|
+
options=(),
|
|
347
|
+
channel_credentials=None,
|
|
348
|
+
call_credentials=None,
|
|
349
|
+
insecure=False,
|
|
350
|
+
compression=None,
|
|
351
|
+
wait_for_ready=None,
|
|
352
|
+
timeout=None,
|
|
353
|
+
metadata=None):
|
|
354
|
+
return grpc.experimental.unary_unary(
|
|
355
|
+
request,
|
|
356
|
+
target,
|
|
357
|
+
'/eventbus.v1.PubSub/Publish',
|
|
358
|
+
pubsub__api__pb2.PublishRequest.SerializeToString,
|
|
359
|
+
pubsub__api__pb2.PublishResponse.FromString,
|
|
360
|
+
options,
|
|
361
|
+
channel_credentials,
|
|
362
|
+
insecure,
|
|
363
|
+
call_credentials,
|
|
364
|
+
compression,
|
|
365
|
+
wait_for_ready,
|
|
366
|
+
timeout,
|
|
367
|
+
metadata,
|
|
368
|
+
_registered_method=True)
|
|
369
|
+
|
|
370
|
+
@staticmethod
|
|
371
|
+
def PublishStream(request_iterator,
|
|
372
|
+
target,
|
|
373
|
+
options=(),
|
|
374
|
+
channel_credentials=None,
|
|
375
|
+
call_credentials=None,
|
|
376
|
+
insecure=False,
|
|
377
|
+
compression=None,
|
|
378
|
+
wait_for_ready=None,
|
|
379
|
+
timeout=None,
|
|
380
|
+
metadata=None):
|
|
381
|
+
return grpc.experimental.stream_stream(
|
|
382
|
+
request_iterator,
|
|
383
|
+
target,
|
|
384
|
+
'/eventbus.v1.PubSub/PublishStream',
|
|
385
|
+
pubsub__api__pb2.PublishRequest.SerializeToString,
|
|
386
|
+
pubsub__api__pb2.PublishResponse.FromString,
|
|
387
|
+
options,
|
|
388
|
+
channel_credentials,
|
|
389
|
+
insecure,
|
|
390
|
+
call_credentials,
|
|
391
|
+
compression,
|
|
392
|
+
wait_for_ready,
|
|
393
|
+
timeout,
|
|
394
|
+
metadata,
|
|
395
|
+
_registered_method=True)
|
|
396
|
+
|
|
397
|
+
@staticmethod
|
|
398
|
+
def ManagedSubscribe(request_iterator,
|
|
399
|
+
target,
|
|
400
|
+
options=(),
|
|
401
|
+
channel_credentials=None,
|
|
402
|
+
call_credentials=None,
|
|
403
|
+
insecure=False,
|
|
404
|
+
compression=None,
|
|
405
|
+
wait_for_ready=None,
|
|
406
|
+
timeout=None,
|
|
407
|
+
metadata=None):
|
|
408
|
+
return grpc.experimental.stream_stream(
|
|
409
|
+
request_iterator,
|
|
410
|
+
target,
|
|
411
|
+
'/eventbus.v1.PubSub/ManagedSubscribe',
|
|
412
|
+
pubsub__api__pb2.ManagedFetchRequest.SerializeToString,
|
|
413
|
+
pubsub__api__pb2.ManagedFetchResponse.FromString,
|
|
414
|
+
options,
|
|
415
|
+
channel_credentials,
|
|
416
|
+
insecure,
|
|
417
|
+
call_credentials,
|
|
418
|
+
compression,
|
|
419
|
+
wait_for_ready,
|
|
420
|
+
timeout,
|
|
421
|
+
metadata,
|
|
422
|
+
_registered_method=True)
|