Module com.github.alexdlaird.ngrok
Class NgrokInstaller
- java.lang.Object
-
- com.github.alexdlaird.ngrok.installer.NgrokInstaller
-
public class NgrokInstaller extends java.lang.Object
A helper for downloading and installing thengrok
for the current system.Config File
By default,ngrok
will look for its config file in the default location. We can override this behavior withJavaNgrokConfig.Builder.withConfigPath(Path)
.Binary Path
Thejava-ngrok
package manages its ownngrok
binary. We can use ourngrok
binary if we want by setting it withJavaNgrokConfig.Builder.withNgrokPath(Path)
and passing that config toNgrokClient
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.file.Path
DEFAULT_CONFIG_PATH
static java.nio.file.Path
DEFAULT_NGROK_PATH
static java.lang.String
FREEBSD
static java.lang.String
LINUX
static java.lang.String
MAC
static java.util.List<java.lang.String>
UNIX_BINARIES
static java.lang.String
WINDOWS
-
Constructor Summary
Constructors Constructor Description NgrokInstaller()
NgrokInstaller(HttpClient httpClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
getDefaultConfig(NgrokVersion ngrokVersion)
Get the default config params for the given major version ofngrok
.static java.lang.String
getNgrokBin()
Get thengrok
executable for the current system.NgrokCDNUrl
getNgrokCDNUrl()
SeegetNgrokCDNUrl()
.NgrokCDNUrl
getNgrokCDNUrl(NgrokVersion ngrokVersion)
Determine thengrok
CDN URL for the current OS and architecture.java.util.Map<java.lang.String,java.lang.Object>
getNgrokConfig(java.nio.file.Path configPath)
java.util.Map<java.lang.String,java.lang.Object>
getNgrokConfig(java.nio.file.Path configPath, boolean useCache)
java.util.Map<java.lang.String,java.lang.Object>
getNgrokConfig(java.nio.file.Path configPath, boolean useCache, NgrokVersion ngrokVersion)
Get thengrok
config from the given path.static java.lang.String
getSystem()
Parse the name fo the OS from system properties and return a friendly name.void
installDefaultConfig(java.nio.file.Path configPath, java.util.Map<java.lang.String,java.lang.Object> data)
void
installDefaultConfig(java.nio.file.Path configPath, java.util.Map<java.lang.String,java.lang.Object> data, NgrokVersion ngrokVersion)
Install the defaultngrok
config.void
installNgrok(java.nio.file.Path ngrokPath)
void
installNgrok(java.nio.file.Path ngrokPath, NgrokVersion ngrokVersion)
Download and install the latestngrok
for the current system, overwriting any existing contents at the given path.void
validateConfig(java.nio.file.Path configPath)
Validate that the config file at the given path is valid forngrok
andjava-ngrok
.void
validateConfig(java.util.Map<java.lang.String,java.lang.Object> data)
Validate that the given map of config items are valid forngrok
andjava-ngrok
.
-
-
-
Field Detail
-
MAC
public static final java.lang.String MAC
- See Also:
- Constant Field Values
-
WINDOWS
public static final java.lang.String WINDOWS
- See Also:
- Constant Field Values
-
LINUX
public static final java.lang.String LINUX
- See Also:
- Constant Field Values
-
FREEBSD
public static final java.lang.String FREEBSD
- See Also:
- Constant Field Values
-
UNIX_BINARIES
public static final java.util.List<java.lang.String> UNIX_BINARIES
-
DEFAULT_NGROK_PATH
public static final java.nio.file.Path DEFAULT_NGROK_PATH
-
DEFAULT_CONFIG_PATH
public static final java.nio.file.Path DEFAULT_CONFIG_PATH
-
-
Constructor Detail
-
NgrokInstaller
public NgrokInstaller()
-
NgrokInstaller
public NgrokInstaller(HttpClient httpClient)
-
-
Method Detail
-
getNgrokBin
public static java.lang.String getNgrokBin()
Get thengrok
executable for the current system.- Returns:
- The name of the
ngrok
executable.
-
installDefaultConfig
public void installDefaultConfig(java.nio.file.Path configPath, java.util.Map<java.lang.String,java.lang.Object> data)
-
installDefaultConfig
public void installDefaultConfig(java.nio.file.Path configPath, java.util.Map<java.lang.String,java.lang.Object> data, NgrokVersion ngrokVersion)
Install the defaultngrok
config. If a config is not already present for the given path, create one.- Parameters:
configPath
- The path to where thengrok
config should be installed.data
- A map of things to add to the default config.
-
installNgrok
public void installNgrok(java.nio.file.Path ngrokPath)
-
installNgrok
public void installNgrok(java.nio.file.Path ngrokPath, NgrokVersion ngrokVersion)
Download and install the latestngrok
for the current system, overwriting any existing contents at the given path.- Parameters:
ngrokPath
- The path to where thengrok
binary will be downloaded.ngrokVersion
- The majorngrok
version to install.
-
getNgrokCDNUrl
public NgrokCDNUrl getNgrokCDNUrl()
SeegetNgrokCDNUrl()
.
-
getNgrokCDNUrl
public NgrokCDNUrl getNgrokCDNUrl(NgrokVersion ngrokVersion)
Determine thengrok
CDN URL for the current OS and architecture.- Parameters:
ngrokVersion
- The major version ofngrok
to install.- Returns:
- The
ngrok
CDN URL.
-
validateConfig
public void validateConfig(java.nio.file.Path configPath)
Validate that the config file at the given path is valid forngrok
andjava-ngrok
.- Parameters:
configPath
- The config path to validate.
-
validateConfig
public void validateConfig(java.util.Map<java.lang.String,java.lang.Object> data)
Validate that the given map of config items are valid forngrok
andjava-ngrok
.- Parameters:
data
- A map of things to be validated as config items.
-
getSystem
public static java.lang.String getSystem()
Parse the name fo the OS from system properties and return a friendly name.- Returns:
- The friendly name of the OS.
-
getNgrokConfig
public java.util.Map<java.lang.String,java.lang.Object> getNgrokConfig(java.nio.file.Path configPath, boolean useCache, NgrokVersion ngrokVersion)
Get thengrok
config from the given path.- Parameters:
configPath
- Thengrok
config path to read.useCache
- Use the cached version of the config (if populated).- Returns:
- A map of the
ngrok
config.
-
getDefaultConfig
public java.util.Map<java.lang.String,java.lang.Object> getDefaultConfig(NgrokVersion ngrokVersion)
Get the default config params for the given major version ofngrok
.- Parameters:
ngrokVersion
- The major version ofngrok
installed.- Returns:
- The default config.
-
getNgrokConfig
public java.util.Map<java.lang.String,java.lang.Object> getNgrokConfig(java.nio.file.Path configPath)
-
getNgrokConfig
public java.util.Map<java.lang.String,java.lang.Object> getNgrokConfig(java.nio.file.Path configPath, boolean useCache)
-
-