Socket
Socket
Sign inDemoInstall

@serverless/platform-client

Package Overview
Dependencies
154
Maintainers
3
Versions
159
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @serverless/platform-client

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 s


Version published
Weekly downloads
984K
decreased by-3.1%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

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");

Classes

ServerlessSDK

The Serverless Platform SDK Class

Typedefs

onEvent : function

onEvent callback

onDisconnect : function

onDisconnect callback

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.

ParamTypeDescription
[config.accessKey]stringCan either be a Serverless Platform Access Key or an ID Token.
[config.platformStage]stringThe Serverless Platform Stage you wish to interact with. This can also be set by the environment variable SERVERLESS_PLATFORM_STAGE=
[context.orgName]stringThe 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]stringThe 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]stringThe Serverless Platform Organization Stage you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.appName]stringThe Serverless Platform Application you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.instanceName]stringThe Serverless Platform Instance you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentName]stringThe Serverless Platform Component you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentVersion]stringThe 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.session : object

Methods to create, update, delete User Sessions on the Serverless Platform

Kind: instance namespace of ServerlessSDK

session.refreshToken(refreshToken) ⇒ Promise.<object>

Uses a Refresh Token to generate a new ID Token for a User within a specific Serverless Organization.

Kind: static method of session

ParamTypeDescription
refreshTokenstringThe refresh token used to create a new ID Token.

Example

const tokenData = await sdk.session.refreshToken(refreshToken);

serverlessSDK.events : object

Publish and retrieve Serverless Platform Events

Kind: instance namespace of ServerlessSDK

events.publish(event) ⇒ 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: static method of events
Returns: Promise.<null> - A successful publish request will be ack'ed with a 200:OK HTTP status and empty response.

ParamTypeDescription
eventObject | Array.<Object>An event object, or if publishing a batch of events, an array of event objects.
event.eventstringEvent type. Serverless Platform system events are required to follow a <entity>[.<sub-entity>].<action> naming convention (e.g. user.created, org.membership.updated, etc).
event.dataObjectEvent metadata. Serverless Platform system events are required to be formatted as described in the example below.

Example (user event)

sdk.config({ context: { orgUid: "3xVy2MWGFqpGYSlRMd" } });
await sdk.events.publish({
  event: "user.created",
  data: {
    id: "user-123",
    username: "testuser",
  },
});

Example (system event)

await sdk.events.publish({
  event: "entity.updated", // follows a `<entity>[.<sub-entity>].<action>` naming convention
  user_uid: "user-111", // user attributable for event action if applicable - optional
  // either of the following properties are required to be set and if not, inherit from current sdk context
  org_uid: "org-42",
  org_name: "serverless",
  // the following properties are optional and default to inheriting from current sdk context
  app_name: "app-222",
  instance_name: "instance-333",
  stage_name: "us-east-1",
  component_name: "component-444",
  component_version: "1.2.3",
  data: {
    // event payload - required and must match the format below
    object: {
      // Serverless Platform object targeted by action
      object: "name",
      // ...properties
    },
    previous_attributes: {
      // only set on `*.updated` event types and contains modified property values as of before the update
      //...properties
    },
  },
});

events.get(uid) ⇒ Promise.<Object>

Retrieve a Serverless Platform Event.

Kind: static method of events
Returns: Promise.<Object> - An event object if a valid id was provided.

ParamTypeDescription
uidstringUID of event to be fetched.

Example

const event = await sdk.events.get("evt_EsbM82sYTVscqYvcD4CKcLe1");
console.log(JSON.stringify(event, null, 2));
// outputs:
// {
//   "uid": "evt_EsbM82sYTVscqYvcD4CKcLe1",
//   "event": "member.invite.sent",
//   "org_uid": "3xVy2MWGFqpGYSlRMd",
//   "user_uid": "ps4Vt2phVXsMyD0byW",
//   "object": "event",
//   "created": 1600686488878,
//   "data": {
//     "object": {
//       "org_uid": "3xVy2MWGFqpGYSlRMd",
//       "role": "collaborator",
//       "invited_by_user_uid": "ps4Vt2phVXsMyD0byW",
//       "created": "2020-09-21T11:08:08.603Z",
//       "recipient_email": "dev@serverless.com",
//       "org_name": "serverless",
//       "object": "invite"
//     }
//   }
// }

events.list([options]) ⇒ Promise.<Object>

List all Serverless Platform events.

Kind: static method of events
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.

ParamTypeDescription
[options]ObjectList options
options.org_uidstringUID of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context.
options.org_namestringName of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context.
options.eventstringA string containing a specific event name, or all events by using '*' as a wildcard.
options.limitnumberA limit on the number of events to be returned. Limit can range between 1 and 100, and the default is 10.
options.creatednumberA 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_afterstringA 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.

