JSPM

  • Created
  • Published
  • Downloads 980204
  • Score
    100M100P100Q184976F
  • License ISC

Package Exports

  • @serverless/platform-client

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@serverless/platform-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Serverless Platform SDK

This Serverless Platform SDK makes it easy to interact with the Serverless Platform and perform operations on it. Please note that there is an existing @serverless/platform-sdk npm module for interacting with the Serverless Inc. SaaS original platform services. This SDK is for the new services, which are multi-cloud, self-hostable and focued on Components. At some point, we will try to merge these SDKs.

The SDK is light-weight, so that it can be used in the following: CLIs, Dashboards, Back-End Services, FaaS Layers. Please DO NOT add any big Node.js dependencies to this SDK.

This SDK should guide the interface design between Services and Clients. All Clients and Services MUST use the SDK and should never hardcode API endpoints or FaaS resources identifiers.

Quick-Start

If you are working within a Node.js environment, install the Serverless Platform Client SDK via NPM:

npm i @serverless/platform-client

If you are working within a web/browser environment, use the CDN hosted Serverless Platform Client SDK:

This is minified, tree-shaked, browserified. The CDN fetches it directly from NPM, so just reference any npm version, like below.

This CDN service has several locations in China, so it works well there.

// In index.html <head></head>
<!-- Load the Serverless Platform (Components) SDK -->
<script src="https://cdn.jsdelivr.net/npm/@serverless/platform-client@0.17.2" async></script>

You can also pin to the latest version, but this could break at any time:

// In index.html <head></head>
<!-- Load the Serverless Platform (Components) SDK -->
<script src="https://cdn.jsdelivr.net/npm/@serverless/platform-client" async></script>

If you are working with the dev environment of the Serverless Platform, set the following environment variable, or configure the client programmatically, as detailed below.

export SERVERLESS_PLATFORM_STAGE=dev

Here is how you require, instantiate the Client and use it:

const { ServerlessSDK } = require("@serverless/platform-client");

sdk = new ServerlessSDK({
  platformStage: "dev", // Optional.  Defaults to 'prod'
  accessKey: "JA98JAJFASLFJSALFJASLFJ", // Optional, but recommended.  Platform Access Key needed to identify all requests.
});

const instances = await sdk.listInstances("my-org");

ServerlessSDK

The Serverless Platform SDK Class

Kind: global class

new ServerlessSDK()

Creates an instance of the SDK. Accepts a configuration object and calls the config() method. See the config() method for more information on allowed configuration.

Param Type Description
[config.accessKey] string Can either be a Serverless Platform Access Key or an ID Token.
[config.platformStage] string The Serverless Platform Stage you wish to interact with. This can also be set by the environment variable SERVERLESS_PLATFORM_STAGE=
[context.orgName] string The name of the Serverless Platform Organization you wish to interact with. If set, this value is used upon creating a Websockets connection, and auto-added to every Event you publish.
[context.orgUid] string The ID of the Serverless Platform Organization you wish to interact with. If set, this value is used upon creating a Websockets connection, and auto-added to every Event you publish.
[context.stageName] string The Serverless Platform Organization Stage you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.appName] string The Serverless Platform Application you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.instanceName] string The Serverless Platform Instance you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentName] string The Serverless Platform Component you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentVersion] string The Serverless Platform Component version you wish to interact with. If set, this value is auto-added to every Event you publish.

Example

const { ServerlessSDK } = require("@serverless/platform-client");

const sdk = new ServerlessSDK({
  accessKey: "123456789",
  context: {
    orgName: "my-org",
    orgUid: "1234",
    stageName: "prod",
    appName: "my-app",
    instanceName: "my-instance",
  },
});

serverlessSDK.config() ⇒ null

Updates the SDK configuration

Kind: instance method of ServerlessSDK

Param Type Description
[config.accessKey] string Can either be a Serverless Platform Access Key or an ID Token.
[config.platformStage] string The Serverless Platform Stage you wish to interact with. This can also be set by the environment variable SERVERLESS_PLATFORM_STAGE=
[context.orgName] string The name of the Serverless Platform Organization you wish to interact with. If set, this value is used upon creating a Websockets connection, and auto-added to every Event you publish.
[context.orgUid] string The ID of the Serverless Platform Organization you wish to interact with. If set, this value is used upon creating a Websockets connection, and auto-added to every Event you publish.
[context.stageName] string The Serverless Platform Organization Stage you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.appName] string The Serverless Platform Application you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.instanceName] string The Serverless Platform Instance you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentName] string The Serverless Platform Component you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentVersion] string The Serverless Platform Component version you wish to interact with. If set, this value is auto-added to every Event you publish.

