View | Details | Raw Unified | Return to bug 39190
Collapse All | Expand All

(-)a/Koha/REST/V1/SFTPServer.pm (-55 lines)
Lines 1-55 Link Here
1
package Koha::REST::V1::SFTPServer;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::SFTP::Servers;
23
24
use Try::Tiny qw( catch try );
25
26
=head1 API
27
28
=head2 Methods
29
30
=head3 test
31
32
Controller method that invokes Koha::SFTP::Server->test_conn
33
34
=cut
35
36
sub test {
37
    my $c = shift->openapi->valid_input or return;
38
39
    return try {
40
        my $sftp_server = Koha::SFTP::Servers->find( $c->param('sftp_server_id') );
41
        return $c->render_resource_not_found("FTP/SFTP Server")
42
            unless $sftp_server;
43
44
        my $sftp_server_test_conn = $sftp_server->test_conn;
45
46
        return $c->render(
47
            status  => 200,
48
            openapi => $sftp_server_test_conn,
49
        );
50
    } catch {
51
        $c->unhandled_exception($_);
52
    };
53
}
54
55
1;
(-)a/api/v1/swagger/paths/test_sftp_servers.yaml (-48 lines)
Lines 1-48 Link Here
1
---
2
"/sftp_server/{sftp_server_id}/test_connection":
3
  get:
4
    x-mojo-to: SFTPServer#test
5
    operationId: testSFTPServer
6
    tags:
7
      - sftp_servers
8
    summary: Test FTP/SFTP server
9
    produces:
10
      - application/json
11
    parameters:
12
      - $ref: "../swagger.yaml#/parameters/sftp_server_id_pp"
13
    responses:
14
      "200":
15
        description: Results of FTP/SFTP server test
16
        schema:
17
          type: object
18
          items:
19
            $ref: "../swagger.yaml#/definitions/sftp_server"
20
      "400":
21
        description: |
22
          Bad request. Possible `error_code` attribute values:
23
24
            * `invalid_query`
25
        schema:
26
          $ref: "../swagger.yaml#/definitions/error"
27
      "404":
28
        description: Not Found
29
        schema:
30
          $ref: "../swagger.yaml#/definitions/error"
31
      "403":
32
        description: Access forbidden
33
        schema:
34
          $ref: "../swagger.yaml#/definitions/error"
35
      "500":
36
        description: |
37
          Internal server error. Possible `error_code` attribute values:
38
39
          * `internal_server_error`
40
        schema:
41
          $ref: "../swagger.yaml#/definitions/error"
42
      "503":
43
        description: Under maintenance
44
        schema:
45
          $ref: "../swagger.yaml#/definitions/error"
46
    x-koha-authorization:
47
      permissions:
48
        parameters: manage_sftp_servers
(-)a/api/v1/swagger/swagger.yaml (-4 / +1 lines)
Lines 559-566 paths: Link Here
559
    $ref: "./paths/rotas.yaml#/~1rotas~1{rota_id}"
559
    $ref: "./paths/rotas.yaml#/~1rotas~1{rota_id}"
560
  "/rotas/{rota_id}/stages/{stage_id}/position":
560
  "/rotas/{rota_id}/stages/{stage_id}/position":
561
    $ref: "./paths/rotas.yaml#/~1rotas~1{rota_id}~1stages~1{stage_id}~1position"
561
    $ref: "./paths/rotas.yaml#/~1rotas~1{rota_id}~1stages~1{stage_id}~1position"
562
  "/sftp_server/{sftp_server_id}/test_connection":
563
    $ref: "./paths/test_sftp_servers.yaml#/~1sftp_server~1{sftp_server_id}~1test_connection"
564
  /suggestions:
562
  /suggestions:
565
    $ref: ./paths/suggestions.yaml#/~1suggestions
563
    $ref: ./paths/suggestions.yaml#/~1suggestions
566
  "/suggestions/{suggestion_id}":
564
  "/suggestions/{suggestion_id}":
Lines 1308-1311 tags: Link Here
1308
    x-displayName: Two factor authentication
1306
    x-displayName: Two factor authentication
1309
  - description: "Manage vendors for the acquisitions module\n"
1307
  - description: "Manage vendors for the acquisitions module\n"
1310
    name: vendors
1308
    name: vendors
1311
    x-displayName: Vendors
1309
    x-displayName: Vendors
1312
- 

Return to bug 39190