Example

const events = await sdk.events.list({
  event: "member.invite.accepted",
  created: {
    gte: 1600686488878,
  },
  limit: 1,
});
console.log(JSON.stringify(events, null, 2));
// outputs:
// {
//   "object": "list",
//   "data": [
//     {
//       "uid": "evt_DdUCdz2tsY7gZr1a9Z6Xw9BD",
//       "event": "member.invite.accepted",
//       "object": "event",
//       "created": 1600707548900,
//       "data": {
//         "object": {
//            "object": "invite",
//            "org_uid": "3xVy2MWGFqpGYSlRMd",
//            "role": "collaborator",
//            "invited_by_user_uid": "ps4Vt2phVXsMyD0byW",
//            "recipient_email": "dev@serverless.com",
//            "org_name": "serverless",
//            "created": "2020-09-21T11:08:08.603Z",
//         }
//       }
//     }
//   ]
// }

events.send(event) ⇒ Promise.<null>

Deprecated

Dispatches 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: static method of events
Returns: Promise.<null> - A successful publish request will be ack'ed with a 200: OK HTTP status and empty response.
See: publish

ParamTypeDescription
eventObject | Array.<Object>An event object, or if publishing a batch of events, an array of event objects.
event.eventstringEvent type. Serverless Platform system events are required to follow a <entity>[.<sub-entity>].<action> naming convention (e.g. user.created, org.membership.updated, etc).
event.dataObjectEvent metadata. Serverless Platform system events are required to be formatted as described in the example below.

serverlessSDK.frameworkDeployments : object

Manage Serverless Platform Deployments for Serverless Framework Traditional

Kind: instance namespace of ServerlessSDK

frameworkDeployments.create([params]) ⇒ Promise.<object>

Create a new Serverless Platform Deployment. Additionally, if Service with provided serviceName does not exist, it will be created automatically as well.

Kind: static method of frameworkDeployments
Returns: Promise.<object> - Saved deployment object.

ParamTypeDescription
[params]ObjectCreate deployment params.
params.orgNamestringThe name of the Serverless Platform Organization to create the Deployment in.
params.appNamestringThe name of the Serverless Platform Application to create the Deployment in.
params.serviceNamestringThe name of the Serverless Platform Service to create the Deployment in.
params.stageNamestringThe name of the Serverless Service Stage to create the Deployment in.
params.regionNamestringThe name of the AWS Region to create the Deployment in.
params.deploymentDataObjectData associated with saved deployment

frameworkDeployments.list([params]) ⇒ Promise.<array>

List Serverless Platform Deployments.

Kind: static method of frameworkDeployments
Returns: Promise.<array> - Array of Deployments.

ParamTypeDescription
[params]ObjectList deployment params.
params.orgNamestringThe name of the Serverless Platform Organization to list the Deployments for.
params.appNamestringThe name of the Serverless Platform Application to list the Deployment for.
params.serviceNamestringThe name of the Serverless Platform Service to list the Deployment for.
params.stageNamestringThe name of the Serverless Service Stage to list the Deployment for.
params.regionNamestringThe name of the AWS Region to list the Deployment for.
params.cursorstringThe cursor from which Deployments should be listed. Used for pagination.

serverlessSDK.webhooks : object

Register, modify and query Serverless Platform Event Webhooks

Kind: instance namespace of ServerlessSDK

webhooks.register(url, [options]) ⇒ Promise.<object>

Registers a webhook endpoint to receive Serverless Platform events.

Endpoint should be able to receieve JSON formatted events as a HTTP POST payload. Furthermore, a 3 second timeout limit is enforced on event delivery with no additional retries performed. The following HTTP headers are set on the POST request:

HeaderValue
Content-typeapplication/json
X-Serverless-EventEvent type
X-Serverless-DeliveryUnique delivery ID
User-AgentPrefix of Serverless-Webhook/

Kind: static method of webhooks
Returns: Promise.<object> - Registered webhook endpoint.

ParamTypeDescription
urlstringHTTP webhook endpoint URL.
[options]ObjectRegistration options.
options.descriptionstringAn optional description of what the webhook is used for.
options.org_uidstringUID of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context. If registering a Serverless Platform system webhook, use a special wildcard value of '*' to consume events generated from all orgs.
options.org_namestringName of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context.
options.filterObjectOptionally, filter which events this endpoint should receive.
options.filter.enabled_eventsArray.<string>The list of events to enable for this endpoint. ["*"] indicates that all events are enabled.

Example

const webhook = await sdk.webhooks.register(
  "https://postb.in/1598300732037-0682672155089",
  { description: "This is my webhook, I like it a lot" }
);
console.log(JSON.stringify(webhook, null, 2));
// outputs:
// {
//   "uid": "whe_FPYDtTL37ye13m3sJvtcdyuF",
//   "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": 1602078105978
// }

