solarnetwork-api-core
    Preparing search index...

    Class SolarUserApi

    The SolarUser API URL helper.

    Hierarchy

    • AuthUrlHelperMixin<
          { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              new (...args: any[]): __type;
          } & {
              prototype: __type<any>;
              canUseSimpleRequest(parameters?: InstructionParameter[]): boolean;
              instructionParameter(name: string, value: string): InstructionParameter;
              urlEncodeInstructionParameters(
                  parameters?: InstructionParameter[],
              ): string;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & typeof SolarUserUrlHelper,
          this,
      > & __type<
          { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              canUseSimpleRequest(parameters?: InstructionParameter[]): boolean;
              instructionParameter(name: string, value: string): InstructionParameter;
              urlEncodeInstructionParameters(
                  parameters?: InstructionParameter[],
              ): string;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & typeof SolarUserUrlHelper,
          this,
      > & __type<
          {
              prototype: __type<any>;
              canUseSimpleRequest(parameters?: InstructionParameter[]): boolean;
              instructionParameter(name: string, value: string): InstructionParameter;
              urlEncodeInstructionParameters(
                  parameters?: InstructionParameter[],
              ): string;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & typeof SolarUserUrlHelper,
          this,
      > & __type<
          { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              new (...args: any[]): __type;
          } & { prototype: __type<any>; new (...args: any[]): __type } & typeof SolarUserUrlHelper,
          this,
      > & __type<
          { prototype: __type<any>; new (...args: any[]): __type } & {
              prototype: __type<any>;
              new (...args: any[]): __type;
          } & typeof SolarUserUrlHelper,
          this,
      > & __type<
          { prototype: __type<any>; new (...args: any[]): __type } & typeof SolarUserUrlHelper,
          this,
      > & __type<typeof SolarUserUrlHelper, this> & SolarUserUrlHelper<this>
      • SolarUserApi
    Index

    Constructors

    • Constructor.

      Parameters

      • Optionalenvironment: HostConfigInfo

        the 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

      Returns SolarUserApi

    Accessors

    • get parameters(): Configuration

      Get a parameters object that can be used to hold URL variables.

      Returns Configuration

    Methods

    • Generate a URL for adding metadata to a node via a POST request.

      Parameters

      • OptionalnodeId: number

        a specific node ID to use; if not provided the nodeId parameter of this class will be used

      Returns string

      the URL

      Error if no node ID available

    • Generate a URL for adding user metadata via a POST request.

      Parameters

      • OptionaluserId: number

        a 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

      Returns string

      the URL

    • Returns string

      the base URL to the REST API

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

      This will look for the following parameters:

      • nodeIds
      • sourceIds

      Returns DatumFilter

      the filter

    • Generate a URL for deleting the metadata of a node via a DELETE request.

      Parameters

      • OptionalnodeId: number

        a specific node ID to use; if not provided the nodeId parameter of this class will be used

      Returns string

      the URL

      Error if no node ID available

    • Generate a URL for deleting a DatumAuxiliaryType via a DELETE request.

      The Net.SolarUserApi#userDatumAuxiliaryIdUrl method is used to generate the URL.

      Parameters

      • type: DatumAuxiliaryType

        the datum auxiliary type

      • nodeId: number

        the node ID

      • date: Date

        a date

      • sourceId: string

        the source ID

      Returns string

      the URL

    • Generate a URL for deleting user metadata via a DELETE request.

      Parameters

      • OptionaluserId: number

        a 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

      Returns string

      the URL

    • 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

    • Generate a URL for posting an instruction execution request.

      Parameters

      • topic: string

        the instruction topic

      • Optionalparameters: InstructionParameter[]

        an array of parameter objects

      • OptionalnodeIds: number | number[]

        the specific node ID(s) to use; if not provided the nodeIds parameter of this class will be used

      Returns string

      the URL

    • Generate a URL for searching for node metadata.

      Parameters

      • OptionalnodeId: null | number | number[]

        a specific node ID, or array of node IDs, to use; if not provided the nodeIds property of this class will be used, unless null is passed in which case no node IDs will be added to the URL so that all available node metadata objects will be returned

      • Optionalsorts: SortDescriptor[]

        optional sort settings to use

      • Optionalpagination: Pagination

        optional pagination settings to use

      Returns string

      the URL

      Error if no node ID available

    • Generate a URL for viewing the configured user's metadata via a GET request.

      Parameters

      Returns string

      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.

      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

    • Generate a URL for viewing the configured user's metadata via a GET request.

      Parameters

      Returns string

      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

      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

    • Create a queue instruction request object, suitable for submitting as JSON content.

      Parameters

      • Optionaltopic: string

        the topic to include (can be omitted if the topic is included in the request URL)

      • Optionalparameters: InstructionParameter[]

        the parameter to include

      • OptionalnodeId: number

        the specific node ID to use; if not provided the nodeId parameter of this class will be used

      • OptionalexecutionDate: Date

        a deferred execution date; this will be encoded as a executionDate parameter as an ISO 8601 timestamp value

      Returns QueueInstructionRequest | QueueInstructionSimpleRequest

      the request, encoded as a Net.QueueInstructionSimpleRequest if possible

    • Generate a URL for posting instruction requests for multiple nodes.

      Parameters

      • topic: string

        the instruction topic

      • Optionalparameters: InstructionParameter[]

        an array of parameter objects

      • OptionalnodeIds: number[]

        a list of node IDs to use; if not provided the nodeIds parameter of this class will be used

      • OptionaltopicAsParam: boolean

        true to encode topic as request parameter, false as the final URL path segment

      Returns string

      the URL

    • Generate a URL for posting an instruction request.

      Parameters

      • topic: string

        the instruction topic

      • Optionalparameters: InstructionParameter[]

        an array of parameter objects

      • OptionalnodeId: number

        the specific node ID to use; if not provided the nodeId parameter of this class will be used

      • OptionaltopicAsParam: boolean

        true to encode topic as request parameter, false as the final URL path segment

      Returns string

      the URL

    • Generate a URL to refresh the signing key of an authentication token.

      Note this method only works against the /sec version of the API endpoint.

      Parameters

      • Optionaldate: Date

        the signing date to use, or null for the current date

      Returns string

      the URL

    • Generate a URL for setting the metadata of a node via a PUT request.

      Parameters

      • OptionalnodeId: number

        a specific node ID to use; if not provided the nodeId parameter of this class will be used

      Returns string

      the URL

      Error if no node ID available

    • Generate a URL for replacing user metadata via a PUT request.

      Parameters

      • OptionaluserId: number

        a 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

      Returns string

      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.

      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

    • Generate a URL for storing a DatumAuxiliaryType via a POST request.

      The Net.SolarUserApi#userDatumAuxiliaryIdUrl method is used to generate the URL.

      Parameters

      • type: DatumAuxiliaryType

        the datum auxiliary type

      • nodeId: number

        the node ID

      • date: Date

        a date

      • sourceId: string

        the source ID

      Returns string

      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.

      Parameters

      • url: string

      Returns string

      the URL to make reqeusts to the SolarNet host

    • Generate a URL for changing the state of an instruction.

      Parameters

      • instructionId: number

        the instruction ID to update

      • state: InstructionState

        the instruction state to set

      Returns string

      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.

      Parameters

      • archived: boolean

        true to mark the nodes as archived; false to un-mark and return to normal status

      • OptionalnodeId: 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

      Returns string

      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.

      Parameters

      • type: DatumAuxiliaryType

        the datum auxiliary type

      • nodeId: number

        the node ID

      • date: Date

        a date

      • sourceId: string

        the source ID

      Returns string

      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.

      Parameters

      • type: DatumAuxiliaryType

        the datum auxiliary type

      • nodeId: number

        the node ID

      • date: Date

        a date

      • sourceId: string

        the source ID

      Returns string

      the URL

    • Generate a URL for viewing active instructions.

      Parameters

      • OptionalnodeId: number

        a specific node ID to use; if not provided the nodeId parameter of this instance will be used

      Returns string

      the URL

    • Generate a URL to get a list of all archived nodes for the user account.

      Returns string

      the URL to access the user's archived nodes

    • Generate a URL to get all details for a specific instruction.

      Parameters

      • instructionId: number

        the instruction ID to get

      Returns string

      the URL

    • Generate a URL for viewing the configured node's metadata.

      Parameters

      • OptionalnodeId: number

        a specific node ID to use; if not provided the nodeId parameter of this class will be used

      Returns string

      the URL

      Error if no node ID available

    • Generate a URL to get a list of all active nodes for the user account.

      Returns string

      the URL to access the user's active nodes

    • Generate a URL for viewing pending instructions.

      Parameters

      • OptionalnodeId: number

        a specific node ID to use; if not provided the nodeId parameter of this instance will be used

      Returns string

      the URL

    • Generate a URL to get a list of all pending nodes for the user account.

      Returns string

      the URL to access the user's pending nodes

    • Generate a URL for viewing a DatumAuxiliaryType via a GET request.

      The Net.SolarUserApi#userDatumAuxiliaryIdUrl method is used to generate the URL.

      Parameters

      • type: DatumAuxiliaryType

        the datum auxiliary type

      • nodeId: number

        the node ID

      • date: Date

        a date

      • sourceId: string

        the source ID

      Returns string

      the URL

    • Generate a URL for viewing a specific user's metadata via a GET request.

      Parameters

      • OptionaluserId: number

        a 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

      Returns string

      the URL

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

      Returns string

      the URL to view information about the authenticated user

    • Test if a list of instructions can be encoded as a Net.QueueInstructionSimpleRequest object.

      Parameters

      Returns boolean

      true if a QueueInstructionSimpleRequest can be used to encode the instruction parameters

    • Create an instruction parameter.

      Parameters

      • name: string

        the parameter name

      • value: string

        the parameter value

      Returns InstructionParameter

      the parameter object

    • 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

    • Generate URL encoded query string for posting instruction parameters.

      Parameters

      Returns string

      the URL encoded query string, or an empty string if parameters is empty