Skip to content

Add SMB examples and move the FTP and SFTP examples off the deprecated APIs - #6420

Open
niveathika wants to merge 6 commits into
ballerina-platform:masterfrom
niveathika:master-ftp-sftp-smb-examples
Open

Add SMB examples and move the FTP and SFTP examples off the deprecated APIs#6420
niveathika wants to merge 6 commits into
ballerina-platform:masterfrom
niveathika:master-ftp-sftp-smb-examples

Conversation

@niveathika

Copy link
Copy Markdown
Contributor

Ports the two examples changes already merged to 2201.13.x#6418 and #6419 — to master.

SMB examples (#6418)

Adds the four SMB examples: an SMB service that receives files, the smb:Caller, and clients that write and read a file. They use the typed API (onFileText, putText, getText) and @smb:ServiceConfig rather than the deprecated onFileChange/put/get and the deprecated listener config fields.

FTP and SFTP examples off the deprecated APIs (#6419)

Every FTP and SFTP sample demonstrated an API the library has since deprecated:

  • The client samples used put and get, and now use putText and getText.
  • The service samples used onFileChange, and the path/fileNamePattern listener config fields; they now declare onFileText and take the watched directory from @ftp:ServiceConfig.
  • ftp-service-send-file and sftp-service-send-file are renamed to ftp-caller and sftp-caller ("Caller object", matching the HTTP samples) — a listener service does not send files, and both samples exist to show the caller. The published URLs of these two samples change, so a redirect is needed for the previous ones.
  • Corrects the tip in the service samples, which told the reader to run a client sample that writes to a directory the service does not watch.

verifyBuild is true for every FTP, SFTP, and SMB sample.

The example sources are byte-identical to what is on 2201.13.x. index.json keeps needCentral: true on the SMB samples, since ballerina/smb is not bundled in the distribution; master's ballerina/build.gradle does not read that flag today (it builds examples online), so it has no effect here, but it stays accurate if the flag is ported forward.

Add four Ballerina by Example entries for the `smb` module, mirroring the
set that already exists for FTP: sending and receiving a file with an
`smb:Client`, and receiving a file and writing one back with an
`smb:Listener` service.

The `smb` module is not bundled in the distribution, so the samples are
registered with `needCentral` and resolved from Ballerina Central.
Name the samples after what they demonstrate rather than a direction of
transfer, following the way the HTTP samples are organised. A listener
service does not send files, so the former "service - send file" sample
becomes "Caller object", which is the concept it was really showing.

Use the format specific methods throughout. The client samples write and
read a string with `putText` and `getText` and bind JSON to a record with
`putJson` and `getJson`, and the service binds the file content to a record
through `onFileJson`, instead of moving bytes around.

Also address the review feedback: document the Samba user the samples
authenticate with, and drop the undocumented local file fixtures by keeping
every sample on the share. The tip in each sample now points at a path the
sample actually uses.
Every FTP and SFTP sample demonstrated an API the library has since
deprecated, so the examples taught the wrong thing.

The client samples used `put` and `get`, which are deprecated in favour of
the format specific methods, and now use `putText` and `getText`. The
service samples used `onFileChange`, which is deprecated in favour of the
format specific handlers, along with the `path` and `fileNamePattern` fields
of the listener configuration, which are deprecated in favour of
`@ftp:ServiceConfig`. They now declare `onFileText` and take the watched
directory from the annotation. The `ftp:Caller` sample appends with
`putText` rather than the deprecated `append`.

Also correct the tip in the service samples, which told the reader to run a
client sample that writes to a directory the service does not watch.
A listener service does not send files, so the name described neither what
the sample does nor what it teaches. Both samples exist to show the
`ftp:Caller`, which is what the HTTP samples call a "Caller object", so name
them the same way.

The published URLs of the two samples change with this, and a redirect is
needed for the previous ones.
SFTP is a protocol of the ftp module, so the type is ftp:Caller. There is
no sftp module for the description to name.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant