Skip to content

Commit

Permalink
feat(docs): add full examples for fs tasks (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutimantri committed Sep 7, 2024
1 parent 9fb3301 commit c99627c
Show file tree
Hide file tree
Showing 33 changed files with 699 additions and 445 deletions.
21 changes: 14 additions & 7 deletions src/main/java/io/kestra/plugin/fs/ftp/Delete.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"uri: \"/upload/dir1/file.txt\"",
}
full = true,
code = """
id: fs_ftp_delete
namespace: company.team
tasks:
- id: delete
type: io.kestra.plugin.fs.ftp.Delete
host: localhost
port: 21
username: foo
password: pass
uri: "/upload/dir1/file.txt"
"""
)
}
)
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/io/kestra/plugin/fs/ftp/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"from: \"/in/file.txt\"",
}
full = true,
code = """
id: fs_ftp_download
namespace: company.team
tasks:
- id: download
type: io.kestra.plugin.fs.ftp.Download
host: localhost
port: 21
username: foo
password: pass
from: "/in/file.txt"
"""
)
}
)
Expand Down
27 changes: 17 additions & 10 deletions src/main/java/io/kestra/plugin/fs/ftp/Downloads.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@
examples = {
@Example(
title = "Download a list of files and move it to an archive folders",
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"from: \"/in/\"",
"interval: PT10S",
"action: MOVE",
"moveDirectory: \"/archive/\"",
}
full = true,
code = """
id: fs_ftp_downloads
namespace: company.team
tasks:
- id: downloads
type: io.kestra.plugin.fs.ftp.Downloads
host: localhost
port: 21
username: foo
password: pass
from: "/in/"
interval: PT10S
action: MOVE
moveDirectory: "/archive/"
"""
)
}
)
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/io/kestra/plugin/fs/ftp/List.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"from: \"/upload/dir1/\"",
"regExp: \".*\\/dir1\\/.*\\.(yaml|yml)\"",
}
full = true,
code = """
id: fs_ftp_list
namespace: company.team
tasks:
- id: list
type: io.kestra.plugin.fs.ftp.List
host: localhost
port: 21
username: foo
password: pass
from: "/upload/dir1/"
regExp: ".*\/dir1\/.*\.(yaml|yml)"
"""
)
}
)
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/io/kestra/plugin/fs/ftp/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"from: \"/upload/dir1/file.txt\"",
"to: \"/upload/dir2/file.txt\"",
}
full = true,
code = """
id: fs_ftp_move
namespace: company.team
tasks:
- id: move
type: io.kestra.plugin.fs.ftp.Move
host: localhost
port: 21
username: foo
password: pass
from: "/upload/dir1/file.txt"
to: "/upload/dir2/file.txt"
"""
)
}
)
Expand Down
115 changes: 58 additions & 57 deletions src/main/java/io/kestra/plugin/fs/ftp/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,66 +25,66 @@
@Example(
title = "Wait for one or more files in a given FTP server's directory and process each of these files sequentially.",
full = true,
code = {
"id: ftp_trigger_flow",
"namespace: company.team",
"",
"tasks:",
" - id: for_each_file",
" type: io.kestra.plugin.core.flow.EachSequential",
" value: \"{{ trigger.files }}\"",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ taskrun.value | jq('.path') }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.fs.ftp.Trigger",
" host: localhost",
" port: 21",
" username: foo",
" password: bar",
" from: \"/in/\"",
" interval: PT10S",
" action: MOVE",
" moveDirectory: \"/archive/\"",
}
code = """
id: ftp_trigger_flow
namespace: company.team
tasks:
- id: for_each_file
type: io.kestra.plugin.core.flow.EachSequential
value: "{{ trigger.files }}"
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ taskrun.value | jq('.path') }}"
triggers:
- id: watch
type: io.kestra.plugin.fs.ftp.Trigger
host: localhost
port: 21
username: foo
password: bar
from: "/in/"
interval: PT10S
action: MOVE
moveDirectory: "/archive/"
"""
),
@Example(
title = "Wait for one or more files in a given FTP server's directory and process each of these files sequentially. Delete files manually after processing to prevent infinite triggering.",
full = true,
code = {
"id: ftp_trigger_flow",
"namespace: company.team",
"",
"tasks:",
" - id: for_each_file",
" type: io.kestra.plugin.core.flow.EachSequential",
" value: \"{{ trigger.files }}\"",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ taskrun.value | jq('.name') }}\"",
" - id: delete",
" type: io.kestra.plugin.fs.ftp.Delete",
" host: localhost",
" port: 21",
" username: foo",
" password: bar",
" uri: \"/in/{{ taskrun.value | jq('.name') }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.fs.ftp.Trigger",
" host: localhost",
" port: 21",
" username: foo",
" password: bar",
" from: \"/in/\"",
" interval: PT10S",
" action: NONE",
}
code = """
id: ftp_trigger_flow
namespace: company.team
tasks:
- id: for_each_file
type: io.kestra.plugin.core.flow.EachSequential
value: "{{ trigger.files }}"
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ taskrun.value | jq('.name') }}"
- id: delete
type: io.kestra.plugin.fs.ftp.Delete
host: localhost
port: 21
username: foo
password: bar
uri: "/in/{{ taskrun.value | jq('.name') }}"
triggers:
- id: watch
type: io.kestra.plugin.fs.ftp.Trigger
host: localhost
port: 21
username: foo
password: bar
from: "/in/"
interval: PT10S
action: NONE
"""
),
@Example(
title = "Wait for one or more files in a given FTP server's directory and process each of these files sequentially. In this example, we restrict the trigger to only wait for CSV files in the `mydir` directory.",
Expand Down Expand Up @@ -113,7 +113,8 @@
regExp: ".*.csv"
action: MOVE
moveDirectory: "archive/"
interval: PTS"""
interval: PTS
"""
)
}
)
Expand Down
27 changes: 19 additions & 8 deletions src/main/java/io/kestra/plugin/fs/ftp/Upload.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"from: \"{{ outputs.taskid.uri }}\"",
"to: \"/upload/dir2/file.txt\"",
}
full = true,
code = """
id: fs_ftp_upload
namespace: company.team
inputs:
- id: file
type: FILE
tasks:
- id: upload
type: io.kestra.plugin.fs.ftp.Upload
host: localhost
port: 21
username: foo
password: pass
from: "{{ inputs.file }}"
to: "/upload/dir2/file.txt"
"""
)
}
)
Expand Down
33 changes: 23 additions & 10 deletions src/main/java/io/kestra/plugin/fs/ftp/Uploads.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,29 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 21",
"username: foo",
"password: pass",
"from:",
" - \"{{ outputs.taskid1.uri }}\"",
" - \"{{ outputs.taskid2.uri }}\"",
"to: \"/upload/dir2\"",
}
full = true,
code = """
id: fs_ftp_uploads
namespace: company.team
inputs:
- id: file1
type: FILE
- id: file2
type: FILE
tasks:
- id: uploads
type: io.kestra.plugin.fs.ftp.Uploads
host: localhost
port: 21
username: foo
password: pass
from:
- "{{ inputs.file1 }}"
- "{{ inputs.file2 }}"
to: "/upload/dir2"
"""
)
}
)
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/io/kestra/plugin/fs/ftps/Delete.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@
@Plugin(
examples = {
@Example(
code = {
"host: localhost",
"port: 990",
"username: foo",
"password: pass",
"uri: \"/upload/dir1/file.txt\"",
}
full = true,
code = """
id: fs_ftps_delete
namespace: company.team
tasks:
- id: delete
type: io.kestra.plugin.fs.ftps.Delete
host: localhost
port: 990
username: foo
password: pass
uri: "/upload/dir1/file.txt"
"""
)
}
)
Expand Down
Loading

0 comments on commit c99627c

Please sign in to comment.