aikido-ruby-client 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/exe/aikido +7 -2
- data/lib/aikido/client.rb +31 -3
- data/lib/aikido/context.rb +28 -0
- data/lib/aikido/errors.rb +8 -3
- data/lib/aikido/version.rb +1 -1
- data/lib/aikido-ruby-client.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d270cfc87dd0e7cfbd288c3902cc602030c8c55001f60c9bf3c6af44d354be8d
|
4
|
+
data.tar.gz: c792ec85c9a4b0cd57bf2e858b560e504ae0c10365c60a50038621151ebb6715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54553c34d78e5277062e839656225363e8184f04b373303240e680e87f48eba7bc3217c1f4e8c23163377446ad2e1490aaf348e6571405a40019e44c376f29a1
|
7
|
+
data.tar.gz: 2a29da55b4608fc9df5697b5de1ec016ca4837a10a138ac6032c85e2ae65ff1f1fcea819664932da814583ddc253eda8fc88b1a48a6600c3529877307128064b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.0.4](https://github.com/anakinj/aikido-ruby-client/tree/v0.0.4) (2024-04-2)
|
4
|
+
|
5
|
+
** Fixes: **
|
6
|
+
- Require the version for the client to work when released
|
7
|
+
- Match external repo id as strings
|
8
|
+
|
9
|
+
## [v0.0.3](https://github.com/anakinj/aikido-ruby-client/tree/v0.0.3) (2024-03-10)
|
10
|
+
|
11
|
+
**Features:**
|
12
|
+
|
13
|
+
- Support for even more endpoints
|
14
|
+
|
3
15
|
## [v0.0.2](https://github.com/anakinj/aikido-ruby-client/tree/v0.0.2) (2024-03-10)
|
4
16
|
|
5
17
|
**Features:**
|
data/exe/aikido
CHANGED
@@ -5,5 +5,10 @@ require 'aikido-ruby-client'
|
|
5
5
|
|
6
6
|
client = Aikido::Client.new
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
result = client.public_send(ARGV[0], *ARGV[1..-1])
|
9
|
+
|
10
|
+
if result.is_a?(Aikido::PaginatedResponse)
|
11
|
+
puts result.to_a
|
12
|
+
else
|
13
|
+
puts result
|
14
|
+
end
|
data/lib/aikido/client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'httpx'
|
4
4
|
|
5
|
+
require_relative 'version'
|
5
6
|
require_relative 'errors'
|
6
7
|
require_relative 'paginated_response'
|
7
8
|
|
@@ -30,8 +31,15 @@ module Aikido
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
-
|
34
|
+
def connect_aws_cloud(role_arn:, name:, environment:)
|
35
|
+
handle_response!(authed_http.post('/public/v1/clouds/aws',
|
36
|
+
json: { role_arn: role_arn,
|
37
|
+
name: name,
|
38
|
+
environment: environment })).json
|
39
|
+
end
|
40
|
+
|
41
|
+
def issues(options = {})
|
42
|
+
get('/public/v1/issues/export', params: options).json
|
35
43
|
end
|
36
44
|
|
37
45
|
def issue(id)
|
@@ -55,7 +63,25 @@ module Aikido
|
|
55
63
|
end
|
56
64
|
|
57
65
|
def code_repository_sbom(id, format: 'csv')
|
58
|
-
get("repositories/code/#{id.to_i}/licenses/export", params: { format: format }).
|
66
|
+
get("/public/v1/repositories/code/#{id.to_i}/licenses/export", params: { format: format }).read
|
67
|
+
end
|
68
|
+
|
69
|
+
def teams
|
70
|
+
PaginatedResponse.new do |page|
|
71
|
+
get('/public/v1/teams', params: { page: page }).json
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_team(name:)
|
76
|
+
handle_response!(authed_http.post('/public/v1/teams', json: { name: name })).json
|
77
|
+
end
|
78
|
+
|
79
|
+
def update_team(id)
|
80
|
+
raise NotImplementedError
|
81
|
+
end
|
82
|
+
|
83
|
+
def containers
|
84
|
+
get('/public/v1/containers').json
|
59
85
|
end
|
60
86
|
|
61
87
|
private
|
@@ -92,6 +118,8 @@ module Aikido
|
|
92
118
|
|
93
119
|
def raise_response_error!(response)
|
94
120
|
case response.status
|
121
|
+
when 400
|
122
|
+
raise Errors::BadRequestError, response
|
95
123
|
when 401
|
96
124
|
raise Errors::UnauthorizedError, response
|
97
125
|
else
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aikido
|
4
|
+
# Represents a context for interacting with the Aikido API
|
5
|
+
# Context will store data in memory for further processing
|
6
|
+
class Context
|
7
|
+
def initialize(client: nil)
|
8
|
+
@client = client || Aikido::Client.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def issues_for_code_repository(external_repo_id:)
|
12
|
+
repo = code_repositories.find { |r| r['external_repo_id'].to_s == external_repo_id.to_s }
|
13
|
+
return [] unless repo
|
14
|
+
|
15
|
+
issues.select do |issue|
|
16
|
+
issue['code_repo_id'] == repo['id']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def code_repositories
|
21
|
+
@code_repositories ||= @client.code_repositories
|
22
|
+
end
|
23
|
+
|
24
|
+
def issues
|
25
|
+
@issues ||= @client.issues
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/aikido/errors.rb
CHANGED
@@ -12,14 +12,19 @@ module Aikido
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def message
|
15
|
-
|
16
|
-
|
15
|
+
json = @response.json
|
16
|
+
if json.key?('error_description')
|
17
|
+
"#{super} - #{json['error_description']}"
|
18
|
+
elsif json.key?('reason_phrase')
|
19
|
+
"#{super} - #{json['reason_phrase']}"
|
17
20
|
else
|
18
21
|
super
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
25
|
+
|
26
|
+
BadRequestError = Class.new(ApiError)
|
22
27
|
UnauthorizedError = Class.new(ApiError)
|
23
|
-
NotFoundError
|
28
|
+
NotFoundError = Class.new(ApiError)
|
24
29
|
end
|
25
30
|
end
|
data/lib/aikido/version.rb
CHANGED
data/lib/aikido-ruby-client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aikido-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Antman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpx
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- exe/aikido
|
42
42
|
- lib/aikido-ruby-client.rb
|
43
43
|
- lib/aikido/client.rb
|
44
|
+
- lib/aikido/context.rb
|
44
45
|
- lib/aikido/errors.rb
|
45
46
|
- lib/aikido/paginated_response.rb
|
46
47
|
- lib/aikido/version.rb
|
@@ -49,8 +50,8 @@ licenses:
|
|
49
50
|
- MIT
|
50
51
|
metadata:
|
51
52
|
homepage_uri: https://github.com/anakinj/aikido-ruby-client
|
52
|
-
source_code_uri: https://github.com/anakinj
|
53
|
-
changelog_uri: https://github.com/anakinj/
|
53
|
+
source_code_uri: https://github.com/anakinj/aikido-ruby-client
|
54
|
+
changelog_uri: https://github.com/anakinj/aikido-ruby-client/blob/0.0.4/CHANGELOG.md
|
54
55
|
rubygems_mfa_required: 'true'
|
55
56
|
post_install_message:
|
56
57
|
rdoc_options: []
|