123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- {
- "openapi": "3.0.0",
- "info": {
- "title": "AWSMetricsServiceApi",
- "description": "Service API for the data analytics pipeline defined by the AWS Metrics Gem",
- "version": "1.0.1"
- },
- "x-amazon-apigateway-request-validators": {
- "all": {
- "validateRequestBody": true,
- "validateRequestParameters": true
- }
- },
- "x-amazon-apigateway-request-validator": "all",
- "paths": {
- "/producer/events": {
- "post": {
- "x-amazon-apigateway-auth": {
- "type": "AWS_IAM"
- },
- "x-amazon-apigateway-integration": {
- "credentials": "${ApiGatewayRoleArn}",
- "uri": "arn:${AWS::Partition}:apigateway:${AWS::Region}:kinesis:action/PutRecords",
- "httpMethod": "POST",
- "responses": {
- "200": {
- "statusCode": "200",
- "responseTemplates": {
- "application/json": "#set($response = $input.path('$'))\n#set($records = $input.json('$.Records'))\n{\n \"result\": {\n \"total\": $response.Records.size(),\n \"failed_record_count\": $input.json('$.FailedRecordCount'),\n \"events\": [\n #foreach($record in $response.Records)\n #if($record.ErrorCode != $null)\n {\n \"result\": \"Error\", \n \"error_code\": \"$record.ErrorCode\"\n }\n #else\n {\n \"result\": \"Ok\"\n }\n #end\n #if($foreach.hasNext),#end\n #end\n ]\n }\n}\n"
- }
- },
- "4\\d{2}": {
- "statusCode": "400",
- "responseTemplates": {
- "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"type\": \"BadRequest\",\n \"message\": $input.json('$.message')\n}\n"
- }
- },
- "5\\d{2}": {
- "statusCode": "500",
- "responseTemplates": {
- "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"type\": $input.json('$.__type'),\n \"message\": $input.json('$.message')\n}\n"
- }
- }
- },
- "requestParameters": {
- "integration.request.header.Content-Type": "'x-amz-json-1.1'"
- },
- "requestTemplates": {
- "application/json": "{\n \"StreamName\": \"${InputStreamName}\",\n \"Records\": [\n #set($i = 0)\n #foreach($event in $input.path('$.events'))\n #set($data = $input.json(\"$.events[$i]\"))\n {\n \"Data\": \"$util.base64Encode($data)\",\n \"PartitionKey\": \"$event.application_id\"\n }#if($foreach.hasNext),#end\n #set($i = $i + 1)\n #end\n ]\n}\n"
- },
- "passthroughBehavior": "never",
- "type": "aws"
- },
- "operationId": "SendEvents",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/MetricsEventsBatchSchema"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Successful POST /producer/events",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PostMetricsEventsResponse"
- }
- }
- }
- },
- "400": {
- "description": "Bad Request Exception",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PostMetricsEventsError"
- }
- }
- }
- },
- "401": {
- "description": "Unauthorized Exception",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PostMetricsEventsError"
- }
- }
- }
- },
- "500": {
- "description": "Internal Server PostMetricsEventsError",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PostMetricsEventsError"
- }
- }
- }
- }
- }
- }
- }
- },
- "components": {
- "schemas": {
- "PostMetricsEventsError": {
- "type": "object",
- "properties": {
- "message": {
- "type": "string",
- "description": "Error message"
- },
- "type": {
- "type": "string",
- "description": "Error code from the API"
- }
- }
- },
- "MetricsEventsBatchSchema": {
- "title": "Batched Metrics Events Schema",
- "required": [
- "events"
- ],
- "type": "object",
- "properties": {
- "events": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/MetricsEventSchema"
- }
- }
- }
- },
- "MetricsEventSchema": {
- "type": "object",
- "title": "AWSMetrics API Event Schema",
- "description": "Metrics Event sent to the service API",
- "required": [
- "application_id",
- "event_id",
- "event_name",
- "event_timestamp"
- ],
- "properties": {
- "application_id": {
- "type": "string",
- "pattern": "^[0-9-.]+-\\{[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\\}$",
- "description": "Identifier for the application that generated the event"
- },
- "event_id": {
- "type": "string",
- "pattern": "^\\{[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\\}$",
- "description": "A random UUID that uniquely identifies an event."
- },
- "event_name": {
- "type": "string",
- "pattern": "^[A-Za-z0-9-_.]+$",
- "description": "Name of the event that occurred"
- },
- "event_timestamp": {
- "type": "string",
- "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})\\:(\\d{2})\\:(\\d{2})Z$",
- "description": "The time in seconds since the Unix epoch at which this event occurred (set by producer of event)."
- },
- "event_type": {
- "type": "string",
- "pattern": "^[A-Za-z0-9-_.]+$",
- "description": "Identifies the type of event"
- },
- "event_version": {
- "type": "string",
- "pattern": "^[A-Za-z0-9-_.]+$",
- "description": "An API version for this event format."
- },
- "event_data": {
- "type": "object",
- "description": "Custom metrics attributes defined by this event."
- }
- }
- },
- "PostMetricsEventsResponse": {
- "title": "Metrics Event Success Response Schema",
- "type": "object",
- "properties": {
- "failed_record_count": {
- "type": "number",
- "description": "Number of events that failed to be sent to the backend"
- },
- "events": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/PostMetricsEventsResponseEntry"
- }
- },
- "total": {
- "type": "number",
- "description": "Total number of events that were processed in the request"
- }
- }
- },
- "PostMetricsEventsResponseEntry": {
- "type": "object",
- "properties": {
- "error_code": {
- "type": "string",
- "description": "Error code if the individual metrics event failed to be sent"
- },
- "result": {
- "type": "string",
- "description": "Result for the processed individual metrics event. Expected value: \"Error\" or \"Ok\""
- }
- }
- }
- }
- }
- }
|