Skip to content

Commit

Permalink
fix: update db schema and swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdh committed Feb 3, 2022
1 parent 6c8a6e4 commit 0ce95ab
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 6 deletions.
3 changes: 2 additions & 1 deletion store/postgres/migrations/000003_create_assets_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ CREATE TABLE assets (
updated_at timestamp DEFAULT NOW()
);

CREATE UNIQUE INDEX assets_idx_urn_type_service ON assets(urn,type,service);
CREATE UNIQUE INDEX assets_idx_urn_type ON assets(urn,type);
CREATE INDEX assets_idx_service ON assets(service);

CREATE TABLE asset_owners (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
Expand Down
1 change: 1 addition & 0 deletions store/postgres/migrations/000004_create_stars_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CREATE TABLE stars (
);

CREATE UNIQUE INDEX stars_idx_user_id_asset_id ON stars(user_id,asset_id);
CREATE UNIQUE INDEX stars_idx_asset_id ON stars(asset_id);
85 changes: 80 additions & 5 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
paths:
"/v1beta1/assets":
get:
tags:
tags:
- Assets
summary: Get list of assets
description: "Returns list of assets, optionally filtered by type and service"
Expand Down Expand Up @@ -59,7 +59,7 @@ paths:
schema:
$ref: "#/definitions/InternalServerError"
put:
tags:
tags:
- Assets
summary: Upsert an asset
description: "Create a new asset if a combination of urn, type and service does not exist. If exists update instead"
Expand Down Expand Up @@ -89,7 +89,7 @@ paths:
$ref: "#/definitions/InternalServerError"
"/v1beta1/assets/{id}":
get:
tags:
tags:
- Assets
summary: Find an asset
description: "Returns a single asset with given ID"
Expand All @@ -115,7 +115,7 @@ paths:
schema:
$ref: "#/definitions/InternalServerError"
delete:
tags:
tags:
- Assets
summary: Delete an asset
description: "Delete a single asset with given ID"
Expand All @@ -141,6 +141,39 @@ paths:
description: "internal server error"
schema:
$ref: "#/definitions/InternalServerError"
"/v1beta1/assets/{id}/stargazers":
get:
tags:
- Assets
summary: Find users that stars an asset
description: "Returns a list of users that stars an asset"
produces:
- "application/json"
parameters:
- in: path
name: id
description: "asset's ID"
schema:
$ref: "#/definitions/UUID"
responses:
200:
description: OK
schema:
type: array
items:
$ref: "#/definitions/User"
400:
description: "bad request error"
schema:
$ref: "#/definitions/Error"
404:
description: "not found error"
schema:
$ref: "#/definitions/Error"
500:
description: "internal server error"
schema:
$ref: "#/definitions/InternalServerError"
"/v1beta1/lineage/{type}/{record}":
get:
tags:
Expand Down Expand Up @@ -307,6 +340,48 @@ paths:
description: type or record cannot be found
schema:
$ref: "#/definitions/Error"
"/v1beta1/types/{name}/records/{id}/stargazers":
delete:
tags:
- Record
summary: get list of users that stars a record
produces:
- "application/json"
parameters:
- in: header
name: Columbus-User-Email
schema:
type: string
format: email
example: user@odpf.io
required: true
- in: path
name: name
type: string
required: true
- in: path
name: id
type: string
required: true
responses:
200:
description: OK
schema:
type: array
items:
$ref: "#/definitions/User"
404:
description: type or record cannot be found
schema:
$ref: "#/definitions/Error"
400:
description: bad request
schema:
$ref: "#/definitions/Error"
500:
description: internal server error
schema:
$ref: "#/definitions/Error"
"/v1beta1/types/{name}/{id}":
get:
tags:
Expand Down Expand Up @@ -984,7 +1059,7 @@ definitions:
type: object
allOf:
- type: object
properties:
properties:
id:
$ref: "#/definitions/UUID"
description: "Main asset identifer in UUID"
Expand Down

0 comments on commit 0ce95ab

Please sign in to comment.