aikido-ruby-client 0.0.2 → 0.0.3
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/CHANGELOG.md +6 -0
- data/exe/aikido +7 -2
- data/lib/aikido/client.rb +30 -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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6692ba6b0f697d0f69b840a95e96cbbca656863ed9c71af7c48fc2634678a659
|
4
|
+
data.tar.gz: 9997f0daca4a3e133a3d5e3c041f8ddf66bd6af56521d18d6c8bfbffbc323b40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5597d2ddd0e6a518a078e6fa6d2b55e3c01a022ffadbb018fe76423f761f9c4381a4dc06bc647866b8bea5ea21cdb8230811c0e71cc60f9ef46e78ed2d4057c3
|
7
|
+
data.tar.gz: d1659f8a75fe77dbd4e60f8b74884b3354458c520482531b49d7b10e014ca1ccbbc8958743686814a5bc075ecbf03b176bb321055df6bc12145651e6aa5dae40
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.0.3](https://github.com/anakinj/aikido-ruby-client/tree/v0.0.3) (2024-03-10)
|
4
|
+
|
5
|
+
**Features:**
|
6
|
+
|
7
|
+
- Support for even more endpoints
|
8
|
+
|
3
9
|
## [v0.0.2](https://github.com/anakinj/aikido-ruby-client/tree/v0.0.2) (2024-03-10)
|
4
10
|
|
5
11
|
**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
@@ -30,8 +30,15 @@ module Aikido
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
|
33
|
+
def connect_aws_cloud(role_arn:, name:, environment:)
|
34
|
+
handle_response!(authed_http.post('/public/v1/clouds/aws',
|
35
|
+
json: { role_arn: role_arn,
|
36
|
+
name: name,
|
37
|
+
environment: environment })).json
|
38
|
+
end
|
39
|
+
|
40
|
+
def issues(options = {})
|
41
|
+
get('/public/v1/issues/export', params: options).json
|
35
42
|
end
|
36
43
|
|
37
44
|
def issue(id)
|
@@ -55,7 +62,25 @@ module Aikido
|
|
55
62
|
end
|
56
63
|
|
57
64
|
def code_repository_sbom(id, format: 'csv')
|
58
|
-
get("repositories/code/#{id.to_i}/licenses/export", params: { format: format }).
|
65
|
+
get("/public/v1/repositories/code/#{id.to_i}/licenses/export", params: { format: format }).read
|
66
|
+
end
|
67
|
+
|
68
|
+
def teams
|
69
|
+
PaginatedResponse.new do |page|
|
70
|
+
get('/public/v1/teams', params: { page: page }).json
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_team(name:)
|
75
|
+
handle_response!(authed_http.post('/public/v1/teams', json: { name: name })).json
|
76
|
+
end
|
77
|
+
|
78
|
+
def update_team(id)
|
79
|
+
raise NotImplementedError
|
80
|
+
end
|
81
|
+
|
82
|
+
def containers
|
83
|
+
get('/public/v1/containers').json
|
59
84
|
end
|
60
85
|
|
61
86
|
private
|
@@ -92,6 +117,8 @@ module Aikido
|
|
92
117
|
|
93
118
|
def raise_response_error!(response)
|
94
119
|
case response.status
|
120
|
+
when 400
|
121
|
+
raise Errors::BadRequestError, response
|
95
122
|
when 401
|
96
123
|
raise Errors::UnauthorizedError, response
|
97
124
|
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'] == external_repo_id }
|
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,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Antman
|
@@ -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
|
@@ -50,7 +51,7 @@ licenses:
|
|
50
51
|
metadata:
|
51
52
|
homepage_uri: https://github.com/anakinj/aikido-ruby-client
|
52
53
|
source_code_uri: https://github.com/anakinj
|
53
|
-
changelog_uri: https://github.com/anakinj/jwk-loader/blob/0.0.
|
54
|
+
changelog_uri: https://github.com/anakinj/jwk-loader/blob/0.0.3/CHANGELOG.md
|
54
55
|
rubygems_mfa_required: 'true'
|
55
56
|
post_install_message:
|
56
57
|
rdoc_options: []
|