1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the "php-ipfs" package. |
7
|
|
|
* |
8
|
|
|
* (c) Robert Schönthal <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace IPFS\Api; |
15
|
|
|
|
16
|
|
|
use IPFS\Annotation\Api as Endpoint; |
17
|
|
|
use IPFS\Command\Command; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Robert Schönthal <[email protected]> |
21
|
|
|
* @autogenerated |
22
|
|
|
* @codeCoverageIgnore |
23
|
|
|
*/ |
24
|
|
|
final class Basics implements Api |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Add a file or directory to ipfs. |
28
|
|
|
* |
29
|
|
|
* @Endpoint(name="add") |
30
|
|
|
* |
31
|
|
|
* @param string $file the path to a file to be added to ipfs |
32
|
|
|
* @param bool $recursive add directory paths recursively |
33
|
|
|
* @param bool $quiet write minimal output |
34
|
|
|
* @param bool $quieter write only final hash |
35
|
|
|
* @param bool $silent write no output |
36
|
|
|
* @param bool $progress stream progress data |
37
|
|
|
* @param bool $trickle use trickle-dag format for dag generation |
38
|
|
|
* @param bool $onlyHash only chunk and hash - do not write to disk |
39
|
|
|
* @param bool $wrapWithDirectory wrap files with a directory object |
40
|
|
|
* @param bool $hidden include files that are hidden |
41
|
|
|
* @param string $chunker chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max] |
42
|
|
|
* @param bool $pin pin this object when adding |
43
|
|
|
* @param bool $rawLeaves use raw blocks for leaf nodes |
44
|
|
|
* @param bool $nocopy add the file using filestore |
45
|
|
|
* @param bool $fscache check the filestore for pre-existing blocks |
46
|
|
|
* @param int $cidVersion CID version |
47
|
|
|
* @param string $hash hash function to use |
48
|
|
|
* |
49
|
|
|
* @return Command |
50
|
|
|
*/ |
51
|
|
|
public function add(string $file, bool $recursive = false, bool $quiet = false, bool $quieter = false, bool $silent = false, bool $progress = false, bool $trickle = false, bool $onlyHash = false, bool $wrapWithDirectory = false, bool $hidden = false, string $chunker = 'size-262144', bool $pin = true, bool $rawLeaves = false, bool $nocopy = false, bool $fscache = false, int $cidVersion = 0, string $hash = 'sha2-256'): Command |
52
|
|
|
{ |
53
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Show IPFS object data. |
58
|
|
|
* |
59
|
|
|
* @Endpoint(name="cat") |
60
|
|
|
* |
61
|
|
|
* @param string $arg the path to the IPFS object(s) to be outputted |
62
|
|
|
* @param int $offset byte offset to begin reading from |
63
|
|
|
* @param int $length maximum number of bytes to read |
64
|
|
|
* |
65
|
|
|
* @return Command |
66
|
|
|
*/ |
67
|
|
|
public function cat(string $arg, int $offset = 0, int $length = 0): Command |
68
|
|
|
{ |
69
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* List all available commands. |
74
|
|
|
* |
75
|
|
|
* @Endpoint(name="commands") |
76
|
|
|
* |
77
|
|
|
* @param bool $flags show command flags |
78
|
|
|
* |
79
|
|
|
* @return Command |
80
|
|
|
*/ |
81
|
|
|
public function commands(bool $flags = false): Command |
82
|
|
|
{ |
83
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Resolve DNS links. |
88
|
|
|
* |
89
|
|
|
* @Endpoint(name="dns") |
90
|
|
|
* |
91
|
|
|
* @param string $arg the domain-name name to resolve |
92
|
|
|
* @param bool $recursive resolve until the result is not a DNS link |
93
|
|
|
* |
94
|
|
|
* @return Command |
95
|
|
|
*/ |
96
|
|
|
public function dns(string $arg, bool $recursive = false): Command |
97
|
|
|
{ |
98
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Download IPFS objects. |
103
|
|
|
* |
104
|
|
|
* @Endpoint(name="get") |
105
|
|
|
* |
106
|
|
|
* @param string $arg the path to the IPFS object(s) to be outputted |
107
|
|
|
* @param string $output the path where the output should be stored |
108
|
|
|
* @param bool $archive output a TAR archive |
109
|
|
|
* @param bool $compress compress the output with GZIP compression |
110
|
|
|
* @param int $compressionLevel the level of compression (1-9) |
111
|
|
|
* |
112
|
|
|
* @return Command |
113
|
|
|
*/ |
114
|
|
|
public function get(string $arg, string $output = null, bool $archive = false, bool $compress = false, int $compressionLevel = 0): Command |
115
|
|
|
{ |
116
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Show ipfs node id info. |
121
|
|
|
* |
122
|
|
|
* @Endpoint(name="id") |
123
|
|
|
* |
124
|
|
|
* @param string $arg peer |
125
|
|
|
* @param string $format optional output format |
126
|
|
|
* |
127
|
|
|
* @return Command |
128
|
|
|
*/ |
129
|
|
|
public function id(string $arg = null, string $format = null): Command |
130
|
|
|
{ |
131
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* List directory contents for Unix filesystem objects. |
136
|
|
|
* |
137
|
|
|
* @Endpoint(name="ls") |
138
|
|
|
* |
139
|
|
|
* @param string $arg the path to the IPFS object(s) to list links from |
140
|
|
|
* @param bool $headers print table headers (Hash, Size, Name) |
141
|
|
|
* @param bool $resolveType resolve linked objects to find out their types |
142
|
|
|
* |
143
|
|
|
* @return Command |
144
|
|
|
*/ |
145
|
|
|
public function ls(string $arg, bool $headers = false, bool $resolveType = true): Command |
146
|
|
|
{ |
147
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Mounts IPFS to the filesystem (read-only). |
152
|
|
|
* |
153
|
|
|
* @Endpoint(name="mount") |
154
|
|
|
* |
155
|
|
|
* @param string $ipfsPath the path where IPFS should be mounted |
156
|
|
|
* @param string $ipnsPath the path where IPNS should be mounted |
157
|
|
|
* |
158
|
|
|
* @return Command |
159
|
|
|
*/ |
160
|
|
|
public function mount(string $ipfsPath = null, string $ipnsPath = null): Command |
161
|
|
|
{ |
162
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Send echo request packets to IPFS hosts. |
167
|
|
|
* |
168
|
|
|
* @Endpoint(name="ping") |
169
|
|
|
* |
170
|
|
|
* @param string $arg ID of peer to be pinged |
171
|
|
|
* @param int $count number of ping messages to send |
172
|
|
|
* |
173
|
|
|
* @return Command |
174
|
|
|
*/ |
175
|
|
|
public function ping(string $arg, int $count = 10): Command |
176
|
|
|
{ |
177
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Resolve the value of names to IPFS. |
182
|
|
|
* |
183
|
|
|
* @Endpoint(name="resolve") |
184
|
|
|
* |
185
|
|
|
* @param string $arg the name to resolve |
186
|
|
|
* @param bool $recursive resolve until the result is an IPFS name |
187
|
|
|
* @param uint $dhtRecordCount number of records to request for DHT resolution |
188
|
|
|
* @param string $dhtTimeout max time to collect values during DHT resolution eg “30s” |
189
|
|
|
* |
190
|
|
|
* @return Command |
191
|
|
|
*/ |
192
|
|
|
public function resolve(string $arg, bool $recursive = false, uint $dhtRecordCount = null, string $dhtTimeout = null): Command |
193
|
|
|
{ |
194
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Shut down the ipfs daemon. |
199
|
|
|
* |
200
|
|
|
* @Endpoint(name="shutdown") |
201
|
|
|
* |
202
|
|
|
* @return Command |
203
|
|
|
*/ |
204
|
|
|
public function shutdown(): Command |
205
|
|
|
{ |
206
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @Endpoint(name="update") |
211
|
|
|
* |
212
|
|
|
* @param string $arg arguments for subcommand |
213
|
|
|
* |
214
|
|
|
* @return Command |
215
|
|
|
*/ |
216
|
|
|
public function update(string $arg = null): Command |
217
|
|
|
{ |
218
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Show ipfs version information. |
223
|
|
|
* |
224
|
|
|
* @Endpoint(name="version") |
225
|
|
|
* |
226
|
|
|
* @param bool $number only show the version number |
227
|
|
|
* @param bool $commit show the commit hash |
228
|
|
|
* @param bool $repo show repo version |
229
|
|
|
* @param bool $all show all version information |
230
|
|
|
* |
231
|
|
|
* @return Command |
232
|
|
|
*/ |
233
|
|
|
public function version(bool $number = false, bool $commit = false, bool $repo = false, bool $all = false): Command |
234
|
|
|
{ |
235
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
|