webhooks.list([options]) ⇒ Promise.<object>

Lists all regsitered webhook endpoints.

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

ParamTypeDescription
[options]ObjectList options.
options.starting_afterstringA 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.limitnumberA limit on the number of webhook endpoints to be returned. Limit can range between 1 and 100, and the default is 10.

Example

const webhooks = await sdk.webhooks.list({
  limit: 1,
});
console.log(JSON.stringify(webhooks, null, 2));
// outputs:
// {
//   "object": "list",
//   "data": [
//     {
//       "uid": "whe_FPYDtTL37ye13m3sJvtcdyuF",
//       "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
//     },
//   ]
// }

webhooks.get(uid) ⇒ Promise.<object>

Retrieves a webhook endpoint with the given ID.

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

ParamTypeDescription
uidstringWebhook endpoint ID.

Example

const webhook = await sdk.webhooks.get("whe_FPYDtTL37ye13m3sJvtcdyuF");
console.log(JSON.stringify(webhook, null, 2));
// outputs:
// {
//   "uid": "whe_FPYDtTL37ye13m3sJvtcdyuF",
//   "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
// }

webhooks.update(uid) ⇒ Promise.<object>

Updates the registered webhook endpoint. You may edit the url, description, the list of filters, and the status of your endpoint.

Kind: static method of webhooks
Returns: Promise.<object> - Updated webhook endpoint.

ParamTypeDescription
uidstringWebhook endpoint ID.
updates.urlstringHTTP webhook endpoint url, if updating.
updates.descriptionstringAn optional updated description of what the webhook is used for.
updates.filterObjectOptionally, update filter which events this endpoint should receive. An existing filter can reset by setting it to null.
updates.filter.enabled_eventsArray.<string>The list of events to enable for this endpoint. ["*"] indicates that all events are enabled.
updates.status.disabledbooleanEnable/disable the webhook endpoint.

Example

const webhook = await sdk.webhooks.update("whe_FPYDtTL37ye13m3sJvtcdyuF", {
  url: "http://437f01fa092e.ngrok.io",
  filter: {
    enabled_events: ["user.created", "member.invite.sent"],
  },
});
console.log(JSON.stringify(webhook, null, 2));
// outputs:
// {
//   "uid": "whe_FPYDtTL37ye13m3sJvtcdyuF",
//   "object": "webhook_endpoint",
//   "url": "http://437f01fa092e.ngrok.io",
//   "description": "This is my webhook, I like it a lot",
//   "filter": {
//     "enabled_events": [
//       "user.created",
//       "member.invite.sent"
//     ]
//   },
//   "status": {
//     "disabled": false
//   },
//   "created": 1602078105978,
//   "updated": 1602078663800
// }

webhooks.delete(uid) ⇒ Promise.<object>

Deletes the webhook endpoint with the given ID.

Kind: static method of webhooks
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.

ParamTypeDescription
uidstringWebhook endpoint ID.

Example

const webhook = await sdk.webhooks.delete("whe_FPYDtTL37ye13m3sJvtcdyuF");
console.log(JSON.stringify(webhook, null, 2));
// outputs:
// {
//   "uid": "whe_FPYDtTL37ye13m3sJvtcdyuF",
//   "object": "webhook_endpoint",
//   "url": "http://437f01fa092e.ngrok.io",
//   "description": "This is my webhook, I like it a lot",
//   "filter": {
//     "enabled_events": [
//       "user.created",
//       "member.invite.sent"
//     ]
//   },
//   "status": {
//     "disabled": false
//   },
//   "created": 1602078105978,
//   "updated": 1602078663800
// }

serverlessSDK.accessKeys : object

Create, get and delete Serverless Platform Access Keys for an Organization

Kind: instance namespace of ServerlessSDK

accessKeys.create(orgName, userName, accessKeyName) ⇒ Promise.<object>

Creates a new Access Key for a User within a Serverless Organization.

Kind: static method of accessKeys

ParamTypeDescription
orgNamestringThe name of the Serverless Organization to create the Access Key for
userNamestringThe name of the User within the Serverless Organization to create the Access Key for
accessKeyNamestringThe name of the Access Key you would like to create

Example

const accessKey = await sdk.accessKeys.create(orgName, accessKeyName);

accessKeys.list(orgName) ⇒ Promise.<object>

Lists all Access Keys within a Serverless Organization.

Kind: static method of accessKeys

ParamTypeDescription
orgNamestringThe name of the Serverless Organization to list Access Keys

Example

const accessKeys = await sdk.accessKeys.list(orgName);

