class Resources
Public Instance Methods
apply(resourceID)
click to toggle source
# File lib/canzea/commands/ecosystem/resources.rb, line 53 def apply(resourceID) token = Login.new.get() esFile = Canzea::config[:config_location] + '/.scope' es = JSON.parse(File.read(esFile)) uri = URI(Canzea::config[:canzea_platform_uri] + "/api/v2/saasexpress/resources/plus/#{es['id']}/#{resourceID}") puts "Calling #{uri}" req = Net::HTTP::Post.new(uri, 'Authorization' => "Bearer #{token}", 'Content-Type' => 'application/json') req.body = {}.to_json https = Net::HTTP.new(uri.hostname,uri.port) https.use_ssl = uri.instance_of? URI::HTTPS res = https.request(req) case res when Net::HTTPSuccess, Net::HTTPRedirection es = JSON.parse(res.body) puts JSON.pretty_generate(es) puts "Successfully scheduled. Batch reference # #{es['ref']}." else puts "Error #{res}" puts res.body end end
plus(manifest, segment)
click to toggle source
# File lib/canzea/commands/ecosystem/resources.rb, line 21 def plus(manifest, segment) token = Login.new.get() esFile = Canzea::config[:config_location] + '/.scope' es = JSON.parse(File.read(esFile)) puts "Using #{es['id']}" uri = URI(Canzea::config[:canzea_platform_uri] + "/api/v2/saasexpress/buildingblocks/#{es['id']}/buildingblocks/configure") config = File.read(manifest) req = Net::HTTP::Post.new(uri, 'Authorization' => "Bearer #{token}", 'Content-Type' => 'application/json') req.body = {config: config, segment: segment, resources: []}.to_json https = Net::HTTP.new(uri.hostname,uri.port) https.use_ssl = uri.instance_of? URI::HTTPS res = https.request(req) case res when Net::HTTPSuccess, Net::HTTPRedirection es = JSON.parse(res.body) puts JSON.pretty_generate(es) puts "Run 'escli resource apply #{es['id']}'" else puts "Error #{res}" puts res.body end end