fastlyctl 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fastlyctl/cli.rb +1 -0
- data/lib/fastlyctl/commands/condition.rb +92 -0
- data/lib/fastlyctl/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987113b9085a2a49c56a460d19ca8dd4d865627cf54a479b1969cdcfb6038ade
|
4
|
+
data.tar.gz: 85b785765d0343e55335146d6ad7db9629ccfb58c3323620e22287d403594de5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf7e09910fdfb6de30cca198e65f650577c953f1d67e4732ae10f94908de697a0e2a22b90e94b3e25a947f2fbd42c8507b6a666fb57a1ffd20c4e63209ab2cb
|
7
|
+
data.tar.gz: 779371688739cd0900402a39d506b06c8bad7e902097444a062fa58404a435bd7f4718c17f4601793e1da83b0ace1d7f8acbfef6fa4e08efcc77be27fcacb9d1
|
data/Gemfile.lock
CHANGED
data/lib/fastlyctl/cli.rb
CHANGED
@@ -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
|
data/lib/fastlyctl/version.rb
CHANGED
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.
|
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-
|
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
|