forked from allenheltondev/gopher-holes-unlimited
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathghu-asyncapi.yaml
214 lines (192 loc) · 6.33 KB
/
ghu-asyncapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
asyncapi: 2.3.0
info:
title: Gopher Holes Unlimited
version: 1.0.0
description: >
Describes the events used in Gopher Holes Unlimited. Contained in the spec are:
* WebSocket connection information
* EventBridge event configuration used internally in teh application
* SNS message details when gopher updates are made in the system
defaultContentType: application/json
servers:
private:
url: ws.gopherholesunlimited.com
protocol: wss
description: >
Connection url for the WebSocket. When creating a new gopher, status updates are pushed in the form of WebSocket notifications.
### Authentication
To connect to this WebSocket, you must get a valid auth token from the
*create-test-jwt* lambda function from the [WebSocket microservice](https://github.com/allenheltondev/serverless-websockets). You can use the token in one of two
ways:
* As a query parameter on *$connect* called `auth_token`
* As a comma separated value in the `Sec-WebSocket-Protocol` header
* The `Sec-WebSocket-Protocol` header is required on connect. It must have a value of `websocket`. If using this header as the auth method, the value would be `websocket, <auth token>`
### Example Connection Url
> wss://ws.gopherholesunlimited.com?access_token=eyJhbG
channels:
/:
publish:
operationId: sendMessage
tags:
- name: WebSocket
message:
oneOf:
- $ref: '#/components/messages/subscribe'
- $ref: '#/components/messages/unsubscribe'
subscribe:
operationId: receiveSubscriptionMessage
tags:
- name: WebSocket
message:
$ref: '#/components/messages/receiveSubscriptionMessage'
GopherAdded:
subscribe:
operationId: gopherAdded
description: Event triggered when a new gopher is added in the system
tags:
- name: SNS
message:
$ref: '#/components/messages/gopherAddedMessage'
GopherStatusChanged:
subscribe:
operationId: gopherStatusChanged
description: Event triggered when a gopher status is updated
tags:
- name: SNS
message:
$ref: '#/components/messages/gopherStatusChangedMessage'
GopherUpdated:
subscribe:
operationId: gopherUpdated
description: Event triggered when details about a gopher have changed
tags:
- name: SNS
message:
$ref: '#/components/messages/gopherUpdatedMessage'
components:
messages:
subscribe:
name: subscribe
title: Subscribe for Updates
summary: Subscribes for updates when an entity is updated in the system
contentType: application/json
payload:
$ref: '#/components/schemas/subscribe'
examples:
- payload:
action: subscribe
entityId: myEntityId
unsubscribe:
name: unsubscribe
title: Unsubscribe from Updates
summary: Removes subscription for updates when an entity is updated in the system
contentType: application/json
payload:
$ref: '#/components/schemas/unsubscribe'
examples:
- payload:
action: unsubscribe
entityId: myEntityId
receiveSubscriptionMessage:
name: receiveMessage
title: Receive Push Notification
summary: Push notification received when a subscribed entity has been updated
contentType: application/json
payload:
$ref: '#/components/schemas/receiveSubscriptionMessage'
examples:
- payload:
type: Entity Updated
entityId: myEntityId
message: Status changed from 'New' to 'In Progress'
gopherStatusChangedMessage:
name: gopherStatusChanged
title: Notify subscribers when a gopher status is updated
summary: >-
When a gopher status is changed, notify subscribers so they are aware
contentType: application/json
payload:
$ref: '#/components/schemas/gopherSnsMessage'
examples:
- payload:
id: 83425-odfgh94-jsdfg03
name: Bucktooth Joe
gopherAddedMessage:
name: gopherAddedMessage
title: Notify subscribers when a new gopher is added
summary: >-
When a new gopher is added in the system, notify users so they can watch for them
contentType: application/json
payload:
$ref: '#/components/schemas/gopherSnsMessage'
examples:
- payload:
id: 83425-odfgh94-jsdfg03
name: Bucktooth Joe
gopherUpdatedMessage:
name: gopherUpdatedMessage
title: Notify subscribers when gopher details are updated
summary: >-
When any information changes with a gopher, notify subscribers
contentType: application/json
payload:
$ref: '#/components/schemas/gopherSnsMessage'
examples:
- payload:
id: 83425-odfgh94-jsdfg03
name: Bucky
schemas:
subscribe:
type: object
required:
- action
- entityId
properties:
action:
const: subscribe
entityId:
type: string
description: Unique identifier of the entity to subscribe for updates
example: myEntityId
unsubscribe:
type: object
required:
- action
- entityId
properties:
action:
const: unsubscribe
entityId:
type: string
description: Unique identifier of the entity to unsubscribe from
example: myEntityId
receiveSubscriptionMessage:
type: object
required:
- type
- entityId
properties:
type:
const: Entity Updated
entityId:
type: string
description: Unique identifier of the entity that was updated
example: myEntityId
message:
type: string
description: Message provided by the system related to the entity update
example: Status changed from 'New' to 'In Progress'
gopherSnsMessage:
type: object
required:
- id
- name
properties:
id:
type: string
description: Unique identifier of the gopher
example: 904j84-rtjdxsfgh-348g-934k
name:
type: string
description: Name of the gopher
example: Bucktooth Joe