diff --git a/docs/docs.go b/docs/docs.go index a61f4af..a60ed8c 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -39,8 +39,8 @@ const docTemplate = `{ } } }, - "/filenames": { - "post": { + "/v1/vehicle/{tokenId}/filenames": { + "get": { "description": "Retrieves a list of filenames that match the provided search options", "consumes": [ "application/json" @@ -54,13 +54,34 @@ const docTemplate = `{ "summary": "Get multiple filenames based on search criteria", "parameters": [ { - "description": "Search criteria and limit for finding files", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/internal_fetch_httphandler.SearchOptionsWithLimit" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -77,7 +98,7 @@ const docTemplate = `{ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -97,8 +118,8 @@ const docTemplate = `{ } } }, - "/files": { - "post": { + "/v1/vehicle/{tokenId}/files": { + "get": { "description": "Retrieves the content of multiple files that match the provided search options", "consumes": [ "application/json" @@ -112,13 +133,34 @@ const docTemplate = `{ "summary": "Get multiple files based on search criteria", "parameters": [ { - "description": "Search criteria and limit for finding files", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/internal_fetch_httphandler.SearchOptionsWithLimit" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -135,7 +177,7 @@ const docTemplate = `{ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -155,8 +197,8 @@ const docTemplate = `{ } } }, - "/latest-file": { - "post": { + "/v1/vehicle/{tokenId}/latest-file": { + "get": { "description": "Retrieves the content of the most recent file that matches the provided search options", "consumes": [ "application/json" @@ -170,13 +212,34 @@ const docTemplate = `{ "summary": "Get the latest file based on search criteria", "parameters": [ { - "description": "Search criteria for finding the latest file", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/indexrepo.SearchOptions" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -193,7 +256,7 @@ const docTemplate = `{ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -213,8 +276,8 @@ const docTemplate = `{ } } }, - "/latest-filename": { - "post": { + "/v1/vehicle/{tokenId}/latest-filename": { + "get": { "description": "Retrieves the most recent filename that matches the provided search options", "consumes": [ "application/json" @@ -228,13 +291,34 @@ const docTemplate = `{ "summary": "Get the latest filename based on search criteria", "parameters": [ { - "description": "Search criteria for finding the latest file", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/indexrepo.SearchOptions" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -248,7 +332,7 @@ const docTemplate = `{ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -269,102 +353,6 @@ const docTemplate = `{ } } }, - "definitions": { - "indexrepo.SearchOptions": { - "type": "object", - "properties": { - "after": { - "description": "After if set only files after this time are returned.", - "type": "string" - }, - "before": { - "description": "Before if set only files before this time are returned.", - "type": "string" - }, - "dataType": { - "description": "DataType if set only files for this data type are returned.", - "type": "string" - }, - "optional": { - "description": "Optional is the optional data for additional metadata.", - "type": "string" - }, - "primaryFiller": { - "description": "PrimaryFiller if set only files for this primary filler are returned.", - "type": "string" - }, - "producer": { - "description": "Producer is the specific source entity that created the data.", - "type": "string" - }, - "secondaryFiller": { - "description": "SecondaryFiller if set only files for this secondary filler are returned.", - "type": "string" - }, - "source": { - "description": "Source is the party responsible for creating the data.", - "type": "string" - }, - "subject": { - "description": "Subject if set only files for this subject are returned.", - "type": "string" - }, - "timestampAsc": { - "description": "TimestampAsc if set files are queried and returned in ascending order by timestamp.\nThis option is not applied for the latest file query.", - "type": "boolean" - } - } - }, - "internal_fetch_httphandler.SearchOptionsWithLimit": { - "type": "object", - "properties": { - "after": { - "description": "After if set only files after this time are returned.", - "type": "string" - }, - "before": { - "description": "Before if set only files before this time are returned.", - "type": "string" - }, - "dataType": { - "description": "DataType if set only files for this data type are returned.", - "type": "string" - }, - "limit": { - "type": "integer", - "example": 10 - }, - "optional": { - "description": "Optional is the optional data for additional metadata.", - "type": "string" - }, - "primaryFiller": { - "description": "PrimaryFiller if set only files for this primary filler are returned.", - "type": "string" - }, - "producer": { - "description": "Producer is the specific source entity that created the data.", - "type": "string" - }, - "secondaryFiller": { - "description": "SecondaryFiller if set only files for this secondary filler are returned.", - "type": "string" - }, - "source": { - "description": "Source is the party responsible for creating the data.", - "type": "string" - }, - "subject": { - "description": "Subject if set only files for this subject are returned.", - "type": "string" - }, - "timestampAsc": { - "description": "TimestampAsc if set files are queried and returned in ascending order by timestamp.\nThis option is not applied for the latest file query.", - "type": "boolean" - } - } - } - }, "securityDefinitions": { "BearerAuth": { "type": "apiKey", diff --git a/docs/swagger.json b/docs/swagger.json index 52bb390..c152037 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -30,8 +30,8 @@ } } }, - "/filenames": { - "post": { + "/v1/vehicle/{tokenId}/filenames": { + "get": { "description": "Retrieves a list of filenames that match the provided search options", "consumes": [ "application/json" @@ -45,13 +45,34 @@ "summary": "Get multiple filenames based on search criteria", "parameters": [ { - "description": "Search criteria and limit for finding files", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/internal_fetch_httphandler.SearchOptionsWithLimit" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -68,7 +89,7 @@ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -88,8 +109,8 @@ } } }, - "/files": { - "post": { + "/v1/vehicle/{tokenId}/files": { + "get": { "description": "Retrieves the content of multiple files that match the provided search options", "consumes": [ "application/json" @@ -103,13 +124,34 @@ "summary": "Get multiple files based on search criteria", "parameters": [ { - "description": "Search criteria and limit for finding files", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/internal_fetch_httphandler.SearchOptionsWithLimit" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -126,7 +168,7 @@ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -146,8 +188,8 @@ } } }, - "/latest-file": { - "post": { + "/v1/vehicle/{tokenId}/latest-file": { + "get": { "description": "Retrieves the content of the most recent file that matches the provided search options", "consumes": [ "application/json" @@ -161,13 +203,34 @@ "summary": "Get the latest file based on search criteria", "parameters": [ { - "description": "Search criteria for finding the latest file", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/indexrepo.SearchOptions" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -184,7 +247,7 @@ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -204,8 +267,8 @@ } } }, - "/latest-filename": { - "post": { + "/v1/vehicle/{tokenId}/latest-filename": { + "get": { "description": "Retrieves the most recent filename that matches the provided search options", "consumes": [ "application/json" @@ -219,13 +282,34 @@ "summary": "Get the latest filename based on search criteria", "parameters": [ { - "description": "Search criteria for finding the latest file", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/indexrepo.SearchOptions" - } + "type": "string", + "name": "after", + "in": "query" + }, + { + "type": "string", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "name": "producer", + "in": "query" + }, + { + "type": "string", + "name": "source", + "in": "query" + }, + { + "type": "string", + "name": "type", + "in": "query" } ], "responses": { @@ -239,7 +323,7 @@ } }, "400": { - "description": "Invalid request body", + "description": "Invalid request", "schema": { "type": "object", "additionalProperties": { @@ -260,102 +344,6 @@ } } }, - "definitions": { - "indexrepo.SearchOptions": { - "type": "object", - "properties": { - "after": { - "description": "After if set only files after this time are returned.", - "type": "string" - }, - "before": { - "description": "Before if set only files before this time are returned.", - "type": "string" - }, - "dataType": { - "description": "DataType if set only files for this data type are returned.", - "type": "string" - }, - "optional": { - "description": "Optional is the optional data for additional metadata.", - "type": "string" - }, - "primaryFiller": { - "description": "PrimaryFiller if set only files for this primary filler are returned.", - "type": "string" - }, - "producer": { - "description": "Producer is the specific source entity that created the data.", - "type": "string" - }, - "secondaryFiller": { - "description": "SecondaryFiller if set only files for this secondary filler are returned.", - "type": "string" - }, - "source": { - "description": "Source is the party responsible for creating the data.", - "type": "string" - }, - "subject": { - "description": "Subject if set only files for this subject are returned.", - "type": "string" - }, - "timestampAsc": { - "description": "TimestampAsc if set files are queried and returned in ascending order by timestamp.\nThis option is not applied for the latest file query.", - "type": "boolean" - } - } - }, - "internal_fetch_httphandler.SearchOptionsWithLimit": { - "type": "object", - "properties": { - "after": { - "description": "After if set only files after this time are returned.", - "type": "string" - }, - "before": { - "description": "Before if set only files before this time are returned.", - "type": "string" - }, - "dataType": { - "description": "DataType if set only files for this data type are returned.", - "type": "string" - }, - "limit": { - "type": "integer", - "example": 10 - }, - "optional": { - "description": "Optional is the optional data for additional metadata.", - "type": "string" - }, - "primaryFiller": { - "description": "PrimaryFiller if set only files for this primary filler are returned.", - "type": "string" - }, - "producer": { - "description": "Producer is the specific source entity that created the data.", - "type": "string" - }, - "secondaryFiller": { - "description": "SecondaryFiller if set only files for this secondary filler are returned.", - "type": "string" - }, - "source": { - "description": "Source is the party responsible for creating the data.", - "type": "string" - }, - "subject": { - "description": "Subject if set only files for this subject are returned.", - "type": "string" - }, - "timestampAsc": { - "description": "TimestampAsc if set files are queried and returned in ascending order by timestamp.\nThis option is not applied for the latest file query.", - "type": "boolean" - } - } - } - }, "securityDefinitions": { "BearerAuth": { "type": "apiKey", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 07e65dd..f3dd3de 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,79 +1,3 @@ -definitions: - indexrepo.SearchOptions: - properties: - after: - description: After if set only files after this time are returned. - type: string - before: - description: Before if set only files before this time are returned. - type: string - dataType: - description: DataType if set only files for this data type are returned. - type: string - optional: - description: Optional is the optional data for additional metadata. - type: string - primaryFiller: - description: PrimaryFiller if set only files for this primary filler are returned. - type: string - producer: - description: Producer is the specific source entity that created the data. - type: string - secondaryFiller: - description: SecondaryFiller if set only files for this secondary filler are - returned. - type: string - source: - description: Source is the party responsible for creating the data. - type: string - subject: - description: Subject if set only files for this subject are returned. - type: string - timestampAsc: - description: |- - TimestampAsc if set files are queried and returned in ascending order by timestamp. - This option is not applied for the latest file query. - type: boolean - type: object - internal_fetch_httphandler.SearchOptionsWithLimit: - properties: - after: - description: After if set only files after this time are returned. - type: string - before: - description: Before if set only files before this time are returned. - type: string - dataType: - description: DataType if set only files for this data type are returned. - type: string - limit: - example: 10 - type: integer - optional: - description: Optional is the optional data for additional metadata. - type: string - primaryFiller: - description: PrimaryFiller if set only files for this primary filler are returned. - type: string - producer: - description: Producer is the specific source entity that created the data. - type: string - secondaryFiller: - description: SecondaryFiller if set only files for this secondary filler are - returned. - type: string - source: - description: Source is the party responsible for creating the data. - type: string - subject: - description: Subject if set only files for this subject are returned. - type: string - timestampAsc: - description: |- - TimestampAsc if set files are queried and returned in ascending order by timestamp. - This option is not applied for the latest file query. - type: boolean - type: object info: contact: {} title: DIMO Fetch API @@ -95,18 +19,30 @@ paths: summary: Show the status of server. tags: - root - /filenames: - post: + /v1/vehicle/{tokenId}/filenames: + get: consumes: - application/json description: Retrieves a list of filenames that match the provided search options parameters: - - description: Search criteria and limit for finding files - in: body - name: request - required: true - schema: - $ref: '#/definitions/internal_fetch_httphandler.SearchOptionsWithLimit' + - in: query + name: after + type: string + - in: query + name: before + type: string + - in: query + name: limit + type: integer + - in: query + name: producer + type: string + - in: query + name: source + type: string + - in: query + name: type + type: string produces: - application/json responses: @@ -119,7 +55,7 @@ paths: type: array type: object "400": - description: Invalid request body + description: Invalid request schema: additionalProperties: type: string @@ -133,19 +69,31 @@ paths: summary: Get multiple filenames based on search criteria tags: - files - /files: - post: + /v1/vehicle/{tokenId}/files: + get: consumes: - application/json description: Retrieves the content of multiple files that match the provided search options parameters: - - description: Search criteria and limit for finding files - in: body - name: request - required: true - schema: - $ref: '#/definitions/internal_fetch_httphandler.SearchOptionsWithLimit' + - in: query + name: after + type: string + - in: query + name: before + type: string + - in: query + name: limit + type: integer + - in: query + name: producer + type: string + - in: query + name: source + type: string + - in: query + name: type + type: string produces: - application/json responses: @@ -158,7 +106,7 @@ paths: type: array type: object "400": - description: Invalid request body + description: Invalid request schema: additionalProperties: type: string @@ -172,19 +120,31 @@ paths: summary: Get multiple files based on search criteria tags: - files - /latest-file: - post: + /v1/vehicle/{tokenId}/latest-file: + get: consumes: - application/json description: Retrieves the content of the most recent file that matches the provided search options parameters: - - description: Search criteria for finding the latest file - in: body - name: request - required: true - schema: - $ref: '#/definitions/indexrepo.SearchOptions' + - in: query + name: after + type: string + - in: query + name: before + type: string + - in: query + name: limit + type: integer + - in: query + name: producer + type: string + - in: query + name: source + type: string + - in: query + name: type + type: string produces: - application/json responses: @@ -197,7 +157,7 @@ paths: type: array type: object "400": - description: Invalid request body + description: Invalid request schema: additionalProperties: type: string @@ -211,19 +171,31 @@ paths: summary: Get the latest file based on search criteria tags: - files - /latest-filename: - post: + /v1/vehicle/{tokenId}/latest-filename: + get: consumes: - application/json description: Retrieves the most recent filename that matches the provided search options parameters: - - description: Search criteria for finding the latest file - in: body - name: request - required: true - schema: - $ref: '#/definitions/indexrepo.SearchOptions' + - in: query + name: after + type: string + - in: query + name: before + type: string + - in: query + name: limit + type: integer + - in: query + name: producer + type: string + - in: query + name: source + type: string + - in: query + name: type + type: string produces: - application/json responses: @@ -234,7 +206,7 @@ paths: type: string type: object "400": - description: Invalid request body + description: Invalid request schema: additionalProperties: type: string diff --git a/internal/fetch/httphandler/httphandler.go b/internal/fetch/httphandler/httphandler.go index debe718..3ba1107 100644 --- a/internal/fetch/httphandler/httphandler.go +++ b/internal/fetch/httphandler/httphandler.go @@ -81,7 +81,7 @@ func (s *searchParams) toSearchOptions(subject cloudevent.NFTDID) indexrepo.Sear // @Tags files // @Accept json // @Produce json -// @Param params query SearchParams false "Search parameters" +// @Param params query searchParams false "Search parameters" // @Success 200 {object} map[string]string "Returns the latest filename" // @Failure 400 {object} map[string]string "Invalid request" // @Failure 500 {object} map[string]string "Server error" @@ -117,7 +117,7 @@ func (h *Handler) GetLatestFileName(fCtx *fiber.Ctx) error { // @Tags files // @Accept json // @Produce json -// @Param params query SearchParams false "Search parameters" +// @Param params query searchParams false "Search parameters" // @Success 200 {object} map[string][]string "Returns list of filenames" // @Failure 400 {object} map[string]string "Invalid request" // @Failure 500 {object} map[string]string "Server error" @@ -153,7 +153,7 @@ func (h *Handler) GetFileNames(fCtx *fiber.Ctx) error { // @Tags files // @Accept json // @Produce json -// @Param params query SearchParams false "Search parameters" +// @Param params query searchParams false "Search parameters" // @Success 200 {object} map[string][]byte "Returns file data" // @Failure 400 {object} map[string]string "Invalid request" // @Failure 500 {object} map[string]string "Server error" @@ -189,7 +189,7 @@ func (h *Handler) GetFiles(fCtx *fiber.Ctx) error { // @Tags files // @Accept json // @Produce json -// @Param params query SearchParams false "Search parameters" +// @Param params query searchParams false "Search parameters" // @Success 200 {object} map[string][]byte "Returns latest file data" // @Failure 400 {object} map[string]string "Invalid request" // @Failure 500 {object} map[string]string "Server error"