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 "skansen" |faas-cli invoke bikeshare-function |jq # { # "Name: "skansen", # "BikesAvailable": 18, # "LocksAvailable": 0 # } 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.txtand initialize the bot by trigging the function after deploy:
echo "init" |faas-cli invoke bikeshare-slack-function # Bot initializingNow simply ask the bot for a station:
andmos [8:40 PM] @BikeshareBot Lerkendal BikeshareBot APP [8:40 PM] Lerkendal: :bike:: 17 :unlock:: 3To run OpenFaaS, look at the guides for Docker Swarm, Kubernetes or OpenShift.