@serverless/platform-client
v4.5.1
Published
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
Downloads
3,823,610
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/[email protected]" 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
Typedefs
ServerlessSDK
The Serverless Platform SDK Class
Kind: global class
- ServerlessSDK
- new ServerlessSDK()
- .session : object
- .refreshToken(refreshToken) ⇒ Promise.<object>
- .events : object
- .publish(event) ⇒ Promise.<null>
- .get(uid) ⇒ Promise.<Object>
- .list([options]) ⇒ Promise.<Object>
- ~~.send(event) ⇒ Promise.<null>~~
- .frameworkDeployments : object
- .create([params]) ⇒ Promise.<object>
- .list([params]) ⇒ Promise.<array>
- .webhooks : object
- .register(url, [options]) ⇒ Promise.<object>
- .list([options]) ⇒ Promise.<object>
- .get(uid) ⇒ Promise.<object>
- .update(uid) ⇒ Promise.<object>
- .delete(uid) ⇒ Promise.<object>
- .accessKeys : object
- .create(orgName, userName, accessKeyName) ⇒ Promise.<object>
- .list(orgName) ⇒ Promise.<object>
- .remove(orgName, uid) ⇒ Promise.<object>
- .get() ⇒ Promise.<(object|null)>
- .connections : object
- .create(orgUid, providerUid, accountAlias) ⇒ Promise.<object>
- .list(orgUid) ⇒ Promise.<object>
- .get(orgUid, connectionUid) ⇒ Promise.<object>
- .getByOrgAndAccountAlias(orgUid, accountAlias) ⇒ Promise.<object>
- .update(orgUid, connectionUid, providerUid, accountAlias, status) ⇒ Promise.<object>
- .remove(orgUid, connectionUid) ⇒ Promise.<object>
- .syncAll(orgUid) ⇒ Promise.<object>
- .unsync(orgUid, connectionUid) ⇒ Promise.<object>
- .desktop : object
- .createSavedQuery(orgUid, appUid, serviceName, savedQuery) ⇒ Promise.<object>
- .getSavedQuery(orgUid, appUid, serviceName, savedQueryUid) ⇒ Promise.<object>
- .updateSavedQuery(orgUid, appUid, serviceName, savedQueryUid, savedQuery) ⇒ Promise.<object>
- .deleteSavedQuery(orgUid, appUid, serviceName, savedQueryUid) ⇒ Promise.<object>
- .listSavedQueries(orgUid, appUid, serviceName) ⇒ Promise.<object>
- .logDestinations : object
- .getOrCreate([params]) ⇒ Promise.<object>
- .remove([params]) ⇒ Promise.<object>
- .deploymentProfiles : object
- .get([params]) ⇒ Promise.<Object>
- .create([params]) ⇒ Promise.<Object>
- .list([params]) ⇒ Promise.<array>
- .setDefault([params]) ⇒ Promise.<Object>
- .organizations : object
- .get([params]) ⇒ object
- .list([params]) ⇒ array
- .create([params]) ⇒ object
- .validate([params]) ⇒ array
- .apps : object
- .metadata : object
- .get() ⇒ Promise.<Object>
- .config() ⇒ null
- .getDomain(serviceName) ⇒ string
- .getUser() ⇒ object
- .getUserMeta() ⇒ object
- .saveUserMeta(userMeta) ⇒ object
- ~~.validateUserAndOrgName(userAndOrgName) ⇒ array~~
- ~~.createUserAndOrg(userAndOrgName) ⇒ object~~
- ~~.createOrg(userAndOrgName) ⇒ object~~
- ~~.getOrgByName(orgName) ⇒ object~~
- ~~.listOrgs(username) ⇒ object~~
- ~~.createApp(orgName) ⇒ object~~
- ~~.updateApp(orgName) ⇒ object~~
- ~~.deleteApp(orgName, appName)~~
- ~~.listApps(orgName)~~
- .createInitToken(orgName)
- .getInitToken(initTokenUid)
- .createProvider(orgUid, data)
- .updateProvider(orgUid, providerUid, data)
- .setDefaultProvider(orgUid, providerUid)
- .unsetDefaultProvider(orgUid, providerUid)
- .deleteProvider(orgUid, providerUid)
- .createProviderLink(orgUid, linkType, linkUid, providerUid)
- .deleteProviderLink(orgUid, linkType, linkUid, providerUid)
- .getProviders(orgUid)
- .getProvider(orgUid, providerUid)
- .getProvidersByOrgServiceInstance(orgUid, serviceUid, instanceUid)
- .getProvidersByLink(orgUid, linkType, linkUid)
- .getAllowedProviders()
- .createParam(orgUid, linkType, linkUid, data)
- .deleteParam(orgUid, linkType, linkUid, paramUid)
- .updateParam(orgUid, linkType, linkUid, paramUid, data)
- .getParams(orgUid, linkType, linkUid)
- .getParamsByOrgServiceInstance(orgUid, serviceUid, instanceUid)
- .getParamsAndProvidersByOrgServiceInstance(orgUid, serviceUid, instanceUid)
- .connect([options]) ⇒ null
- .disconnect() ⇒ null
- .isConnected() ⇒ boolean
- .unpublishFromRegistry(registryPackage)
- .publishToRegistry(registryPackage) ⇒ object
- .getFromRegistry(name, version) ⇒ object
- .generateInstanceId(orgUid, stageName, appUid, instanceName) ⇒ object
- .validateInstance(instanceToValidate) ⇒ object
- .createInstance(orgName, stageName, appName, instanceName, instanceStatus) ⇒ object
- .saveInstance(instanceRecord)
- .getInstance(orgName, stageName, appName, instanceName)
- .listInstances(orgName, orgUid)
- .run(action, instanceData, options)
- .runFinish(method, instanceData, meta)
- .deploy()
- .remove()
- .startInterceptingLogs(eventType, context)
- .stopInterceptingLogs()
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.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
| Param | Type | Description | | ------------ | ------------------- | ------------------------------------------------ | | refreshToken | string | The 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 : object
- .publish(event) ⇒ Promise.<null>
- .get(uid) ⇒ Promise.<Object>
- .list([options]) ⇒ Promise.<Object>
- ~~.send(event) ⇒ Promise.<null>~~
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.
| Param | Type | Description |
| ----------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| event | Object | Array.<Object> | An event object, or if publishing a batch of events, an array of event objects. |
| event.event | string | Event 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.data | Object | Event 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.
| Param | Type | Description | | ----- | ------------------- | --------------------------- | | uid | string | UID 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": "[email protected]",
// "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.
| Param | Type | Description |
| ---------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [options] | Object | List options |
| options.org_uid | string | UID of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context. |
| options.org_name | string | Name of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context. |
| 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. |
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": "[email protected]",
// "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
| Param | Type | Description |
| ----------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| event | Object | Array.<Object> | An event object, or if publishing a batch of events, an array of event objects. |
| event.event | string | Event 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.data | Object | Event 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 : object
- .create([params]) ⇒ Promise.<object>
- .list([params]) ⇒ Promise.<array>
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.
| Param | Type | Description | | --------------------- | ------------------- | ----------------------------------------------------------------------------- | | [params] | Object | Create deployment params. | | params.orgName | string | The name of the Serverless Platform Organization to create the Deployment in. | | params.appName | string | The name of the Serverless Platform Application to create the Deployment in. | | params.serviceName | string | The name of the Serverless Platform Service to create the Deployment in. | | params.stageName | string | The name of the Serverless Service Stage to create the Deployment in. | | params.regionName | string | The name of the AWS Region to create the Deployment in. | | params.deploymentData | Object | Data associated with saved deployment |
frameworkDeployments.list([params]) ⇒ Promise.<array>
List Serverless Platform Deployments.
Kind: static method of frameworkDeployments
Returns: Promise.<array> - Array of Deployments.
| Param | Type | Description | | ------------------ | ------------------- | ----------------------------------------------------------------------------- | | [params] | Object | List deployment params. | | params.orgName | string | The name of the Serverless Platform Organization to list the Deployments for. | | params.appName | string | The name of the Serverless Platform Application to list the Deployment for. | | params.serviceName | string | The name of the Serverless Platform Service to list the Deployment for. | | params.stageName | string | The name of the Serverless Service Stage to list the Deployment for. | | params.regionName | string | The name of the AWS Region to list the Deployment for. | | params.cursor | string | The 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 : object
- .register(url, [options]) ⇒ Promise.<object>
- .list([options]) ⇒ Promise.<object>
- .get(uid) ⇒ Promise.<object>
- .update(uid) ⇒ Promise.<object>
- .delete(uid) ⇒ Promise.<object>
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:
| Header | Value |
| ----------------------- | ------------------------------- |
| Content-type
| application/json
|
| X-Serverless-Event
| Event type |
| X-Serverless-Delivery
| Unique delivery ID |
| User-Agent
| Prefix of Serverless-Webhook/
|
Kind: static method of webhooks
Returns: Promise.<object> - Registered webhook endpoint.
| Param | Type | Description |
| ----------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| url | string | HTTP webhook endpoint URL. |
| [options] | Object | Registration options. |
| options.description | string | An optional description of what the webhook is used for. |
| options.org_uid | string | UID 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_name | string | Name of the Serverless Platform Organization. Optional - defaults to inheriting from current SDK context. |
| options.filter | Object | Optionally, filter which events this endpoint should receive. |
| options.filter.enabled_events | Array.<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.
| Param | Type | Description |
| ---------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [options] | Object | List options. |
| 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. |
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.
| Param | Type | Description | | ----- | ------------------- | -------------------- | | uid | string | Webhook 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.
| 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 | Array.<string> | The list of events to enable for this endpoint. ["*"]
indicates that all events are enabled. |
| updates.status.disabled | boolean | Enable/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.
| Param | Type | Description | | ----- | ------------------- | -------------------- | | uid | string | Webhook 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 : object
- .create(orgName, userName, accessKeyName) ⇒ Promise.<object>
- .list(orgName) ⇒ Promise.<object>
- .remove(orgName, uid) ⇒ Promise.<object>
- .get() ⇒ Promise.<(object|null)>
accessKeys.create(orgName, userName, accessKeyName) ⇒ Promise.<object>
Creates a new Access Key for a User within a Serverless Organization.
Kind: static method of accessKeys
| Param | Type | Description | | ------------- | ------------------- | ------------------------------------------------------------------------------------ | | orgName | string | The name of the Serverless Organization to create the Access Key for | | userName | string | The name of the User within the Serverless Organization to create the Access Key for | | accessKeyName | string | The 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
| Param | Type | Description | | ------- | ------------------- | ----------------------------------------------------------- | | orgName | string | The 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
| Param | Type | Description | | ------- | ------------------- | ---------------------------------------------------------------------- | | orgName | string | The name of the Serverless Organization that the Access Key belongs to | | uid | string | The 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 : object
- .create(orgUid, providerUid, accountAlias) ⇒ Promise.<object>
- .list(orgUid) ⇒ Promise.<object>
- .get(orgUid, connectionUid) ⇒ Promise.<object>
- .getByOrgAndAccountAlias(orgUid, accountAlias) ⇒ Promise.<object>
- .update(orgUid, connectionUid, providerUid, accountAlias, status) ⇒ Promise.<object>
- .remove(orgUid, connectionUid) ⇒ Promise.<object>
- .syncAll(orgUid) ⇒ Promise.<object>
- .unsync(orgUid, connectionUid) ⇒ Promise.<object>
connections.create(orgUid, providerUid, accountAlias) ⇒ Promise.<object>
Creates a new Connection between a vendor account and a Serverless Organization.
Kind: static method of connections
| Param | Type | Description | | ------------ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to create a Connection in. | | providerUid | string | The 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. | | accountAlias | string | An 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
| Param | Type | Description | | ------ | ------------------- | ----------------------------------------------------------------- | | orgUid | string | The 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
| Param | Type | Description | | ------------- | ------------------- | -------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to get a Connection in. | | connectionUid | string | The 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
| Param | Type | Description | | ------------ | ------------------- | ---------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to get a Connection in. | | accountAlias | string | The 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
| Param | Type | Description | | ------------- | ------------------- | ----------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to update a Connection in. | | connectionUid | string | The UID of the Connection to update within the Serverless Organization. | | providerUid | string | The updated Provider UID within the Connection. | | accountAlias | string | The updated alias of the Connection. | | status | string | The updated status of the Connection. |
connections.remove(orgUid, connectionUid) ⇒ Promise.<object>
Remove a single Connection within the Serverless Organization.
Kind: static method of connections
| Param | Type | Description | | ------------- | ------------------- | ----------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to remove a Connection in. | | connectionUid | string | The 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
| Param | Type | Description | | ------ | ------------------- | ------------------------------------------------------------------ | | orgUid | string | The 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
| Param | Type | Description | | ------------- | ------------------- | ----------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to sync all Connections in. | | connectionUid | string | The 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 : object
- .createSavedQuery(orgUid, appUid, serviceName, savedQuery) ⇒ Promise.<object>
- .getSavedQuery(orgUid, appUid, serviceName, savedQueryUid) ⇒ Promise.<object>
- .updateSavedQuery(orgUid, appUid, serviceName, savedQueryUid, savedQuery) ⇒ Promise.<object>
- .deleteSavedQuery(orgUid, appUid, serviceName, savedQueryUid) ⇒ Promise.<object>
- .listSavedQueries(orgUid, appUid, serviceName) ⇒ Promise.<object>
desktop.createSavedQuery(orgUid, appUid, serviceName, savedQuery) ⇒ Promise.<object>
Create a Saved Query for a Service by specifying some data.
Kind: static method of desktop
| Param | Type | Description | | ----------- | ------------------- | -------------------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to create the Saved Query in. | | appUid | string | The UID of the Serverless Application to create the Saved Query in. | | serviceName | string | The name of the Serverless Service to create the Saved Query in. | | savedQuery | string | The 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
| Param | Type | Description | | ------------- | ------------------- | ------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to get the Saved Query from. | | appUid | string | The UID of the Serverless Application to get the Saved Query from. | | serviceName | string | The name of the Serverless Service to get the Saved Query from. | | savedQueryUid | string | The 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
| Param | Type | Description | | ------------- | ------------------- | -------------------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to create the Saved Query in. | | appUid | string | The UID of the Serverless Application to create the Saved Query in. | | serviceName | string | The name of the Serverless Service to create the Saved Query in. | | savedQueryUid | string | The UID of the Saved Query to get for this Serverless Service. | | savedQuery | string | The 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
| Param | Type | Description | | ------------- | ------------------- | ---------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to delete the Saved Query from. | | appUid | string | The UID of the Serverless Application to delete the Saved Query from. | | serviceName | string | The name of the Serverless Service to delete the Saved Query from. | | savedQueryUid | string | The 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
| Param | Type | Description | | ----------- | ------------------- | ---------------------------------------------------------------------- | | orgUid | string | The UID of the Serverless Organization to list the Saved Queries from. | | appUid | string | The UID of the Serverless Application to list the Saved Queries from. | | serviceName | string | The 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 : object
- .getOrCreate([params]) ⇒ Promise.<object>
- .remove([params]) ⇒ Promise.<object>
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](#ServerlessSDK+logDestinat