daino 0.1.0
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 +7 -0
- data/.gitignore +52 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +82 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/daino.gemspec +33 -0
- data/lib/daino.rb +15 -0
- data/lib/daino/api.rb +19 -0
- data/lib/daino/clients/analyzer.rb +49 -0
- data/lib/daino/clients/base.rb +105 -0
- data/lib/daino/clients/job.rb +31 -0
- data/lib/daino/clients/organization.rb +32 -0
- data/lib/daino/clients/user.rb +30 -0
- data/lib/daino/version.rb +5 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 88c21305b34d0d8c669770ec9ba40497f3c6cf18ad5fe21591ca8ffeda527051
|
4
|
+
data.tar.gz: 4fe7cc4fe0fd24ebeff6d76b22a4dd1b6c58766b8e5ceff95faa69ed365aff81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f154a40263dea68fbe8623d4c8795d3f0230de7f98c53b794e41504df5041b916cee5067b5b9f2f8c6b82ea95e944e76bc4cc27e8d766732b82368f5fd60072
|
7
|
+
data.tar.gz: 1d402c74e4ceced9bbc6638a2c0ed1f9d7eaae683a74d631687ab7c97e77affe400094343a4ce6978fccc89dcf9301c1a22f3c869b1b25e2cd5d9aaf93d07dac
|
data/.gitignore
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
Gemfile.lock
|
46
|
+
.ruby-version
|
47
|
+
.ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
.rspec_status
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Manabu Niseki
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# daino
|
2
|
+
|
3
|
+
[](https://travis-ci.org/ninoseki/daino)
|
4
|
+
[](https://coveralls.io/github/ninoseki/daino?branch=master)
|
5
|
+
|
6
|
+
daino(`大脳`) is a dead simple [Cortex](https://github.com/TheHive-Project/Cortex) API wrapper for Ruby.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```bash
|
11
|
+
gem install daino
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require "daino"
|
18
|
+
|
19
|
+
# when given nothing, it tries to load your API key from ENV["CORTEX_API_KEY"] & API endpoint from ENV["CORTEX_API_ENDPOINT"]
|
20
|
+
api = Daino::API.new
|
21
|
+
# or you can set them manually
|
22
|
+
api = Daino::API.new(api_endpoint: "http://your_api_endpoint", api_key: "yoru_api_key")
|
23
|
+
|
24
|
+
# search jobs
|
25
|
+
jobs = api.job.search(data: "1.1.1.1", data_type: "ip")
|
26
|
+
|
27
|
+
jobs.each do |job|
|
28
|
+
id = job.dig("id")
|
29
|
+
next unless id
|
30
|
+
|
31
|
+
# get a report of a job
|
32
|
+
report = api.job.report(id)
|
33
|
+
puts JSON.pretty_generate(report)
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Implemented methods
|
38
|
+
|
39
|
+
### Analyzer
|
40
|
+
|
41
|
+
| HTTP Method | URI | Action | API method |
|
42
|
+
|-------------|-------------------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
43
|
+
| GET | /api/analyzer | List analyzers | `#api.analyzer.list` |
|
44
|
+
| POST | /api/analyzer/_search | Search analyzers | `#api.analyzer.search(attributes)` |
|
45
|
+
| GET | /api/analyzer/:analyzerId | Get an analyzer | `#api.analyzer.get_by_id(id)` |
|
46
|
+
| GET | /api/analyzer/:analyzerId | Get an analyzer | `#api.analyzer.get_by_id(id)` or `#api.analyzer.get_by_name(name)` |
|
47
|
+
| GET | /api/analyzer/type/:dataType | Get analyzers by type | `#api.analyzer.get_by_type(type)` |
|
48
|
+
| POST | /api/analyzer/:analyzerId/run | Run an analyzer | `#api.analyzer.run_by_id(id, data:, data_type:, tlp: 0, message: nil, parameters: nil, force: nil)` or `#api.analyzer.run_by_name(name, data:, data_type:, tlp: 0, message: nil, parameters: nil, force: nil)` |
|
49
|
+
|
50
|
+
### Job
|
51
|
+
|
52
|
+
| HTTP Method | URI | Action | API method |
|
53
|
+
|-------------|---------------------------|------------------------|---------------------------------|
|
54
|
+
| POST | /api/job/_search | Search jobs | `#api.job.search(range: "all")` |
|
55
|
+
| GET | /api/job/:jobId | Get a job by id | `#api.job.get_by_id(id)` |
|
56
|
+
| GET | /api/job/:jobId/report | Get a report of a job | `#api.job.report(id)` |
|
57
|
+
| GET | /api/job/:jobID/artifacts | Get artifacts of a job | `#api.job.artifacts(id)` |
|
58
|
+
| DELETE | /api/job/:jobId | Delete a job | `#api.job.delete_by_id(id)` |
|
59
|
+
|
60
|
+
### Organization
|
61
|
+
|
62
|
+
| HTTP Method | URI | Action | API method |
|
63
|
+
|-------------|----------------------------------------|------------------------------|-------------------------------------------------------------------|
|
64
|
+
| GET | /api/organization | List organizations | `#api.organization.list` |
|
65
|
+
| POST | /api/organization/_search | Search organizations | `#api.organization.search(attributes)` |
|
66
|
+
| GET | /api/organization/:organizationId | Get an organization | `#api.organization.get_by_id(id)` |
|
67
|
+
| GET | /api/organization/:organizationId/user | Get users of an organization | `#api.organization.users(id)` |
|
68
|
+
| POST | /api/organization | Create an organization | `#api.organization.create(name:, description:, status: "Active")` |
|
69
|
+
| DELETE | /api/organization/:organizationId | Delete an organization | `#api.organization.delete_by_id(id)` |
|
70
|
+
|
71
|
+
### User
|
72
|
+
|
73
|
+
| HTTP Method | URI | Action | API method |
|
74
|
+
|-------------|---------------------|---------------|------------------------------------------------------------------------|
|
75
|
+
| GET | /api/user | List users | `#api.user.list` |
|
76
|
+
| POST | /api/user/_search | Search users | `#api.user.search(attributes)` |
|
77
|
+
| GET | /api/user/:userName | Get a user | `#api.user.get_by_name(name)` |
|
78
|
+
| POST | /api/user | Create a user | `#api.user.create(name:, roles:, organization:, login:, status: "Ok")` |
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "daino"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/daino.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "daino/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "daino"
|
9
|
+
spec.version = Daino::VERSION
|
10
|
+
spec.authors = ["Manabu Niseki"]
|
11
|
+
spec.email = ["manabu.niseki@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = "A dead simple Cortex API wrapper for Ruby."
|
14
|
+
spec.description = "A dead simple Cortex API wrapper for Ruby."
|
15
|
+
spec.homepage = "https://github.com/ninoseki/daino"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
+
spec.add_development_dependency "coveralls", "~> 0.8"
|
29
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.8"
|
31
|
+
spec.add_development_dependency "vcr", "~> 5.0"
|
32
|
+
spec.add_development_dependency "webmock", "~> 3.6"
|
33
|
+
end
|
data/lib/daino.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "daino/version"
|
4
|
+
|
5
|
+
require "daino/clients/base"
|
6
|
+
require "daino/clients/job"
|
7
|
+
require "daino/clients/analyzer"
|
8
|
+
require "daino/clients/organization"
|
9
|
+
require "daino/clients/user"
|
10
|
+
|
11
|
+
require "daino/api"
|
12
|
+
|
13
|
+
module Daino
|
14
|
+
class Error < StandardError; end
|
15
|
+
end
|
data/lib/daino/api.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Daino
|
4
|
+
class API
|
5
|
+
attr_reader :job
|
6
|
+
attr_reader :analyzer
|
7
|
+
attr_reader :organization
|
8
|
+
|
9
|
+
def initialize(api_endpoint: ENV["CORTEX_API_ENDPOINT"], api_key: ENV["CORTEX_API_KEY"])
|
10
|
+
raise(ArgumentError, "api_endpoint argument is required") unless api_endpoint
|
11
|
+
raise(ArgumentError, "api_key argument is required") unless api_key
|
12
|
+
|
13
|
+
@job = Clients::Job.new(api_endpoint: api_endpoint, api_key: api_key)
|
14
|
+
@analyzer = Clients::Analyzer.new(api_endpoint: api_endpoint, api_key: api_key)
|
15
|
+
@organization = Clients::Organization.new(api_endpoint: api_endpoint, api_key: api_key)
|
16
|
+
@user = Clients::User.new(api_endpoint: api_endpoint, api_key: api_key)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Daino
|
4
|
+
module Clients
|
5
|
+
class Analyzer < Base
|
6
|
+
def list
|
7
|
+
get("/api/analyzer") { |json| json }
|
8
|
+
end
|
9
|
+
|
10
|
+
def search(attributes)
|
11
|
+
post("/api/analyzer/_search", query: attributes) { |json| json }
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_by_id(id)
|
15
|
+
get("/api/analyzer/#{id}") { |json| json }
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_by_name(name)
|
19
|
+
search(name: name)&.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_by_type(type)
|
23
|
+
get("/api/analyzer/type/#{type}") { |json| json }
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_by_id(id, data:, data_type:, tlp: 0, message: nil, parameters: nil, force: nil)
|
27
|
+
payload = {
|
28
|
+
data: data,
|
29
|
+
dataType: data_type,
|
30
|
+
tlp: tlp,
|
31
|
+
message: message,
|
32
|
+
parameters: parameters
|
33
|
+
}.compact
|
34
|
+
|
35
|
+
options = force.nil? ? {} : { force: force }
|
36
|
+
|
37
|
+
post("/api/analyzer/#{id}/run", payload, options) { |json| json }
|
38
|
+
end
|
39
|
+
|
40
|
+
def run_by_name(name, data:, data_type:, tlp: 0, message: nil, parameters: nil, force: nil)
|
41
|
+
analyzer = get_by_name(name)
|
42
|
+
raise ArgumentError, "#{name} does not exist." unless analyzer
|
43
|
+
|
44
|
+
id = analyzer.dig("id")
|
45
|
+
run_by_id(id, data: data, data_type: data_type, tlp: tlp, message: message, parameters: parameters, force: force)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "net/https"
|
5
|
+
|
6
|
+
module Daino
|
7
|
+
module Clients
|
8
|
+
class Base
|
9
|
+
attr_reader :api_endpoint
|
10
|
+
attr_reader :api_key
|
11
|
+
|
12
|
+
def initialize(api_endpoint:, api_key:)
|
13
|
+
@api_endpoint = URI(api_endpoint)
|
14
|
+
@api_key = api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def base_url
|
20
|
+
"#{api_endpoint.scheme}://#{api_endpoint.hostname}:#{api_endpoint.port}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def url_for(path)
|
24
|
+
URI(base_url + path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def https_options
|
28
|
+
return nil if api_endpoint.scheme != "https"
|
29
|
+
|
30
|
+
if proxy = ENV["HTTPS_PROXY"] || ENV["https_proxy"]
|
31
|
+
uri = URI(proxy)
|
32
|
+
{
|
33
|
+
proxy_address: uri.hostname,
|
34
|
+
proxy_port: uri.port,
|
35
|
+
proxy_from_env: false,
|
36
|
+
use_ssl: true,
|
37
|
+
}
|
38
|
+
else
|
39
|
+
{ use_ssl: true }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def http_options
|
44
|
+
if proxy = ENV["HTTP_PROXY"] || ENV["http_proxy"]
|
45
|
+
uri = URI(proxy)
|
46
|
+
{
|
47
|
+
proxy_address: uri.hostname,
|
48
|
+
proxy_port: uri.port,
|
49
|
+
proxy_from_env: false,
|
50
|
+
}
|
51
|
+
else
|
52
|
+
{}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_body(body)
|
57
|
+
JSON.parse body.to_s
|
58
|
+
rescue JSON::ParserError => _e
|
59
|
+
body.to_s
|
60
|
+
end
|
61
|
+
|
62
|
+
def request(req)
|
63
|
+
Net::HTTP.start(api_endpoint.hostname, api_endpoint.port, https_options || http_options) do |http|
|
64
|
+
response = http.request(req)
|
65
|
+
json = parse_body(response.body)
|
66
|
+
|
67
|
+
raise(Error, "Unsupported response code returned: #{response.code} (#{json&.dig('message')})") unless response.code.start_with? "20"
|
68
|
+
|
69
|
+
yield json
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def get(path, params = {}, &block)
|
74
|
+
url = url_for(path)
|
75
|
+
url.query = URI.encode_www_form(params) unless params.empty?
|
76
|
+
|
77
|
+
get = Net::HTTP::Get.new(url)
|
78
|
+
get.add_field "Authorization", "Bearer #{api_key}"
|
79
|
+
request(get, &block)
|
80
|
+
end
|
81
|
+
|
82
|
+
def post(path, data, params = {}, &block)
|
83
|
+
url = url_for(path)
|
84
|
+
url.query = URI.encode_www_form(params) unless params.empty?
|
85
|
+
|
86
|
+
post = Net::HTTP::Post.new(url)
|
87
|
+
post.body = data.is_a?(Hash) ? data.to_json : data.to_s
|
88
|
+
|
89
|
+
post.add_field "Content-Type", "application/json"
|
90
|
+
post.add_field "Authorization", "Bearer #{api_key}"
|
91
|
+
|
92
|
+
request(post, &block)
|
93
|
+
end
|
94
|
+
|
95
|
+
def delete(path, params = {}, &block)
|
96
|
+
url = url_for(path)
|
97
|
+
url.query = URI.encode_www_form(params) unless params.empty?
|
98
|
+
|
99
|
+
delete = Net::HTTP::Delete.new(url)
|
100
|
+
delete.add_field "Authorization", "Bearer #{api_key}"
|
101
|
+
request(delete, &block)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Daino
|
4
|
+
module Clients
|
5
|
+
class Job < Base
|
6
|
+
def list(range: "all")
|
7
|
+
search({}, range: range)
|
8
|
+
end
|
9
|
+
|
10
|
+
def search(attributes, range: "all")
|
11
|
+
post("/api/job/_search", attributes, range: range) { |json| json }
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_by_id(id)
|
15
|
+
get("/api/job/#{id}") { |json| json }
|
16
|
+
end
|
17
|
+
|
18
|
+
def report(id)
|
19
|
+
get("/api/job/#{id}/report") { |json| json }
|
20
|
+
end
|
21
|
+
|
22
|
+
def artifacts(id)
|
23
|
+
get("/api/job/#{id}/artifacts") { |json| json }
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_by_id(id)
|
27
|
+
delete("/api/job/#{id}") { |json| json }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Daino
|
4
|
+
module Clients
|
5
|
+
class Organization < Base
|
6
|
+
def list
|
7
|
+
get("/api/organization") { |json| json }
|
8
|
+
end
|
9
|
+
|
10
|
+
def search(attributes)
|
11
|
+
post("/api/organization/_search", query: attributes) { |json| json }
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_by_id(id)
|
15
|
+
get("/api/organization/#{id}") { |json| json }
|
16
|
+
end
|
17
|
+
|
18
|
+
def users(id)
|
19
|
+
get("/api/organization/#{id}/user") { |json| json }
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(name:, description:, status: "Active")
|
23
|
+
payload = { name: name, description: description, status: status }
|
24
|
+
post("/api/organization", payload) { |json| json }
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete_by_id(id)
|
28
|
+
delete("/api/organization/#{id}") { |res| res }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Daino
|
4
|
+
module Clients
|
5
|
+
class User < Base
|
6
|
+
def list
|
7
|
+
get("/api/user") { |json| json }
|
8
|
+
end
|
9
|
+
|
10
|
+
def search(attributes)
|
11
|
+
post("/api/user/_search", query: attributes) { |json| json }
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_by_name(name)
|
15
|
+
get("/api/user/#{name}") { |json| json }
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(name:, roles:, organization:, login:, status: "Ok")
|
19
|
+
payload = {
|
20
|
+
name: name,
|
21
|
+
roles: roles,
|
22
|
+
organization: organization,
|
23
|
+
login: login,
|
24
|
+
status: status
|
25
|
+
}
|
26
|
+
post("/api/user", payload) { |json| json }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: daino
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manabu Niseki
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coveralls
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.6'
|
97
|
+
description: A dead simple Cortex API wrapper for Ruby.
|
98
|
+
email:
|
99
|
+
- manabu.niseki@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- daino.gemspec
|
114
|
+
- lib/daino.rb
|
115
|
+
- lib/daino/api.rb
|
116
|
+
- lib/daino/clients/analyzer.rb
|
117
|
+
- lib/daino/clients/base.rb
|
118
|
+
- lib/daino/clients/job.rb
|
119
|
+
- lib/daino/clients/organization.rb
|
120
|
+
- lib/daino/clients/user.rb
|
121
|
+
- lib/daino/version.rb
|
122
|
+
homepage: https://github.com/ninoseki/daino
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubygems_version: 3.0.2
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: A dead simple Cortex API wrapper for Ruby.
|
145
|
+
test_files: []
|