Example

const { ServerlessSDK } = require("@serverless/platform-client");

const sdk = new ServerlessSDK();
sdk.config({
  accessKey: "123456789",
  context: {
    orgName: "my-org",
    orgUid: "1234",
    stageName: "prod",
    appName: "my-app",
    instanceName: "my-instance",
  },
});

serverlessSDK.getDomain(serviceName) ⇒ string

Gets a domain for a specific service: 'engine', 'registry', 'events-streaming'

Kind: instance method of ServerlessSDK
Returns: string - The domain of that service.

Param Type Default Description
serviceName string null The name of the Serverless Platform Service you want the domain for.

serverlessSDK.getUser() ⇒ object

Get User account

Kind: instance method of ServerlessSDK
Returns: object - Returns a user record.

serverlessSDK.getUserMeta() ⇒ object

Get User account meta information.

Kind: instance method of ServerlessSDK
Returns: object - Returns a data object of custom "meta" information.

serverlessSDK.saveUserMeta(userMeta) ⇒ object

Updates User account meta information. This method fetches meta information and merges it with the meta object you provide before saving. Please note that this does a shallow merge and not a deep merge. That means nested properties might be replaced.

Kind: instance method of ServerlessSDK
Returns: object - Returns a data object of User data.

Param Type Description
userMeta object An object of new userMeta that will be automaticaly merged with the old user meta.

serverlessSDK.validateUserAndOrgName(userAndOrgName) ⇒ array

Validates whether a potential User and Organization name meets the Platform requirements. Most importantly, this calls the Platform to validate whether the User and Organization names are already taken. This method is necessary because every User must have an Organization and we want to be sure both namespaces are availbale, before creating one or the other. In the future, both of these records should be created in the back-end, not on the client-side. Until then, this method is essential.

Kind: instance method of ServerlessSDK
Returns: array - Returns an array of validation errors, if any. Otherwise, returns null.

Param Type Description
userAndOrgName string The name of the User and Org name.

serverlessSDK.createUserAndOrg(userAndOrgName) ⇒ object

In the Serverless Platform, every User must have an Organization by default. This method creates both a User and an Organization record, at the same time. Please note, the endpoint called is specific to Tenants (Organizations), which also has User creation logic within it. This API design is non-sensible and we should consider a better API design ASAP. Until then, this method abstracts over that.

Kind: instance method of ServerlessSDK
Returns: object - Returns the newly create Organization.

Param Type Description
userAndOrgName string The name of the User and Org name.

serverlessSDK.createOrg(userAndOrgName) ⇒ object

Creates an Organization.

Kind: instance method of ServerlessSDK
Returns: object - Returns the newly create Organization.

Param Type Description
userAndOrgName string The name of the Organization you wish to create. WARNING: This also creates a User record if one does not exist under this Organization name. This API design needs improvement.

serverlessSDK.getOrgByName(orgName) ⇒ object

Gets an Organization by Organization name.

Kind: instance method of ServerlessSDK
Returns: object - Returns the Organization record.

Param Type Description
orgName string The name of the Organization you wish to retrieve.

serverlessSDK.listOrgs(username) ⇒ object

Lists Organizations by User, whether the User is an Owner or a Member of a given Organization.

Kind: instance method of ServerlessSDK
Returns: object - Returns an array of Organizations

Param Type Description
username string The name of the User whose Organizations you wish to list.

serverlessSDK.createApp(orgName) ⇒ object

Create an Application within an Organization

Kind: instance method of ServerlessSDK
Returns: object - Returns a data object of the newly created Application

Param Type Default Description
orgName string null The name of the Organization you wish to create an Application in.
app.name string The name of the Application.
app.description string The description of the Application.
app.deploymentProfiles object An object of deployment profiles and stages. This structure is a bit confusing. Look at the back-end service for more details and hopefully we can design this more elegantly in the future.

serverlessSDK.updateApp(orgName) ⇒ object

Update an Application within an Organization

Kind: instance method of ServerlessSDK
Returns: object - Returns a data object of the updated Application

