opensearch-ruby-cli 1.0.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: ba1d0759c720a3d63f50653ff4b5ae6dfaa232d1b3def7b0448a90fc0179e705
4
+ data.tar.gz: 5f9b0156045b9f3f83a37e3dedb0612e2a529d02158b539f3c71ccb6f69c213d
5
+ SHA512:
6
+ metadata.gz: a52af0a64154ce4b8c6ac6d2e6b68c1ba713818a3598cdf39f1ad013fb67830741bcef99d4704aa17651d38fc6578de3494db7092da35d8a6a8ff0888593b057
7
+ data.tar.gz: 8d2eb8b28bce00d885e326552218c2f5008f89a31567f60e40f24f222e2d6f690d785d481668cf5518f38816f82cad5718ce71d84f8a829620d0b0648a3bfed9
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## [v1.0.0](https://github.com/opus-codium/opensearch-ruby-cli/tree/v1.0.0) (2024-04-10)
4
+
5
+ [Full Changelog](https://github.com/opus-codium/opensearch-ruby-cli/compare/db66419f41d79ec468150c416a7929e5e0c9c4ee...v1.0.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Make sure static type information is up-to-date [\#1](https://github.com/opus-codium/opensearch-ruby-cli/pull/1) ([smortex](https://github.com/smortex))
10
+
11
+
12
+
13
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
@@ -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 romain@blogreen.org. 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/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in opensearch-ruby-cli.gemspec
6
+ gemspec
7
+
8
+ gem "github_changelog_generator"
9
+
10
+ gem "rake", "~> 13.0"
11
+
12
+ gem "rspec", "~> 3.0"
13
+
14
+ gem "standard", "~> 1.3"
15
+
16
+ group :development do
17
+ gem "steep", require: false
18
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Romain Tartière
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,77 @@
1
+ # OpenSearch::CLI
2
+
3
+ A wrapper around Ruby's OptionParser to to connect to OpenSearch.
4
+
5
+ It provide options similar to the `curl` command line tool and handle creation of a client to connect to an OpenSearch cluster from your CLI application.
6
+
7
+ ```
8
+ OpenSearch options:
9
+ --url=URL URL of the OpenSearch instance
10
+ --cacert=CERTIFICATE Verify certificate against the provided CERTIFICATE
11
+ --cert=CERTIFICATE Use the provided CERTIFICATE for TLS client authentication
12
+ --key=KEY Use the provided KEY for TLS client authentication
13
+ -k, --insecure Skip certificate verification against trust store
14
+ -u, --user=USER[:PASSWORD] Specify the user name and password to use for authentication
15
+ -v, --verbose Show what's going on "under the hood"
16
+ ```
17
+
18
+ ## Installation
19
+
20
+ Install the gem and add to the application's Gemfile by executing:
21
+
22
+ $ bundle add opensearch-ruby-cli
23
+
24
+ If bundler is not being used to manage dependencies, install the gem by executing:
25
+
26
+ $ gem install opensearch-ruby-cli
27
+
28
+ ## Usage
29
+
30
+ Basic usage:
31
+
32
+ ```ruby
33
+ require 'opensearch/cli'
34
+
35
+ cli = OpenSearch::CLI.new
36
+ cli.parse!(ARGV)
37
+ cli.client.search(index: 'my-index', body: { query: { match_all: {} } })
38
+ ```
39
+
40
+ Advanced usage:
41
+
42
+ ```ruby
43
+ require 'opensearch/cli'
44
+
45
+ options = {
46
+ index: 'default'
47
+ }
48
+
49
+ cli = OpenSearch::CLI.new do |opts|
50
+ opts.separator ''
51
+ opts.separator 'Options:'
52
+ opts.on('-i', '--index=INDEX', 'Work on INDEX') do |index|
53
+ options[:index] = index
54
+ end
55
+ end
56
+ cli.load # Load user defaults
57
+ cli.parse!(ARGV)
58
+ cli.client.search(index: options[:index], body: { query: { match_all: {} } })
59
+ ```
60
+
61
+ ## Development
62
+
63
+ 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.
64
+
65
+ 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).
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/opus-codium/opensearch-ruby-cli. 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/opus-codium/opensearch-ruby-cli/blob/main/CODE_OF_CONDUCT.md).
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
74
+
75
+ ## Code of Conduct
76
+
77
+ Everyone interacting in the Opensearch::Ruby::Cli project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/opus-codium/opensearch-ruby-cli/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "github_changelog_generator/task"
6
+
7
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
8
+ config.user = "opus-codium"
9
+ config.project = "opensearch-ruby-cli"
10
+ config.exclude_labels = %w[dependencies skip-changelog]
11
+ config.future_release = "v#{OpenSearch::CLI::VERSION}"
12
+ end
13
+
14
+ RSpec::Core::RakeTask.new(:spec)
15
+
16
+ require "standard/rake"
17
+
18
+ task default: %i[spec standard]
data/Steepfile ADDED
@@ -0,0 +1,18 @@
1
+ target :lib do
2
+ signature "sig", "sig-private"
3
+
4
+ check "lib"
5
+
6
+ library "io-console"
7
+ library "openssl"
8
+ library "optparse"
9
+ library "uri"
10
+ end
11
+
12
+ # target :test do
13
+ # signature "sig", "sig-private"
14
+ #
15
+ # check "spec"
16
+ #
17
+ # library "optparse"
18
+ # end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "openssl"
4
+ require "optparse"
5
+
6
+ module OpenSearch
7
+ class CLI < OptionParser
8
+ VERSION = "1.0.0"
9
+
10
+ def initialize(banner = nil, width = 32, indent = " " * 4, &block)
11
+ @opensearch_options = {
12
+ host: "https://localhost:9200",
13
+ transport_options: {ssl: {}}
14
+ }
15
+ super(banner, width, indent) {}
16
+
17
+ add_opensearch_options
18
+
19
+ yield(self) if block
20
+ end
21
+
22
+ def client
23
+ require "opensearch"
24
+ @client ||= OpenSearch::Client.new(@opensearch_options)
25
+ end
26
+
27
+ private
28
+
29
+ def add_opensearch_options
30
+ separator("")
31
+ separator("OpenSearch options:")
32
+ on("-u", "--url=URL", "URL of the OpenSearch instance") do |url|
33
+ @opensearch_options[:host] = URI(url)
34
+ end
35
+ on("--cacert=CERTIFICATE", "Verify certificate against the provided CERTIFICATE") do |filename|
36
+ @opensearch_options[:transport_options][:ssl][:ca_file] = filename
37
+ end
38
+ on("--cert=CERTIFICATE", "Use the provided CERTIFICATE for TLS client authentication") do |filename|
39
+ @opensearch_options[:transport_options][:ssl][:client_cert] = OpenSSL::X509::Certificate.new(File.read(filename))
40
+ end
41
+ on("--key=KEY", "Use the provided KEY for TLS client authentication") do |filename|
42
+ @opensearch_options[:transport_options][:ssl][:client_key] = OpenSSL::PKey.read(File.read(filename))
43
+ end
44
+ on("-k", "--insecure", "Skip certificate verification against trust store") do
45
+ @opensearch_options[:transport_options][:ssl][:verify] = false
46
+ end
47
+ on("-u", "--user=USER[:PASSWORD]", "Specify the user name and password to use for authentication") do |user_pass|
48
+ @opensearch_options[:user], @opensearch_options[:password] = user_pass.split(":", 2)
49
+ if @opensearch_options[:password].nil?
50
+ require "io/console"
51
+
52
+ print "Enter password for user '#{@opensearch_options[:user]}': "
53
+ @opensearch_options[:password] = $stdin.noecho(&:gets)&.chomp!
54
+ end
55
+ end
56
+ on("-v", "--verbose", %(Show what's going on "under the hood")) do
57
+ @opensearch_options[:log] = true
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/opensearch/cli"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "opensearch-ruby-cli"
7
+ spec.version = OpenSearch::CLI::VERSION
8
+ spec.authors = ["Romain Tartière"]
9
+ spec.email = ["romain@blogreen.org"]
10
+
11
+ spec.summary = "Wrapper for Ruby's OptionParser to connect to OpenSearch"
12
+ spec.homepage = "https://github.com/opus-codium/opensearch-ruby-cli"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "#{spec.homepage}/tree/main"
20
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
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 "opensearch-ruby", ">= 1.0.0", "< 4.0.0"
34
+ end
@@ -0,0 +1,13 @@
1
+ module OpenSearch
2
+ class CLI < OptionParser
3
+ VERSION: ::String
4
+
5
+ def initialize: (?::String banner, ?::Integer width, ?::String indent) { (CLI) -> void } -> void
6
+
7
+ def client: () -> ::OpenSearch::Client
8
+
9
+ private
10
+
11
+ def add_opensearch_options: () -> void
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module OpenSearch
2
+ class Client
3
+ def initialize: (Hash[Symbol, untyped]) -> void
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opensearch-ruby-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Romain Tartière
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opensearch-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
33
+ description:
34
+ email:
35
+ - romain@blogreen.org
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".rspec"
41
+ - ".standard.yml"
42
+ - CHANGELOG.md
43
+ - CODE_OF_CONDUCT.md
44
+ - Gemfile
45
+ - LICENSE.txt
46
+ - README.md
47
+ - Rakefile
48
+ - Steepfile
49
+ - lib/opensearch/cli.rb
50
+ - opensearch-ruby-cli.gemspec
51
+ - sig-private/opensearch.rbs
52
+ - sig/opensearch/cli.rbs
53
+ homepage: https://github.com/opus-codium/opensearch-ruby-cli
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ allowed_push_host: https://rubygems.org
58
+ homepage_uri: https://github.com/opus-codium/opensearch-ruby-cli
59
+ source_code_uri: https://github.com/opus-codium/opensearch-ruby-cli/tree/main
60
+ changelog_uri: https://github.com/opus-codium/opensearch-ruby-cli/blob/main/CHANGELOG.md
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.6.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.3.15
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Wrapper for Ruby's OptionParser to connect to OpenSearch
80
+ test_files: []