diff --git a/connectors/box/element-templates/box-outbound-connector.json b/connectors/box/element-templates/box-outbound-connector.json index f722967655..2f64884509 100644 --- a/connectors/box/element-templates/box-outbound-connector.json +++ b/connectors/box/element-templates/box-outbound-connector.json @@ -3,6 +3,9 @@ "name" : "Box Outbound Connector", "id" : "io.camunda.connectors.box", "description" : "Interact with the Box Document API", + "metadata" : { + "keywords" : [ ] + }, "documentationRef" : "https://docs.camunda.io/docs/components/connectors/out-of-the-box-connectors/box/", "version" : 1, "category" : { @@ -237,20 +240,29 @@ }, { "name" : "Delete Folder", "value" : "deleteFolder" + }, { + "name" : "Upload File", + "value" : "uploadFile" }, { "name" : "Download File", "value" : "downloadFile" + }, { + "name" : "Move File", + "value" : "moveFile" + }, { + "name" : "Delete File", + "value" : "deleteFile" }, { "name" : "Search", "value" : "search" - }, { - "name" : "Upload File", - "value" : "uploadFile" } ] }, { "id" : "operation.createFolderName", "label" : "Create folder name", "optional" : false, + "constraints" : { + "notEmpty" : true + }, "feel" : "optional", "group" : "operation", "binding" : { @@ -267,6 +279,9 @@ "id" : "operation.createFolderParentPath", "label" : "Create folder parent path", "optional" : false, + "constraints" : { + "notEmpty" : true + }, "feel" : "optional", "group" : "operation", "binding" : { @@ -283,6 +298,9 @@ "id" : "operation.deleteFolderPath", "label" : "Delete folder path", "optional" : false, + "constraints" : { + "notEmpty" : true + }, "feel" : "optional", "group" : "operation", "binding" : { @@ -312,6 +330,63 @@ "type" : "simple" }, "type" : "String" + }, { + "id" : "operation.uploadFileName", + "label" : "Upload file name", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.name", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "uploadFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.uploadFileFolderPath", + "label" : "Upload file folder path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.folderPath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "uploadFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.uploadFileDocument", + "label" : "Upload file document", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "required", + "group" : "operation", + "binding" : { + "name" : "operation.document", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "uploadFile", + "type" : "simple" + }, + "type" : "String" }, { "id" : "operation.downloadFilePath", "label" : "Download file path", @@ -328,6 +403,63 @@ "type" : "simple" }, "type" : "String" + }, { + "id" : "operation.moveFilePath", + "label" : "File path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.filePath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "moveFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.moveFileFolderPath", + "label" : "Target folder path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.folderPath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "moveFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.deleteFilePath", + "label" : "File path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.filePath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "deleteFile", + "type" : "simple" + }, + "type" : "String" }, { "id" : "operation.searchQuery", "label" : "Search query", @@ -422,54 +554,6 @@ "type" : "simple" }, "type" : "String" - }, { - "id" : "operation.uploadFileName", - "label" : "Upload file name", - "optional" : false, - "feel" : "optional", - "group" : "operation", - "binding" : { - "name" : "operation.name", - "type" : "zeebe:input" - }, - "condition" : { - "property" : "operation.type", - "equals" : "uploadFile", - "type" : "simple" - }, - "type" : "String" - }, { - "id" : "operation.uploadFileFolderPath", - "label" : "Upload file folder path", - "optional" : false, - "feel" : "optional", - "group" : "operation", - "binding" : { - "name" : "operation.folderPath", - "type" : "zeebe:input" - }, - "condition" : { - "property" : "operation.type", - "equals" : "uploadFile", - "type" : "simple" - }, - "type" : "String" - }, { - "id" : "operation.uploadFileDocument", - "label" : "Upload file document", - "optional" : false, - "feel" : "required", - "group" : "operation", - "binding" : { - "name" : "operation.document", - "type" : "zeebe:input" - }, - "condition" : { - "property" : "operation.type", - "equals" : "uploadFile", - "type" : "simple" - }, - "type" : "String" }, { "id" : "resultVariable", "label" : "Result variable", @@ -519,7 +603,6 @@ "label" : "Retry backoff", "description" : "ISO-8601 duration to wait between retries", "value" : "PT0S", - "feel" : "optional", "group" : "retries", "binding" : { "key" : "retryBackoff", diff --git a/connectors/box/element-templates/hybrid/box-outbound-connector-hybrid.json b/connectors/box/element-templates/hybrid/box-outbound-connector-hybrid.json index b96a74c271..f5485b126e 100644 --- a/connectors/box/element-templates/hybrid/box-outbound-connector-hybrid.json +++ b/connectors/box/element-templates/hybrid/box-outbound-connector-hybrid.json @@ -3,6 +3,9 @@ "name" : "Hybrid Box Outbound Connector", "id" : "io.camunda.connectors.box-hybrid", "description" : "Interact with the Box Document API", + "metadata" : { + "keywords" : [ ] + }, "documentationRef" : "https://docs.camunda.io/docs/components/connectors/out-of-the-box-connectors/box/", "version" : 1, "category" : { @@ -242,20 +245,29 @@ }, { "name" : "Delete Folder", "value" : "deleteFolder" + }, { + "name" : "Upload File", + "value" : "uploadFile" }, { "name" : "Download File", "value" : "downloadFile" + }, { + "name" : "Move File", + "value" : "moveFile" + }, { + "name" : "Delete File", + "value" : "deleteFile" }, { "name" : "Search", "value" : "search" - }, { - "name" : "Upload File", - "value" : "uploadFile" } ] }, { "id" : "operation.createFolderName", "label" : "Create folder name", "optional" : false, + "constraints" : { + "notEmpty" : true + }, "feel" : "optional", "group" : "operation", "binding" : { @@ -272,6 +284,9 @@ "id" : "operation.createFolderParentPath", "label" : "Create folder parent path", "optional" : false, + "constraints" : { + "notEmpty" : true + }, "feel" : "optional", "group" : "operation", "binding" : { @@ -288,6 +303,9 @@ "id" : "operation.deleteFolderPath", "label" : "Delete folder path", "optional" : false, + "constraints" : { + "notEmpty" : true + }, "feel" : "optional", "group" : "operation", "binding" : { @@ -317,6 +335,63 @@ "type" : "simple" }, "type" : "String" + }, { + "id" : "operation.uploadFileName", + "label" : "Upload file name", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.name", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "uploadFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.uploadFileFolderPath", + "label" : "Upload file folder path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.folderPath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "uploadFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.uploadFileDocument", + "label" : "Upload file document", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "required", + "group" : "operation", + "binding" : { + "name" : "operation.document", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "uploadFile", + "type" : "simple" + }, + "type" : "String" }, { "id" : "operation.downloadFilePath", "label" : "Download file path", @@ -333,6 +408,63 @@ "type" : "simple" }, "type" : "String" + }, { + "id" : "operation.moveFilePath", + "label" : "File path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.filePath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "moveFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.moveFileFolderPath", + "label" : "Target folder path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.folderPath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "moveFile", + "type" : "simple" + }, + "type" : "String" + }, { + "id" : "operation.deleteFilePath", + "label" : "File path", + "optional" : false, + "constraints" : { + "notEmpty" : true + }, + "feel" : "optional", + "group" : "operation", + "binding" : { + "name" : "operation.filePath", + "type" : "zeebe:input" + }, + "condition" : { + "property" : "operation.type", + "equals" : "deleteFile", + "type" : "simple" + }, + "type" : "String" }, { "id" : "operation.searchQuery", "label" : "Search query", @@ -427,54 +559,6 @@ "type" : "simple" }, "type" : "String" - }, { - "id" : "operation.uploadFileName", - "label" : "Upload file name", - "optional" : false, - "feel" : "optional", - "group" : "operation", - "binding" : { - "name" : "operation.name", - "type" : "zeebe:input" - }, - "condition" : { - "property" : "operation.type", - "equals" : "uploadFile", - "type" : "simple" - }, - "type" : "String" - }, { - "id" : "operation.uploadFileFolderPath", - "label" : "Upload file folder path", - "optional" : false, - "feel" : "optional", - "group" : "operation", - "binding" : { - "name" : "operation.folderPath", - "type" : "zeebe:input" - }, - "condition" : { - "property" : "operation.type", - "equals" : "uploadFile", - "type" : "simple" - }, - "type" : "String" - }, { - "id" : "operation.uploadFileDocument", - "label" : "Upload file document", - "optional" : false, - "feel" : "required", - "group" : "operation", - "binding" : { - "name" : "operation.document", - "type" : "zeebe:input" - }, - "condition" : { - "property" : "operation.type", - "equals" : "uploadFile", - "type" : "simple" - }, - "type" : "String" }, { "id" : "resultVariable", "label" : "Result variable", @@ -524,7 +608,6 @@ "label" : "Retry backoff", "description" : "ISO-8601 duration to wait between retries", "value" : "PT0S", - "feel" : "optional", "group" : "retries", "binding" : { "key" : "retryBackoff", diff --git a/connectors/box/src/main/java/io/camunda/connector/box/BoxOperations.java b/connectors/box/src/main/java/io/camunda/connector/box/BoxOperations.java index b068a6955a..32f30a4884 100644 --- a/connectors/box/src/main/java/io/camunda/connector/box/BoxOperations.java +++ b/connectors/box/src/main/java/io/camunda/connector/box/BoxOperations.java @@ -16,6 +16,8 @@ import com.box.sdk.BoxConfig; import com.box.sdk.BoxDeveloperEditionAPIConnection; import com.box.sdk.BoxFile; +import com.box.sdk.BoxFolder; +import com.box.sdk.BoxItem; import com.box.sdk.BoxSearch; import com.box.sdk.BoxSearchParameters; import com.box.sdk.IAccessTokenCache; @@ -37,6 +39,8 @@ public static BoxResult execute(BoxRequest request, OutboundConnectorContext con case BoxRequest.Operation.UploadFile uploadFile -> uploadFile(uploadFile, api); case BoxRequest.Operation.DownloadFile downloadFile -> downloadFile(downloadFile, api, context); + case BoxRequest.Operation.MoveFile moveFile -> moveFile(moveFile, api); + case BoxRequest.Operation.DeleteFile deleteFile -> deleteFile(deleteFile, api); case BoxRequest.Operation.CreateFolder createFolder -> createFolder(createFolder, api); case BoxRequest.Operation.DeleteFolder deleteFolder -> deleteFolder(deleteFolder, api); case BoxRequest.Operation.Search search -> search(search, api); @@ -83,6 +87,20 @@ private static Document createDocument(BoxFile file, OutboundConnectorContext co return context.createDocument(documentCreationRequest); } + private static BoxResult deleteFile( + BoxRequest.Operation.DeleteFile deleteFile, BoxAPIConnection api) { + BoxFile file = getFile(deleteFile.filePath(), api); + file.delete(); + return new BoxResult.Generic(item(file)); + } + + private static BoxResult moveFile(BoxRequest.Operation.MoveFile moveFile, BoxAPIConnection api) { + BoxFile file = getFile(moveFile.filePath(), api); + BoxFolder folder = getFolder(moveFile.folderPath(), api); + BoxItem.Info info = file.move(folder); + return new BoxResult.Generic(item(info)); + } + private static BoxResult deleteFolder( BoxRequest.Operation.DeleteFolder deleteFolder, BoxAPIConnection api) { var folder = getFolder(deleteFolder.folderPath(), api); diff --git a/connectors/box/src/main/java/io/camunda/connector/box/model/BoxRequest.java b/connectors/box/src/main/java/io/camunda/connector/box/model/BoxRequest.java index 96bb14f05c..7d0cc37e1e 100644 --- a/connectors/box/src/main/java/io/camunda/connector/box/model/BoxRequest.java +++ b/connectors/box/src/main/java/io/camunda/connector/box/model/BoxRequest.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import io.camunda.connector.feel.annotation.FEEL; import io.camunda.connector.generator.dsl.Property; import io.camunda.connector.generator.java.annotation.TemplateDiscriminatorProperty; import io.camunda.connector.generator.java.annotation.TemplateProperty; @@ -123,6 +122,8 @@ record JWTJsonConfig( @JsonSubTypes.Type(value = Operation.DeleteFolder.class, name = "deleteFolder"), @JsonSubTypes.Type(value = Operation.UploadFile.class, name = "uploadFile"), @JsonSubTypes.Type(value = Operation.DownloadFile.class, name = "downloadFile"), + @JsonSubTypes.Type(value = Operation.MoveFile.class, name = "moveFile"), + @JsonSubTypes.Type(value = Operation.DeleteFile.class, name = "deleteFile"), @JsonSubTypes.Type(value = Operation.Search.class, name = "search") }) @TemplateDiscriminatorProperty( @@ -134,31 +135,35 @@ record JWTJsonConfig( public sealed interface Operation permits Operation.CreateFolder, Operation.DeleteFolder, + Operation.UploadFile, Operation.DownloadFile, - Operation.Search, - Operation.UploadFile { + Operation.MoveFile, + Operation.DeleteFile, + Operation.Search { @TemplateSubType(id = "createFolder", label = "Create Folder") record CreateFolder( - @TemplateProperty(id = "createFolderName", group = "operation") String name, - @TemplateProperty(id = "createFolderParentPath", group = "operation") String folderPath) + @TemplateProperty(id = "createFolderName", group = "operation") @NotBlank String name, + @TemplateProperty(id = "createFolderParentPath", group = "operation") @NotBlank + String folderPath) implements Operation {} @TemplateSubType(id = "deleteFolder", label = "Delete Folder") record DeleteFolder( - @TemplateProperty(id = "deleteFolderPath", group = "operation") String folderPath, + @TemplateProperty(id = "deleteFolderPath", group = "operation") @NotBlank String folderPath, @TemplateProperty(defaultValue = "true", group = "operation") boolean recursive) implements Operation {} @TemplateSubType(id = "uploadFile", label = "Upload File") record UploadFile( - @TemplateProperty(id = "uploadFileName", group = "operation") String name, - @TemplateProperty(id = "uploadFileFolderPath", group = "operation") String folderPath, + @TemplateProperty(id = "uploadFileName", group = "operation") @NotBlank String name, + @TemplateProperty(id = "uploadFileFolderPath", group = "operation") @NotBlank + String folderPath, @TemplateProperty( id = "uploadFileDocument", group = "operation", type = TemplateProperty.PropertyType.String, feel = Property.FeelMode.required) - @FEEL + @NotNull Document document) implements Operation { @@ -172,6 +177,24 @@ record DownloadFile( @TemplateProperty(id = "downloadFilePath", group = "operation") String filePath) implements Operation {} + @TemplateSubType(id = "moveFile", label = "Move File") + record MoveFile( + @TemplateProperty(id = "moveFilePath", group = "operation", label = "File path") @NotBlank + String filePath, + @TemplateProperty( + id = "moveFileFolderPath", + group = "operation", + label = "Target folder path") + @NotBlank + String folderPath) + implements Operation {} + + @TemplateSubType(id = "deleteFile", label = "Delete File") + record DeleteFile( + @TemplateProperty(id = "deleteFilePath", group = "operation", label = "File path") @NotBlank + String filePath) + implements Operation {} + @TemplateSubType(id = "search", label = "Search") record Search( @TemplateProperty(id = "searchQuery", group = "operation") String query,