Signal K
    Preparing search index...

    Interface ResourcesApi

    interface ResourcesApi {
        deleteResource(
            resType: SignalKResourceType,
            resId: string,
            providerId?: string,
        ): Promise<void>;
        getResource(
            resType: string,
            resId: string,
            providerId?: string,
        ): Promise<object>;
        listResources(
            resType: SignalKResourceType,
            params: { [key: string]: any },
            providerId?: string,
        ): Promise<{ [id: string]: any }>;
        register(pluginId: string, provider: ResourceProvider): void;
        setResource(
            resType: SignalKResourceType,
            resId: string,
            data: { [key: string]: any },
            providerId?: string,
        ): Promise<void>;
        unRegister(pluginId: string): void;
    }
    Index

    Methods

    • Delete the resource with the supplied SignalK resource_type and resource_id.

      Note

      Requires a registered Resource Provider. See ResourceProviderRegistry.registerResourceProvider.

      Parameters

      • resType: SignalKResourceType

        A SignalKResourceType or user defined resource type.

      • resId: string

        The resource identifier. (e.g. ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a)

      • OptionalproviderId: string

        The id of the Resource Provider plugin to use to complete the request.

      Returns Promise<void>

      app.resourcesApi.deleteResource(
      'notes',
      'ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a'
      ).then ( () => {
      // success
      ...
      }).catch (error) {
      // handle error
      console.log(error.message);
      ...
      }
    • Retrieve the resource with the supplied SignalK resource_type and resource_id.

      Note

      Requires a registered Resource Provider. See ResourceProviderRegistry.registerResourceProvider.

      Parameters

      • resType: string

        A SignalKResourceType or user defined resource type.

      • resId: string

        The resource identifier. (e.g. ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a)

      • OptionalproviderId: string

        The id of the Resource Provider plugin to use to complete the request. Most commonly used for creating a new resource entry when more than one provider is registered for the specified resource type.

      Returns Promise<object>

      try {
      const waypoint = await app.resourcesApi.getResource('waypoints', 'ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a');
      // success
      } catch (error) {
      // handle error
      console.error(error);
      // ...
      }
    • Retrieve collection of resource entries of the supplied resource_type matching the provided criteria.

      Note

      Requires a registered Resource Provider. See ResourceProviderRegistry.registerResourceProvider.

      Parameters

      • resType: SignalKResourceType

        A SignalKResourceType or user defined resource type.

      • params: { [key: string]: any }

        Object containing key | value pairs representing the criteria by which to filter the returned entries.

        Note

        The registered Resource Provider must support the supplied parameters for results to be filtered.

      • OptionalproviderId: string

        The id of the Resource Provider plugin to use to complete the request.

      Returns Promise<{ [id: string]: any }>

      app.resourcesApi.listResources(
      'waypoints',
      {region: 'fishing_zone'}
      ).then (data => {
      // success
      console.log(data);
      ...
      }).catch (error) {
      // handle error
      console.log(error.message);
      ...
      }
    • Create / update value of the resource with the supplied SignalK resource_type and resource_id.

      Note

      Requires a registered Resource Provider. See ResourceProviderRegistry.registerResourceProvider.

      Parameters

      • resType: SignalKResourceType

        A SignalKResourceType or user defined resource type.

      • resId: string

        The resource identifier. (e.g. ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a)

      • data: { [key: string]: any }

        A complete and valid resource record.

      • OptionalproviderId: string

        The id of the Resource Provider plugin to use to complete the request. Most commonly used for creating a new resource entry when more than one provider is registered for the specified resource type.

      Returns Promise<void>

      app.resourcesApi.setResource(
      'waypoints',
      'ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a',
      {
      "name": "My Waypoint",
      "feature": {
      "type":"Feature",
      "geometry": {
      "type": "Point",
      "coordinates": [138.5, -38.6]
      },
      "properties":{}
      }
      }
      ).then ( () => {
      // success
      ...
      }).catch (error) {
      // handle error
      console.log(error.message);
      ...
      }
    • Parameters

      • pluginId: string

      Returns void