Class: Aikido::Client
- Inherits:
-
Object
- Object
- Aikido::Client
- Defined in:
- lib/aikido/client.rb
Overview
HTTP Client to interact with the Aikido API Official documentation: apidocs.aikido.dev/
Instance Method Summary collapse
- #authorize ⇒ Object
- #clouds ⇒ Object
- #code_repositories ⇒ Object
- #code_repository_sbom(id, format: 'csv') ⇒ Object
- #connect_aws_cloud(role_arn:, name:, environment:) ⇒ Object
- #containers ⇒ Object
- #create_team(name:) ⇒ Object
-
#initialize(client_id: nil, client_secret: nil) ⇒ Client
constructor
A new instance of Client.
- #issue(id) ⇒ Object
- #issue_group(id) ⇒ Object
- #issue_groups ⇒ Object
- #issues(options = {}) ⇒ Object
- #teams ⇒ Object
- #update_team(id) ⇒ Object
- #workspace ⇒ Object
Constructor Details
#initialize(client_id: nil, client_secret: nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/aikido/client.rb', line 13 def initialize(client_id: nil, client_secret: nil) @client_id = client_id || ENV.fetch('AIKIDO_CLIENT_ID', nil) @client_secret = client_secret || ENV.fetch('AIKIDO_CLIENT_SECRET', nil) end |
Instance Method Details
#authorize ⇒ Object
18 19 20 21 22 |
# File 'lib/aikido/client.rb', line 18 def handle_response!(http.plugin(:basic_auth) .basic_auth(@client_id, @client_secret) .post('/oauth/token', json: { grant_type: 'client_credentials' })) end |
#clouds ⇒ Object
28 29 30 31 32 |
# File 'lib/aikido/client.rb', line 28 def clouds PaginatedResponse.new do |page| get('/public/v1/clouds', params: { page: page }).json end end |
#code_repositories ⇒ Object
59 60 61 62 63 |
# File 'lib/aikido/client.rb', line 59 def code_repositories PaginatedResponse.new do |page| get('/public/v1/repositories/code', params: { page: page }).json end end |
#code_repository_sbom(id, format: 'csv') ⇒ Object
65 66 67 |
# File 'lib/aikido/client.rb', line 65 def code_repository_sbom(id, format: 'csv') get("/public/v1/repositories/code/#{id.to_i}/licenses/export", params: { format: format }).read end |
#connect_aws_cloud(role_arn:, name:, environment:) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/aikido/client.rb', line 34 def connect_aws_cloud(role_arn:, name:, environment:) handle_response!(authed_http.post('/public/v1/clouds/aws', json: { role_arn: role_arn, name: name, environment: environment })).json end |
#containers ⇒ Object
83 84 85 |
# File 'lib/aikido/client.rb', line 83 def containers get('/public/v1/containers').json end |
#create_team(name:) ⇒ Object
75 76 77 |
# File 'lib/aikido/client.rb', line 75 def create_team(name:) handle_response!(authed_http.post('/public/v1/teams', json: { name: name })).json end |
#issue(id) ⇒ Object
45 46 47 |
# File 'lib/aikido/client.rb', line 45 def issue(id) get("/public/v1/issues/#{id.to_i}").json end |
#issue_group(id) ⇒ Object
55 56 57 |
# File 'lib/aikido/client.rb', line 55 def issue_group(id) get("/public/v1/issues/groups/#{id.to_i}").json end |
#issue_groups ⇒ Object
49 50 51 52 53 |
# File 'lib/aikido/client.rb', line 49 def issue_groups PaginatedResponse.new do |page| get('/public/v1/open-issue-groups', params: { page: page }).json end end |
#issues(options = {}) ⇒ Object
41 42 43 |
# File 'lib/aikido/client.rb', line 41 def issues( = {}) get('/public/v1/issues/export', params: ).json end |
#teams ⇒ Object
69 70 71 72 73 |
# File 'lib/aikido/client.rb', line 69 def teams PaginatedResponse.new do |page| get('/public/v1/teams', params: { page: page }).json end end |
#update_team(id) ⇒ Object
79 80 81 |
# File 'lib/aikido/client.rb', line 79 def update_team(id) raise NotImplementedError end |
#workspace ⇒ Object
24 25 26 |
# File 'lib/aikido/client.rb', line 24 def workspace get('/public/v1/workspace').json end |