antbird 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +2 -1
- data/Guardfile +16 -0
- data/README.md +60 -6
- data/antbird.gemspec +9 -2
- data/bin/console +2 -5
- data/lib/antbird.rb +1 -4
- data/lib/antbird/client.rb +152 -0
- data/lib/antbird/rest_api/rest_api_v5_5.rb +1012 -0
- data/lib/antbird/rest_api/rest_api_v5_6.rb +1020 -0
- data/lib/antbird/rest_api/rest_api_v6_1.rb +972 -0
- data/lib/antbird/rest_api/rest_api_v6_2.rb +980 -0
- data/lib/antbird/version.rb +1 -1
- data/script/generate_api_methods +44 -0
- data/script/rest_api_template.erb +29 -0
- metadata +97 -4
data/lib/antbird/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
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 = '6.2.3')
|
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
|
+
puts ApiMethodsGenerator.new(*ARGV).run
|
@@ -0,0 +1,29 @@
|
|
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
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: antbird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fukayatsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +80,63 @@ dependencies:
|
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '3.0'
|
55
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-nc
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: octokit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.0'
|
139
|
+
description: Nearly auto-generated Elasticsearch client
|
56
140
|
email:
|
57
141
|
- fukayatsu@gmail.com
|
58
142
|
executables: []
|
@@ -64,6 +148,7 @@ files:
|
|
64
148
|
- ".travis.yml"
|
65
149
|
- CODE_OF_CONDUCT.md
|
66
150
|
- Gemfile
|
151
|
+
- Guardfile
|
67
152
|
- LICENSE.txt
|
68
153
|
- README.md
|
69
154
|
- Rakefile
|
@@ -71,7 +156,15 @@ files:
|
|
71
156
|
- bin/console
|
72
157
|
- bin/setup
|
73
158
|
- lib/antbird.rb
|
159
|
+
- lib/antbird/client.rb
|
160
|
+
- lib/antbird/rest_api/rest_api_v5_5.rb
|
161
|
+
- lib/antbird/rest_api/rest_api_v5_6.rb
|
162
|
+
- lib/antbird/rest_api/rest_api_v6_1.rb
|
163
|
+
- lib/antbird/rest_api/rest_api_v6_2.rb
|
74
164
|
- lib/antbird/version.rb
|
165
|
+
- script/generate_api_methods
|
166
|
+
- script/rest_api_template.erb
|
167
|
+
- tmp/.keep
|
75
168
|
homepage: https://github.com/fukayatsu/antbird
|
76
169
|
licenses:
|
77
170
|
- MIT
|
@@ -95,5 +188,5 @@ rubyforge_project:
|
|
95
188
|
rubygems_version: 2.7.3
|
96
189
|
signing_key:
|
97
190
|
specification_version: 4
|
98
|
-
summary:
|
191
|
+
summary: Nearly auto-generated Elasticsearch client
|
99
192
|
test_files: []
|