accessKeys.remove(orgName, uid) ⇒ Promise.<object>

Delete an Access Key from a Serverless Organization.

Kind: static method of accessKeys

ParamTypeDescription
orgNamestringThe name of the Serverless Organization that the Access Key belongs to
uidstringThe UID of the Access Key

Example

const accessKeys = await sdk.accessKeys.remove(orgName, uid);

accessKeys.get() ⇒ Promise.<(object|null)>

Get metadata for the Access Key configured under sdk.accessKey

Kind: static method of accessKeys
Example

const accessKeyData = await sdk.accessKeys.get();

serverlessSDK.connections : object

Create, manage and sync Serverless Platform Connections between vendor accounts and their Serverless Organization.

Kind: instance namespace of ServerlessSDK

connections.create(orgUid, providerUid, accountAlias) ⇒ Promise.<object>

Creates a new Connection between a vendor account and a Serverless Organization.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to create a Connection in.
providerUidstringThe UID of an existing Serverless Provider tied to a vendor account within the Organization to use for this Connection. A vendor account (e.g. an AWS account) can only be registered once with a Connection, across all Serverless Organizations. They are globally unique.
accountAliasstringAn alias or nickname of the vendor account used to conveniently identify which account this Connection is used with. This must be unique within the Serverless Organization.

connections.list(orgUid) ⇒ Promise.<object>

List all Connections within the Serverless Organization.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to create a Connection in.

connections.get(orgUid, connectionUid) ⇒ Promise.<object>

Get a single Connection within the Serverless Organization.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to get a Connection in.
connectionUidstringThe UID of the Connection to get within the Serverless Organization.

connections.getByOrgAndAccountAlias(orgUid, accountAlias) ⇒ Promise.<object>

Get a single Connection by Organization UID and vendor account alias within the Serverless Organization.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to get a Connection in.
accountAliasstringThe alias of the Connection to get within the Serverless Organization.

connections.update(orgUid, connectionUid, providerUid, accountAlias, status) ⇒ Promise.<object>

Update a single Connection within the Serverless Organization.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to update a Connection in.
connectionUidstringThe UID of the Connection to update within the Serverless Organization.
providerUidstringThe updated Provider UID within the Connection.
accountAliasstringThe updated alias of the Connection.
statusstringThe updated status of the Connection.

connections.remove(orgUid, connectionUid) ⇒ Promise.<object>

Remove a single Connection within the Serverless Organization.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to remove a Connection in.
connectionUidstringThe UID of the Connection to remove within the Serverless Organization.

connections.syncAll(orgUid) ⇒ Promise.<object>

Run a sync operation across all Connections within the Serverless Organization. This only runs sync on Connections with an "inactive", "synced", "unsynced", "error" state. Call connections.list() to view status of all Connections.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to sync all Connections in.

connections.unsync(orgUid, connectionUid) ⇒ Promise.<object>

Run an unsync operation on a specific Connection within the Serverless Organization. This only runs sync on Connections with an "synced", "error" state. Call connections.list() to view status of all Connections.

Kind: static method of connections

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to sync all Connections in.
connectionUidstringThe UID of the Connection to unsync within the Serverless Organization.

serverlessSDK.desktop : object

Interact with the Serverless Desktop back-end functions, like storing state for views.

Kind: instance namespace of ServerlessSDK

desktop.createSavedQuery(orgUid, appUid, serviceName, savedQuery) ⇒ Promise.<object>

Create a Saved Query for a Service by specifying some data.

Kind: static method of desktop

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to create the Saved Query in.
appUidstringThe UID of the Serverless Application to create the Saved Query in.
serviceNamestringThe name of the Serverless Service to create the Saved Query in.
savedQuerystringThe object of arbitrary data you would like to save for this Serverless Service.

desktop.getSavedQuery(orgUid, appUid, serviceName, savedQueryUid) ⇒ Promise.<object>

Get Saved Query for a Service Stage via its key.

Kind: static method of desktop

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to get the Saved Query from.
appUidstringThe UID of the Serverless Application to get the Saved Query from.
serviceNamestringThe name of the Serverless Service to get the Saved Query from.
savedQueryUidstringThe UID of the Saved Query to get for this Serverless Service.

desktop.updateSavedQuery(orgUid, appUid, serviceName, savedQueryUid, savedQuery) ⇒ Promise.<object>

Update a Saved Query for a Service by specifying the UID and the data.

Kind: static method of desktop

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to create the Saved Query in.
appUidstringThe UID of the Serverless Application to create the Saved Query in.
serviceNamestringThe name of the Serverless Service to create the Saved Query in.
savedQueryUidstringThe UID of the Saved Query to get for this Serverless Service.
savedQuerystringThe object of arbitrary data you would like to save for this Serverless Service.