Param Type Default Description
orgName string null The name of the Organization the Application belongs to.
app.name string The name of the Application you wish to update. This property cannot be updated due to current data modeling issues.
app.description string The description of the Application. This property can be updated.
app.deploymentProfiles object An object of deployment profiles and stages. This property can be updated. This structure is a bit confusing. Look at the back-end service for more details and hopefully we can design this more elegantly in the future.

serverlessSDK.deleteApp(orgName, appName)

Delete an Application within an Organization

Kind: instance method of ServerlessSDK

Param Type Default Description
orgName string null The name of the Organization the Application belongs to.
appName string null The name of the Application you wish to delete.

serverlessSDK.listApps(orgName)

List all Applications within an Organization

Kind: instance method of ServerlessSDK

Param Type Default Description
orgName string null The name of the Organization the Application belongs to.

serverlessSDK.createInitToken(orgName)

Create an initToken for a user and organization

Kind: instance method of ServerlessSDK

Param Type Default Description
orgName string null The name of the Organization the Init Token belongs to.
template.type string Must be either s3, github, or existing.
template.commands Array.<string> Array of commands executed by the user's shell env in order to fetch and set up the template

serverlessSDK.getInitToken(initTokenUid)

Get an initToken by UID

Kind: instance method of ServerlessSDK

Param Type Description
initTokenUid string Unique identifier of an initToken

serverlessSDK.createProvider(orgUid, data)

Create a provider

Kind: instance method of ServerlessSDK

Param Type
orgUid *
data *

serverlessSDK.updateProvider(orgUid, providerUid, data)

Update a provider

Kind: instance method of ServerlessSDK

Param Type
orgUid *
providerUid *
data *

serverlessSDK.deleteProvider(orgUid, providerUid)

Delete a provider

Kind: instance method of ServerlessSDK

Param Type
orgUid *
providerUid *

serverlessSDK.createProviderLink(orgUid, linkType, linkUid, providerUid)

Create a providerLink Link type can be either service or instance

Kind: instance method of ServerlessSDK

Param Type
orgUid *
linkType *
linkUid *
providerUid *

serverlessSDK.deleteProviderLink(orgUid, linkType, linkUid, providerUid)

Delete a providerLink Link type can be either service or instance

Kind: instance method of ServerlessSDK

Param Type
orgUid *
linkType *
linkUid *
providerUid *

serverlessSDK.getProviders(orgUid)

List providers by OrgUid

Kind: instance method of ServerlessSDK

Param Type
orgUid *

serverlessSDK.getProvider(orgUid, providerUid)

Get a Provider

Kind: instance method of ServerlessSDK

Param Type
orgUid *
providerUid *

serverlessSDK.getProvidersByOrgServiceInstance(orgUid, serviceUid, instanceUid)

Get providers by org, service, and instance Configuration set at the instance level will override defaults set at the service level

Kind: instance method of ServerlessSDK

Param Type
orgUid *
serviceUid *
instanceUid *

serverlessSDK.connect() ⇒ null

Establishes a websockets connection with the Serverless Platform

Kind: instance method of ServerlessSDK

Param Type Description
options.orgName string Name of the Serverless Platform Org.
options.orgUid string ID of the Serverless Platform Org.
options.onEvent function A function that handles events recieved from the Serverless Platform
options.filter string Filters which events this connection should receive
options.filter.stageName string Tells the SDK to only receive events on a specific stage
options.filter.appName string Tells the SDK to only receive events on a specific app
options.filter.instanceName string Tells the SDK to only receive events on a specific service

serverlessSDK.disconnect() ⇒ null

Disconnects a websockets connection with the Serverless Platform

Kind: instance method of ServerlessSDK

serverlessSDK.isConnected() ⇒ boolean

Checks if the SDK is currently connected to the Serverless Platform

Kind: instance method of ServerlessSDK
Returns: boolean - Will return true if the websocket connection is active.

serverlessSDK.publish() ⇒ null

Publishes a Serverless Platform Event via Websockets. The use-case for this is asynchronous publishing, where you do not want to synchronous auth requests, where every message must be authorized first, adding latency.

Kind: instance method of ServerlessSDK

serverlessSDK.publishSync(events) ⇒ Promise.<null>

Publishes Serverless Platform Event(s) via HTTP API. The use-case for this is synchronous publishing, where you do not want to open a websockets connection.

Kind: instance method of ServerlessSDK
Returns: Promise.<null> - A successful publish request will be ack'ed with a 200:OK HTTP status and empty response.

