Skip to content

Commit

Permalink
Update swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Oct 16, 2024
1 parent 729d1ca commit 97a2e2d
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 8 deletions.
82 changes: 82 additions & 0 deletions disperser/dataapi/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,57 @@ const docTemplate = `{
}
}
},
"/operators-info/ejected-operators": {
"get": {
"produces": [
"application/json"
],
"tags": [
"OperatorsInfo"
],
"summary": "Fetch list of operators that have been ejected over lookback days interval.",
"parameters": [
{
"type": "integer",
"description": "Lookback in days [default: 1]",
"name": "days",
"in": "query"
},
{
"type": "string",
"description": "Operator ID",
"name": "operator_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjectionsResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
}
}
}
},
"/operators-info/operators-stake": {
"get": {
"produces": [
Expand Down Expand Up @@ -920,6 +971,37 @@ const docTemplate = `{
}
}
},
"dataapi.QueriedOperatorEjections": {
"type": "object",
"properties": {
"block_number": {
"type": "integer"
},
"block_timestamp": {
"type": "string"
},
"operator_id": {
"type": "string"
},
"quorum": {
"type": "integer"
},
"transaction_hash": {
"type": "string"
}
}
},
"dataapi.QueriedOperatorEjectionsResponse": {
"type": "object",
"properties": {
"ejections": {
"type": "array",
"items": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjections"
}
}
}
},
"dataapi.QueriedStateOperatorMetadata": {
"type": "object",
"properties": {
Expand Down
82 changes: 82 additions & 0 deletions disperser/dataapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,57 @@
}
}
},
"/operators-info/ejected-operators": {
"get": {
"produces": [
"application/json"
],
"tags": [
"OperatorsInfo"
],
"summary": "Fetch list of operators that have been ejected over lookback days interval.",
"parameters": [
{
"type": "integer",
"description": "Lookback in days [default: 1]",
"name": "days",
"in": "query"
},
{
"type": "string",
"description": "Operator ID",
"name": "operator_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjectionsResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
}
}
}
},
"/operators-info/operators-stake": {
"get": {
"produces": [
Expand Down Expand Up @@ -916,6 +967,37 @@
}
}
},
"dataapi.QueriedOperatorEjections": {
"type": "object",
"properties": {
"block_number": {
"type": "integer"
},
"block_timestamp": {
"type": "string"
},
"operator_id": {
"type": "string"
},
"quorum": {
"type": "integer"
},
"transaction_hash": {
"type": "string"
}
}
},
"dataapi.QueriedOperatorEjectionsResponse": {
"type": "object",
"properties": {
"ejections": {
"type": "array",
"items": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjections"
}
}
}
},
"dataapi.QueriedStateOperatorMetadata": {
"type": "object",
"properties": {
Expand Down
53 changes: 53 additions & 0 deletions disperser/dataapi/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@ definitions:
type: array
type: object
type: object
dataapi.QueriedOperatorEjections:
properties:
block_number:
type: integer
block_timestamp:
type: string
operator_id:
type: string
quorum:
type: integer
transaction_hash:
type: string
type: object
dataapi.QueriedOperatorEjectionsResponse:
properties:
ejections:
items:
$ref: '#/definitions/dataapi.QueriedOperatorEjections'
type: array
type: object
dataapi.QueriedStateOperatorMetadata:
properties:
block_number:
Expand Down Expand Up @@ -605,6 +625,39 @@ paths:
is a query parameter with a default value of 14 and max value of 30.
tags:
- OperatorsInfo
/operators-info/ejected-operators:
get:
parameters:
- description: 'Lookback in days [default: 1]'
in: query
name: days
type: integer
- description: Operator ID
in: query
name: operator_id
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dataapi.QueriedOperatorEjectionsResponse'
"400":
description: 'error: Bad request'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
"404":
description: 'error: Not found'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
"500":
description: 'error: Server error'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
summary: Fetch list of operators that have been ejected over lookback days interval.
tags:
- OperatorsInfo
/operators-info/operators-stake:
get:
parameters:
Expand Down
2 changes: 1 addition & 1 deletion disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *server) getRegisteredOperatorForDays(ctx context.Context, days int32) (
// Function to get ejected operators for given number of days
// Queries subgraph for ejected operators
// Returns list of Operators with their quorum, block number, txn and timestemp they were ejected
func (s *server) getEjectedOperatorForDays(ctx context.Context, days int32) ([]*QueriedOperatorEjections, error) {
func (s *server) getEjectedOperatorsForDays(ctx context.Context, days int32) ([]*QueriedOperatorEjections, error) {
startTime := time.Now()

operatorEjections, err := s.subgraphClient.QueryIndexedOperatorEjectionsForTimeWindow(ctx, days)
Expand Down
16 changes: 9 additions & 7 deletions disperser/dataapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,13 +874,15 @@ func (s *server) FetchRegisteredOperators(c *gin.Context) {

// FetchEjectedOperators godoc
//
// @Summary Fetch list of operators that have been ejected over days. Days is a query parameter with a default value of 1 and max value of 30.
// @Summary Fetch list of operators that have been ejected over lookback days interval.
// @Tags OperatorsInfo
// @Produce json
// @Success 200 {object} QueriedStateOperatorsResponse
// @Failure 400 {object} ErrorResponse "error: Bad request"
// @Failure 404 {object} ErrorResponse "error: Not found"
// @Failure 500 {object} ErrorResponse "error: Server error"
// @Param days query int false "Lookback in days [default: 1]"
// @Param operator_id query string false "Operator ID"
// @Success 200 {object} QueriedOperatorEjectionsResponse
// @Failure 400 {object} ErrorResponse "error: Bad request"
// @Failure 404 {object} ErrorResponse "error: Not found"
// @Failure 500 {object} ErrorResponse "error: Server error"
// @Router /operators-info/ejected-operators [get]
func (s *server) FetchEjectedOperators(c *gin.Context) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(f float64) {
Expand All @@ -889,7 +891,7 @@ func (s *server) FetchEjectedOperators(c *gin.Context) {
defer timer.ObserveDuration()

// Get query parameters
// Default Value 14 days
// Default Value 1 days
days := c.DefaultQuery("days", "1") // If not specified, defaults to 1

// Convert days to integer
Expand All @@ -904,7 +906,7 @@ func (s *server) FetchEjectedOperators(c *gin.Context) {
return
}

operatorEjections, err := s.getEjectedOperatorForDays(c.Request.Context(), int32(daysInt))
operatorEjections, err := s.getEjectedOperatorsForDays(c.Request.Context(), int32(daysInt))
if err != nil {
s.logger.Error("Failed to fetch ejected operators", "error", err)
s.metrics.IncrementFailedRequestNum("FetchEjectedOperators")
Expand Down

0 comments on commit 97a2e2d

Please sign in to comment.