Class: Aspera::Cli::Plugins::Bss
- Inherits:
-
BasicAuthPlugin
- Object
- Aspera::Cli::Plugin
- BasicAuthPlugin
- Aspera::Cli::Plugins::Bss
- Defined in:
- lib/aspera/cli/plugins/bss.rb
Constant Summary collapse
- ACTIONS =
[ :subscription ]
- FIELDS =
{ 'bssSubscriptions' => %w{id name termVolumeGb termMonths trial startDate endDate plan renewalType chargeAgreementNumber customerName} }
Constants inherited from Aspera::Cli::Plugin
Aspera::Cli::Plugin::ALL_OPS, Aspera::Cli::Plugin::GLOBAL_OPS, Aspera::Cli::Plugin::INSTANCE_OPS
Instance Method Summary collapse
- #all_fields(name) ⇒ Object
- #execute_action ⇒ Object
-
#initialize(env) ⇒ Bss
constructor
A new instance of Bss.
Methods inherited from BasicAuthPlugin
Methods inherited from Aspera::Cli::Plugin
#config, #entity_action, #entity_command, #format, #options, #transfer
Constructor Details
#initialize(env) ⇒ Bss
14 15 16 17 18 19 |
# File 'lib/aspera/cli/plugins/bss.rb', line 14 def initialize(env) super(env) if env.has_key?(:bss_api) @api_bss=env[:bss_api] end end |
Instance Method Details
#all_fields(name) ⇒ Object
21 22 23 |
# File 'lib/aspera/cli/plugins/bss.rb', line 21 def all_fields(name) return FIELDS[name].join(' ') end |
#execute_action ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/aspera/cli/plugins/bss.rb', line 25 def execute_action if @api_bss.nil? key = self..get_option(:password,:mandatory) @api_bss=Rest.new( base_url: 'https://dashboard.bss.asperasoft.com/platform', headers: {cookie: "_dashboard_key=#{key}"}) end command=self..get_next_command(ACTIONS) case command when :subscription command=self..get_next_command([:find,:show, :instances]) object='bssSubscriptions' case command when :find query = self..get_option(:query,:mandatory) # AOC_ORGANIZATION_QUERY AOC_USER_EMAIL value = self..get_option(:value,:mandatory) request={ 'variables'=>{'filter'=>{'key'=>query,'value'=>value}}, 'query'=>"query($filter: BssSubscriptionFilter!) {#{object}(filter: $filter) { #{all_fields('bssSubscriptions')} } }" } result=@api_bss.create('graphql',request)[:data] # give fields to keep order return {:type=>:object_list, :data=>result['data'][object],:fields=> FIELDS['bssSubscriptions']} when :show id = self..get_option(:id,:mandatory) request={ 'variables'=>{'id'=>id}, 'query'=>"query($id: ID!) {#{object}(id: $id) { #{all_fields('bssSubscriptions')} roleAssignments(uniqueSubjectId: true) { id subjectId } instances { id state planId serviceId ssmSubscriptionId entitlement { id } aocOrganization { id subdomainName name status tier urlId trialExpiresAt users(organizationAdmin: true) { id name email atsAdmin subscriptionAdmin } } } } }" } result=@api_bss.create('graphql',request)[:data]['data'][object].first result.delete('instances') return {:type=>:single_object, :data=>result} when :instances id = self..get_option(:id,:mandatory) request={ 'variables'=>{'id'=>id}, 'query'=>"query($id: ID!) {#{object}(id: $id) { aocOrganization { id subdomainName name status tier urlId trialExpiresAt } } } }" } result=@api_bss.create('graphql',request)[:data]['data'][object].first return {:type=>:object_list, :data=>result['instances']} end end end |