# IPFS

    public class IPFS

IPFS is a class that wraps a go-ipfs node and its shell over UDS

Show on GitHub

- `defaultRepoPath`

  Undocumented

  #### Declaration

  Swift

      public static let defaultRepoPath: String

  Show on GitHub
- `init(_:)`

  Class constructor using repoPath passed as parameter on internal storage

  Throws

  - `SockManagerError`: If the initialization of SockManager failed
  - `ConfigError`: If the creation of the config failed
  - `RepoError`: If the initialization of the repo failed

  #### Declaration

  Swift

      public init(_ repoPath: String = defaultRepoPath) throws

  #### Parameters

  `repoPath` | The path of the go-ipfs repo (default: `ipfs/repo`)

  Show on GitHub
- `getAbsoluteRepoPath()`

  Returns the absolute repo path as an URL

  #### Declaration

  Swift

      public func getAbsoluteRepoPath() -> URL

  #### Return Value

  The absolute repo path

  Show on GitHub
- `isStarted()`

  Returns True if this IPFS instance is started by checking if the underlying go-ipfs node is instantiated

  #### Declaration

  Swift

      public func isStarted() -> Bool

  #### Return Value

  True, if this IPFS instance is started

  Show on GitHub
- `start()`

  Starts this IPFS instance

  Throws

  - `RepoError`: If the opening of the repo failed
  - `NodeError`: If the node is already started or if its startup fails

  #### Declaration

  Swift

      public func start() throws

  Show on GitHub
- `stop()`

  Stops this IPFS instance

  Throws

  `IPFSError`: If the node is already stopped or if its stop fails

  #### Declaration

  Swift

      public func stop() throws

  Show on GitHub
- `restart()`

  Restarts this IPFS instance

  Throws

  - `IPFSError`: If the node is already stopped or if its stop fails
  - `RepoError`: If the opening of the repo failed

  #### Declaration

  Swift

      public func restart() throws

  Show on GitHub
- `getConfig()`

  Gets the IPFS instance config as a dict

  Throws

  - `RepoError`: If the opening of the repo or the getting of its config failed
  - `ConfigError`: If the getting of the config as a dict failed

  Seealso

  IPFS Config Doc

  #### Declaration

  Swift

      public func getConfig() throws -> [String : Any]

  #### Return Value

  The IPFS instance config as a dict

  Show on GitHub
- `setConfig(_:)`

  Sets dict config passed as parameter as IPFS config or reset to default config (with a new identity) if the config parameter is nil

  Attention

  A started IPFS instance must be restarted for its config to be applied

  Throws

  - `RepoError`: If the opening of the repo or the setting of its config failed
  - `ConfigError`: If the setting of the config as a dict failed

  Seealso

  IPFS Config Doc

  #### Declaration

  Swift

      public func setConfig(_ config: [String : Any]? = nil) throws

  #### Parameters

  `config` | The IPFS instance dict config to set (if nil, default config will be used)

  Show on GitHub
- `getConfigKey(_:)`

  Gets the dict value associated to the key passed as parameter in the IPFS instance config

  Throws

  - `RepoError`: If the opening of the repo or the getting of its config failed
  - `ConfigError`: If the getting of the config value as a dict failed

  Seealso

  IPFS Config Doc

  #### Declaration

  Swift

      public func getConfigKey(_ key: String) throws -> [String : Any]

  #### Parameters

  `key` | The key associated to the value to get in the IPFS config

  #### Return Value

  The dict value associated to the key passed as parameter in the IPFS instance config

  Show on GitHub
- `setConfigKey(_:_:)`

  Sets dict config value to the key passed as parameters in the IPFS instance config

  Attention

  A started IPFS instance must be restarted for its config to be applied

  Throws

  - `RepoError`: If the opening of the repo or the getting/setting of its config failed
  - `ConfigError`: If the setting of the config value as a dict failed

  Seealso

  IPFS Config Doc

  #### Declaration

  Swift

      public func setConfigKey(_ key: String, _ value: [String : Any]) throws

  #### Parameters

  `key` | The key associated to the value to set in the IPFS instance config
  `value` | The dict value associated to the key to set in the IPFS instance config

  Show on GitHub
- `newRequest(_:)`

  Creates and returns a RequestBuilder associated to this IPFS instance shell

  Throws

  `IPFSError`: If the request creaton failed

  #### Declaration

  Swift

      public func newRequest(_ command: String) throws -> RequestBuilder

  #### Parameters

  `command` | The command of the request

  #### Return Value

  A RequestBuilder based on the command passed as parameter

  Show on GitHub
- `serveGateway(onMultiaddr:_:)`

  Serves node Gateway over the given Multiaddr

  Throws

  `NodeError`: If the node failed to serve

  #### Declaration

  Swift

      public func serveGateway(onMultiaddr: String, _ writable: Bool = false) throws -> String

  #### Parameters

  `onMultiaddr` | The multiaddr to serve on
  `writable` | If true: will also support support `POST`, `PUT`, and `DELETE` methods.

  Show on GitHub
- `serveAPI(onTCPPort:)`

  Serves node opi over the given TCPPort

  Throws

  `NodeError`: If the node failed to serve

  #### Declaration

  Swift

      public func serveAPI(onTCPPort: String) throws -> String

  #### Parameters

  `onMultiaddr` | The multiaddr to serve on
  `writable` | If true: will also support support `POST`, `PUT`, and `DELETE` methods.

  Show on GitHub

© 2022 . All rights reserved. (Last updated: 2022-12-05)

Generated by jazzy ♪♫ v0.14.3, a Realm project.