Code Monkey home page Code Monkey logo

-serverless-platform-sdkpy's Introduction

Platform SDK (deprecated)

Note: This package is deprecated in favor of @serverless/platform-client. It accepts only bug fixes

Functional SDK for the Serverless Platfrom.

Project Status

Build Status license coverage Known Vulnerabilities

Contents

installation

npm i -s @serverless/platform-sdk

Functions

login

Opens a browser for the user to login, along with a running server awaiting auth data once the user logs in.

Parameters

None

Returns

Promise resolving to the following object:

  • username - string - dashboard username
  • accessToken - string - Auth0 access token
  • idToken - string - Auth0 idToken
  • refreshToken - string - Auth0 refreshToken
  • expiresAt - string - epoch time at which the idToken expires

Example

const { login } = require('@serverless/platform-sdk')

const { username, accessToken, idToken, expiresAt } = await login()

refreshToken

Refreshes Auth0 idToken

Parameters

refresh token string

Returns

Promise resolving to the following object:

  • id_token - string - new Auth0 id token
  • access_token - string - new Auth0 access token
  • expires_in - string - number of seconds until token expiration

Example

const { refreshToken } = require('@serverless/platform-sdk')

const { id_token, access_token, expires_in } = await refreshToken('some-refresh-token')

createAccessKey

Creates a platform access key for the authenticated user.

Parameters

Object

  • username - string - dashboard username
  • tenant - string - dashboard tenant
  • idToken - string - Auth0 idToken
  • title - string - title of the access key

Returns

Promise resolving to an accessKey string, that is the access key.

Example

const { createAccessKey } = require('@serverless/platform-sdk')

const data = {
  username: 'eahefnawy',
  tenant: 'eahefnawy',
  idToken: 'abc',
  title: 'Framework'
}

const accessKey = await createAccessKey(data)

archiveService

Archives a service in the platform.

Parameters

Object

  • tenant - string - dashboard tenant
  • accessKey - string - dashboard access key
  • app - string - service app
  • name - string - service name
  • provider - string - provider name
  • region - string - region name

Returns

None

Example

const { archiveService } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  accessKey: 'abc',
  app: 'my-app',
  name: 'my-service',
  provider: 'aws',
  region: 'us-east-1'
}

await archiveService(data)

getServiceUrl

Constructs a service url based on passed-in data.

Parameters

Object

  • tenant - string - dashboard tenant
  • app - string - service app
  • name - string - service name

Returns

The service url string.

Example

const { getServiceUrl } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  name: 'my-service'
}

const serviceUrl = getServiceUrl(data)

listTenants

Lists the tenants for a given username

Parameters

Object

  • username - string - dashboard username
  • idToken - string - auth0 user id token

Returns

Array of objects, each represents a single tenant data model.

Example

const { listTenants } = require('@serverless/platform-sdk')

const data = {
  username: 'eahefnawy',
  idToken: 'abc'
}

const tenants = await listTenants(data)

createDeploymnet

Creates a platform deployment

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • serviceName - string - service name
  • accessKey - string - dashboard access key
  • files - object - files which should be stored in the Platforms deployment record

Returns

Object - Deployment model

Example

const { createDeployment } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  serviceName: 'my-service',
  accessKey: 'abc',
  files: {
    'serverless-state.json': {
      //...snip...
    }
  }
}

const { id } = await createDeployment(data)

updateDeployment

Updates a platform deployment

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • serviceName - string - service name
  • deploymentId - string - id of the previously created deployment
  • status - string - status of the deployment to update
  • accessKey - string - dashboard access key
  • computedData - object - computed data the Platform needs to generate the state items

Returns

Object - Deployment model

Example

const { updateDeployment } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  serviceName: 'my-service',
  deploymentId: 'abc',
  status: 'failed',
  accessKey: 'abc',
  computedData: {
    // ...snip...
  }
}

const { id } = await updateDeployment(data)

getApp

Gets a platform app

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • token - string - Auth0 id token

Returns

Object - App model

Example

const { getApp } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  token: 'abc'
}

const app = await getApp(data)

createApp

Creates a platform app

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • token - string - Auth0 id token

Returns

Object - App model

Example

const { createApp } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  token: 'abc'
}

const app = await createApp(data)

-serverless-platform-sdkpy's People

Contributors

dschep avatar eahefnawy avatar medikoo avatar alexdebrie avatar austencollins avatar westergaards avatar pmuens avatar plfx avatar brianneisler avatar astuyve avatar sebito91 avatar tpxp avatar gsingh1 avatar skierkowski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.