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