Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backplane API
class BackplaneApi
include HTTParty
debug_output $stderr if Rails.env.development?
base_uri 'www.backplane.io:443'
basic_auth ENV['BACKPLANE_TOKEN'], ''
format :json
def add_route(pattern, labels={})
raw_selector = labels.map{|k,v|"#{k}=#{v}"}.join(',')
body = {
Pattern: pattern,
Route: {
RawSelector: raw_selector
}
}.to_json
self.class.post("/route", {body: body}).ok?
end
def require_tls(pattern)
body = {
Pattern: pattern,
RequireTLS: true
}.to_json
self.class.put("/e", {body: body}).ok?
end
def remove_tls(pattern)
body = {
Pattern: pattern,
RequireTLS: false
}.to_json
self.class.put("/e", {body: body}).ok?
end
def remove_route(pattern)
self.class.delete("/e/#{pattern}").ok?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.