antbird 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -11
- data/antbird.gemspec +5 -5
- data/lib/antbird/client.rb +7 -1
- data/lib/antbird/rest_api/rest_api_v6_4.rb +1 -1
- data/lib/antbird/rest_api/rest_api_v6_5.rb +1 -1
- data/lib/antbird/rest_api/rest_api_v6_6.rb +1 -1
- data/lib/antbird/rest_api/rest_api_v6_7.rb +1 -1
- data/lib/antbird/rest_api/rest_api_v6_8.rb +2 -2
- data/lib/antbird/rest_api/{rest_api_v6_2.rb → rest_api_v7_0.rb} +93 -61
- data/lib/antbird/rest_api/{rest_api_v6_3.rb → rest_api_v7_1.rb} +77 -53
- data/lib/antbird/rest_api/rest_api_v7_2.rb +1020 -0
- data/lib/antbird/rest_api/rest_api_v7_3.rb +1012 -0
- data/lib/antbird/rest_api/rest_api_v7_4.rb +1028 -0
- data/lib/antbird/rest_api/rest_api_v7_5.rb +1028 -0
- data/lib/antbird/version.rb +1 -1
- metadata +24 -27
- data/lib/antbird/rest_api/rest_api_v5_1.rb +0 -987
- data/lib/antbird/rest_api/rest_api_v5_5.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v5_6.rb +0 -1020
- data/lib/antbird/rest_api/rest_api_v6_1.rb +0 -972
- data/script/generate_api_methods +0 -48
- data/script/rest_api_template.erb +0 -29
data/script/generate_api_methods
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bundle exec ruby
|
2
|
-
|
3
|
-
require 'octokit'
|
4
|
-
require 'base64'
|
5
|
-
require 'json'
|
6
|
-
require 'yaml'
|
7
|
-
require 'erb'
|
8
|
-
|
9
|
-
class ApiMethodsGenerator
|
10
|
-
def initialize(version)
|
11
|
-
@version = version
|
12
|
-
|
13
|
-
sliced = @version.split(".").slice(0,2)
|
14
|
-
@short_version = sliced.join(".")
|
15
|
-
@class_version = sliced.join("_")
|
16
|
-
end
|
17
|
-
attr_reader :version, :short_version, :class_version
|
18
|
-
|
19
|
-
def run
|
20
|
-
api_spec = fetch_api_spec("v#{version}")
|
21
|
-
File.open("lib/antbird/rest_api/rest_api_v#{class_version}.rb", "w") do |f|
|
22
|
-
f.puts ERB.new(File.read('script/rest_api_template.erb'), 0, "<>").result(binding)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def fetch_api_spec(ref)
|
27
|
-
cache_file = "tmp/api_spec_#{ref}.yml"
|
28
|
-
return YAML.load_file(cache_file) if File.exists?(cache_file)
|
29
|
-
|
30
|
-
client = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
|
31
|
-
files = client.contents('elastic/elasticsearch', path: 'rest-api-spec/src/main/resources/rest-api-spec/api', query: {ref: ref})
|
32
|
-
api_spec = {}
|
33
|
-
files.each do |f|
|
34
|
-
puts f.url
|
35
|
-
file = client.content('elastic/elasticsearch', path: f.path, query: { ref: ref })
|
36
|
-
api_spec[File.basename(file.name)] = JSON.parse(Base64.decode64(file.content))
|
37
|
-
end
|
38
|
-
|
39
|
-
File.open(cache_file, 'w') { |f| f.write(api_spec.to_yaml) }
|
40
|
-
api_spec
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
travis_yaml = YAML.load_file('.travis.yml')
|
45
|
-
versions = travis_yaml['env'].map { |v| v.scan(/ES_VERSION=([\d\.]+)/) }.flatten.uniq
|
46
|
-
versions.each do |version|
|
47
|
-
ApiMethodsGenerator.new(version).run
|
48
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# Generated REST API methods file - DO NOT EDIT!
|
2
|
-
# Date: <%= Time.now.strftime("%Y-%m-%d") %>
|
3
|
-
# ES version: <%= version %>
|
4
|
-
|
5
|
-
module Antbird
|
6
|
-
module RestApi
|
7
|
-
module RestApiV<%= class_version %>
|
8
|
-
def common_params
|
9
|
-
@common_params ||= <%= api_spec['_common.json'] || {} %>
|
10
|
-
end
|
11
|
-
<% api_spec.each do |file_name, file_content| %>
|
12
|
-
<% next if file_name == '_common.json' %>
|
13
|
-
<% file_content.each do |api_name, api_spec| %>
|
14
|
-
|
15
|
-
# <%= api_name %> <%= api_spec['methods'] %>
|
16
|
-
# <%= api_spec['documentation'] %>
|
17
|
-
def <%= api_name.tr('.', '_') %>(params = {})
|
18
|
-
api_name = '<%= api_name %>'
|
19
|
-
api_spec = @api_specs[api_name] ||= <%= api_spec %>
|
20
|
-
request(api_name, api_spec, params)
|
21
|
-
end
|
22
|
-
<% if api_spec['methods'] == ['HEAD'] %>
|
23
|
-
alias :<%= api_name.tr('.', '_') %>? :<%= api_name.tr('.', '_') %>
|
24
|
-
<% end %>
|
25
|
-
<% end # file_content.each %>
|
26
|
-
<% end # api_spec.each %>
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|