Param Type Description
events object An event object, or if publishing a batch of events, an array of event objects, each structured as follows: json { "event": "name", "data": { "object": { "object": "name", ...properties }, "previous_attributes": { ...properties } } } With previous_attributes only being set on *.updated event types, and contains the properties with values as of before the update.

serverlessSDK.getEvent(uid) ⇒ Promise.<object>

Retrieve a Serverless Platform Event.

Kind: instance method of ServerlessSDK
Returns: Promise.<object> - An event object if a valid id was provided. All events share a common structure, detailed below. The only property that will differ is the data payload.

{
  "uid": "evt_P3Soi8VviLNve2QYd6zasxSc",
  "event": "application.init_token.created",
  "created": 1594652316623,
  "data": {
    "object": {
      "object": "init_token",
      "template": {
        "directory": "my-fullstack-app",
        "packageName": "fullstack-app",
        "projectType": "components",
        "serviceName": "my-fullstack-app",
        "type": "registry"
      },
      "uid": "ae9L37wJym0",
      "user_uid": "MswS9z6GtpSd6gG694",
      "username": "testuser123"
    }
  }
}
Param Type Description
uid string UID of event to be fetched

serverlessSDK.listEvents(options) ⇒ Promise.<object>

List all Serverless Platform events.

Kind: instance method of ServerlessSDK
Returns: Promise.<object> - A dictionary with a data property that contains an array of up to limit events, starting after event starting_after. Each entry in the array is a separate event object. If no more events are available, the resulting array will be empty.

{
  "object": "list",
  "data": [
    {
      "uid": "evt_P3Soi8VviLNve2QYd6zasxSc",
      "event": "application.init_token.created",
      "created": 1594652316623,
      "data": {
        "object": {
          "object": "init_token",
          "template": {
            "directory": "my-fullstack-app",
            "packageName": "fullstack-app",
            "projectType": "components",
            "serviceName": "my-fullstack-app",
            "type": "registry"
          },
          "uid": "ae9L37wJym0",
          "user_uid": "MswS9z6GtpSd6gG694",
          "username": "testuser123"
        }
      }
    }
    {...},
    {...}
  ]
}
Param Type Description
options Object List options
options.org_name string The name of the Serverless Platform Organization. Optional. By default, fetches events under the connecting organization.
options.org_uid string UID of the Serverless Platform Organization. Optional. By default, fetches events under the connecting organization.
options.event string A string containing a specific event name, or all events by using '*' as a wildcard.
options.limit number A limit on the number of events to be returned. Limit can range between 1 and 100, and the default is 10.
options.created number A filter on the list based on the object created field. The value can be an integer Unix timestamp, or it can be a dictionary with the following options: - created.gt, created.gte, created.lt, created.lte returning results where the event created field is greater, greater than or equal to, lesser than, or lesser than or equal to respectively.
options.starting_after string A cursor for use in pagination. starting_after is an event ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with evt_foo, your subsequent call can include starting_after=evt_foo in order to fetch the next page of the list.

serverlessSDK.unpublishFromRegistry(registryPackage)

Unpublishes a package from the registry

Kind: instance method of ServerlessSDK

Param Type Description
registryPackage * An object containing the properties of a registry package.

serverlessSDK.publishToRegistry(registryPackage) ⇒ object

Publishes a package to the registry

Kind: instance method of ServerlessSDK
Returns: object - The published registry package is returned from the Platform API.

Param Type Description
registryPackage * An object containing the properties of a registry package.

serverlessSDK.getFromRegistry(name, version) ⇒ object

Fetches package/s from the registry

Kind: instance method of ServerlessSDK
Returns: object - Returns a registry package from the Registry.

Param Type Default Description
name * The name of the registry package to fetch. If this is not provided, this method will return a list of everything in the registry.
version * The version of the registry package to fetch. If this is not provided, this method will always return the latest version.

serverlessSDK.generateInstanceId(orgUid, stageName, appUid, instanceName) ⇒ object

Returns a properly formatted ID for an Instance

Kind: instance method of ServerlessSDK
Returns: object - Returns a properly formatted ID for an Instance

Param Type Description
orgUid * The Uid of the Serverless Platform Organization.
stageName * The name of the Serverless Platform Stage.
appUid * The Uid of the Serverless Platform Application.
instanceName * The name of the Serverless Platform Instance.

serverlessSDK.validateInstance(instanceToValidate) ⇒ object

Validates the properties of an Instance, as well as auto-corrects shortened syntax (e.g. org => orgName)