desktop.deleteSavedQuery(orgUid, appUid, serviceName, savedQueryUid) ⇒ Promise.<object>

Delete Saved Query for a Service Stage by specifying its key.

Kind: static method of desktop

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to delete the Saved Query from.
appUidstringThe UID of the Serverless Application to delete the Saved Query from.
serviceNamestringThe name of the Serverless Service to delete the Saved Query from.
savedQueryUidstringThe UID of the Saved Query to delete for this Serverless Service.

desktop.listSavedQueries(orgUid, appUid, serviceName) ⇒ Promise.<object>

List Saved Queries for a Service.

Kind: static method of desktop

ParamTypeDescription
orgUidstringThe UID of the Serverless Organization to list the Saved Queries from.
appUidstringThe UID of the Serverless Application to list the Saved Queries from.
serviceNamestringThe name of the Serverless Service to list the Saved Queries from.

serverlessSDK.logDestinations : object

Manage Log Destinations for your Organization

Log Destination is represented by CloudWatch Logs Destination resource that is responsible for forwarding logs from selected service to Kinesis streams. These logs are later forwarded form Kinesis streams to Elasticsearch service.

Kind: instance namespace of ServerlessSDK

logDestinations.getOrCreate([params]) ⇒ Promise.<object>

Get or Create Log Destination. If Log Destination already exists for a service in selected region and for selected stage, it will be returned, otherwise it will be created.

Kind: static method of logDestinations

ParamTypeDescription
[params]ObjectGet or Create params
params.orgUidstringThe UID of the Serverless Organization to create the Log Destination for.
params.appUidstringThe UID of the Serverless Application to create the Log Destination for.
params.serviceNamestringThe name of the Serverless Service to create the Log Destination for.
params.stageNamestringThe name of the Serverless Service Stage to create the Log Destination for.
params.regionNamestringThe name of the AWS Region to create the Log Destination for.
params.accountIdstringThe ID of the AWS Account to create the Log Destination for.

Example

const result = await sdk.logDestinations.getOrCreate({
  orgUid: "1234",
  appUid: "123456789",
  serviceName: "log-dest-integration-test-service-name",
  stageName: "log-dest-integration-test-stage",
  regionName: "us-east-1",
  accountId: "111111111111",
});
console.log(JSON.stringify(result, null, 2));
// outputs:
// {
//   "destinationArn": "arn:aws:logs:us-east-1:111111111111:destination:c492b73f-3704-4d5b-839a-d4fbc7adc328#123456789#log-dest-integration-test-service-name#log-dest-integration-test-stage",
// }

logDestinations.remove([params]) ⇒ Promise.<object>

Remove Log Destination

Kind: static method of logDestinations

ParamTypeDescription
[params]ObjectRemove params
params.orgUidstringThe UID of the Serverless Organization to remove the Log Destination from.
params.appUidstringThe UID of the Serverless Application to remove the Log Destination from.
params.serviceNamestringThe name of the Serverless Service to remove the Log Destination from.
params.stageNamestringThe name of the Serverless Service Stage to remove the Log Destination from.
params.regionNamestringThe name of the AWS Region to remove the Log Destination from.

Example

await sdk.logDestinations.remove({
  orgUid: "1234",
  appUid: "123456789",
  serviceName: "log-dest-integration-test-service-name",
  stageName: "log-dest-integration-test-stage",
  regionName: "us-east-1",
});

serverlessSDK.deploymentProfiles : object

Manage Deployment Profiles for your Organization

Kind: instance namespace of ServerlessSDK

deploymentProfiles.get([params]) ⇒ Promise.<Object>

Get a Deployment Profile associated with an Application

Kind: static method of deploymentProfiles

ParamTypeDescription
[params]ObjectGet params
params.orgNamestringThe name of the Serverless Organization.
params.appNamestringThe name of the Serverless Organization.
params.serviceNamestringThe name of the Serverless Service.
params.stageNamestringThe name of the Serverless Service Stage.

deploymentProfiles.create([params]) ⇒ Promise.<Object>

Create a Deployment Profile

Kind: static method of deploymentProfiles
Returns: Promise.<Object> - Created Deployment Profile

ParamTypeDescription
[params]ObjectCreate params
params.profileNamestringThe name of the created Deployment Profile.
params.orgNamestringThe name of the Serverless Organization.
params.descriptionstringOptional The description for the created Deployment Profile.
params.secretsarrayOptional The secrets for the created Deployment Profile.
params.safeguardsPoliciesarrayOptional The safeguard policies for the created Deployment Profile.
params.providerCredentialsobjectOptional The provider credentials for the created Deployment Profile.

deploymentProfiles.list([params]) ⇒ Promise.<array>

