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

Created endpoint for creating dataset members #66

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 17 additions & 4 deletions c/datasetService.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ static bool isDatasetMember(char* dsPath, HttpResponse* response) {
return FALSE;
}

static void parseMemberName(char* dsPath, char* dsName, char* memberName, HttpResponse* response){
int lParenIndex = lastIndexOf(dsPath, strlen(dsPath), '(');
int rParenIndex = lastIndexOf(dsPath, strlen(dsPath), ')');
memcpy(dsName, dsPath, lParenIndex);
memcpy(memberName, dsPath + lParenIndex + 1, rParenIndex - lParenIndex - 1);
padWithSpaces(dsName, DATASET_NAME_LEN, 1, 0);
padWithSpaces(memberName, MEMBER_MAXLEN, 1, 0);
}

static int serveDatasetMetadata(HttpService *service, HttpResponse *response) {
zowelog(NULL, LOG_COMP_ID_DATASET, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__);
HttpRequest *request = response->request;
Expand Down Expand Up @@ -125,8 +134,10 @@ static int serveDataset(HttpService *service, HttpResponse *response){
return -1;
}
else {
respondWithJsonError(response, "Dataset Member allocation is not supported", 501, "Not Implemented");
return -1;
char datasetName[DATASET_NAME_LEN] = {0};
char memberName[MEMBER_MAXLEN] = {0};
parseMemberName(dsName, datasetName, memberName, response);
newDatasetMember(response, datasetName, memberName);
}
}
else if (!strcmp(request->method, methodDELETE)){
Expand All @@ -135,8 +146,10 @@ static int serveDataset(HttpService *service, HttpResponse *response){
return -1;
}
else {
respondWithJsonError(response, "Dataset member deletion is not supported", 501, "Not Implemented");
return -1;
char datasetName[DATASET_NAME_LEN] = {0};
char memberName[MEMBER_MAXLEN] = {0};
parseMemberName(dsName, datasetName, memberName, response);
removeDatasetMember(response, datasetName, memberName);
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion deps/zowe-common-c
1 change: 1 addition & 0 deletions h/datasetService.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define __DATASET_SERVICE_H__

#define MEMBER_MAXLEN 8
#define DATASET_NAME_LEN 44

void installServeDatasetService(HttpServer *server);
void installDatasetMetadataService(HttpServer *server);
Expand Down