Kind: instance method of ServerlessSDK
Returns: object - Returns a validated, formatted version of the Instance

Param Type Description
instanceToValidate * The Serverless Platform Instance you want to validate.

serverlessSDK.createInstance(orgName, stageName, appName, instanceName) ⇒ object

Returns a new Instance as a Javascript object.

Kind: instance method of ServerlessSDK
Returns: object - Returns a new Instance definition as a Javascript Object.

Param Type Default Description
orgName * The name of the Serverless Platform Organization.
stageName * The name of the Serverless Platform Stage.
appName * The name of the Serverless Platform Application.
instanceName * The name of the Serverless Platform Instance.

serverlessSDK.getInstance(orgName, stageName, appName, instanceName)

Get an Instance from the Serverless Platform by it's name and the names of its Organization, Stage, Application.

Kind: instance method of ServerlessSDK

Param Type Default Description
orgName * The name of the Serverless Platform Organization.
stageName * The name of the Serverless Platform Stage.
appName * The name of the Serverless Platform Application.
instanceName * The name of the Serverless Platform Instance.

serverlessSDK.listInstances(orgName, orgUid)

List all Component Instances within an Org, given an org name or org UId

Kind: instance method of ServerlessSDK

Param Type Default Description
orgName * Optional. Must include either orgName or orgUid.
orgUid * Optional. Must include either orgName or orgUid.

serverlessSDK.run(action, instanceData, credentials, options)

Run an action on a Component Instance. Is an asynchronous call by default, but you can perform this synchronously if you set options.sync. Please note that synchronous runs have a 24 second timeout limit. That is not ideal for long operations, and is not recommended for deployments.

Kind: instance method of ServerlessSDK

Param Type
action *
instanceData *
credentials *
options *

serverlessSDK.runFinish(method, instanceData)

Run Finish

Kind: instance method of ServerlessSDK

Param Type Default Description
method string null The action that was performed on the Component.
instanceData object An object representing your Instance definition.

serverlessSDK.deploy()

Performs a 'deploy' action and polls the 'getInstance' endpoint until its 'instanceStatus' reflects a successful deployment, or error.

Kind: instance method of ServerlessSDK

serverlessSDK.remove()

Performs a 'remove' action and polls the 'getInstance' endpoint until its 'instanceStatus' reflects a successful deployment, or error.

Kind: instance method of ServerlessSDK

serverlessSDK.startInterceptingLogs(eventType, context)

Intercepts console 'log' 'debug' and 'error' methods, and sends their data to the Serverless Platform as an Event, before writing to stdout.

Kind: instance method of ServerlessSDK

Param Type Default Description
eventType * Optional. The event name used to publish logs. Defaults to "instance.logs".
context * Optional. Additional context added to the published log data.

serverlessSDK.stopInterceptingLogs()

Stop intercepting console methods

Kind: instance method of ServerlessSDK

serverlessSDK.registerWebhook(url) ⇒ Promise.<object>

Registers a webhook endpoint to receive Serverless Platform events. Endpoint should be able to receieve JSON formatted event as a HTTP POST payload.

Kind: instance method of ServerlessSDK
Returns: Promise.<object> - Registered webhook endpoint.

{
  "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
  "object": "webhook_endpoint",
  "url": "https://postb.in/1598300732037-0682672155089",
  "description": "This is my webhook, I like it a lot",
  "filter": {
    "enabled_events": ["*"]
  },
  "status": {
    "disabled": false
  },
  "created": 1593710260258
}
Param Type Description
url string HTTP webhook endpoint URL.
options.description string An optional description of what the webhook is used for.
options.filter object Optionally, filter which events this endpoint should receive.
options.filter.enabled_events object The list of events to enable for this endpoint. ["*"] indicates that all events are enabled.

serverlessSDK.listWebhooks() ⇒ Promise.<object>

Lists all regsitered webhook endpoints.

Kind: instance method of ServerlessSDK
Returns: Promise.<object> - A dictionary with a data property that contains an array, with each entry being a webhook object.