List Deployment Profiles

Kind: static method of deploymentProfiles
Returns: Promise.<array> - Array of DeploymentProfile objects.

ParamTypeDescription
[params]ObjectList params
params.orgNamestringThe name of the Serverless Organization.

deploymentProfiles.setDefault([params]) ⇒ Promise.<Object>

Set default Deployment Profile for an Application

Kind: static method of deploymentProfiles

ParamTypeDescription
[params]ObjectGet params
params.orgNamestringThe name of the Serverless Organization.
params.appNamestringThe name of the Serverless Organization.
params.profileUidstringThe UID of the Deployment Profile that should be associated with an Application.

serverlessSDK.organizations : object

Create, get and list Serverless Platform Organizations.

Kind: instance namespace of ServerlessSDK

organizations.get([params]) ⇒ object

Gets an Organization

Kind: static method of organizations
Returns: object - Returns the Organization record.

ParamTypeDescription
[params]ObjectGet organization params
params.orgNamestringThe name of the Organization you wish to retrieve.

organizations.list([params]) ⇒ array

List organizations

Kind: static method of organizations
Returns: array - Returns an array of Organizations

ParamTypeDescription
[params]ObjectList organizations params
params.usernamestringThe name of the User whose Organizations you wish to list.

organizations.create([params]) ⇒ object

Creates an Organization and User if one does not exist.

Kind: static method of organizations
Returns: object - Returns the newly created Organization.

ParamTypeDescription
[params]ObjectCreate organization params
params.orgNamestringThe name of the Organization you wish to create.
params.usernamestringOptional The username for a User that will be created if one does not exist. If it's not provided, it will default to params.orgName.
params.emailstringOptional The email that will be associated with created User.
params.passwordstringOptional The password that will be associated with created User.

organizations.validate([params]) ⇒ 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 available, 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: static method of organizations
Returns: array - Returns an array of validation errors, if any. Otherwise, returns null.

ParamTypeDescription
[params]ObjectValidate params
params.orgNamestringThe name of the Organization.
params.usernamestringOptional The username for a User. If it's not provided, it will default to params.orgName.

serverlessSDK.apps : object

Register, update, delete and list Applications

Kind: instance namespace of ServerlessSDK

apps.create([params]) ⇒ object

Create an Application within an Organization

Kind: static method of apps
Returns: object - Returns a data object of the newly created Application

ParamTypeDescription
[params]ObjectCreate app params
params.orgNamestringThe name of the Organization you wish to create an Application in.
params.app.namestringThe name of the Application.
params.app.descriptionstringThe description of the Application.
params.app.deploymentProfilesobjectAn 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.

apps.get([params])

Get an Application within an Organization

Kind: static method of apps

ParamTypeDescription
[params]ObjectGet app params
params.orgNamestringThe name of the Organization the Application belongs to.
params.appNamestringThe name of the Application you want to retrieve.

apps.update([params]) ⇒ object

Update an Application within an Organization

Kind: static method of apps
Returns: object - Returns a data object of the updated Application

ParamTypeDescription
[params]ObjectUpdate app params
params.orgNamestringThe name of the Organization the Application belongs to.
params.app.namestringThe name of the Application you wish to update. This property cannot be updated due to current data modeling issues.
params.app.descriptionstringThe description of the Application. This property can be updated.
params.app.deploymentProfilesobjectAn 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.

apps.remove([params])

Delete an Application within an Organization

Kind: static method of apps

ParamTypeDescription
[params]ObjectUpdate app params
params.orgNamestringThe name of the Organization the Application belongs to.
params.appNamestringThe name of the Application you wish to delete.

apps.list([params])

List all Applications within an Organization

Kind: static method of apps

ParamTypeDescription
[params]ObjectUpdate app params
params.orgNamestringThe name of the Organization the Application belongs to.

serverlessSDK.metadata : object

Get Metadata for Serverless Platform

Kind: instance namespace of ServerlessSDK

metadata.get() ⇒ Promise.<Object>

Get Metadata for Serverless Platform, which includes informations about regions and runtimes that are supported by the platform.

Kind: static method of metadata
Returns: Promise.<Object> - A dictionary with an awsAccountId, supportedRegions and supportedRuntimes properties. Both supportedRuntimes and supportedRegions are arrays.
Example

const metadata = await sdk.metadata.get();
console.log(JSON.stringify(metadata, null, 2));
// outputs:
// {
//   "awsAccountId": "111111111111",
//   "supportedRuntimes": [
//     "nodejs8.10",
//     "nodejs10.x",
//     "nodejs12.x",
//     "python2.7",
//     "python3.6",
//     "python3.7",
//     "python3.8"
//   ],
//   "supportedRegions": [
//     "us-east-1",
//     "us-east-2",
//     "us-west-1",
//     "us-west-2",
//     "eu-central-1",
//     "eu-west-1",
//     "eu-west-2",
//     "eu-west-3",
//     "ap-northeast-1",
//     "ap-southeast-1",
//     "ap-southeast-2",
//     "eu-central-1",
//     "ap-south-1",
//     "ca-central-1",
//     "sa-east-1"
//   ]
// }

