Skip to content
OpenFaaS function for BikeshareClient
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bikeshare-function
bikeshare-slack-function
gbfs-systems-function
.gitignore
.travis.yml
LICENSE
README.md
bikeshare-function.yml

README.md

BikeshareFunction

OpenFaaS function for BikeshareClient access. Provides a simple serverless GBFS status system.

gbfs-systems-function parses the GBFS Systems CSV to JSON, providing API for systems overview.

faas-cli template pull https://github.com/burtonr/csharp-kestrel-template
faas-cli build -f bikeshare-function.yml

faas-cli deploy -f bikeshare-function.yml

echo "johanneskirken" |faas-cli invoke bikeshare-function |jq
# {
#  "Name: "Johanneskirken",
#  "BikesAvailable": 1,
#  "LocksAvailable": 23
# }

echo |faas-cli invoke gbfs-systems-function |jq
#{
#    "CountryCode": "US",
#    "Name": "Sobi Long Beach",
#    "Location": "Long Beach, NY",
#    "Id": "sobi_long_beach",
#    "Url": "http://sobilongbeach.com/",
#    "GBFSFileUrl": "http://sobilongbeach.com/opendata/gbfs.json"
#  }

Change GBFS system by updating the GBFSAddress variable:

faas-cli deploy -f bikeshare-function.yml --env=GBFSAddress=https://gbfs.urbansharing.com/oslobysykkel.no/gbfs.json update=true
echo "Diakonhjemmet" |faas-cli invoke bikeshare-function
# {
#  "Name: "Diakonhjemmet",
#  "BikesAvailable": 9,
#  "LocksAvailable": 5
# }

This project also contains function to post from bikeshare-function to Slack. Add a new bot named bikesharebot to a Slack workspace, and update the variable under bikeshare-slack-function: in bikeshare-function.yml with the location of the OpenFaaS gateway:

environment:
    gateway_hostname: http://gateway:8080/

Add the bot's OAUTH token to OpenFaaS secrets:

faas-cli secret create bikeBotSlackToken --from-file=slackbot-key.txt

and initialize the bot by trigging the function after deploy:

echo "init" |faas-cli invoke bikeshare-slack-function
# Bot initializing

Now simply ask the bot for a station:

andmos [8:40 PM]
@BikeshareBot Lerkendal
BikeshareBot APP [8:40 PM]
Lerkendal: :bike:: 17 :unlock:: 3

To run OpenFaaS, look at the guides for Docker Swarm, Kubernetes or OpenShift.

Build Status

You can’t perform that action at this time.