Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
#10 Update documention
  • Loading branch information
clever-age-gtonon committed Dec 10, 2024
commit 8889c3b7803601d3c0f69f3b17aa00de5caa1f23
67 changes: 67 additions & 0 deletions docs/01 - FileFetchTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FileFetchTask
========

Perform copy between 2 flysystems storage

Task reference
--------------

* **Service**: [`CleverAge\FlysystemProcessBundle\Task\FileFetchTask`](../src/Task/RemoveFileTask.php)

Accepted inputs
---------------

The filename or filenames to copy from.

If the option `file_pattern` is not set the input is used as strict filename(s) to match.

If input is set but not corresponding as any file into `source_filesystem` task failed with UnableToReadFile exception.

If FileFetchTask is the fisrt task of you process and you wan to use input, don't forgive to set the `entry_point` task name at process level

Possible outputs
----------------

Filename of copied file.

Options
-------

| Code | Type | Required | Default | Description |
| ---- |------|:------------------:|-|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `source_filesystem` | `string` |**X**|| The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
| `destination_filesystem` | `string` |**X**|| The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
| `file_pattern` | `string` || null | The file_parttern used in preg_match to match into `source_filesystem` list of files. If not set try to use input as strict filename to match |
| `remove_source`|`bool`|| false | If true delete source file after copy |


Examples
--------

```yaml
# Task configuration level
code:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
description: >
Download all .csv files from storage.source to storage.destination.
See config/packages/flysystem.yaml to see configured flysystem/storages.
options:
source_filesystem: 'storage.source'
destination_filesystem: 'storage.destination'
file_pattern: '/.csv$/'
remove_source: true
```

```yaml
# Full process configuration to use input as filename with the following call
# bin/console cleverage:process:execute my_custom_process --input=foobar.csv -vv
my_custom_process:
entry_point: copy_from_input
tasks:
copy_from_input:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
options:
source_filesystem: 'storage.source'
destination_filesystem: 'storage.destination'
remove_source: true
```
43 changes: 43 additions & 0 deletions docs/02 -ListContentTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ListContentTask
========

List files of a flysystem storage

Task reference
--------------

* **Service**: [`CleverAge\FlysystemProcessBundle\Task\ListContentTask`](../src/Task/ListContentTask.php)

Accepted inputs
---------------

Input is ignored

Possible outputs
----------------

League\Flysystem\StorageAttributes

Options
-------

| Code | Type | Required | Default | Description |
| ---- |----------|:-----------------:|-|----------------------------------------------------------------|
| `filesystem` | `string` | **X** || The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
| `file_pattern` | `string` ||| he file_parttern used in preg_match to match into `filesystem` |

Examples
--------

```yaml
# Task configuration level
code:
service: '@CleverAge\FlysystemProcessBundle\Task\ListContentTask'
description: >
List .csv files from storage.source.
See config/packages/flysystem.yaml to see configured flysystem/storages.
outputs: get_file_path
options:
filesystem: 'storage.source'
file_pattern: '/.csv$/'
```
44 changes: 44 additions & 0 deletions docs/03 - RemoveFileTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
RemoveFileTask
========

Remove a file from a flysystem storage

Task reference
--------------

* **Service**: [`CleverAge\FlysystemProcessBundle\Task\RemoveFileTask`](../src/Task/RemoveFileTask.php)

Accepted inputs
---------------

The filename of the file to remove on `filesystem`.

When filename is deleted add a info log.

If filename not found or cannot be deleted on `filesystem` add a warning log.

Possible outputs
----------------

None

Options
-------

| Code | Type | Required | Default | Description |
| ---- |------|:------------------:|-|--------------------------------|
| `filesystem` | `string` |**X**|| The source flysystem/storage. <br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |

Examples
--------

```yaml
# bin/console cleverage:process:execute my_custom_process --input=foobar.csv -vv
my_custom_process:
entry_point: remove_from_input
tasks:
remove_from_input:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
options:
filesystem: 'storage.source'
```
21 changes: 18 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@ Remember to add the following line to config/bundles.php (not required if Symfon
CleverAge\FlysystemProcessBundle\CleverAgeFlysystemProcessBundle::class => ['all' => true],
```

Configure at least one flysytem/storage into `config/packages/flysytem.yaml`

```yaml
#config/packages/flysytem.yaml
flysystem:
storages:
storage.source: # This is the identifier of flysytem/storage
adapter: 'local'
options:
directory: '%kernel.project_dir%/var/storage/source'
```

See https://github.com/thephpleague/flysystem-bundle?tab=readme-ov-file for more sample configuration (sftp, ftp, amazon s3 ...)


## Reference

- Tasks
- [FileFetchTask]
- [ListContentTask]
- [RemoveFileTask]
- [FileFetchTask](01%20-%20FileFetchTask.md)
- [ListContentTask](02%20-ListContentTask.md)
- [RemoveFileTask](03%20-%20RemoveFileTask.md)