serverlessSDK.config() ⇒ null

Updates the SDK configuration

Kind: instance method of ServerlessSDK

ParamTypeDescription
[config.accessKey]stringCan either be a Serverless Platform Access Key or an ID Token.
[config.platformStage]stringThe Serverless Platform Stage you wish to interact with. This can also be set by the environment variable SERVERLESS_PLATFORM_STAGE=
[context.orgName]stringThe 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]stringThe 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]stringThe Serverless Platform Organization Stage you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.appName]stringThe Serverless Platform Application you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.instanceName]stringThe Serverless Platform Instance you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentName]stringThe Serverless Platform Component you wish to interact with. If set, this value is auto-added to every Event you publish.
[context.componentVersion]stringThe 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.

ParamTypeDefaultDescription
serviceNamestringnullThe 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.

ParamTypeDescription
userMetaobjectAn object of new userMeta that will be automaticaly merged with the old user meta.

serverlessSDK.validateUserAndOrgName(userAndOrgName) ⇒ array

Deprecated

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.

ParamTypeDescription
userAndOrgNamestringThe name of the User and Org name.

serverlessSDK.createUserAndOrg(userAndOrgName) ⇒ object

Deprecated

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.

ParamTypeDescription
userAndOrgNamestringThe name of the User and Org name.

serverlessSDK.createOrg(userAndOrgName) ⇒ object

Deprecated

Creates an Organization.

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

ParamTypeDescription
userAndOrgNamestringThe 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

Deprecated

Gets an Organization by Organization name.

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

ParamTypeDescription
orgNamestringThe name of the Organization you wish to retrieve.

serverlessSDK.listOrgs(username) ⇒ object

Deprecated

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

ParamTypeDescription
usernamestringThe name of the User whose Organizations you wish to list.

serverlessSDK.createApp(orgName) ⇒ object

Deprecated

Create an Application within an Organization

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

ParamTypeDefaultDescription
orgNamestringnullThe name of the Organization you wish to create an Application in.
app.namestringThe name of the Application.
app.descriptionstringThe description of the Application.
app.deploymentProfilesobjectAn 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

Deprecated

Update an Application within an Organization

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

ParamTypeDefaultDescription
orgNamestringnullThe name of the Organization the Application belongs to.
app.namestringThe name of the Application you wish to update. This property cannot be updated due to current data modeling issues.
app.descriptionstringThe description of the Application. This property can be updated.
app.deploymentProfilesobjectAn 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)

Deprecated

Delete an Application within an Organization

Kind: instance method of ServerlessSDK

ParamTypeDefaultDescription
orgNamestringnullThe name of the Organization the Application belongs to.
appNamestringnullThe name of the Application you wish to delete.

serverlessSDK.listApps(orgName)

Deprecated

List all Applications within an Organization

Kind: instance method of ServerlessSDK

ParamTypeDefaultDescription
orgNamestringnullThe name of the Organization the Application belongs to.

serverlessSDK.createInitToken(orgName)

Create an initToken for a user and organization

Kind: instance method of ServerlessSDK

ParamTypeDefaultDescription
orgNamestringnullThe name of the Organization the Init Token belongs to.
template.typestringMust be either s3, github, or existing.
template.commandsArray.<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

ParamTypeDescription
initTokenUidstringUnique identifier of an initToken

serverlessSDK.createProvider(orgUid, data)

Create a provider

Kind: instance method of ServerlessSDK

ParamType
orgUid*
data*

serverlessSDK.updateProvider(orgUid, providerUid, data)

Update a provider

Kind: instance method of ServerlessSDK

ParamType
orgUid*
providerUid*
data*

serverlessSDK.setDefaultProvider(orgUid, providerUid)

Set a default provider

Kind: instance method of ServerlessSDK

ParamType
orgUid*
providerUid*

serverlessSDK.unsetDefaultProvider(orgUid, providerUid)

Unsets the default provider

Kind: instance method of ServerlessSDK

ParamType
orgUid*
providerUid*

serverlessSDK.deleteProvider(orgUid, providerUid)

Delete a provider

Kind: instance method of ServerlessSDK

ParamType
orgUid*
providerUid*

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

Create a providerLink Link type can be either service or instance

Kind: instance method of ServerlessSDK

ParamType
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

ParamType
orgUid*
linkType*
linkUid*
providerUid*

