API: configurations
Source:
core/configurations.ts
API Configurations
- Provides a static interface for accessing and manipulating configuration properties, and checking the operating system type.
Usage
import { response } from "sdk/http";
import { configurations } from "sdk/core";
configurations.set("ENV_VAR_1", "ENV_VAR_1");
configurations.set("ENV_VAR_2", "ENV_VAR_2");
let credentials = {
envVar1: configurations.get("ENV_VAR_1"),
envVar2: configurations.get("ENV_VAR_2")
};
response.println(JSON.stringify(credentials));Classes
Configurations
API Configurations
* Provides a static interface for accessing and manipulating configuration properties,
and checking the operating system type.
Methods
get
get (key:string, defaultValue?:string):string|undefinedRetrieves the configuration value associated with the given key.
@param key The configuration key.
@param defaultValue The optional default value to return if the key is not found.
@returns The configuration value as a string, orundefinedif the key is not found and no default is provided.
set
set (key:string, value:string):voidSets the configuration value for the given key.
If the key already exists, its value is overwritten.
@param key The configuration key.
@param value The configuration value to set.
remove
remove (key:string):voidRemoves the configuration property associated with the given key.
@param key The configuration key to remove.
getKeys
getKeys ():string[]Retrieves a list of all current configuration keys.
@returns An array of configuration keys (strings).
load
load (path:string):voidLoads configuration properties from a file at the specified path, overriding existing ones.
@param path The file path to load configurations from.
update
update ():voidReloads or updates the current configuration settings from their source (e.g., persistence layer).
getOS
getOS ():stringRetrieves the name of the current Operating System.
@returns The OS name as a string (e.g., "Windows", "Linux", "Mac OS X").
isOSWindows
isOSWindows ():booleanChecks if the current Operating System is Windows.
@returns True if the OS is Windows, false otherwise.
isOSMac
isOSMac ():booleanChecks if the current Operating System is Mac OS (or Mac OS X).
@returns True if the OS is Mac, false otherwise.
isOSUNIX
isOSUNIX ():booleanChecks if the current Operating System is a UNIX-like system (e.g., Linux, macOS, or others).
@returns True if the OS is a UNIX variant, false otherwise.
isOSSolaris
isOSSolaris ():booleanChecks if the current Operating System is Solaris.
@returns True if the OS is Solaris, false otherwise.