solarnetwork-api-core
    Preparing search index...

    Class SolarSshApi

    The SolarSSH API URL helper.

    Hierarchy

    Index

    Constructors

    Accessors

    Methods

    • Returns string

      the base URL to the REST API

    • Create an instruction auth builder for pre-signing the terminal connect request.

      The returned builder will be configured for a GET request using the viewNodeMetadataUrl() URL.

      Parameters

      • OptionalnodeId: number

        the node ID to connect to; if not provided the nodeId parameter of this object will be used

      Returns AuthorizationV2Builder

      the builder

    • Create an instruction auth builder for pre-signing the create session request.

      The returned builder will be configured for a GET request using the viewPendingInstructionsUrl() URL.

      Parameters

      • OptionalnodeId: number

        the node ID to connect to; if not provided the nodeId parameter of this object will be used

      Returns AuthorizationV2Builder

      the builder

      Error if no node ID available

    • Generate a URL for creating a new SolarSSH session.

      Parameters

      • OptionalnodeId: number

        the node ID to connect to; if not provided the nodeId parameter of this object will be used

      Returns string

      the URL

      Error if no node ID available

    • Get a new DatumFilter configured with parameters of this instance.

      This will look for the following parameters:

      • nodeIds
      • sourceIds

      Returns DatumFilter

      the filter

    • Get an environment parameter.

      This is a shortcut for calling Util.Configuration#value on the environment object.

      Parameters

      • key: string

        the environment parameter name to get

      Returns any

      the environment parameter value

    • Set an environment parameter.

      This is a shortcut for calling Util.Configuration#value on the environment object.

      Parameters

      • key: string

        the environment parameter name to set

      • val: any

        the value to set

      Returns EnvironmentConfig & HostConfig

      the environment object

    • Get a URL for just the SolarNet host, without any path to be used for actual requests.

      Calls the toRequestUrl() with hostUrl() as the argument.

      Returns string

      the URL to make reqeusts to the SolarNet host

    • Get a URL for just the SolarNet host, without any path.

      This method constructs an absolute URL based on the following properties configured on this instance's Net.Environment:

      1. If environment.useTls() returns true then use HTTPS as the protocol, otherwise HTTP.
      2. Use host for the host name or IP address.
      3. Use port for the port if available and not the standard 443 for HTTPS or 80 for HTTP.

      Returns string

      the URL to the SolarNet host

    • Get a URL for just the SolarNet host using the WebSocket protocol, without any path.

      This method constructs an absolute URL based on the following properties configured on this instance's Net.Environment:

      1. If environment.useTls() returns true then use WSS as the protocol, otherwise WS.
      2. Use host for the host name or IP address.
      3. Use port for the port if available and not the standard 443 for WSS or 80 for WS.

      Returns string

      the URL to the SolarNet host WebSocket

    • Get the URL to the SolarSSH HTTP proxy to the configured SolarNode.

      Parameters

      Returns string

      the HTTP proxy URL

      Error if no session ID available

    • Get a parameter, with plural suffix array support.

      This method will first look for a parameter named exactly key, and if found return that. Otherwise it will look for an array parameter named key with s appended, and if found return the first element from that array. For example:

      const helper = new UrlHelper();
      helper.parameter('nodeIds', [1, 2, 3]);

      helper.param('nodeIds'); // [1, 2, 3]
      helper.param('nodeId'); // 1

      If key already ends in s, then a desired array result is assumed. If a value is not found for the parameter, then s is removed from key and that parameter value is returned, as an array if it is not already. For example:

      const helper = new UrlHelper();
      helper.parameter('nodeId', 1);

      helper.param('nodeIds'); // [1]
      helper.param('nodeId'); // 1

      Type Parameters

      • T

        the expected type

      Parameters

      • key: string

        the parameter name to get

      Returns undefined | T

      the parameter value

    • Get a parameter.

      This is a shortcut for calling Util.Configuration#value on the parameters object.

      Parameters

      • key: string

        the parameter name to get

      Returns any

      the parameter value

    • Set a parameter.

      This is a shortcut for calling Util.Configuration#value on the parameters object.

      Parameters

      • key: string

        the parameter name to set

      • val: any

        the value to set

      Returns Configuration

      the parameters object

    • Replace occurances of URL template variables with values from the parameters property and append to the host URL.

      This method provides a way to resolve an absolute URL based on the configured environment and parameters on this object.

      Parameters

      • template: string

        a URL path template

      Returns string

      an absolute URL

    • Replace occurances of URL template variables with values from the parameters property.

      URL template variables are specified as {<em>name</em>}. The variable will be replaced by the value associated with property name in the parameters object. The value will be URI encoded.

      Parameters

      • template: string

        a URL template

      Returns string

      the URL with template variables resolved

    • Create an instruction auth builder for pre-signing the start session request.

      The returned builder will be configured for a POST request using the queueInstructionUrl() URL with the StartRemoteSsh instruction.

      Parameters

      Returns AuthorizationV2Builder

      the builder

      Error if no session or node ID available

    • Generate a URL for starting a SolarSSH session.

      Parameters

      Returns string

      the URL

      Error if no session ID available

    • Create an instruction auth builder for pre-signing the stop session request.

      The returned builder will be configured for a POST request using the queueInstructionUrl() URL with the StopRemoteSsh instruction.

      Parameters

      Returns AuthorizationV2Builder

      the builder

      Error if no session or node ID available

    • Generate a URL for stopping a SolarSSH session.

      Parameters

      Returns string

      the URL

      Error if no session ID available

    • Get the URL to the SolarSSH WebSocket termainl connection for a SolarNode.

      Parameters

      Returns string

      the WebSocket terminal URL

      Error if no session ID available

    • Get the URL to actually request, incorporating the environment's proxyUrlPrefix if available.

      If a environment.proxyUrlPrefix value is configured, this will re-write the URL to use that host prefix, otherwise url will be returned unchanged.

      Parameters

      • url: string

      Returns string

      the URL to make reqeusts to the SolarNet host

    • Generate a URL for viewing the StartRemoteSsh instruction.

      Parameters

      Returns string

      the URL

      Error if no instruction ID available

    • Generate a URL for viewing the StopRemoteSsh instruction.

      Parameters

      Returns string

      the URL

      Error if no instruction ID available

    • Generate a URL to get information about the requesting authenticated user.

      Returns string

      the URL to view information about the authenticated user

    • Replace occurances of URL template variables with values from a parameter object.

      URL template variables are specified as {<em>name</em>}. The variable will be replaced by the value associated with property name in the provided parameter object. The value will be URI encoded.

      Any occurances of // after replacing template variables will be reduced to /.

      Parameters

      • template: string

        a URL template

      • params: Record<string, any>

        an object whose properties should serve as template variables

      Returns string

      the URL

      Error if template length is too long