cortex_app 0.1.0

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: '08dcfbf8f5f11bf8ed6134346c3a58abf81d61fbb394675a802611fe4e4e5460'
4
+ data.tar.gz: 2f1b572b7d3d4e1b81b17795ce0563fa9fb2d813b85a2e07e526b7beb5d1fc16
5
+ SHA512:
6
+ metadata.gz: '01487e7ba40bc55374b9b460e888bb97eb61b9d9f8c3a0ebdf8df1bfa4d32e59f742577bd6889db1d0e47f5d0ef89c2815ad95eafd32f9b9cdc86edd90d92670'
7
+ data.tar.gz: d4a1b7c9c228b12878f02c8fc630ae686bc9e9e8cd1580d2d739de194d280a05b4b1609d3e4e8bf26d5cf6aee97053ee11fa38f0e843c7456cc87afff217bac3
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Metrics/BlockLength:
8
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+
5
+ SimpleCov.start 'rails' do
6
+ add_filter %w[version.rb initializer.rb]
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Bryan Hickerson
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,35 @@
1
+ # Cortex App API Integration
2
+
3
+ [Cortex](https://www.cortex.io/) is a platform for cataloging and tracking software platforms.
4
+
5
+ This gem adds a Ruby integration for Cortex's API.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ See [RubyDoc](https://rubydoc.info/github/betterup/cortex_app/)
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ 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).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/betterup/cortex_app.
32
+
33
+ ## License
34
+
35
+ 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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+
5
+ module CortexApp
6
+ # Base class for Cortex API classes
7
+ class Api
8
+ API_URL = 'https://api.getcortexapp.com/api/v1'
9
+
10
+ # @param bearer_token [String] the bearer token to authenticate with Cortex
11
+ def initialize(bearer_token:) = @bearer_token = bearer_token
12
+
13
+ private
14
+
15
+ def http_post(path:, data:)
16
+ HTTParty.post("#{API_URL}/#{path}", headers: headers, body: data.to_json)
17
+ end
18
+
19
+ def http_put(path:, data:)
20
+ HTTParty.put("#{API_URL}/#{path}", headers: headers, body: data.to_json)
21
+ end
22
+
23
+ def headers
24
+ @headers ||= { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{@bearer_token}" }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CortexApp
4
+ # API client to interact with Cortex {https://docs.cortex.io/docs/reference/basics/custom-data custom data}
5
+ class CustomData < Api
6
+ # POSTs custom data to Cortex for a specific entity
7
+ #
8
+ # @param entity_tag [String] the entity tag in Cortex
9
+ # @param data [Hash] the custom data to POST
10
+ def post(entity_tag:, data:)
11
+ http_post(path: post_path(entity_tag), data: data)
12
+ end
13
+
14
+ # Bulk PUTs custom data to Cortex for multiple entities
15
+ #
16
+ # @param data [Hash] the custom data to PUT
17
+ def put_bulk(data:)
18
+ http_put(path: 'catalog/custom-data', data: data)
19
+ end
20
+
21
+ private
22
+
23
+ def post_path(entity_tag)
24
+ "catalog/#{entity_tag}/custom-data"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CortexApp
4
+ VERSION = '0.1.0'
5
+ end
data/lib/cortex_app.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cortex_app/version'
4
+ require_relative 'cortex_app/api'
5
+ require_relative 'cortex_app/custom_data'
6
+
7
+ module CortexApp
8
+ end
@@ -0,0 +1,4 @@
1
+ module CortexApp
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cortex_app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - BetterUp Developers
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.22'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.22'
27
+ description:
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".rspec"
34
+ - ".rubocop.yml"
35
+ - ".simplecov"
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/cortex_app.rb
40
+ - lib/cortex_app/api.rb
41
+ - lib/cortex_app/custom_data.rb
42
+ - lib/cortex_app/version.rb
43
+ - sig/cortex_app.rbs
44
+ homepage:
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.0.0
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.5.19
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Ruby client for Cortex API
67
+ test_files: []