enfcli 4.1.0.pre.beta → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2019 Xaptum,Inc
2
+ # Copyright 2019-2020 Xaptum,Inc
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  require "enfthor"
17
- require "enfapi"
17
+ require "enfapi/dns"
18
18
 
19
19
  module EnfCli
20
20
  module Cmd
@@ -46,9 +46,9 @@ module EnfCli
46
46
  end
47
47
 
48
48
  def display_zones_table(zones)
49
- headings = ["Id", "Zone", "Description", "Enf Domain"]
49
+ headings = ["Id", "Zone", "Description", "Privileged", "Enf Domain"]
50
50
  rows = zones.map { |hash|
51
- [hash[:id], hash[:zone_domain_name], hash[:description], hash[:enf_domain]]
51
+ [hash[:id], hash[:zone_domain_name], hash[:description], hash[:privileged], hash[:enf_domain]]
52
52
  }
53
53
  render_table(headings, rows)
54
54
  end
@@ -82,6 +82,7 @@ module EnfCli
82
82
  method_option :'zone-domain-name', :type => :string, :required => true
83
83
  method_option :description, :type => :array, :banner => "DESCRIPTION"
84
84
  method_option :'enf-domain', :type => :string, :banner => "/48 Enf Domain"
85
+ method_option :'enf-network', :type => :string, :banner => "/64 Enf Network"
85
86
 
86
87
  def create_zone
87
88
  try_with_rescue_in_session do
@@ -91,12 +92,16 @@ module EnfCli
91
92
  ## Gather parameters
92
93
  zone_domain_name = options["zone-domain-name"]
93
94
  description = array_option_to_string(options.description) if options.description
94
- case session[:type]
95
- when "XAPTUM_ADMIN"
95
+ if EnfCli::CTX.instance.xaptum_admin?
96
96
  enf_domain = options["enf-domain"]
97
97
  raise "No value provided for required options '--enf-domain'" unless enf_domain
98
98
  else
99
- enf_domain = session[:domain_network]
99
+ enf_domain = session[:domain]
100
+ end
101
+
102
+ enf_network = options["enf-network"]
103
+ unless EnfCli::CTX.instance.edit_domain_role?
104
+ raise "No value provided for required option '--enf-network'" unless enf_network
100
105
  end
101
106
 
102
107
  ## create request hash
@@ -106,6 +111,9 @@ module EnfCli
106
111
  :enf_domain => enf_domain,
107
112
  }
108
113
 
114
+ ## add enf_network to request if present
115
+ new_zone[:enf_network] = enf_network if enf_network
116
+
109
117
  ## call api
110
118
  data = EnfApi::Dns.instance.create_dns_zone new_zone
111
119
  zones = data[:data]
@@ -125,12 +133,11 @@ module EnfCli
125
133
  ## session
126
134
  session = EnfCli::CTX.instance.session
127
135
 
128
- case session[:type]
129
- when "XAPTUM_ADMIN"
136
+ if EnfCli::CTX.instance.xaptum_admin?
130
137
  enf_domain = options["enf-domain"]
131
138
  raise "No value provided for required options '--enf-domain'" unless enf_domain
132
139
  else
133
- enf_domain = session[:domain_network]
140
+ enf_domain = session[:domain]
134
141
  end
135
142
 
136
143
  ## call api
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  require "enfthor"
17
- require "enfapi"
17
+ require "enfapi/firewall"
18
18
  require "base64"
19
19
  require "digest"
20
20
  require "openssl"
@@ -44,7 +44,8 @@ module EnfCli
44
44
  def list_firewall_rules
45
45
  try_with_rescue_in_session do
46
46
  # call the api
47
- rules = EnfApi::Firewall.instance.list_firewall_rules options[:network]
47
+ data = EnfApi::Firewall.instance.list_firewall_rules options[:network]
48
+ rules = data[:data]
48
49
 
49
50
  # display empty table and return
50
51
  if rules.length == 0
@@ -117,10 +118,12 @@ module EnfCli
117
118
  }
118
119
 
119
120
  # call the api
120
- EnfApi::Firewall.instance.add_firewall_rule options[:network], rule
121
+ data = EnfApi::Firewall.instance.add_firewall_rule options[:network], rule
122
+ rules = data[:data]
121
123
 
122
124
  # print success
123
125
  say "Created firewall rule!", :green
126
+ display_firewall_rules rules
124
127
  end
125
128
  end
126
129
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2018 Xaptum,Inc
2
+ # Copyright 2018-2020 Xaptum,Inc
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module EnfCli
17
- VERSION = "4.1.0-beta"
17
+ VERSION = "5.0.1"
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enfcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0.pre.beta
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Venkatakumar Srinivasan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -243,6 +243,9 @@ files:
243
243
  - enfcli.gemspec
244
244
  - format.sh
245
245
  - lib/enfapi.rb
246
+ - lib/enfapi/dns.rb
247
+ - lib/enfapi/firewall.rb
248
+ - lib/enfapi/user.rb
246
249
  - lib/enfcli.rb
247
250
  - lib/enfcli/commands/captive.rb
248
251
  - lib/enfcli/commands/user.rb
@@ -266,9 +269,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
269
  version: '0'
267
270
  required_rubygems_version: !ruby/object:Gem::Requirement
268
271
  requirements:
269
- - - ">"
272
+ - - ">="
270
273
  - !ruby/object:Gem::Version
271
- version: 1.3.1
274
+ version: '0'
272
275
  requirements: []
273
276
  rubygems_version: 3.0.3
274
277
  signing_key: