From 459484df51b844f95f99062fdd95dd575224fd93 Mon Sep 17 00:00:00 2001 From: William Dutton Date: Wed, 31 Jul 2024 13:20:36 +1000 Subject: [PATCH] add KiteworksApiHelper and Builder beans --- .../kiteworks/helpers/KiteworksApiHelper.java | 139 +++++++++ ...VersionsGetWithHttpInfoRequestBuilder.java | 135 ++++++++ ...oldersIdActionsFilePostRequestBuilder.java | 93 ++++++ ...tFoldersIdActivitiesGetRequestBuilder.java | 190 ++++++++++++ ...stFoldersParentFilesGetRequestBuilder.java | 292 ++++++++++++++++++ .../au/gov/qld/ssq/kiteworks/model/helper.py | 91 ++++++ .../ssq/kiteworks/KiteworksSpringService.java | 6 + 7 files changed, 946 insertions(+) create mode 100644 kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/helpers/KiteworksApiHelper.java create mode 100644 kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFilesidVersionsGetWithHttpInfoRequestBuilder.java create mode 100644 kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActionsFilePostRequestBuilder.java create mode 100644 kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActivitiesGetRequestBuilder.java create mode 100644 kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersParentFilesGetRequestBuilder.java create mode 100644 kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/helper.py diff --git a/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/helpers/KiteworksApiHelper.java b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/helpers/KiteworksApiHelper.java new file mode 100644 index 0000000..d832ede --- /dev/null +++ b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/helpers/KiteworksApiHelper.java @@ -0,0 +1,139 @@ +package au.gov.qld.ssq.kiteworks.helpers; + +import au.gov.qld.ssq.kiteworks.model.RestFilesidVersionsGetWithHttpInfoRequestBuilder; +import au.gov.qld.ssq.kiteworks.model.RestFoldersIdActionsFilePostRequestBuilder; +import au.gov.qld.ssq.kiteworks.model.RestFoldersIdActivitiesGetRequestBuilder; +import au.gov.qld.ssq.kiteworks.model.RestFoldersParentFilesGetRequestBuilder; +import com.kiteworks.client.ApiException; +import com.kiteworks.client.ApiResponse; +import com.kiteworks.client.api.FilesApi; +import com.kiteworks.client.api.FoldersApi; +import com.kiteworks.client.model.ActivityList; +import com.kiteworks.client.model.FolderChildrenFiles; +import com.kiteworks.client.model.Version; + +import java.io.File; +import java.util.List; + +public class KiteworksApiHelper { + + private FoldersApi foldersApi; + private FilesApi filesApi; + + public KiteworksApiHelper(FoldersApi foldersApi, FilesApi filesApi) { + this.foldersApi = foldersApi; + this.filesApi = filesApi; + } + + // Get a list of files in a folder + // %s/rest/folders/{parent}/files + public ApiResponse getFolderFileNames(RestFoldersParentFilesGetRequestBuilder builder) throws ApiException { + + return foldersApi.restFoldersParentFilesGetWithHttpInfo( + builder.getParent(), + builder.getUserId(), + builder.getReturnEntity(), + builder.getModifiedColonLte(), + builder.getModifiedColonLt(), + builder.getDeleted(), + builder.getCreatedColonLt(), + builder.getOrderBy(), + builder.getOffset(), + builder.getLimit(), + builder.getNameColonContains(), + builder.getCreatedColonGte(), + builder.getMode(), + builder.getModifiedColonGte(), + builder.getCreated(), + builder.getCreatedColonLte(), + builder.getModifiedColonGt(), + builder.getExpireColonLte(), + builder.getModified(), + builder.getUserIdColonIn(), + builder.getExpireColonLt(), + builder.getExpireColonGte(), + builder.getCreatedColonGt(), + builder.getWith(), + builder.getName(), + builder.getIsPushed(), + builder.getExpireColonGt(), + builder.getExpire() + ); + } + + // %s/rest/files/%s (method DELETE) + public void doFileDelete(String fileId) throws ApiException { + filesApi.restFilesIdDeleteWithHttpInfo(fileId); + } + + // %s/folders/%%s/actions/file + public ApiResponse doUpload(RestFoldersIdActionsFilePostRequestBuilder builder) throws ApiException { + return filesApi.restFoldersIdActionsFilePostWithHttpInfo( + builder.getId(), + builder.getBody(), + builder.getReturnEntity(), + builder.getMode(), + builder.getClientCreated(), + builder.getClientModified(), + builder.getDisableAutoVersion(), + builder.getNote() + ); + } + + // %s/files/%%s/content + /** + * List versions + * Returns a list of versions for a given file + **/ + public ApiResponse getFilesContent(String fileId) throws ApiException { + return filesApi.restFilesIdContentGetWithHttpInfo(fileId); + } + + // "%s/files/%%s/versions + public ApiResponse> restFilesIdVersionsGetWithHttpInfo(RestFilesidVersionsGetWithHttpInfoRequestBuilder builder) throws ApiException { + return filesApi.restFilesIdVersionsGetWithHttpInfo( + builder.getId(), + builder.getCreated(), + builder.getCreatedColonGt(), + builder.getCreatedColonGte(), + builder.getCreatedColonLt(), + builder.getCreatedColonLte(), + builder.getOrderBy(), + builder.getOffset(), + builder.getLimit(), + builder.getLocateId(), + builder.getWith(), + builder.getMode() + ); + } + + // %s/files/%%s/versions/%%s/content + public ApiResponse restFilesIdVersionsVersionIdContentGetWithHttpInfo(String id, String versionId, String range) throws ApiException { + return filesApi.restFilesIdVersionsVersionIdContentGetWithHttpInfo(id, versionId, range); + } + + // %s/folders/%%s/activities?limit=%s + public ApiResponse restFoldersIdActivitiesGetWithHttpInfo(RestFoldersIdActivitiesGetRequestBuilder builder) throws ApiException { + return foldersApi.restFoldersIdActivitiesGetWithHttpInfo( + builder.getId(), + builder.getFilter(), + builder.getType(), + builder.getStartTime(), + builder.getWith(), + builder.getOffset(), + builder.getEndTime(), + builder.getReturnEntity(), + builder.getEndDate(), + builder.getSearch(), + builder.getOrderBy(), + builder.getMode(), + builder.getStartDate(), + builder.getTransactionId(), + builder.getFileId(), + builder.getLimit(), + builder.getNested(), + builder.getNoDayBack() + ); + } + +} diff --git a/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFilesidVersionsGetWithHttpInfoRequestBuilder.java b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFilesidVersionsGetWithHttpInfoRequestBuilder.java new file mode 100644 index 0000000..01ca4dc --- /dev/null +++ b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFilesidVersionsGetWithHttpInfoRequestBuilder.java @@ -0,0 +1,135 @@ +package au.gov.qld.ssq.kiteworks.model; + +import java.util.List; + +public class RestFilesidVersionsGetWithHttpInfoRequestBuilder { + private String id; + private Integer created; + private Integer createdColonGt; + private Integer createdColonGte; + private Integer createdColonLt; + private Integer createdColonLte; + private List orderBy; + private Integer offset; + private Integer limit; + private Integer locateId; + private String with; + private String mode; + + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withId(String id) { + this.id = id; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withCreated(Integer created) { + this.created = created; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withCreatedColonGt(Integer createdColonGt) { + this.createdColonGt = createdColonGt; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withCreatedColonGte(Integer createdColonGte) { + this.createdColonGte = createdColonGte; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withCreatedColonLt(Integer createdColonLt) { + this.createdColonLt = createdColonLt; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withCreatedColonLte(Integer createdColonLte) { + this.createdColonLte = createdColonLte; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withOrderBy(List orderBy) { + this.orderBy = orderBy; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withOffset(Integer offset) { + this.offset = offset; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withLimit(Integer limit) { + this.limit = limit; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withLocateId(Integer locateId) { + this.locateId = locateId; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withWith(String with) { + this.with = with; + return this; + } + + public RestFilesidVersionsGetWithHttpInfoRequestBuilder withMode(String mode) { + this.mode = mode; + return this; + } + + // Add build method to return the built object + public RestFilesidVersionsGetWithHttpInfoRequestBuilder build() { + return this; + } + + // Getter methods for each field (if needed) + + public String getId() { + return id; + } + + public Integer getCreated() { + return created; + } + + public Integer getCreatedColonGt() { + return createdColonGt; + } + + public Integer getCreatedColonGte() { + return createdColonGte; + } + + public Integer getCreatedColonLt() { + return createdColonLt; + } + + public Integer getCreatedColonLte() { + return createdColonLte; + } + + public List getOrderBy() { + return orderBy; + } + + public Integer getOffset() { + return offset; + } + + public Integer getLimit() { + return limit; + } + + public Integer getLocateId() { + return locateId; + } + + public String getWith() { + return with; + } + + public String getMode() { + return mode; + } +} + diff --git a/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActionsFilePostRequestBuilder.java b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActionsFilePostRequestBuilder.java new file mode 100644 index 0000000..432a898 --- /dev/null +++ b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActionsFilePostRequestBuilder.java @@ -0,0 +1,93 @@ +package au.gov.qld.ssq.kiteworks.model; + +import java.io.File; +import java.time.LocalDate; + +public class RestFoldersIdActionsFilePostRequestBuilder { + private String id; + private File body; + private Boolean returnEntity; + private String mode; + private LocalDate clientCreated; + private LocalDate clientModified; + private Boolean disableAutoVersion; + private Boolean note; + + public RestFoldersIdActionsFilePostRequestBuilder withId(String id) { + this.id = id; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withBody(File body) { + this.body = body; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withReturnEntity(Boolean returnEntity) { + this.returnEntity = returnEntity; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withMode(String mode) { + this.mode = mode; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withClientCreated(LocalDate clientCreated) { + this.clientCreated = clientCreated; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withClientModified(LocalDate clientModified) { + this.clientModified = clientModified; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withDisableAutoVersion(Boolean disableAutoVersion) { + this.disableAutoVersion = disableAutoVersion; + return this; + } + + public RestFoldersIdActionsFilePostRequestBuilder withNote(Boolean note) { + this.note = note; + return this; + } + + // Add build method to return the built object + public RestFoldersIdActionsFilePostRequestBuilder build() { + return this; + } + + // Getter methods for each field (if needed) + public String getId() { + return id; + } + + public File getBody() { + return body; + } + + public Boolean getReturnEntity() { + return returnEntity; + } + + public String getMode() { + return mode; + } + + public LocalDate getClientCreated() { + return clientCreated; + } + + public LocalDate getClientModified() { + return clientModified; + } + + public Boolean getDisableAutoVersion() { + return disableAutoVersion; + } + + public Boolean getNote() { + return note; + } +} diff --git a/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActivitiesGetRequestBuilder.java b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActivitiesGetRequestBuilder.java new file mode 100644 index 0000000..0d912b8 --- /dev/null +++ b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersIdActivitiesGetRequestBuilder.java @@ -0,0 +1,190 @@ +package au.gov.qld.ssq.kiteworks.model; + +public class RestFoldersIdActivitiesGetRequestBuilder { + private String id; + private String filter; + private String type; + private Integer startTime; + private String with; + private Integer offset; + private Integer endTime; + private Boolean returnEntity; + private String endDate; + private String search; + private String orderBy; + private String mode; + private String startDate; + private String transactionId; + private String fileId; + private Integer limit; + private Boolean nested; + private Integer noDayBack; + + public RestFoldersIdActivitiesGetRequestBuilder withId(String id) { + this.id = id; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withFilter(String filter) { + this.filter = filter; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withType(String type) { + this.type = type; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withStartTime(Integer startTime) { + this.startTime = startTime; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withWith(String with) { + this.with = with; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withOffset(Integer offset) { + this.offset = offset; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withEndTime(Integer endTime) { + this.endTime = endTime; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withReturnEntity(Boolean returnEntity) { + this.returnEntity = returnEntity; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withEndDate(String endDate) { + this.endDate = endDate; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withSearch(String search) { + this.search = search; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withOrderBy(String orderBy) { + this.orderBy = orderBy; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withMode(String mode) { + this.mode = mode; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withStartDate(String startDate) { + this.startDate = startDate; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withTransactionId(String transactionId) { + this.transactionId = transactionId; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withFileId(String fileId) { + this.fileId = fileId; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withLimit(Integer limit) { + this.limit = limit; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withNested(Boolean nested) { + this.nested = nested; + return this; + } + + public RestFoldersIdActivitiesGetRequestBuilder withNoDayBack(Integer noDayBack) { + this.noDayBack = noDayBack; + return this; + } + + // Add build method to return the built object + public RestFoldersIdActivitiesGetRequestBuilder build() { + return this; + } + + // Getter methods for each field (if needed) + public String getId() { + return id; + } + + public String getFilter() { + return filter; + } + + public String getType() { + return type; + } + + public Integer getStartTime() { + return startTime; + } + + public String getWith() { + return with; + } + + public Integer getOffset() { + return offset; + } + + public Integer getEndTime() { + return endTime; + } + + public Boolean getReturnEntity() { + return returnEntity; + } + + public String getEndDate() { + return endDate; + } + + public String getSearch() { + return search; + } + + public String getOrderBy() { + return orderBy; + } + + public String getMode() { + return mode; + } + + public String getStartDate() { + return startDate; + } + + public String getTransactionId() { + return transactionId; + } + + public String getFileId() { + return fileId; + } + + public Integer getLimit() { + return limit; + } + + public Boolean getNested() { + return nested; + } + + public Integer getNoDayBack() { + return noDayBack; + } +} diff --git a/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersParentFilesGetRequestBuilder.java b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersParentFilesGetRequestBuilder.java new file mode 100644 index 0000000..c4092c4 --- /dev/null +++ b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/RestFoldersParentFilesGetRequestBuilder.java @@ -0,0 +1,292 @@ +package au.gov.qld.ssq.kiteworks.model; + +import java.util.List; + +public class RestFoldersParentFilesGetRequestBuilder { + private String parent; + private String userId; + private Boolean returnEntity; + private String modifiedColonLte; + private String modifiedColonLt; + private Boolean deleted; + private String createdColonLt; + private String orderBy; + private Integer offset; + private Integer limit; + private String nameColonContains; + private String createdColonGte; + private String mode; + private String modifiedColonGte; + private String created; + private String createdColonLte; + private String modifiedColonGt; + private String expireColonLte; + private String modified; + private List userIdColonIn; + private String expireColonLt; + private String expireColonGte; + private String createdColonGt; + private String with; + private String name; + private Boolean isPushed; + private String expireColonGt; + private String expire; + + public RestFoldersParentFilesGetRequestBuilder withParent(String parent) { + this.parent = parent; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withUserId(String userId) { + this.userId = userId; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withReturnEntity(Boolean returnEntity) { + this.returnEntity = returnEntity; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withModifiedColonLte(String modifiedColonLte) { + this.modifiedColonLte = modifiedColonLte; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withModifiedColonLt(String modifiedColonLt) { + this.modifiedColonLt = modifiedColonLt; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withDeleted(Boolean deleted) { + this.deleted = deleted; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withCreatedColonLt(String createdColonLt) { + this.createdColonLt = createdColonLt; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withOrderBy(String orderBy) { + this.orderBy = orderBy; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withOffset(Integer offset) { + this.offset = offset; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withLimit(Integer limit) { + this.limit = limit; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withNameColonContains(String nameColonContains) { + this.nameColonContains = nameColonContains; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withCreatedColonGte(String createdColonGte) { + this.createdColonGte = createdColonGte; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withMode(String mode) { + this.mode = mode; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withModifiedColonGte(String modifiedColonGte) { + this.modifiedColonGte = modifiedColonGte; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withCreated(String created) { + this.created = created; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withCreatedColonLte(String createdColonLte) { + this.createdColonLte = createdColonLte; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withModifiedColonGt(String modifiedColonGt) { + this.modifiedColonGt = modifiedColonGt; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withExpireColonLte(String expireColonLte) { + this.expireColonLte = expireColonLte; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withModified(String modified) { + this.modified = modified; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withUserIdColonIn(List userIdColonIn) { + this.userIdColonIn = userIdColonIn; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withExpireColonLt(String expireColonLt) { + this.expireColonLt = expireColonLt; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withExpireColonGte(String expireColonGte) { + this.expireColonGte = expireColonGte; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withCreatedColonGt(String createdColonGt) { + this.createdColonGt = createdColonGt; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withWith(String with) { + this.with = with; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withName(String name) { + this.name = name; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withIsPushed(Boolean isPushed) { + this.isPushed = isPushed; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withExpireColonGt(String expireColonGt) { + this.expireColonGt = expireColonGt; + return this; + } + + public RestFoldersParentFilesGetRequestBuilder withExpire(String expire) { + this.expire = expire; + return this; + } + + // Add build method to return the built object + public RestFoldersParentFilesGetRequestBuilder build() { + return this; + } + + // Getter methods for each field (if needed) + public String getParent() { + return parent; + } + + public String getUserId() { + return userId; + } + + public Boolean getReturnEntity() { + return returnEntity; + } + + public String getModifiedColonLte() { + return modifiedColonLte; + } + + public String getModifiedColonLt() { + return modifiedColonLt; + } + + public Boolean getDeleted() { + return deleted; + } + + public String getCreatedColonLt() { + return createdColonLt; + } + + public String getOrderBy() { + return orderBy; + } + + public Integer getOffset() { + return offset; + } + + public Integer getLimit() { + return limit; + } + + public String getNameColonContains() { + return nameColonContains; + } + + public String getCreatedColonGte() { + return createdColonGte; + } + + public String getMode() { + return mode; + } + + public String getModifiedColonGte() { + return modifiedColonGte; + } + + public String getCreated() { + return created; + } + + public String getCreatedColonLte() { + return createdColonLte; + } + + public String getModifiedColonGt() { + return modifiedColonGt; + } + + public String getExpireColonLte() { + return expireColonLte; + } + + public String getModified() { + return modified; + } + + public List getUserIdColonIn() { + return userIdColonIn; + } + + public String getExpireColonLt() { + return expireColonLt; + } + + public String getExpireColonGte() { + return expireColonGte; + } + + public String getCreatedColonGt() { + return createdColonGt; + } + + public String getWith() { + return with; + } + + public String getName() { + return name; + } + + public Boolean getIsPushed() { + return isPushed; + } + + public String getExpireColonGt() { + return expireColonGt; + } + + public String getExpire() { + return expire; + } +} diff --git a/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/helper.py b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/helper.py new file mode 100644 index 0000000..4ecec74 --- /dev/null +++ b/kiteworks-native-client/src/main/java/au/gov/qld/ssq/kiteworks/model/helper.py @@ -0,0 +1,91 @@ +import re + +def parse_signature(signature): + # Extract the method name and parameters from the signature + method_pattern = re.compile(r'public\s+\w+<\w+>\s+(\w+)\((.*?)\) throws \w+ {') + match = method_pattern.search(signature) + method_name = match.group(1) + params = match.group(2) + + # Split parameters into a list of tuples (type, name) + param_list = [] + param_pattern = re.compile(r'(\w+<\w+>|List<\w+>|Map<\w+, \w+>|String|Boolean|Integer|File|LocalDate|int|boolean) (\w+)') + for param in params.split(','): + param = param.strip() + match = param_pattern.match(param) + param_list.append((match.group(1), match.group(2))) + + return method_name, param_list + +def generate_builder_class(method_name, param_list): + class_name = ''.join([word.capitalize() for word in re.findall(r'\w+', method_name)]) + "RequestBuilder" + + builder_class = f"public class {class_name} {{\n" + + # Declare private fields + for param_type, param_name in param_list: + builder_class += f" private {param_type} {param_name};\n" + + builder_class += "\n" + + # Generate with methods + for param_type, param_name in param_list: + method = f""" + public {class_name} with{param_name[0].upper() + param_name[1:]}({param_type} {param_name}) {{ + this.{param_name} = {param_name}; + return this; + }}\n""" + builder_class += method + + builder_class += "\n // Add build method to return the built object\n" + builder_class += f" public {class_name} build() {{\n" + builder_class += " return this;\n" + builder_class += " }\n" + + builder_class += "\n // Getter methods for each field (if needed)\n" + for param_type, param_name in param_list: + getter = f""" + public {param_type} get{param_name[0].upper() + param_name[1:]}() {{ + return {param_name}; + }}\n""" + builder_class += getter + + builder_class += "}\n" + + return builder_class + +def generate_call_method(method_name, param_list): + builder_class_name = ''.join([word.capitalize() for word in re.findall(r'\w+', method_name)]) + "RequestBuilder" + + call_method = f"public void call{method_name[0].upper() + method_name[1:]}() throws ApiException {{\n" + call_method += f" {builder_class_name} builder = new {builder_class_name}()\n" + + for param_type, param_name in param_list: + call_method += f" .with{param_name[0].upper() + param_name[1:]}(/* {param_name}Value */)\n" + + call_method += " .build();\n\n" + + call_method += f" {method_name}(\n" + for param_type, param_name in param_list: + call_method += f" builder.get{param_name[0].upper() + param_name[1:]}(),\n" + call_method = call_method.rstrip(",\n") + "\n );\n" + + call_method += "}\n" + + return call_method + +def main(): + signature = input("Enter the method signature: ") + method_name, param_list = parse_signature(signature) + + builder_class = generate_builder_class(method_name, param_list) + call_method = generate_call_method(method_name, param_list) + + print("Builder Class:\n") + print(builder_class) + + print("\nCall Method:\n") + print(call_method) + +if __name__ == "__main__": + main() diff --git a/kiteworks-spring-service/src/main/java/au/gov/qld/ssq/kiteworks/KiteworksSpringService.java b/kiteworks-spring-service/src/main/java/au/gov/qld/ssq/kiteworks/KiteworksSpringService.java index a03358d..ca0b9dd 100644 --- a/kiteworks-spring-service/src/main/java/au/gov/qld/ssq/kiteworks/KiteworksSpringService.java +++ b/kiteworks-spring-service/src/main/java/au/gov/qld/ssq/kiteworks/KiteworksSpringService.java @@ -1,5 +1,6 @@ package au.gov.qld.ssq.kiteworks; +import au.gov.qld.ssq.kiteworks.helpers.KiteworksApiHelper; import com.kiteworks.client.api.FilesApi; import com.kiteworks.client.api.FoldersApi; import com.kiteworks.client.api.UploadsApi; @@ -37,4 +38,9 @@ public FoldersApi foldersApi(KiteworksService kiteworksService) { public FilesApi filesApi(KiteworksService kiteworksService) { return kiteworksService.filesApi(); } + + @Bean + public KiteworksApiHelper kiteworksApiHelper(FoldersApi foldersApi, FilesApi filesApi) { + return new KiteworksApiHelper(foldersApi, filesApi); + } }