-
Notifications
You must be signed in to change notification settings - Fork 7
API Documentation
Mike Iversen edited this page Apr 26, 2022
·
49 revisions
The "API" of Netman consists of 3 parts. Those parts are
Each of these 3 pieces have their own specification which is laid out below. For more details on how these parts interact, as well as how Netman as whole works, please checkout the Dev Guide
Each of the above parts will have their "public facing" items documented here. "Private" functions/variables will not be documented in this documentation as they are not meant to be used.
Private functions/variables will usually have a _ leading them (so for example, _my_private_variable or _my_private_function).
Note, the specification for each function below is laid out in the follow example format
function_name(param1, param2, paramX)- Version Added:
- Param1
- Type: Expected Type
- Details: (Optional)
- Param2
- Type: Expected Type
- Details: (Optional)
- ParamX
- Type: Expected Type
- Details: (Optional)
- Returns
- Type: Expected Return Type
- Details: (Optional)
- Throws
- Details about potential errors that are thrown in this function
- Notes (Optional)
function init(core_providers)- Version Added: 0.1
- core_providers
- Type: Array
- Details:
core_providersis an optional array that can be provided on API initialization. If not provided, this will default tonetman.providers
- Returns: nil
- Throws
- Errors thrown by
load_providerwill be thrown from this as well
- Errors thrown by
- Notes
- Init is called automatically on import of
netman.apiand has a lock in place to prevent side effects of multiple imports ofapi. - This function does not need to be called when importing
netman.api
- Init is called automatically on import of
function dump_info(output_path)- Version Added: 0.1
- output_path
- Type: String
- Details:
output_pathis optional and defaults to$HOME/*random string*where*random string*is a randomly generated 10 character string
- Returns: nil
- Throws: nil
- Notes
-
dump_infocan be called via the:Nmlogsvim command and will do the following 2 things- Dump session related logs into the file created at
output_path(Note: if a file exists inoutput_path, it will be overwritten with the dump) - Open this file in a new
NetmanLogsfiletype buffer for viewing
- Dump session related logs into the file created at
-
function unload(buffer_index)- Version Added: 0.1
- buffer_index
- Type: Integer
- Details:
buffer_indexis the index of the buffer to be unloaded fromnetman.api's current state.
- Returns: nil
- Throws: nil
- Notes
- This will be called automatically when a
Netmanmanaged buffer is closed by vim (due to the an autocommand that is registered toBufUnloadfor the specific protocol that the buffer was opened with) - Unload will cleanup the local file used for a remote file pull if the provider performed a remote file pull
- Unload will call
close_connectionon the associated provider if the provider implementedclose_connection
- This will be called automatically when a
function load_provider(provider_path)- Version Added: 0.1
- provider_path
- Type: String
- Details:
provider_pathshould be the string path to import a provider. For examplenetman.provider.ssh
- Returns: nil
- Throws
- "Failed to initialize provider: " error
- This is thrown when an attempt to import the provider fails or the provider has no contents (IE, its an empty file)
- This is also thrown (with different sub details) if the provider is missing one of the required attributes. For more details on required attributes for a provider, please consult the Developer Guide
- "Failed to initialize provider: " error
- Notes
-
load_provideris the expected function to call when you are registering a new provider to handle a protocol, or registering an explorer to handle tree browsing. The function does a handful of things, which are laid out below- Attempts to import the provider. If there is a failure in the initial import, the above error(s) are thrown
- Validates the provider has the required attributes as laid out in the developer guide
- Calls the provider's
initfunction if it has one - Ensures that core providers do not override 3rd party providers. This means that
Netmanwill never attempt to override an existing provider for a protocol that netman supports.- NOTE: Netman does not prevent overriding of 3rd party providers by other 3rd party providers. Netman operates providers on "most recent provider" basis. This means that the most recent provider to register as the provider for a protocol will be used
- Register
autocommandsthat link the providersprotocolstoNetmanto be handled by theAPI
-
function load_explorer(explorer_path, force)function read(buffer_index, path)function delete(delete_path)function write(buffer_index, write_path)version