Skip to content

Commit

Permalink
Created endpoint for creating dataset members
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Caron <ccaron@rocketsoftware.com>
  • Loading branch information
Charlie Caron committed Jul 30, 2019
1 parent b9cda18 commit 7fe6a50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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

0 comments on commit 7fe6a50

Please sign in to comment.