{
  "object": "list",
  "data": [
    {
      "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
      "object": "webhook_endpoint",
      "url": "https://postb.in/1598300732037-0682672155089",
      "description": "This is my webhook, I like it a lot",
      "filter": {
        "enabled_events": ["*"]
      },
      "status": {
        "disabled": false,
        "most_recent_delivery": {
          "event_uid": "evt_5cmXN7kqdu5YY69HFKegmiGR",
          "response_status_code": 200,
          "response_headers": {
            "content-length": "12",
            "connection": "close",
            "content-type": "application/json"
          },
          "request_headers": {
            "User-Agent": "Serverless-Webhook/0.1",
            "Content-type": "application/json",
            "X-Serverless-Delivery": "e1701c44-5d92-4515-8bfb-6c9173a89b60",
            "X-Serverless-Event": "test.webhook.send2"
          },
          "response_text": "{\"ok\": true}",
          "error_message": null,
          "timestamp": 1599595612876
        }
      },
      "created": 1599591851267,
      "updated": 1599595613099
    },
    {...},
    {...}
  ]
}
Param Type Description
options.starting_after string A cursor for use in pagination. starting_after is a webhook endpoint object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with whe_foo, your subsequent call can include starting_after=whe_foo in order to fetch the next page of the list.
options.limit number A limit on the number of webhook endpoints to be returned. Limit can range between 1 and 100, and the default is 10.

serverlessSDK.getWebhook(uid) ⇒ Promise.<object>

Retrieves a webhook endpoint with the given ID.

Kind: instance method of ServerlessSDK
Returns: Promise.<object> - A webhook endpoint if a valid webhook endpoint ID was provided.

{
  "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
  "object": "webhook_endpoint",
  "url": "https://postb.in/1598300732037-0682672155089",
  "description": "This is my webhook, I like it a lot",
  "filter": {
    "enabled_events": ["*"]
  },
  "status": {
    "disabled": false,
    "most_recent_delivery": {
      "event_uid": "evt_5cmXN7kqdu5YY69HFKegmiGR",
      "response_status_code": 200,
      "response_headers": {
        "content-length": "12",
        "connection": "close",
        "content-type": "application/json"
      },
      "request_headers": {
        "User-Agent": "Serverless-Webhook/0.1",
        "Content-type": "application/json",
        "X-Serverless-Delivery": "e1701c44-5d92-4515-8bfb-6c9173a89b60",
        "X-Serverless-Event": "test.webhook.send2"
      },
      "response_text": "{\"ok\": true}",
      "error_message": null,
      "timestamp": 1599595612876
    }
  },
  "created": 1599591851267,
  "updated": 1599595613099
}

| Param | Type | Description |
| --- | --- | --- |
| uid | <code>string</code> | Webhook endpoint ID. |

<a name="ServerlessSDK+updateWebhook"></a>

### serverlessSDK.updateWebhook(uid) ⇒ <code>Promise.&lt;object&gt;</code>
Updates the registered webhook endpoint. You may edit the url, description, the list of filters, and the status of your endpoint.

**Kind**: instance method of [<code>ServerlessSDK</code>](#ServerlessSDK)
**Returns**: <code>Promise.&lt;object&gt;</code> - Updated webhook endpoint.
```json
{
  "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
  "object": "webhook_endpoint",
  "url": "https://postb.in/1598300732037-0682672155089",
  "description": "This is my webhook, I like it a lot",
  "filter": {
    "enabled_events": ["*"]
  },
  "status": {
    "disabled": false
  },
  "created": 1593710260258
}
Param Type Description
uid string Webhook endpoint ID.
updates.url string HTTP webhook endpoint url, if updating.
updates.description string An optional updated description of what the webhook is used for.
updates.filter object Optionally, update filter which events this endpoint should receive. An existing filter can reset by setting it to null.
updates.filter.enabled_events object The list of events to enable for this endpoint. ["*"] indicates that all events are enabled.
updates.status.disabled boolean Enable/disable the webhook endpoint.

serverlessSDK.deleteWebhook(uid) ⇒ Promise.<object>

Deletes the webhook endpoint with the given ID.

Kind: instance method of ServerlessSDK
Returns: Promise.<object> - An object with the deleted webhook endpoints’s ID if a valid webhook endpoint ID was provided. Otherwise, this call throws an error, such as if the webhook endpoint has already been deleted.

{
  "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
  "object": "webhook_endpoint",
  "deleted": true
}

| Param | Type | Description |
| --- | --- | --- |
| uid | <code>string</code> | Webhook endpoint ID. |


## Publishing the SDK

Before publishing the SDK, be sure to run the pre-publish script, which browserifies the code and updates its documentation, by running: `npm run pre-publish` within the `sdk` folder.

* * *

&copy; Serverless Inc.