openlayer 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env +0 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/LICENSE +21 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/lib/openlayer/client.rb +32 -0
- data/lib/openlayer/error.rb +5 -0
- data/lib/openlayer/inference_pipeline.rb +36 -0
- data/lib/openlayer/version.rb +5 -0
- data/lib/openlayer.rb +11 -0
- data/openlayer.gemspec +42 -0
- data/sig/openlayer.rbs +4 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 255305d0ee35d06cd50f6243adece29a13abcd94e39cd72eeaafa0ad9ef64818
|
4
|
+
data.tar.gz: afc2292d13f5bfd99e136c805c300c43d46cbecad09dacfac5c60c5a8f7eadf7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e819098a710660d080afd35ac2de37efcc5259cadb2b9ff446325b7ee5f924f44f68b514816252ca28825c7301caf99a897a4c37b0e2cd505fbd66a8c2f6a82b
|
7
|
+
data.tar.gz: 1f242e2ba0bb14f5a1123aed04b0a8f7f2723641ca9c41a67072b2603f71dd772c866563d3f507a2d1ddb7e2d8642f78f3412722ed8be711d4ce6953ef16eb09
|
data/.env
ADDED
File without changes
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Telos Labs
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Openlayer
|
2
|
+
Openlayer is a Ruby gem that provides a wrapper for the Openlayer HTTP API. It allows you to connect to Openlayer and interact with its features. Please note that this gem is currently in the early stages of development.
|
3
|
+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
Install the gem and add to the application's Gemfile by executing:
|
7
|
+
|
8
|
+
$ bundle add openlayer
|
9
|
+
|
10
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
11
|
+
|
12
|
+
$ gem install openlayer
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
client = OpenLayer::Client.new(api_key: "YOUR_OPENLAYER_API_KEY")
|
18
|
+
inference_pipeline = client.inference_pipeline("YOUR_INFERENCE_PIPELINE_ID")
|
19
|
+
inferencce_pipeline.stream_data(
|
20
|
+
{
|
21
|
+
rows: [...],
|
22
|
+
config: {...}
|
23
|
+
}
|
24
|
+
)
|
25
|
+
```
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/TelosLabs/openlayer.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
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,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "faraday_middleware"
|
5
|
+
|
6
|
+
module Openlayer
|
7
|
+
class Client
|
8
|
+
BASE_URL = "https://api.openlayer.com/v1/"
|
9
|
+
|
10
|
+
attr_reader :api_key, :adapter
|
11
|
+
|
12
|
+
def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil)
|
13
|
+
@api_key = api_key
|
14
|
+
@adapter = adapter
|
15
|
+
@stubs = stubs
|
16
|
+
end
|
17
|
+
|
18
|
+
def connection
|
19
|
+
@connection ||= Faraday.new do |conn|
|
20
|
+
conn.url_prefix = BASE_URL
|
21
|
+
conn.request :authorization, "Bearer", api_key
|
22
|
+
conn.request :json
|
23
|
+
conn.response :json, content_type: "application/json"
|
24
|
+
conn.adapter adapter, @stubs
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def inference_pipeline(inference_pipeline_id)
|
29
|
+
InferencePipeline.new(self, inference_pipeline_id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Openlayer
|
4
|
+
class InferencePipeline
|
5
|
+
attr_reader :client, :inference_pipeline_id
|
6
|
+
|
7
|
+
def initialize(client, inference_pipeline_id)
|
8
|
+
@client = client
|
9
|
+
@inference_pipeline_id = inference_pipeline_id
|
10
|
+
end
|
11
|
+
|
12
|
+
def stream_data(**attributes)
|
13
|
+
handle_response client.connection.post("inference-pipelines/#{inference_pipeline_id}/data-stream", attributes)
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle_response(response)
|
18
|
+
message = response.body["error"]
|
19
|
+
case response.status
|
20
|
+
when 200
|
21
|
+
response.body
|
22
|
+
when 401
|
23
|
+
raise Error, message
|
24
|
+
when 404
|
25
|
+
raise Error, message
|
26
|
+
when 422
|
27
|
+
raise Error, message
|
28
|
+
when 500
|
29
|
+
raise Error, message
|
30
|
+
else
|
31
|
+
raise Error, message
|
32
|
+
end
|
33
|
+
response
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/openlayer.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "openlayer/version"
|
4
|
+
|
5
|
+
module Openlayer
|
6
|
+
autoload :Client, "openlayer/client"
|
7
|
+
autoload :Error, "openlayer/error"
|
8
|
+
autoload :InferencePipeline, "openlayer/inference_pipeline"
|
9
|
+
|
10
|
+
# Your code goes here...
|
11
|
+
end
|
data/openlayer.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/openlayer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "openlayer"
|
7
|
+
spec.version = Openlayer::VERSION
|
8
|
+
spec.authors = ["Jose Fernando Davila"]
|
9
|
+
spec.email = ["davila.jose23@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Openlayer api wrapper"
|
12
|
+
spec.description = "Openlayer api wrapper"
|
13
|
+
spec.homepage = "https://github.com/TelosLabs/openlayer"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(File.expand_path(f) == __FILE__) ||
|
28
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
# Uncomment to register a new dependency of your gem
|
36
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
37
|
+
spec.add_dependency "faraday", "~> 2.9.0"
|
38
|
+
spec.add_dependency "faraday_middleware", "~> 1.2.0"
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, check out our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|
data/sig/openlayer.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openlayer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jose Fernando Davila
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.0
|
41
|
+
description: Openlayer api wrapper
|
42
|
+
email:
|
43
|
+
- davila.jose23@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".env"
|
49
|
+
- ".rspec"
|
50
|
+
- ".rubocop.yml"
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/openlayer.rb
|
55
|
+
- lib/openlayer/client.rb
|
56
|
+
- lib/openlayer/error.rb
|
57
|
+
- lib/openlayer/inference_pipeline.rb
|
58
|
+
- lib/openlayer/version.rb
|
59
|
+
- openlayer.gemspec
|
60
|
+
- sig/openlayer.rbs
|
61
|
+
homepage: https://github.com/TelosLabs/openlayer
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata:
|
65
|
+
homepage_uri: https://github.com/TelosLabs/openlayer
|
66
|
+
source_code_uri: https://github.com/TelosLabs/openlayer
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.6.0
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubygems_version: 3.3.7
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Openlayer api wrapper
|
86
|
+
test_files: []
|