diff --git a/docs/providers/spotinst/README.md b/docs/providers/spotinst/README.md index cafa31408..1667f9cc9 100755 --- a/docs/providers/spotinst/README.md +++ b/docs/providers/spotinst/README.md @@ -29,10 +29,8 @@ If you have questions, join the [chat in gitter](https://gitter.im/serverless/se
  • Credentials
  • Serverless.yml Reference
  • Variables
  • -
  • Document Store API
  • -
  • Document Store SDK
  • -
  • Endpoint Set Up
  • -
  • Endpoint API Documentation
  • +
  • Endpoints
  • +
  • Cross-Origin Resource Sharing
  • Active Versions Documentation
  • diff --git a/docs/providers/spotinst/guide/active-versions.md b/docs/providers/spotinst/guide/active-versions.md index 50ffa48a1..b6d0e239b 100644 --- a/docs/providers/spotinst/guide/active-versions.md +++ b/docs/providers/spotinst/guide/active-versions.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/spotinst/guide/cors.md b/docs/providers/spotinst/guide/cors.md index a0e6cf0f5..091298c75 100644 --- a/docs/providers/spotinst/guide/cors.md +++ b/docs/providers/spotinst/guide/cors.md @@ -1,7 +1,7 @@ @@ -16,7 +16,7 @@ Cross-Origin Resource Sharing is a mechanism that allows restricted resources on You can enable CORS for cross-domain HTTP requests with Spotinst Functions. Add the required fields to you serverless.yml file. Example CORS object: -```yaml +```yml cors: - enabled: true origin: "http://foo.example" diff --git a/docs/providers/spotinst/guide/document-store-sdk.md b/docs/providers/spotinst/guide/document-store-sdk.md deleted file mode 100644 index 0ffa6b13d..000000000 --- a/docs/providers/spotinst/guide/document-store-sdk.md +++ /dev/null @@ -1,72 +0,0 @@ - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/document-store-sdk) - - -# Spotinst Functions - Document Store SDK - -We have encapsulated the Document Store API calls for retrieving your documents so you will not have to make an API call within the given function. This will allow for you as the user to access your documents using thegetDoc/get_doc method located in the context variable. Additionally this will also eliminate the need for authentication within the function for accessing your documents. - -## Node -```basg -module.exports.main = (event, context, callback) => { - context.getDoc("myKey", function(err, res) { - if(res) { - console.log('res: ' + res); //myValue - var body = { - res: res - }; - - callback(null, { - statusCode: 200, - body: JSON.stringify(body), - headers: {"Content-Type": "application/json"} - }); - } - }); -} -``` - -## Python -```bash -def main(event, context): - print ('context: %s' % context) - - doc = context.get_doc('myKey') - print(doc) #myValue - - res = { - 'statusCode': 200, - 'body': 'res: %s' % doc, - 'headers': {"Content-Type": "application/json"} - } - return res -``` - -## Java 8 -```bash -public class Java8Template implements RequestHandler { - @Override - public Response handleRequest(Request request, Context context) { - String value = context.getDoc("myKey"); - System.out.println(value); //myValue - - Response response = new Response(200, String.format("value: %s", value)); - - Map headers = new HashMap<>(); - headers.put("Content-Type", "application/json"); - - response.setHeaders(headers); - - return response; - } -} -``` - diff --git a/docs/providers/spotinst/guide/document-store.md b/docs/providers/spotinst/guide/document-store.md deleted file mode 100644 index f5887f593..000000000 --- a/docs/providers/spotinst/guide/document-store.md +++ /dev/null @@ -1,175 +0,0 @@ - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/credentials) - - -# Spotinst Functions - Document Store API - -Document Store is a way for you to save information across function calls within the same environment without having to access an external database. It is secured by your Spotinst account credentials and can only be accesses within a function. Because you do not need to access an external database you are able to fetch stored documents with low latency (< ~5ms) - -To access the document store you will need to make an API request inside a funciton formatted bellow. - -## Add New Value - -This is how to insert a new key/value pair into your document store in a specific environment - -**HTTPS Request:** - -```bash -POST environment/${environmentId}/userDocument?accountId=${accountId} -``` - -**Host:** - -```bash -api.spotinst.io/functions/ -``` - -**Header:** - -```bash -{ - "Content-Type": "application/json", - "Authorization": "Bearer ${Spotinst API Token}" -} -``` - -**Body:** - -```bash -{ - "userDocument" : { - "key": “${Your Key}”, - "value": “${Your Value}” - } -} -``` - - -## Update Value - -This is how to update a current key/value pair in your document store in a specific environment - -**HTTPS Request:** - -```bash -PUT environment/${environmentId}/userDocument/${Key}?accountId=${accountId} -``` - -**Endpoint:** - -```bash -api.spotinst.io/functions/ -``` - -**Header:** - -```bash -{ - "Content-Type": "application/json", - "Authorization": "Bearer ${Spotinst API Token}" -} -``` - -**Body:** - -```bash -{ - "userDocument" : { - "value": “${Your Value}” - } -} -``` - - -## Get Values - -There are two ways to get the documents from your store, either by specifing a key which will return both the key and the value or you can just leave this out and you will get all the keys in the environment - -### 1. Get Sinlge Key Pair - -**HTTPS Request:** - -```bash -GET environment/${environmentId}/userDocument/${Key}?accountId=${accountId} -``` - -**Endpoint:** - -```bash -api.spotinst.io/functions/ -``` - -**Header:** - -```bash -{ - "Content-Type": "application/json", - "Authorization": "Bearer ${Spotinst API Token}" -} -``` - -### 2. Get All Keys - -**HTTPS Request:** - -```bash -GET environment/${environmentId}/userDocument?accountId=${accountId} -``` - -**Endpoint:** - -```bash -api.spotinst.io/functions/ -``` - -**Header:** - -```bash -{ - "Content-Type": "application/json", - "Authorization": "Bearer ${Spotinst API Token}" -} -``` - - -## Delete Value - -This is how to delete a specific key value pair from your document store - -**HTTPS Request:** - -```bash -DELETE environment/${environmentId}/userDocument/${Key}?accountId=${accountId} -``` - -**Endpoint:** - -```bash -https://api.spotinst.io/functions/ -``` - -**Header:** - -```bash -{ - "Content-Type": "application/json", - "Authorization": "Bearer ${Spotinst API Token}" -} -``` - - -## GitHub - -Check out some examples to help you get started! - -[Get All Values Function](https://github.com/spotinst/spotinst-functions-examples/tree/master/node-docstore-getAll) - -[Insert New Value Function](https://github.com/spotinst/spotinst-functions-examples/tree/master/node-docstore-newValue) \ No newline at end of file diff --git a/docs/providers/spotinst/guide/endpoint-api.md b/docs/providers/spotinst/guide/endpoint-api.md deleted file mode 100644 index 337906662..000000000 --- a/docs/providers/spotinst/guide/endpoint-api.md +++ /dev/null @@ -1,202 +0,0 @@ - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/credentials) - - -# Spotinst Functions - Endpoint API Documentation - -Here is the full list of API calls that you can make to set alias and patterns. Please check out the full article on Setting Up Endpoints first because it will make more sense. - -## Alias -### Create Alias -Create a new alias to point to your environment - -#### HTTPS Request -```bash -POST alias?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Body -```bash -{ - "alias": { - "host": "myAlias.com", - "environmentId": ${Environment ID} - } -} -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json - ``` - -### Get Alias -Returns a single alias - -#### HTTPS Request -```bash -GET alias/${Alias ID}?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -### Get All Alias -Returns all the alias in your account - -#### HTTPS Request -```bash -GET alias?accountId=${accountId} -``` -##### Host -```bash -api.spotinst.io/functions/ -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -### Delete Alias -Deletes a single alias - -#### HTTPS Request -```bash -DELETE alias/${Alias ID}?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - - -## Pattern -### Create Pattern -Create a new pattern that maps to a function - -#### HTTPS Request -```bash -POST pattern?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Body -```bash -{ - "pattern": { - "environmentId":${Environment ID}, - "method": "ALL", - "pattern": "/*", - "functionId": ${Function ID} - } -} -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -### Update Pattern -Update and existing pattern - -#### HTTPS Request -```bash -PUT pattern/${Pattern ID}?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Body -```bash -{ - "pattern": { - "environmentId":${Environment ID}, - "method": "ALL", - "pattern": "/*", - "functionId": ${Function ID} - } -} -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -### Get Pattern -Returns a single pattern - -#### HTTPS Request -```bash -GET pattern/${Pattern ID}?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -### Get All Patterns -Returns all the patterns your account - -#### HTTPS Request -```bash -POST pattern?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -### Delete Pattern -Delete a single pattern - -#### HTTPS Request -```bash -DELETE pattern/${Pattern ID}?accountId=${accountId} -``` -#### Host -```bash -api.spotinst.io/functions/ -``` -#### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` diff --git a/docs/providers/spotinst/guide/endpoint-setup.md b/docs/providers/spotinst/guide/endpoint-setup.md deleted file mode 100644 index 19d3c5568..000000000 --- a/docs/providers/spotinst/guide/endpoint-setup.md +++ /dev/null @@ -1,85 +0,0 @@ - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/credentials) - - -# Spotinst Functions - Endpoint Setup - -You are able to set an alias URL name as an endpoint for your serverless function to make it more accessible to your users. The way this works is you will point the domain of your choosing to your environment URL's then you will set paths to each of the functions in that environment you wish to bundle in together. To do this you will first need a valid domain. For this example I will be using 'myAlias.com'. - -## Set DNS Record -First you will want to create a DNS record set that will point to your environment URL. Your environment URL can be found in the Spotinst console. When you select the environment you wish to connect you will see a list of functions and their individual URL's. Like this -```bash -https://app-123xyz-raffleapp-execute-function1.spotinst.io/fx-abc987 -``` -We only want the URL starting at app and ending before the function id. Like this -```bash -app-123xyz-raffleapp-execute-function1.spotinst.io -``` -With this you will need to go to a DNS record setter and point your domain to this URL. I used AWS Route 53 to set this up. - -## Set Alias -Next you will need to set the alias in your Spotinst environment by making an API call. This does not need to be done within a function and can be set anyway you are most comfortable. The API request is connecting your domain the environment that you want. This is the API request - -### HTTPS Request -```bash -POST alias?accountId=${accountId} -``` -### Host -```bash -api.spotinst.io/functions/ -``` -### Body -```bash -{ - "alias": { - "host": "myAlias.com", - "environmentId": ${Your Environment ID} - } -} -``` -### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -**Note:** You are able to connect multiple alias to the same environment - -## Set Up Pattern -After you have an alias set up you will need to set up pattern to connect to all the functions in the application. This is again another API call and can be done from anywhere. You specify the pattern that you want, the method that will trigger the function, the function ID and the environment ID. The pattern is what will appear after the domain. For example '/home' would point to 'myAlias.com/home'. The methods you can select are any of the usual HTTP request methods: GET, PUT, POST, DELETE , OPTIONS, PATCH, ALL where “ALL” matches every method - -### HTTPS Request -```bash -POST pattern?accountId=${accountId} -``` -### Host -```bash -api.spotinst.io/functions/ -``` -### Body -``` bash -{ - "pattern": { - "environmentId": ${Your Environment ID}, - "method": "ALL", - "pattern": "/*", - "functionId": ${Your Function ID} - } -} -``` -### Headers -```bash -Authorization: Bearer ${Spotinst API Token} -Content-Type: application/json -``` - -## API Documentation -The full API documentation has information like delete and get alias and patterns. Check it out [here](./endpoint-api.md) diff --git a/docs/providers/spotinst/guide/endpoints.md b/docs/providers/spotinst/guide/endpoints.md new file mode 100644 index 000000000..004a8077e --- /dev/null +++ b/docs/providers/spotinst/guide/endpoints.md @@ -0,0 +1,32 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/credentials) + + +# Spotinst Functions - Endpoints + +You are able to set your custom endpoint path in the serverless.yml file if you do not want to use the console or API. You will have to set up your environment Alias in the console but here you can set the path and method for your individual functions to be mapped to. + +Here is a sample function from a yml file. As you can see at the bottom of the file we have listed an endpoint with a path and method. Both of these will need to be set in order to be deployed properly + +```yml + hello: + runtime: nodejs8.3 + handler: handler.main + memory: 128 + timeout: 30 + access: public + endpoint: + path: /home + method: get + +``` + +For more information on how to set up endpoint alias and patterns check out our documentation [here](https://help.spotinst.com/hc/en-us/articles/115005893709) \ No newline at end of file diff --git a/docs/providers/spotinst/guide/variables.md b/docs/providers/spotinst/guide/variables.md index 69411d98a..02db0976a 100644 --- a/docs/providers/spotinst/guide/variables.md +++ b/docs/providers/spotinst/guide/variables.md @@ -39,7 +39,7 @@ URL parameters can be use when a POST request is made to the endpoint of your fu ### 1. Node JS -To access URL parameters in your NodeJS code you just need to put `event.query.['{Your Parameter Name}']` as needed +To access URL parameters in your NodeJS code you just need to put `event.query['{Your Parameter Name}']` as needed ### 2. Python