serverlessSDK.getProviders(orgUid)

List providers by OrgUid

Kind: instance method of ServerlessSDK

ParamType
orgUid*

serverlessSDK.getProvider(orgUid, providerUid)

Get a Provider

Kind: instance method of ServerlessSDK

ParamType
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

ParamType
orgUid*
serviceUid*
instanceUid*

serverlessSDK.getProvidersByLink(orgUid, linkType, linkUid)

List providers by Link

Kind: instance method of ServerlessSDK

ParamType
orgUid*
linkType*
linkUid*

serverlessSDK.getAllowedProviders()

Returns the list of supported providers

Kind: instance method of ServerlessSDK

serverlessSDK.createParam(orgUid, linkType, linkUid, data)

Create a param and link it to a service or an instance

Kind: instance method of ServerlessSDK

ParamType
orgUid*
linkType*
linkUid*
data*

serverlessSDK.deleteParam(orgUid, linkType, linkUid, paramUid)

Destroy a param

Kind: instance method of ServerlessSDK

ParamType
orgUid*
linkType*
linkUid*
paramUid*

serverlessSDK.updateParam(orgUid, linkType, linkUid, paramUid, data)

Update a param

Kind: instance method of ServerlessSDK

ParamType
orgUid*
linkType*
linkUid*
paramUid*
data*

serverlessSDK.getParams(orgUid, linkType, linkUid)

List params by service or instance

Kind: instance method of ServerlessSDK

ParamType
orgUid*
linkType*
linkUid*

serverlessSDK.getParamsByOrgServiceInstance(orgUid, serviceUid, instanceUid)

List params by org, service, and instance

Kind: instance method of ServerlessSDK

ParamType
orgUid*
serviceUid*
instanceUid*

serverlessSDK.getParamsAndProvidersByOrgServiceInstance(orgUid, serviceUid, instanceUid)

List parameters and providers by org, service, and instance

Kind: instance method of ServerlessSDK

ParamType
orgUid*
serviceUid*
instanceUid*

serverlessSDK.connect([options]) ⇒ null

Establishes a websockets connection with the Serverless Platform

Kind: instance method of ServerlessSDK

ParamTypeDefaultDescription
[options]Object{}Connection options.
[options.orgName]stringName of the Serverless Platform Org. If not specified, inherits from SDK context.
[options.orgUid]stringID of the Serverless Platform Org. If not specified, inherits from SDK context.
[options.onEvent]onEventA function that handles events recieved from the Serverless Platform.
[options.onDisconnect]onDisconnectRegister a disconnect callback.
[options.onError]onErrorRegister an onError callback.
[options.filter]ObjectFilters which events this connection should receive.
[options.filter.stageName]stringTells the SDK to only receive events on a specific stage.
[options.filter.appName]stringTells the SDK to only receive events on a specific app.
[options.filter.instanceName]stringTells the SDK to only receive events on a specific service.
[options.filter.events]Array.<string>["*"]Restrict the types of receivable events. ["*"] indicates that all events are enabled.

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.unpublishFromRegistry(registryPackage)

Unpublishes a package from the registry

Kind: instance method of ServerlessSDK

ParamTypeDescription
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.

ParamTypeDescription
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.

ParamTypeDefaultDescription
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

ParamTypeDescription
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

ParamTypeDescription
instanceToValidate*The Serverless Platform Instance you want to validate.

serverlessSDK.createInstance(orgName, stageName, appName, instanceName, instanceStatus) ⇒ 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.

ParamTypeDefaultDescription
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.
instanceStatus*inactiveThe status of the instance

serverlessSDK.saveInstance(instanceRecord)

Saves an instance record, defined by createInstance

Kind: instance method of ServerlessSDK

ParamType
instanceRecord*

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

ParamTypeDefaultDescription
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

ParamTypeDefaultDescription
orgName*Optional. Must include either orgName or orgUid.
orgUid*Optional. Must include either orgName or orgUid.

serverlessSDK.run(action, instanceData, 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

ParamType
action*
instanceData*
options*

serverlessSDK.runFinish(method, instanceData, meta)

Run Finish

Kind: instance method of ServerlessSDK

ParamTypeDefaultDescription
methodstringnullThe Action that was performed on the Component.
instanceDataobjectAn object representing your Instance definition.
metaobjectUseful metadata about the Component Action.

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

ParamTypeDefaultDescription
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

onEvent : function

onEvent callback

Kind: global typedef

ParamTypeDescription
eventObjectIncoming event

onDisconnect : function

onDisconnect callback

Kind: global typedef

ParamTypeDescription
closeEventObjectWebsocket CloseEvent

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.


© Serverless Inc.

FAQs

Last updated on 16 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc