airbyte-ruby 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: e2a30a14f2c6905481634344ea22f7501697b333fca72f40675010ae3c68b1fd
4
+ data.tar.gz: 229ed44f9c8b30fa0abde43061258c7f7bf999a1f1b91309ef476f0c087a3b6f
5
+ SHA512:
6
+ metadata.gz: d979cc2c52149adbbaa7305b4c7a91d8613c58fcac3879f737d0002b724bf64f0d3549a69eab839f5e01af0278f7ecf796805f47e82b9c8c260bcc924eb162f3
7
+ data.tar.gz: 4625746c9f016c46a82855d037c573f742252a71c5afa68a40a6ccf480897028b75350d95761f287a5f5b9f3896f5885021940ac457ba9dba7b646210ef0189e
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - 'spec/**/*'
18
+
19
+ Metrics/MethodLength:
20
+ Enabled: false
21
+
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-09-14
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 26109239+Quentinchampenois@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 quentinchampenois
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,41 @@
1
+ # AirbyteRuby
2
+
3
+ [![codecov](https://codecov.io/gh/Quentinchampenois/airbyte-ruby/graph/badge.svg?token=OCNNZRG0PR)](https://codecov.io/gh/Quentinchampenois/airbyte-ruby)
4
+
5
+ TODO: Delete this and the text below, and describe your gem
6
+
7
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/airbyte_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
8
+
9
+ ## Installation
10
+
11
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_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.
12
+
13
+ Install the gem and add to the application's Gemfile by executing:
14
+
15
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/airbyte_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/airbyte_ruby/blob/main/CODE_OF_CONDUCT.md).
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the AirbyteRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/airbyte_ruby/blob/main/CODE_OF_CONDUCT.md).
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,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/airbyte_ruby/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "airbyte-ruby"
7
+ spec.version = AirbyteRuby::VERSION
8
+ spec.authors = ["quentinchampenois"]
9
+ spec.email = ["26109239+Quentinchampenois@users.noreply.github.com"]
10
+
11
+ spec.summary = "Communicate with Airbyte API."
12
+ spec.description = "Pure ruby library to communicate with Airbyte API."
13
+ spec.homepage = "https://github.com/quentinchampenois/airbyte-ruby"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/quentinchampenois/airbyte-ruby.git"
19
+ spec.metadata["changelog_uri"] = "https://github.com/quentinchampenois/airbyte-ruby/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "faraday", "~> 2.7"
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+
37
+ # For more information and examples about making a new gem, check out our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
data/codecov.yml ADDED
@@ -0,0 +1,4 @@
1
+ coverage:
2
+ round: up
3
+ range: 0..10
4
+ precision: 5
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "airbyte_ruby"
6
+
7
+ AirbyteRuby::Configuration.tap do |c|
8
+ c.endpoint = ENV.fetch("AIRBYTE_ENDPOINT", "http://localhost:8006/")
9
+ c.basic_auth = true
10
+ c.airbyte_username = ENV.fetch("AIRBYTE_USERNAME", "airbyte")
11
+ c.airbyte_password = ENV.fetch("AIRBYTE_PASSWORD", "password")
12
+ end
13
+
14
+ db_host = ENV["DB_HOST"] || "localhost"
15
+ db_port = ENV["DB_PORT"]&.to_i || 5432
16
+ db_name = ENV["DB_NAME"] || "postgres"
17
+ db_username = ENV["DB_USERNAME"] || "postgres"
18
+ db_password = ENV["DB_PASSWORD"] || ""
19
+ workspace_uuid = ENV["WORKSPACE_UUID"]
20
+
21
+ postgres_adapter = AirbyteRuby::Adapters::Postgres.new(
22
+ host: db_host,
23
+ port: db_port,
24
+ database: db_name,
25
+ username: db_username,
26
+ password: db_password,
27
+ schema: "public",
28
+ ssl_mode: { mode: "prefer" },
29
+ replication_method: { method: "Xmin" },
30
+ tunnel_method: { tunnel_method: "NO_TUNNEL" }
31
+ )
32
+
33
+ source = AirbyteRuby::Resources::Source.new(
34
+ postgres_adapter,
35
+ name: "Airbyte new source",
36
+ workspace_id: workspace_uuid
37
+ )
38
+
39
+ res = source.new
40
+
41
+ if res.success?
42
+ params = JSON.parse(res.body)
43
+ puts "
44
+ Source successfully created!
45
+
46
+ Action : Create
47
+ Airbyte response : #{res.status}
48
+ Source UUID: #{params["sourceId"]}
49
+ Source Name: #{params["name"]}
50
+
51
+ See more on http://localhost:8000/workspaces/#{workspace_uuid}/source/#{params["sourceId"]}
52
+ "
53
+ else
54
+ puts "Something went wrong : HTTP Status: #{res.status}"
55
+ end
56
+
57
+ destination = AirbyteRuby::Resources::Destination.new(
58
+ postgres_adapter,
59
+ name: "Airbyte new source",
60
+ workspace_id: workspace_uuid
61
+ )
62
+
63
+ res = destination.new
64
+
65
+ if res.success?
66
+ params = JSON.parse(res.body)
67
+ puts "
68
+ ------------------------------------
69
+
70
+ Destination successfully created!
71
+ Action : Create
72
+ Airbyte response : #{res.status}
73
+ Destination UUID: #{params["destinationId"]}
74
+ Destination Name: #{params["name"]}
75
+
76
+ See more on http://localhost:8000/workspaces/#{workspace_uuid}/destination/#{params["destinationId"]}
77
+ "
78
+ else
79
+ puts "Something went wrong : HTTP Status: #{res.status}"
80
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ module Adapters
5
+ # Postgres type adapter for AirbyteRuby configuration
6
+ class Postgres
7
+ TYPE = :postgres
8
+
9
+ attr_accessor :type, :host, :port, :database, :username, :password, :ssl_mode, :replication_method,
10
+ :tunnel_method
11
+
12
+ def initialize(args = {})
13
+ @type = TYPE.to_s
14
+ @host = args[:host]
15
+ @port = args[:port]
16
+ @database = args[:database]
17
+ @schema = args[:schema] || "public"
18
+ @username = args[:username]
19
+ @password = args[:password]
20
+ @ssl_mode = args[:ssl_mode]
21
+ @replication_method = args[:replication_method]
22
+ @tunnel_method = args[:tunnel_method]
23
+ end
24
+
25
+ def configuration
26
+ {
27
+ host: @host,
28
+ port: @port,
29
+ database: @database,
30
+ schema: @schema,
31
+ username: @username,
32
+ password: @password,
33
+ ssl_mode: @ssl_mode,
34
+ replication_method: @replication_method,
35
+ tunnel_method: @tunnel_method
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ # Configuration class for AirbyteRuby
5
+ class Configuration
6
+ include ActiveSupport::Configurable
7
+
8
+ config_accessor :airbyte_api_version do
9
+ ENV.fetch("AIRBYTE_API_VERSION", "v1")
10
+ end
11
+
12
+ # The endpoint that Airbyte is running on
13
+ # /!\ Must include the trailing slash
14
+ # Defaults to http://localhost:8006/
15
+ # @return [String]
16
+ config_accessor :endpoint do
17
+ endpoint = ENV.fetch("AIRBYTE_ENDPOINT", "http://localhost:8006/")
18
+ endpoint += "/" if endpoint[-1] != "/"
19
+
20
+ endpoint
21
+ end
22
+
23
+ config_accessor :basic_auth do
24
+ ENV.fetch("AIRBYTE_BASIC_AUTH", "false") == "true"
25
+ end
26
+
27
+ config_accessor :airbyte_username do
28
+ ENV.fetch("AIRBYTE_USERNAME", "airbyte")
29
+ end
30
+
31
+ config_accessor :airbyte_password do
32
+ ENV.fetch("AIRBYTE_PASSWORD", "password")
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug"
4
+ module AirbyteRuby
5
+ # Requests module for AirbyteRuby
6
+ module Requests
7
+ private
8
+
9
+ def list(url)
10
+ url = "#{AirbyteRuby::Configuration.airbyte_api_version}#{url}"
11
+ base_conn.get(url)
12
+ end
13
+
14
+ def create(url)
15
+ url = "#{AirbyteRuby::Configuration.airbyte_api_version}#{url}"
16
+ base_conn.post(url, to_json)
17
+ end
18
+
19
+ def get(url)
20
+ url = "#{AirbyteRuby::Configuration.airbyte_api_version}#{url}"
21
+ base_conn.get(url)
22
+ end
23
+
24
+ def patch(url)
25
+ url = "#{AirbyteRuby::Configuration.airbyte_api_version}#{url}"
26
+ base_conn.patch(url, to_json)
27
+ end
28
+
29
+ def delete(url)
30
+ url = "#{AirbyteRuby::Configuration.airbyte_api_version}#{url}"
31
+ base_conn.delete(url)
32
+ end
33
+
34
+ def base_conn
35
+ endpoint = AirbyteRuby::Configuration.endpoint
36
+ endpoint += "/" if endpoint[-1] != "/"
37
+ ::Faraday.new(url: endpoint) do |faraday|
38
+ if AirbyteRuby::Configuration.basic_auth
39
+ faraday.set_basic_auth(AirbyteRuby::Configuration.airbyte_username,
40
+ AirbyteRuby::Configuration.airbyte_password)
41
+ end
42
+ faraday.headers["Content-Type"] = "application/json"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ module Resources
5
+ # Base class for Airbyte Resources
6
+ # TODO: Move to module rather than class
7
+ class Base
8
+ include AirbyteRuby::Requests
9
+
10
+ def to_json(*_args)
11
+ raise NotImplementedError
12
+ end
13
+
14
+ def fetch_all
15
+ raise NotImplementedError
16
+ end
17
+
18
+ def new
19
+ raise NotImplementedError
20
+ end
21
+
22
+ def fetch
23
+ raise NotImplementedError
24
+ end
25
+
26
+ def remove
27
+ raise NotImplementedError
28
+ end
29
+
30
+ private
31
+
32
+ def replace_variable_in_url(url, variable)
33
+ url.gsub(":#{variable}", @id)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ module Resources
5
+ # Resource class for Airbyte Connections
6
+ class Connection < Base
7
+ ENDPOINTS = OpenStruct.new(
8
+ list: "/connections?includeDeleted=false&limit=20&offset=0",
9
+ create: "/connections",
10
+ get: "/connections/:connection_id",
11
+ update: "/connections/:connection_id",
12
+ delete: "/connections/:connection_id"
13
+ )
14
+
15
+ attr_reader :id, :name, :source_id, :destination_id, :workspace_id
16
+
17
+ # TODO: Include Base module once ready
18
+ # rubocop:disable Lint/MissingSuper
19
+ def initialize(args = {})
20
+ @id = args[:id]
21
+ @name = args[:name]
22
+ @workspace_id = args[:workspace_id]
23
+ @source_id = args[:source_id]
24
+ @destination_id = args[:destination_id]
25
+ end
26
+ # rubocop:enable Lint/MissingSuper
27
+
28
+ def to_json(*_args)
29
+ {
30
+ name: @name,
31
+ sourceId: @source_id,
32
+ destinationId: @destination_id
33
+ }.to_json
34
+ end
35
+
36
+ def fetch_all
37
+ list(ENDPOINTS.list)
38
+ end
39
+
40
+ def new
41
+ create(ENDPOINTS.create)
42
+ end
43
+
44
+ def fetch
45
+ url = replace_variable_in_url(ENDPOINTS.get, "connection_id")
46
+ get(url)
47
+ end
48
+
49
+ def update
50
+ url = replace_variable_in_url(ENDPOINTS.update, "connection_id")
51
+ patch(url)
52
+ end
53
+
54
+ def remove
55
+ url = replace_variable_in_url(ENDPOINTS.delete, "connection_id")
56
+ delete(url)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ module Resources
5
+ # Resource class for Airbyte Destinations
6
+ class Destination < Base
7
+ ENDPOINTS = OpenStruct.new(
8
+ list: "/destinations?includeDeleted=false&limit=20&offset=0",
9
+ create: "/destinations",
10
+ get: "/destinations/:destination_id",
11
+ update: "/destinations/:destination_id",
12
+ delete: "/destinations/:destination_id"
13
+ )
14
+
15
+ attr_reader :id, :name, :type, :workspace_id, :connection_configuration
16
+
17
+ # TODO: Include Base module once ready
18
+ # rubocop:disable Lint/MissingSuper
19
+ def initialize(adapter, args = {})
20
+ @id = args[:id]
21
+ @name = args[:name]
22
+ @workspace_id = args[:workspace_id]
23
+ @connection_configuration = adapter.configuration
24
+ @type = adapter.type
25
+ end
26
+ # rubocop:enable Lint/MissingSuper
27
+
28
+ def to_json(*_args)
29
+ {
30
+ name: @name,
31
+ workspaceId: @workspace_id,
32
+ configuration: @connection_configuration.merge(destinationType: @type)
33
+ }.to_json
34
+ end
35
+
36
+ def fetch_all
37
+ list(ENDPOINTS.list)
38
+ end
39
+
40
+ def new
41
+ create(ENDPOINTS.create)
42
+ end
43
+
44
+ def fetch
45
+ url = replace_variable_in_url(ENDPOINTS.get, "destination_id")
46
+ get(url)
47
+ end
48
+
49
+ def update
50
+ url = replace_variable_in_url(ENDPOINTS.update, "destination_id")
51
+ patch(url)
52
+ end
53
+
54
+ def remove
55
+ url = replace_variable_in_url(ENDPOINTS.delete, "destination_id")
56
+ delete(url)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ module Resources
5
+ # Resource class for Airbyte Sources
6
+ class Source < Base
7
+ ENDPOINTS = OpenStruct.new(
8
+ list: "/sources?includeDeleted=false&limit=20&offset=0",
9
+ create: "/sources",
10
+ get: "/sources/:source_id",
11
+ update: "/sources/:source_id",
12
+ delete: "/sources/:source_id"
13
+ )
14
+
15
+ attr_reader :id, :name, :source_type, :workspace_id, :connection_configuration
16
+
17
+ # TODO: Include Base module once ready
18
+ # rubocop:disable Lint/MissingSuper
19
+ def initialize(adapter, args = {})
20
+ @id = args[:id]
21
+ @name = args[:name]
22
+ @workspace_id = args[:workspace_id]
23
+ @connection_configuration = adapter.configuration
24
+ @source_type = adapter.type
25
+ end
26
+ # rubocop:enable Lint/MissingSuper
27
+
28
+ def to_json(*_args)
29
+ {
30
+ name: @name,
31
+ workspaceId: @workspace_id,
32
+ configuration: @connection_configuration.merge(sourceType: @source_type)
33
+ }.to_json
34
+ end
35
+
36
+ def fetch_all
37
+ list(ENDPOINTS.list)
38
+ end
39
+
40
+ def new
41
+ create(ENDPOINTS.create)
42
+ end
43
+
44
+ def fetch
45
+ url = replace_variable_in_url(ENDPOINTS.get, "source_id")
46
+ get(url)
47
+ end
48
+
49
+ def update
50
+ url = replace_variable_in_url(ENDPOINTS.update, "source_id")
51
+ patch(url)
52
+ end
53
+
54
+ def remove
55
+ url = replace_variable_in_url(ENDPOINTS.delete, "source_id")
56
+ delete(url)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbyteRuby
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "ostruct"
5
+ require "active_support/configurable"
6
+ require_relative "airbyte_ruby/version"
7
+ require_relative "airbyte_ruby/configuration"
8
+ require_relative "airbyte_ruby/requests"
9
+ require_relative "airbyte_ruby/resources/base"
10
+ require_relative "airbyte_ruby/resources/source"
11
+ require_relative "airbyte_ruby/resources/destination"
12
+ require_relative "airbyte_ruby/resources/connection"
13
+ require_relative "airbyte_ruby/adapters/postgres"
14
+
15
+ # AirbyteRuby is a Ruby library for the Airbyte API.
16
+ module AirbyteRuby
17
+ class Error < StandardError; end
18
+ end
@@ -0,0 +1,19 @@
1
+ module AirbyteRuby
2
+ module Resources
3
+ class Source
4
+ @source_id: String
5
+ @name: String
6
+ @source_type: String
7
+ @workspace_id: String
8
+ @connection_configuration: Hash[String, String]
9
+
10
+ attr_reader source_id: String
11
+ attr_reader name: String
12
+ attr_reader source_type: String
13
+ attr_reader workspace_id: String
14
+ attr_reader connection_configuration: Hash[String, String]
15
+
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module AirbyteRuby
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: airbyte-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - quentinchampenois
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-10-16 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.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ description: Pure ruby library to communicate with Airbyte API.
28
+ email:
29
+ - 26109239+Quentinchampenois@users.noreply.github.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - ".ruby-version"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - airbyte_ruby.gemspec
43
+ - codecov.yml
44
+ - examples/create.rb
45
+ - lib/airbyte_ruby.rb
46
+ - lib/airbyte_ruby/adapters/postgres.rb
47
+ - lib/airbyte_ruby/configuration.rb
48
+ - lib/airbyte_ruby/requests.rb
49
+ - lib/airbyte_ruby/resources/base.rb
50
+ - lib/airbyte_ruby/resources/connection.rb
51
+ - lib/airbyte_ruby/resources/destination.rb
52
+ - lib/airbyte_ruby/resources/source.rb
53
+ - lib/airbyte_ruby/version.rb
54
+ - sig/airbyte_ruby.rbs
55
+ - sig/airbyte_ruby/resources/source.rbs
56
+ homepage: https://github.com/quentinchampenois/airbyte-ruby
57
+ licenses:
58
+ - MIT
59
+ metadata:
60
+ homepage_uri: https://github.com/quentinchampenois/airbyte-ruby
61
+ source_code_uri: https://github.com/quentinchampenois/airbyte-ruby.git
62
+ changelog_uri: https://github.com/quentinchampenois/airbyte-ruby/blob/main/CHANGELOG.md
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '2.7'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.3.5
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Communicate with Airbyte API.
82
+ test_files: []