Documentation

Mistake on this page? Email us

SubscriptionsApi

Hierarchy

  • ApiBase
    • SubscriptionsApi

Index

Constructors

constructor

  • Parameters

    • Optional options: ConfigOptions
    • Default value responseHandler: function =¬†null
        • (sdkError: SDKError, response: superagent.Response): any
        • Parameters

          • sdkError: SDKError
          • response: superagent.Response

          Returns any

    Returns SubscriptionsApi

Methods

addResourceSubscription

  • addResourceSubscription(deviceId: string, resourcePath: string, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Subscribe to a resource path The Device Management Connect eventing model consists of observable resources. This means that endpoints can deliver updated resource content, periodically or with a more sophisticated solution-dependent logic. The OMA LwM2M resource model including objects, object instances, resources and resource instances is also supported. Applications can subscribe to objects, object instances or individual resources to make the device to provide value change notifications to Device Management Connect service. An application needs to call a `/notification/callback` method to get Device Management Connect to push notifications of the resource changes. Notification rules A web application can place dynamic observation rules for individual Object Instances and Resources to define when the device sends observations. More information in Notification rules. All manual subscriptions are removed during a full device registration and applications need to re-subscribe at that point. To avoid this, you can use `/subscriptions` to set a pre-subscription. Example usage: curl -X PUT \ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id}/{resourcePath} \ -H 'authorization: Bearer {api-key}'

    Parameters

    • deviceId: string

      A unique Device Management device ID for the endpoint. Note that the ID must be an exact match. You cannot use wildcards here.

    • resourcePath: string

      The URL of the resource.

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

checkResourceSubscription

  • checkResourceSubscription(deviceId: string, resourcePath: string, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Read subscription status

    Parameters

    • deviceId: string

      A unique Device Management device ID for the endpoint. Note that the ID must be an exact match. You cannot use wildcards here.

    • resourcePath: string

      The URL of the resource.

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

complete

  • complete(error: any, response: any, acceptHeader: string, callback?: function): void
  • Parameters

    • error: any
    • response: any
    • acceptHeader: string
    • Optional callback: function
        • Parameters

          Returns any

    Returns void

currentConfig

  • currentConfig(): object
  • Returns the current configuration of this API module

    Returns object

    • apiKey: any
    • host: any

deleteEndpointSubscriptions

  • deleteEndpointSubscriptions(deviceId: string, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Delete subscriptions from an endpoint Deletes all resource subscriptions in a single endpoint. Example usage: curl -X DELETE \ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \ -H 'authorization: Bearer {api-key}'

    Parameters

    • deviceId: string

      A unique Device Management device ID for the endpoint. Note that the ID must be an exact match. You cannot use wildcards here.

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

deletePreSubscriptions

  • deletePreSubscriptions(callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Remove pre-subscriptions Removes pre-subscriptions. Example usage: curl -X DELETE https://api.us-east-1.mbedcloud.com/v2/subscriptions -H 'authorization: Bearer {api-key}'

    Parameters

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

deleteResourceSubscription

  • deleteResourceSubscription(deviceId: string, resourcePath: string, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Remove a subscription To remove an existing subscription from a resource path. Example usage: curl -X DELETE \ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id}/{resourcePath} \ -H 'authorization: Bearer {api-key}'

    Parameters

    • deviceId: string

      A unique Device Management device ID for the endpoint. Note that the ID must be an exact match. You cannot use wildcards here.

    • resourcePath: string

      The URL of the resource.

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

getEndpointSubscriptions

  • getEndpointSubscriptions(deviceId: string, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Read endpoints subscriptions Lists all subscribed resources from a single endpoint. Example usage: curl -X GET \ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \ -H 'authorization: Bearer {api-key}'

    Parameters

    • deviceId: string

      A unique Device Management device ID for the endpoint. Note that ID must be an exact match. You cannot use wildcards here.

    • Optional callback: function
        • (error: any, data?: string, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: string
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

getPreSubscriptions

  • getPreSubscriptions(callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Get pre-subscriptions You can retrieve the pre-subscription data with the GET operation. The server returns with the same JSON structure as described above. If there are no pre-subscribed resources, it returns with an empty array. Example usage: curl -X GET https://api.us-east-1.mbedcloud.com/v2/subscriptions -H 'authorization: Bearer {api-key}'

    Parameters

    • Optional callback: function
    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

request

  • request<T>(options: object, callback?: function): superagent.SuperAgentRequest
  • Type parameters

    • T

    Parameters

    • options: object
      • acceptTypes: Array<string>
      • Optional body?: any
      • contentTypes: Array<string>
      • Optional file?: boolean
      • formParams: __type
      • headers: object
        • [key: string]: string
      • method: string
      • query: __type
      • Optional requestOptions?: object
        • [key: string]: any
      • url: string
      • useFormData: boolean
    • Optional callback: function
        • Parameters

          Returns any

    Returns superagent.SuperAgentRequest

updatePreSubscriptions

  • updatePreSubscriptions(presubsription: PresubscriptionArray, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Set pre-subscriptions Pre-subscription is a set of rules and patterns put by the application. When an endpoint registers and its ID, type and registered resources match the pre-subscription data, Device Management Connect sends subscription requests to the device automatically. The pattern may include the endpoint ID (optionally having an `` character at the end), endpoint type, a list of resources or expressions with an `` character at the end. Subscriptions based on pre-subscriptions are done when device registers or does register update. To remove the pre-subscription data, put an empty array as a rule. Notification rules A web application can place dynamic observation rules for individual Object Instances and Resources to define when the device sends observations. More information in Notification rules. Limits: - The maximum length of the endpoint name and endpoint type is 64 characters. - The maximum length of the resource path is 128 characters. - You can listen to 256 separate resource paths. - The maximum number of pre-subscription entries is 1024. Example request: ``` curl -X PUT \ https://api.us-east-1.mbedcloud.com/v2/subscriptions \ -H 'authorization: Bearer {api-key}' \ -H 'content-type: application/json' \ -d '[ { &quot;endpoint-name&quot;: &quot;node-001&quot;, &quot;resource-path&quot;: [&quot;/dev&quot;] }, { &quot;endpoint-type&quot;: &quot;Light&quot;, &quot;resource-path&quot;: [&quot;/sen/_&quot;] }, { &quot;endpoint-name&quot;: &quot;node&quot; }, { &quot;endpoint-type&quot;: &quot;Sensor&quot; }, { &quot;resource-path&quot;: [&quot;/dev/temp&quot;,&quot;/dev/hum&quot;] } ]' ``` - Subscribe to `/dev` resource of endpoint named `node-001`. - Subscribe to `Light` type of endpoints and their resources prefixed with `/sen/`. - Subscribe to all observable resources of endpoint names prefixed with `node`. - Subscribe to all observable resources of `Sensor` type endpoints. - Subscribe to `/dev/temp` and `/dev/hum` resources of all endpoints. Note: For efficiency reasons, you should use resource path patterns in the pre-subscription data. This prevents the notification flow from unwanted resources.

    Parameters

    • presubsription: PresubscriptionArray

      Array of pre-subscriptions.

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest