fastlyctl 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2ae1f51d01ae7427213464df500005c82a6f7e88539189b4ac930a4251c5334
4
- data.tar.gz: 487ee8363712ca396b5c02b1305000a0136336227ec18bc2531bc706123e7f93
3
+ metadata.gz: 987113b9085a2a49c56a460d19ca8dd4d865627cf54a479b1969cdcfb6038ade
4
+ data.tar.gz: 85b785765d0343e55335146d6ad7db9629ccfb58c3323620e22287d403594de5
5
5
  SHA512:
6
- metadata.gz: 15a29375aced1dc02313e6aef32539200529b64414b3812588bed4b74f0c55746bf5f8c1a9a0136e2d3d57a10e3eac091f02bc42cabf72921499517474c8fe70
7
- data.tar.gz: fc607eed5bbbba636be71737750e4a5cdb6cd1fd108df8cac3c7f02bac73394b2430d3b7b594e95811c4e6f4e4cc478c6e8093180dc32e51f8c6fca81ca9e720
6
+ metadata.gz: cbf7e09910fdfb6de30cca198e65f650577c953f1d67e4732ae10f94908de697a0e2a22b90e94b3e25a947f2fbd42c8507b6a666fb57a1ffd20c4e63209ab2cb
7
+ data.tar.gz: 779371688739cd0900402a39d506b06c8bad7e902097444a062fa58404a435bd7f4718c17f4601793e1da83b0ace1d7f8acbfef6fa4e08efcc77be27fcacb9d1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fastlyctl (1.0.13)
4
+ fastlyctl (1.0.14)
5
5
  diffy (~> 3.2.1)
6
6
  launchy (~> 2.4.3, >= 2.4.3)
7
7
  thor (~> 0.19.4)
data/lib/fastlyctl/cli.rb CHANGED
@@ -16,6 +16,7 @@ require "fastlyctl/commands/snippet"
16
16
  require "fastlyctl/commands/acl"
17
17
  require "fastlyctl/commands/copy"
18
18
  require "fastlyctl/commands/logging"
19
+ require "fastlyctl/commands/condition"
19
20
 
20
21
 
21
22
  module FastlyCTL
@@ -0,0 +1,92 @@
1
+ module FastlyCTL
2
+ class CLI < Thor
3
+ desc "condition ACTION NAME", "Manipulate conditions on a service. Available actions are create, delete, update, show and list. NAME parameter not required for list ACTION"
4
+ method_option :service, :aliases => ["--s"]
5
+ method_option :version, :aliases => ["--v"]
6
+ method_option :type, :aliases => ["--t"]
7
+ method_option :yes, :aliases => ["--y"]
8
+ method_option :priority, :aliases => ["--p"]
9
+ method_option :statement, :aliases => ["--st"]
10
+ method_option :comment, :aliases => ["--c"]
11
+
12
+ def self.print_condition_header
13
+ puts
14
+ puts "Name".ljust(40) + " | " + "Priority".ljust(8) + " | " + "Type".ljust(10) + " | " + "Statement".ljust(20)
15
+ puts "-------------------------------------------------------------------------------------------------------"
16
+ end
17
+
18
+ def self.print_conditions(conditions)
19
+ self.print_condition_header
20
+
21
+ conditions.each { |c|
22
+ puts "%s | %s | %s | %s " % [c["name"].ljust(40), c["priority"].ljust(8), c["type"].ljust(10), c["statement"].ljust(20)]
23
+ }
24
+ end
25
+
26
+ def condition(action,name=false)
27
+ id = FastlyCTL::Utils.parse_directory unless options[:service]
28
+ id ||= options[:service]
29
+
30
+ abort "Could not parse service id from directory. Use --s <service> to specify, vcl download, then try again." unless id
31
+
32
+ version = FastlyCTL::Fetcher.get_writable_version(id) unless options[:version]
33
+ version ||= options[:version].to_i
34
+
35
+ encoded_name = URI.escape(name) if name
36
+
37
+ case action
38
+ when "list"
39
+ conditions = FastlyCTL::Fetcher.api_request(:get,"/service/#{id}/version/#{version}/condition")
40
+ CLI.print_conditions(conditions)
41
+
42
+ when "create"
43
+ abort "Must supply a condition name as second parameter" unless name
44
+ abort "Must supply a statement to create a condition" unless options[:statement]
45
+
46
+ params = {}
47
+ params[:name] = name
48
+ params[:statement] = options[:statement]
49
+
50
+ params[:priority] = options[:priority] if options.key?(:priority)
51
+ params[:type] = options[:type] if options.key?(:type)
52
+ params[:comment] = options[:comment] if options.key?(:comment)
53
+
54
+ FastlyCTL::Fetcher.api_request(:post,"/service/#{id}/version/#{version}/condition",{
55
+ params: params
56
+ })
57
+ say("Condition #{name} created on #{id} version #{version}")
58
+
59
+ when "update"
60
+ abort "Must supply a condition name as second parameter" unless name
61
+
62
+ if options.key?(:type)
63
+ puts "WARNING: Can not change the TYPE of a condition, you must delete and re-create, type parameter is ignored in update method.\n"
64
+ end
65
+
66
+ params = {}
67
+ params[:statement] = options[:statement] if options.key?(:statement)
68
+ params[:priority] = options[:priority] if options.key?(:priority)
69
+ params[:comment] = options[:comment] if options.key?(:comment)
70
+
71
+ FastlyCTL::Fetcher.api_request(:put,"/service/#{id}/version/#{version}/condition/#{encoded_name}",{
72
+ params: params
73
+ })
74
+ say("Condition #{name} updated on #{id} version #{version}")
75
+
76
+ when "show"
77
+ abort "Must supply a condition name as second parameter" unless name
78
+
79
+ c = FastlyCTL::Fetcher.api_request(:get,"/service/#{id}/version/#{version}/condition/#{encoded_name}")
80
+ CLI.print_conditions([c])
81
+
82
+ when "delete"
83
+ abort "Must supply a condition name as second parameter" unless name
84
+
85
+ c = FastlyCTL::Fetcher.api_request(:delete,"/service/#{id}/version/#{version}/condition/#{encoded_name}")
86
+ say("Condition #{name} deleted on #{id} version #{version}")
87
+
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -1,3 +1,3 @@
1
1
  module FastlyCTL
2
- VERSION = "1.0.13"
2
+ VERSION = "1.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlyctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Basile
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -97,6 +97,7 @@ files:
97
97
  - lib/fastlyctl/commands/acl.rb
98
98
  - lib/fastlyctl/commands/activate.rb
99
99
  - lib/fastlyctl/commands/clone.rb
100
+ - lib/fastlyctl/commands/condition.rb
100
101
  - lib/fastlyctl/commands/copy.rb
101
102
  - lib/fastlyctl/commands/create_service.rb
102
103
  - lib/fastlyctl/commands/dictionary.rb