@@ -179,6 +179,27 @@ var _ = Service("devbuild", func() {
179
179
Response ("InternalServerError" , StatusInternalServerError )
180
180
})
181
181
})
182
+
183
+ Method ("ingestEvent" , func () {
184
+ Description ("Ingest a CloudEvent for build events" )
185
+ Payload (CloudEvent , func () {
186
+ Required ("id" , "source" , "type" , "specversion" , "time" , "data" )
187
+ })
188
+ Result (CloudEventResponse )
189
+ HTTP (func () {
190
+ POST ("/events" )
191
+ PUT ("/events" )
192
+ Header ("datacontenttype:Content-Type" )
193
+ Header ("id:ce-id" )
194
+ Header ("source:ce-source" )
195
+ Header ("type:ce-type" )
196
+ Header ("specversion:ce-specversion" )
197
+ Header ("time:ce-time" )
198
+ Response (StatusOK )
199
+ Response ("BadRequest" , StatusBadRequest )
200
+ Response ("InternalServerError" , StatusInternalServerError )
201
+ })
202
+ })
182
203
})
183
204
184
205
var ImageSyncRequest = Type ("ImageSyncRequest" , func () {
@@ -332,3 +353,52 @@ var HTTPError = Type("HTTPError", func() {
332
353
Attribute ("message" , String )
333
354
Required ("code" , "message" )
334
355
})
356
+
357
+ var CloudEvent = Type ("CloudEvent" , func () {
358
+ Attribute ("id" , String , "Unique identifier for the event" , func () {
359
+ Example ("f81d4fae-7dec-11d0-a765-00a0c91e6bf6" )
360
+ })
361
+ Attribute ("source" , String , "Identifies the context in which an event happened" , func () {
362
+ Example ("/jenkins/build" )
363
+ })
364
+ Attribute ("type" , String , "Describes the type of event related to the originating occurrence" , func () {
365
+ Example ("com.pingcap.build.complete" )
366
+ })
367
+ Attribute ("datacontenttype" , String , "Content type of the data value" )
368
+ Attribute ("specversion" , String , "The version of the CloudEvents specification which the event uses" , func () {
369
+ Example ("1.0" )
370
+ })
371
+ Attribute ("dataschema" , String , "Identifies the schema that data adheres to" , func () {
372
+ Example ("https://example.com/registry/schemas/build-event.json" )
373
+ })
374
+ Attribute ("subject" , String , "Describes the subject of the event in the context of the event producer" , func () {
375
+ Example ("tidb-build-123" )
376
+ })
377
+ Attribute ("time" , String , "Timestamp of when the occurrence happened" , func () {
378
+ Format (FormatDateTime )
379
+ Example ("2022-10-01T12:00:00Z" )
380
+ })
381
+ Attribute ("data" , Any , "Event payload" , func () {
382
+ Example (map [string ]any {
383
+ "buildId" : "123" ,
384
+ "status" : "success" ,
385
+ "version" : "v6.1.0" ,
386
+ "duration" : 3600 ,
387
+ })
388
+ })
389
+ })
390
+
391
+ var CloudEventResponse = Type ("CloudEventResponse" , func () {
392
+ Attribute ("id" , String , "The ID of the processed CloudEvent" , func () {
393
+ Example ("f81d4fae-7dec-11d0-a765-00a0c91e6bf6" )
394
+ })
395
+ Attribute ("status" , String , "Processing status" , func () {
396
+ Enum ("accepted" , "processing" , "error" )
397
+ Example ("accepted" )
398
+ })
399
+ Attribute ("message" , String , "Additional information about processing result" , func () {
400
+ Example ("Event successfully queued for processing" )
401
+ })
402
+
403
+ Required ("id" , "status" )
404
+ })
0 commit comments