Constructor.
Optional
environment: HostConfigInfothe optional initial environment to use;
if a non-Environment
object is passed then the properties of that object will
be used to construct a new Environment
instance
Private
Readonly
#environmentThe network environment (host, port, and so on).
Private
Readonly
#parametersParameters for URL variables.
Get the environment configuration.
Get a parameters object that can be used to hold URL variables.
Private
#instructionOptional
parameters: InstructionParameter[]Optional
nodeIds: number | number[]Private
#userPrivate
#userGenerate a URL for adding user metadata via a POST
request.
Optional
userId: numbera specific user ID;
if not provided the userId
parameter of this class will be used;
if no userId
parameter is available then view metadata of the requesting user
the URL
Get a new configured with parameters of this instance.
This will look for the following parameters:
nodeIds
sourceIds
the filter
Generate a URL for deleting a DatumAuxiliaryType
via a DELETE
request.
The Net.SolarUserApi#userDatumAuxiliaryIdUrl method is used to generate the URL.
the datum auxiliary type
the node ID
a date
the source ID
the URL
Generate a URL for deleting user metadata via a DELETE
request.
Optional
userId: numbera specific user ID;
if not provided the userId
parameter of this class will be used;
if no userId
parameter is available then view metadata of the requesting user
the URL
Get or set an environment parameter.
This is a shortcut for calling Util.Configuration#value on the
environment
object.
the environment parameter name to get
when called as a getter, the environment parameter value; when called as a setter, the environment object
Generate a URL for posting an instruction execution request.
the instruction topic
Optional
parameters: InstructionParameter[]an array of parameter objects
Optional
nodeIds: number | number[]the specific node ID(s) to use; if not provided the nodeIds
parameter of this class will be used
the URL
Generate a URL for viewing the configured user's metadata via a GET
request.
the search criteria
the URL
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.
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:
true
then
use HTTPS as the protocol, otherwise HTTP.host
for the host name or IP address.port
for the port if available and not the standard 443
for
HTTPS or 80
for HTTP.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:
true
then
use WSS as the protocol, otherwise WS.host
for the host name or IP address.port
for the port if available and not the standard 443
for
WSS or 80
for WS.the URL to the SolarNet host WebSocket
Generate a URL for viewing the configured user's metadata via a GET
request.
the search criteria
the URL
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
the expected type
the parameter name to get
the parameter value
Get or set a parameter.
This is a shortcut for calling Util.Configuration#value on the
parameters
object.
the parameter name to get
when called as a getter, the parameter value; when called as a setter, the parameters object
Create a queue instruction request object, suitable for submitting as JSON content.
Optional
topic: stringthe topic to include (can be omitted if the topic is included in the request URL)
Optional
parameters: InstructionParameter[]the parameter to include
Optional
nodeId: numberthe specific node ID to use; if not provided the nodeId
parameter of this class will be used
Optional
executionDate: Datea deferred execution date; this will be encoded as a executionDate
parameter as an
ISO 8601 timestamp value
the request, encoded as a Net.QueueInstructionSimpleRequest if possible
Generate a URL for posting an instruction request.
the instruction topic
Optional
parameters: InstructionParameter[]an array of parameter objects
Optional
nodeId: numberthe specific node ID to use; if not provided the nodeId
parameter of this class will be used
the URL
Generate a URL for posting instruction requests for multiple nodes.
the instruction topic
Optional
parameters: InstructionParameter[]an array of parameter objects
Optional
nodeIds: number[]a list of node IDs to use; if not provided the nodeIds
parameter of this class will be used
the URL
Generate a URL for replacing user metadata via a PUT
request.
Optional
userId: numbera specific user ID;
if not provided the userId
parameter of this class will be used;
if no userId
parameter is available then view metadata of the requesting user
the URL
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.
a URL path template
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.
a URL template
the URL with template variables resolved
Generate a URL for storing a DatumAuxiliaryType
via a POST
request.
The module:net~UserDatumAuxiliaryUrlHelperMixin#userDatumAuxiliaryIdUrl method is used to generate the URL.
the datum auxiliary type
the node ID
a date
the source ID
the URL
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.
the URL to make reqeusts to the SolarNet host
Generate a URL for changing the state of an instruction.
the instruction ID to update
the instruction state to set
the URL
the Domain.InstructionStates enum for possible state values
Generate a URL to update the archived status of a set of nodes via a POST
request.
true
to mark the nodes as archived; false
to un-mark
and return to normal status
Optional
nodeId: number | number[]a specific node ID, or array of node IDs, to update; if not provided the
nodeIds
property of this class will be used
the URL to update the nodes archived status
Generate a URL for accessing a specific DatumAuxiliaryType
by its primary key,
using query parameters for id components.
the datum auxiliary type
the node ID
a date
the source ID
the URL
Generate a URL for accessing a specific DatumAuxiliaryType
by its primary key.
If sourceId
contains any /
characters, then
Net.SolarUserApi#userDatumAuxiliaryIdQueryUrl
will be invoked instead.
the datum auxiliary type
the node ID
a date
the source ID
the URL
Generate a URL for viewing a DatumAuxiliaryType
via a GET
request.
The Net.SolarUserApi#userDatumAuxiliaryIdUrl method is used to generate the URL.
the datum auxiliary type
the node ID
a date
the source ID
the URL
Generate a URL for viewing a specific user's metadata via a GET
request.
Optional
userId: numbera specific user ID;
if not provided the userId
parameter of this class will be used;
if no userId
parameter is available then view metadata of the requesting user
the URL
Static
canTest if a list of instructions can be encoded as a Net.QueueInstructionSimpleRequest object.
Optional
parameters: InstructionParameter[]the parameters to inspect
true
if a QueueInstructionSimpleRequest
can be used to encode the instruction parameters
Static
instructionCreate an instruction parameter.
the parameter name
the parameter value
the parameter object
Static
resolveReplace 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 /
.
a URL template
an object whose properties should serve as template variables
the URL
Static
urlGenerate URL encoded query string for posting instruction parameters.
Optional
parameters: InstructionParameter[]an array of parameter objects
the URL encoded query string, or an empty string if parameters
is empty
Generated using TypeDoc
The SolarUser API URL helper.