Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

914 [Feature] - "Add remaining CRUD endpoints to SST" #943

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
588f341
Implemented skeleton; still need to fill in handler implementation
alantao912 Aug 26, 2023
257bf5a
Work in progress
alantao912 Sep 3, 2023
361c851
Added type hints
alantao912 Sep 3, 2023
a1f26e0
Implemented get_trainspace endpoint
alantao912 Sep 3, 2023
bcfd0cd
Progress
alantao912 Sep 13, 2023
a444193
Merge branch 'nextjs' into 914-feature-add-the-rest-of-the-crud-endpo…
alantao912 Sep 13, 2023
e7efbd9
Progress
alantao912 Sep 15, 2023
b2b03b8
Resolved ticket 914
alantao912 Sep 22, 2023
0cf2940
Implemented DynamoDB built-in pagination consideration to get all tra…
alantao912 Sep 22, 2023
3f67833
Merge branch 'nextjs' into 914-feature-add-the-rest-of-the-crud-endpo…
alantao912 Sep 22, 2023
39ef536
Installed yarn uuid package
alantao912 Sep 24, 2023
18da65b
Installed dependencies to serverless directory
alantao912 Sep 24, 2023
1144453
Merge branch '914-feature-add-the-rest-of-the-crud-endpoints-to-sst' …
alantao912 Sep 24, 2023
8d00b0b
Added types/uuid
alantao912 Sep 24, 2023
021a1fe
Implemented PR feedback
alantao912 Oct 4, 2023
608f2da
T
alantao912 Oct 13, 2023
33ab13f
Fixed stuff
alantao912 Oct 17, 2023
94ac1cf
Merge branch 'nextjs' into 914-feature-add-the-rest-of-the-crud-endpo…
alantao912 Oct 17, 2023
c85e4d4
Implemented PR changes: Narrowewd scope of SST handler permissions, c…
alantao912 Oct 18, 2023
24da097
:art: Auto-generated directory tree for repository in Architecture.md
alantao912 Oct 18, 2023
412799c
Removed useless comment
alantao912 Oct 18, 2023
57f1adc
Merge branch '914-feature-add-the-rest-of-the-crud-endpoints-to-sst' …
alantao912 Oct 18, 2023
18df85b
Split creation of different trainspaces into different API endpoints
alantao912 Oct 20, 2023
40d631c
Implemented Daniel Wu's PR comments
alantao912 Oct 23, 2023
42af400
Fixed SonarCloud comment changes
alantao912 Oct 24, 2023
9aa6db0
Renamed file
alantao912 Oct 24, 2023
15f8b37
Fixed path issues
alantao912 Oct 24, 2023
9dab55b
Merge branch 'nextjs' into 914-feature-add-the-rest-of-the-crud-endpo…
alantao912 Oct 24, 2023
4bd534e
FF
alantao912 Oct 24, 2023
fd4939a
Implemented Daniel Wu's PR comments
alantao912 Oct 29, 2023
d9c2dd1
:art: Auto-generated directory tree for repository in Architecture.md
alantao912 Oct 29, 2023
9d49a95
PR Changes
alantao912 Nov 1, 2023
19ed58b
Merge branch '914-feature-add-the-rest-of-the-crud-endpoints-to-sst' …
alantao912 Nov 1, 2023
1eb013c
Implemented PR comments
alantao912 Nov 1, 2023
9aa4168
Removed unused file
alantao912 Nov 1, 2023
65841c3
Resolved conflicts
alantao912 Nov 10, 2023
0499c2b
:art: Auto-generated directory tree for repository in Architecture.md
alantao912 Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions serverless/packages/functions/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

export enum TrainStatus {
QUEUED,
STARTING,
UPLOADING,
TRAINING,
SUCCESS,
ERROR
}
10 changes: 10 additions & 0 deletions serverless/packages/functions/src/datasets/user/delete_userdata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
import parseJwt from "@dlp-sst-app/core/parseJwt";

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
alantao912 marked this conversation as resolved.
Show resolved Hide resolved
return {
statusCode: 404,
body: JSON.stringify({ message: "Not Found" }),
karkir0003 marked this conversation as resolved.
Show resolved Hide resolved
};
};
38 changes: 38 additions & 0 deletions serverless/packages/functions/src/trainspace/create_trainspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import parseJwt from "@dlp-sst-app/core/parseJwt";
import TrainspaceData from './trainspace-data';
import { v4 as uuidv4 } from 'uuid';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { PutCommand, DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
if (
event &&
event.pathParameters &&
event.pathParameters.type &&
event.pathParameters.filename
) {

const uid: string = parseJwt(event.headers.authorization ?? "")["user_id"];
const trainspace_id: string = uuidv4();
const trainspaceData: TrainspaceData = new TrainspaceData(trainspace_id, uid);

const client: DynamoDBClient = new DynamoDBClient({});
const docClient: DynamoDBDocumentClient = new DynamoDBDocumentClient.from(client);

const command: PutCommand = new PutCommand({
TableName: "trainspace",
Item: trainspaceData
});

const response = await docClient.send(command);
return {
statusCode: 200,
body: JSON.stringify({ message: "Successfully created a new trainspace."})
};
}
return {
statusCode: 404,
body: JSON.stringify({ message: "Not Found" }),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
import parseJwt from "@dlp-sst-app/core/parseJwt";

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
return {
statusCode: 404,
body: JSON.stringify({ message: "Not Found" }),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
import parseJwt from "@dlp-sst-app/core/parseJwt";

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
return {
statusCode: 404,
body: JSON.stringify({ message: "Not Found" }),
};
};
10 changes: 10 additions & 0 deletions serverless/packages/functions/src/trainspace/get_trainspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
import parseJwt from "@dlp-sst-app/core/parseJwt";

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
return {
statusCode: 404,
body: JSON.stringify({ message: "Not Found" }),
};
};
20 changes: 20 additions & 0 deletions serverless/packages/functions/src/trainspace/trainspace-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { TrainStatus } from '../constants';

export default class TrainspaceData
{
trainspace_id: string;
uid: string;
created: string = "";
data_source: string = "";
dataset_data: object = null;
name: string = "";
parameters_data: object = null;
review_data: string = "";
status: TrainStatus = TrainStatus.QUEUED;

constructor(trainspace_id: string, uid: string) {
this.trainspace_id = trainspace_id;
this.uid = uid;
}

}
10 changes: 10 additions & 0 deletions serverless/stacks/AppStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export function AppStack({ stack }: StackContext) {
"packages/functions/src/datasets/user/all_of_type.handler",
"GET /datasets/user/{type}/{filename}/columns":
"packages/functions/src/datasets/user/columns.handler",
"DELETE /dataset/user/{type}/{filename}" :
"packages/functions/src/datasets/user/delete_userdata.handler",
"POST /trainspace":
"packages/functions/src/trainspace/create_trainspace.handler",
"GET /trainspace/{id}":
"packages/functions/src/trainspace/get_trainspace.handler",
"GET /trainspace":
"packages/functions/src/trainspace/get_all_trainspace.handler",
"DELETE /trainspace/{id}":
"packages/functions/src/trainspace/delete_trainspace.handler"
},
});

Expand Down
Loading