Mercurial > hg > orthanc-transfers
annotate Framework/TransferToolbox.h @ 77:1e396fb509ca default
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 22:44:10 +0200 |
parents | f4e828607f02 |
children |
rev | line source |
---|---|
0 | 1 /** |
2 * Transfers accelerator plugin for Orthanc | |
77
1e396fb509ca
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
44
diff
changeset
|
3 * Copyright (C) 2018-2023 Osimis S.A., Belgium |
1e396fb509ca
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
44
diff
changeset
|
4 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
1e396fb509ca
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
44
diff
changeset
|
5 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include <stdint.h> | |
25 #include <string> | |
10
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
26 #include <json/value.h> |
0 | 27 |
28 static const unsigned int KB = 1024; | |
29 static const unsigned int MB = 1024 * 1024; | |
30 | |
31 static const char* const JOB_TYPE_PULL = "PullTransfer"; | |
32 static const char* const JOB_TYPE_PUSH = "PushTransfer"; | |
33 | |
34 static const char* const PLUGIN_NAME = "transfers"; | |
35 | |
36 static const char* const KEY_BUCKETS = "Buckets"; | |
37 static const char* const KEY_COMPRESSION = "Compression"; | |
38 static const char* const KEY_ID = "ID"; | |
39 static const char* const KEY_INSTANCES = "Instances"; | |
40 static const char* const KEY_LEVEL = "Level"; | |
41 static const char* const KEY_OFFSET = "Offset"; | |
42 static const char* const KEY_ORIGINATOR_UUID = "Originator"; | |
43 static const char* const KEY_PATH = "Path"; | |
44 static const char* const KEY_PEER = "Peer"; | |
45 static const char* const KEY_PLUGIN_CONFIGURATION = "Transfers"; | |
46 static const char* const KEY_PRIORITY = "Priority"; | |
47 static const char* const KEY_REMOTE_JOB = "RemoteJob"; | |
5
5e6de82bb10f
use of user properties instead of BidirectionalPeers option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4
diff
changeset
|
48 static const char* const KEY_REMOTE_SELF = "RemoteSelf"; |
0 | 49 static const char* const KEY_RESOURCES = "Resources"; |
50 static const char* const KEY_SIZE = "Size"; | |
51 static const char* const KEY_URL = "URL"; | |
44
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
52 static const char* const KEY_SENDER_TRANSFER_ID = "SenderTransferID"; |
0 | 53 |
54 static const char* const URI_CHUNKS = "/transfers/chunks"; | |
55 static const char* const URI_JOBS = "/jobs"; | |
56 static const char* const URI_LOOKUP = "/transfers/lookup"; | |
57 static const char* const URI_PEERS = "/transfers/peers"; | |
58 static const char* const URI_PLUGINS = "/plugins"; | |
59 static const char* const URI_PULL = "/transfers/pull"; | |
60 static const char* const URI_PUSH = "/transfers/push"; | |
61 static const char* const URI_SEND = "/transfers/send"; | |
62 | |
44
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
63 static const char* const HEADER_KEY_SENDER_TRANSFER_ID = "sender-transfer-id"; |
0 | 64 |
65 namespace OrthancPlugins | |
66 { | |
10
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
67 class OrthancPeers; |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
68 |
0 | 69 enum BucketCompression |
70 { | |
71 BucketCompression_None, | |
72 BucketCompression_Gzip | |
73 }; | |
74 | |
75 unsigned int ConvertToMegabytes(uint64_t value); | |
76 | |
77 unsigned int ConvertToKilobytes(uint64_t value); | |
78 | |
79 BucketCompression StringToBucketCompression(const std::string& value); | |
80 | |
81 const char* EnumerationToString(BucketCompression compression); | |
10
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
82 |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
83 bool DoPostPeer(Json::Value& answer, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
84 const OrthancPeers& peers, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
85 size_t peerIndex, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
86 const std::string& uri, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
87 const std::string& body, |
44
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
88 unsigned int maxRetries, |
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
89 const std::map<std::string, std::string>& headers); |
10
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
90 |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
91 bool DoPostPeer(Json::Value& answer, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
92 const OrthancPeers& peers, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
93 const std::string& peerName, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
94 const std::string& uri, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
95 const std::string& body, |
44
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
96 unsigned int maxRetries, |
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
97 const std::map<std::string, std::string>& headers); |
10
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
98 |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
99 bool DoDeletePeer(const OrthancPeers& peers, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
100 size_t peerIndex, |
c9e28e31262e
new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
9
diff
changeset
|
101 const std::string& uri, |
44
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
102 unsigned int maxRetries, |
f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents:
33
diff
changeset
|
103 const std::map<std::string, std::string>& headers); |
0 | 104 } |