You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
223 lines
10 KiB
JSON
223 lines
10 KiB
JSON
{
|
|
"openapi": "3.0.0",
|
|
"info": {
|
|
"title": "AWSMetricsServiceApi",
|
|
"description": "Service API for the data analytics pipeline defined by the AWS Metrics Gem",
|
|
"version": "1.0.0"
|
|
},
|
|
"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/MetricsEventSuccessResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request Exception",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Unauthorized Exception",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Internal Server Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"Error": {
|
|
"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."
|
|
}
|
|
}
|
|
},
|
|
"MetricsEventSuccessResponse": {
|
|
"title": "Metrics Event Success Response Schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"failed_record_count": {
|
|
"type": "number",
|
|
"description": "Number of events that failed to be saved to metrics events stream"
|
|
},
|
|
"events": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/MetricsEventSuccessResponseRecord"
|
|
}
|
|
},
|
|
"total": {
|
|
"type": "number",
|
|
"description": "Total number of events that were processed in the request"
|
|
}
|
|
}
|
|
},
|
|
"MetricsEventSuccessResponseRecord": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error_code": {
|
|
"type": "string",
|
|
"description": "The error code from the metrics events stream. Value set if Result is Error"
|
|
},
|
|
"result": {
|
|
"type": "string",
|
|
"description": "Processing result for the input record"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|