|
3 | 3 | * [config.get](#configget)
|
4 | 4 | * [config.set](#configset)
|
5 | 5 | * [config.replace](#configreplace)
|
| 6 | +* [config.profiles.list](#configprofileslist) |
| 7 | +* [config.profiles.apply](#configprofilesapply) |
6 | 8 |
|
7 | 9 | #### `config.get`
|
8 | 10 |
|
@@ -85,5 +87,62 @@ ipfs.config.replace(newConfig, (err) => {
|
85 | 87 |
|
86 | 88 | A great source of [examples][] can be found in the tests for this API.
|
87 | 89 |
|
| 90 | +#### `config.profiles.list` |
| 91 | + |
| 92 | +> List available config profiles |
| 93 | +
|
| 94 | +##### `ipfs.config.profiles.list([options], [callback])` |
| 95 | + |
| 96 | +`options` is a object. |
| 97 | +`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful. |
| 98 | + |
| 99 | +If no callback is passed, a [promise][] is returned |
| 100 | + |
| 101 | +**Example:** |
| 102 | + |
| 103 | +```JavaScript |
| 104 | +ipfs.config.profiles.list(newConfig, (err, profiles) => { |
| 105 | + if (err) { |
| 106 | + throw err |
| 107 | + } |
| 108 | + |
| 109 | + profiles.forEach(profile => { |
| 110 | + console.info(profile.name, profile.description) |
| 111 | + }) |
| 112 | +}) |
| 113 | +``` |
| 114 | + |
| 115 | +A great source of [examples][] can be found in the tests for this API. |
| 116 | + |
| 117 | +#### `config.profiles.apply` |
| 118 | + |
| 119 | +> Apply a config profile |
| 120 | +
|
| 121 | +##### `ipfs.config.profiles.apply(name, [options], [callback])` |
| 122 | + |
| 123 | +`name` is a string. Call `config.profiles.list()` for a list of valid profile names. |
| 124 | +`options` an object that might contain the following values: |
| 125 | + - `dryRun` is a boolean which if true does not apply the profile |
| 126 | +`callback` must follow the `function (err, result) {}` signature, where `err` is an error if the operation was not successful. |
| 127 | + |
| 128 | +If no callback is passed, a [promise][] is returned |
| 129 | + |
| 130 | +**Example:** |
| 131 | + |
| 132 | +```JavaScript |
| 133 | +ipfs.config.profiles.apply('lowpower', (err, diff) => { |
| 134 | + if (err) { |
| 135 | + throw err |
| 136 | + } |
| 137 | + |
| 138 | + console.info(diff.old) |
| 139 | + console.info(diff.new) |
| 140 | +}) |
| 141 | +``` |
| 142 | + |
| 143 | +Note that you will need to restart your node for config changes to take effect. |
| 144 | + |
| 145 | +A great source of [examples][] can be found in the tests for this API. |
| 146 | + |
88 | 147 | [promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
89 | 148 | [examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/config
|
0 commit comments