Class: Ecosystem
- Inherits:
-
Object
- Object
- Ecosystem
- Defined in:
- lib/canzea/commands/ecosystem/ecosystem.rb
Instance Method Summary collapse
Instance Method Details
#list ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/canzea/commands/ecosystem/ecosystem.rb', line 43 def list() token = Login.new.get() uri = URI(Canzea::config[:canzea_platform_uri] + "/api/v2/saasexpress/ecosystem/summary") req = Net::HTTP::Get.new(uri, 'Authorization' => "Bearer #{token}") 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 list = JSON.parse(res.body) list.each { | es | printf "Ecosystem: %-25s %-15s %-15s %-8s %s\n", es['_id'], es['status'], es['fqdomainName'], es['ecosystemRefId'], es['name'] } else puts res.body end end |
#set(id) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/canzea/commands/ecosystem/ecosystem.rb', line 17 def set(id) token = Login.new.get() uri = URI(Canzea::config[:canzea_platform_uri] + "/api/v2/saasexpress/ecosystem/#{id}") req = Net::HTTP::Get.new(uri, 'Authorization' => "Bearer #{token}") 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 puts JSON.pretty_generate(JSON.parse(res.body)) es = JSON.parse(res.body) scope = Canzea::config[:config_location] + '/.scope' File.open(scope, 'w') { |file| file.write({id:id}.to_json) } puts "Ecosystem set to #{es['ecosystemRefId']} with domain #{es['fqdomainName']}" else puts res.body end end |