aikido-ruby-client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e1aff36ac4f8ac9f17a073b5acfead422df83829a80e7f6f7ec3a8d68426214d
4
+ data.tar.gz: 7a84efa160d1e3701ab301d04a71eb967f24e7cda172c9b34f60c34bd277e467
5
+ SHA512:
6
+ metadata.gz: 5250c5726c5920423b88b31c982a792251fca565fca0996bee526a1e222e6dc38c27074482e93fa8752ef7a09ca89588e00f996bb4f85f3baf8369d884fc98bf
7
+ data.tar.gz: f74ecf9b1df49a4e84608ed68900ded1dfa8b672e8a00cbdd5d762214bf670be3ba6117d60a21dc44a8bc5792d42498d4a574c19a4e2d18ce715a72c296e50b9
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
4
+
5
+ Naming/FileName:
6
+ Exclude:
7
+ - 'lib/aikido-ruby-client.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## [v0.0.1](https://github.com/anakinj/aikido-ruby-client/tree/v0.0.1) (2024-03-10)
4
+
5
+ **Features:**
6
+
7
+ - Simple issue listing and fetching
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 TODO: Write your name
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # aikido-ruby-client
2
+
3
+ Ruby client for interacting with the Aikido HTTP api.
4
+
5
+ ## Usage
6
+
7
+ Instructions pending...
8
+
9
+ ## Development
10
+
11
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
12
+
13
+ ## Contributing
14
+
15
+ Bug reports and pull requests are welcome on GitHub at https://github.com/anakinj/aikido-ruby-client.
16
+
17
+ ## License
18
+
19
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: %i[]
data/exe/aikido ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'aikido-ruby-client'
5
+
6
+ client = Aikido::Client.new
7
+
8
+ puts client.issues
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httpx'
4
+
5
+ module Aikido
6
+ # HTTP Client to interact with the Aikido API
7
+ # Official documentation: https://apidocs.aikido.dev/
8
+ class Client
9
+ def initialize(client_id: nil, client_secret: nil)
10
+ @client_id = client_id || ENV.fetch('AIKIDO_CLIENT_ID', nil)
11
+ @client_secret = client_secret || ENV.fetch('AIKIDO_CLIENT_SECRET', nil)
12
+ end
13
+
14
+ def authorize
15
+ http.plugin(:basic_auth).basic_auth(@client_id, @client_secret).post('/oauth/token',
16
+ json: { grant_type: 'client_credentials' })
17
+ end
18
+
19
+ def issues(params: {})
20
+ authed_http.get('/public/v1/issues/export', params: params).json
21
+ end
22
+
23
+ def issue(id)
24
+ authed_http.get("/public/v1/issues/#{id.to_i}").json
25
+ end
26
+
27
+ def repositories
28
+ # TODO: Paginated response
29
+ authed_http.get('/public/v1/repositories/code', params: params).json
30
+ end
31
+
32
+ private
33
+
34
+ def authed_http
35
+ http.plugin(:auth).bearer_auth(auth_token)
36
+ end
37
+
38
+ def http
39
+ @http ||= HTTPX.with(origin: 'https://app.aikido.dev',
40
+ base_path: '/api',
41
+ headers: { 'Content-Type' => 'application/json',
42
+ 'Accept' => 'application/json',
43
+ 'User-Agent' => "Aikido Ruby Client #{Aikido::VERSION}" })
44
+ end
45
+
46
+ def auth_token
47
+ # TODO: Handle token expiration
48
+ @auth_token ||= authorize.json['access_token']
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aikido
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'aikido/client'
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aikido-ruby-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joakim Antman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httpx
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A Ruby client for the Aikido API (https://apidocs.aikido.dev/)
28
+ email:
29
+ - antmanj@gmail.com
30
+ executables:
31
+ - aikido
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rubocop.yml"
36
+ - CHANGELOG.md
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - exe/aikido
41
+ - lib/aikido-ruby-client.rb
42
+ - lib/aikido/client.rb
43
+ - lib/aikido/version.rb
44
+ homepage: https://github.com/anakinj/aikido-ruby-client
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/anakinj/aikido-ruby-client
49
+ source_code_uri: https://github.com/anakinj
50
+ changelog_uri: https://github.com/anakinj/jwk-loader/blob/0.0.1/CHANGELOG.md
51
+ rubygems_mfa_required: 'true'
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.7.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.3.7
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Aikido API client
71
+ test_files: []