op_connect 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/workflows/coverage.yml +27 -0
  5. data/.github/workflows/publish.yml +42 -0
  6. data/.github/workflows/test.yml +27 -0
  7. data/.gitignore +11 -0
  8. data/CODE_OF_CONDUCT.md +84 -0
  9. data/Gemfile +16 -0
  10. data/Guardfile +23 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +322 -0
  13. data/Rakefile +12 -0
  14. data/bin/console +17 -0
  15. data/bin/setup +8 -0
  16. data/docker-compose.yml +20 -0
  17. data/lib/op_connect/api_request/actor.rb +15 -0
  18. data/lib/op_connect/api_request/resource.rb +14 -0
  19. data/lib/op_connect/api_request.rb +17 -0
  20. data/lib/op_connect/client/files.rb +20 -0
  21. data/lib/op_connect/client/items.rb +34 -0
  22. data/lib/op_connect/client/vaults.rb +15 -0
  23. data/lib/op_connect/client.rb +45 -0
  24. data/lib/op_connect/configurable.rb +45 -0
  25. data/lib/op_connect/connection.rb +103 -0
  26. data/lib/op_connect/default.rb +57 -0
  27. data/lib/op_connect/error.rb +60 -0
  28. data/lib/op_connect/item/field.rb +18 -0
  29. data/lib/op_connect/item/file.rb +16 -0
  30. data/lib/op_connect/item/generator_recipe.rb +12 -0
  31. data/lib/op_connect/item/section.rb +12 -0
  32. data/lib/op_connect/item/url.rb +14 -0
  33. data/lib/op_connect/item.rb +31 -0
  34. data/lib/op_connect/object.rb +21 -0
  35. data/lib/op_connect/response/raise_error.rb +16 -0
  36. data/lib/op_connect/response.rb +5 -0
  37. data/lib/op_connect/server_health/dependency.rb +13 -0
  38. data/lib/op_connect/server_health.rb +13 -0
  39. data/lib/op_connect/vault.rb +16 -0
  40. data/lib/op_connect/version.rb +5 -0
  41. data/lib/op_connect.rb +47 -0
  42. data/op_connect.gemspec +34 -0
  43. metadata +116 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '04619cb5c704b7ce616e03250fbc321dbfd0d6682a391c31158a12336165935d'
4
+ data.tar.gz: 9ee0335c82ac5593ec4789e0882b787b6033364f84fb4030a4cab852c4b5646e
5
+ SHA512:
6
+ metadata.gz: 5b6007f3d1db23525862b0063ee18e62129230d8d21a4cee6a4253a1edd73af1beb8dde70229117db7eb26a0bef2056493d0187f5d5197890086f346452b5c20
7
+ data.tar.gz: b0575f5782b12e9298554fe6fcf1750dcb6b2f5d8efe7c7a1af98baa88189f2428a70a4e32fedee5dd421e99897ec13bda040e36c0aa0aee3e0232c36158c806
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: partydrone
7
+
8
+ ---
9
+
10
+ ## Describe the bug
11
+ A clear and concise description of what the bug is.
12
+
13
+ ## To Reproduce
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ ## Expected behavior
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ ## Screenshots
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ ## Environment
27
+ - Gem version:
28
+ - Ruby version:
29
+
30
+ ## Additional context
31
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: partydrone
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,27 @@
1
+ name: Report Test Coverage
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ jobs:
8
+ coverage:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@master
13
+
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: '3.0'
18
+ bundler: default
19
+ bundler-cache: true
20
+
21
+ - uses: paambaati/codeclimate-action@v2.7.5
22
+ env:
23
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
24
+ with:
25
+ coverageCommand: bundle exec rake test
26
+ coverageLocations: |
27
+ ${{ github.workspace }}/test/coverage/lcov/*.lcov:lcov
@@ -0,0 +1,42 @@
1
+ name: Publish
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ build:
8
+ name: Build + Publish
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ packages: write
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 3.0
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 3.0
20
+
21
+ - name: Publish to GitHub
22
+ run: |
23
+ mkdir -p $HOME/.gem
24
+ touch $HOME/.gem/credentials
25
+ chmod 0600 $HOME/.gem/credentials
26
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
27
+ gem build *.gemspec
28
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
29
+ env:
30
+ GEM_HOST_API_KEY: 'Bearer ${{secrets.GITHUB_TOKEN}}'
31
+ OWNER: ${{ github.repository_owner }}
32
+
33
+ - name: Publish to RubyGems
34
+ run: |
35
+ mkdir -p $HOME/.gem
36
+ touch $HOME/.gem/credentials
37
+ chmod 0600 $HOME/.gem/credentials
38
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
39
+ gem build *.gemspec
40
+ gem push *.gem
41
+ env:
42
+ GEM_HOST_API_KEY: '${{secrets.RUBYGEMS_AUTH_TOKEN}}'
@@ -0,0 +1,27 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.5', '2.6', '2.7', '3.0']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ bundler: default
23
+ bundler-cache: true
24
+ - name: Check coding standards
25
+ run: bundle exec standardrb
26
+ - name: Run tests
27
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/coverage/
9
+ /tmp/
10
+ Gemfile.lock
11
+ 1password-credentials.json
@@ -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 partydrone@icloud.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/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in op_connect.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "minitest", "~> 5.0"
10
+ gem "minitest-reporters"
11
+ gem "guard"
12
+ gem "guard-minitest"
13
+ gem "standard"
14
+ gem "simplecov", require: false
15
+ gem "simplecov-lcov", require: false
16
+ gem "simplecov-tailwindcss", require: false
data/Guardfile ADDED
@@ -0,0 +1,23 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest, all_on_start: false do
19
+ # with Minitest::Unit
20
+ watch(%r{^test/(.*)_test\.rb$})
21
+ watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
22
+ watch(%r{^test/test_helper\.rb$}) { "test" }
23
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Andrew Porter
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,322 @@
1
+ # 1Password Connect Ruby SDK
2
+
3
+ ![example workflow](https://github.com/partydrone/connect-sdk-ruby/actions/workflows/test.yml/badge.svg) [![Maintainability](https://api.codeclimate.com/v1/badges/e5d93bbb1ec1b779aada/maintainability)](https://codeclimate.com/github/partydrone/connect-sdk-ruby/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e5d93bbb1ec1b779aada/test_coverage)](https://codeclimate.com/github/partydrone/connect-sdk-ruby/test_coverage)
4
+
5
+ <img width="1012" alt="op_connect_banner" src="https://user-images.githubusercontent.com/57892/139618110-63e92aa3-794a-463b-b72a-d6a5909a5b8a.png">
6
+
7
+ The 1Password Connect Ruby SDK provides access to the 1Password Connect API
8
+ hosted on your infrastructure. The gem is intended to be used by your
9
+ applications, pipelines, and other automations to simplify accessing items
10
+ stored in your 1Password vaults.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'op_connect'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```sh
23
+ bundle install
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```sh
29
+ gem install op_connect
30
+ ```
31
+
32
+ ## Configuration and Defaults
33
+
34
+ While `OpConnect::Client` accepts a range of options when creating a new client
35
+ instance, OpConnect's configuration API allows you to set your configuration
36
+ options at the module level. This is particularly handy if you're creating a
37
+ number of client instances based on some shared defaults. Changing options
38
+ affects new instances only and will not modify existing `OpConnect::Client`
39
+ instances created with previous options.
40
+
41
+ ### Configuring module defaults
42
+
43
+ Every writable attribute in `OpConnect::Configurable` can be set one at a time:
44
+
45
+ ```ruby
46
+ OpConnect.api_endpoint = "http://localhost:8080/v1"
47
+ OpConnect.access_token = "secret_access_token"
48
+ ```
49
+
50
+ Or in a batch:
51
+
52
+ ```ruby
53
+ OpConnect.configure do |config|
54
+ config.api_endpoint = "http://localhost:8080/v1"
55
+ config.access_token = "secret_access_token"
56
+ end
57
+ ```
58
+
59
+ ### Using ENV variables
60
+
61
+ Default configuration values are specified in `OpConnect::Default`. Many attributes look for a
62
+ default value from ENV before returning OpConnect's default.
63
+
64
+ | Variable | Description | Default |
65
+ | ------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------- |
66
+ | `OP_CONNECT_ACCESS_TOKEN` | The API token used to authenticate the client to a 1Password Connect API. | |
67
+ | `OP_CONNECT_API_ENDPOINT` | The URL of the 1Password Connect API server. | <http://localhost:8080/v1> |
68
+ | `OP_CONNECT_USER_AGENT` | The user-agent string the client uses when making requests. This is optional. | 1Password Connect Ruby SDK {OpConnect::VERSION} |
69
+
70
+ ## Usage
71
+
72
+ ### Making requests
73
+
74
+ API methods are available as client instance methods.
75
+
76
+ ```ruby
77
+ # Provide an access token
78
+ client = OpConnect::Client.new(access_token: "secret_access_token")
79
+
80
+ # Fetch a list of vaults
81
+ client.vaults
82
+ ```
83
+
84
+ ### Using query parameters
85
+
86
+ You can pass query parameters to some GET-based requests.
87
+
88
+ ```ruby
89
+ client.vaults filter: "title eq 'Secrets Automation'"
90
+ ```
91
+
92
+ > 👀 For more information, see the [API documentation][api_docs].
93
+
94
+ ### Consuming resources
95
+
96
+ Most methods return an object which provides convenient dot notation for fields
97
+ returned in the API response.
98
+
99
+ #### List vaults
100
+
101
+ ```ruby
102
+ vaults = client.vaults
103
+ # => [#<OpConnect::Vault:0x00007fae27198610 …
104
+ vaults.first.id
105
+ # => "alynbizzypgx62nti6zxajloei"
106
+ ```
107
+
108
+ #### Get vault details
109
+
110
+ ```ruby
111
+ vault = client.vault(id: "alynbizzypgx62nti6zxajloei")
112
+ # => #<OpConnect::Vault:0x00007fae200c1a18 …
113
+ ```
114
+
115
+ #### List items
116
+
117
+ ```ruby
118
+ items = client.items(vault_id: vault.id)
119
+ # => [#<OpConnect::Item:0x00007fae27151490 …
120
+ ```
121
+
122
+ #### Add item
123
+
124
+ The request must include a `FullItem` object containing the information to
125
+ create the item.
126
+
127
+ > 👀 See the [API documentation](https://support.1password.com/connect-api-reference/#add-an-item)
128
+ > for an example.
129
+
130
+ ```ruby
131
+ attributes = {
132
+ vault: {
133
+ id: vault.id
134
+ },
135
+ title: "Secrets Automation Item",
136
+ category: "LOGIN",
137
+ fields: [
138
+ {
139
+ value: "wendy",
140
+ purpose: "USERNAME"
141
+ },
142
+ {
143
+ purpose: "PASSWORD",
144
+ generate: true,
145
+ recipe: {
146
+ length: 55,
147
+ characterSets: ["LETTERS", "DIGITS"]
148
+ }
149
+ }
150
+ ]
151
+ # …
152
+ }
153
+
154
+ item = client.create_item(vault_id: vault.id, body: attributes)
155
+ # => #<OpConnect::Item:0x00007fae27151490 …
156
+ ```
157
+
158
+ #### Get item details
159
+
160
+ ```ruby
161
+ item = client.item(vault_id: vault.id, id: "yqthoh76cfzpbsimk6zixshosq")
162
+ # => #<OpConnect::Item:0x00007fae27151490 …
163
+ item.title
164
+ # => "AWS IAM Account"
165
+ item.favorite?
166
+ # => false
167
+ ```
168
+
169
+ #### Replace an item
170
+
171
+ ```ruby
172
+ attributes = {
173
+ vault: {
174
+ id: vault.id
175
+ },
176
+ title: "Secrets Automation Item",
177
+ category: "LOGIN",
178
+ fields: [
179
+ {
180
+ value: "jonathan",
181
+ purpose: "USERNAME"
182
+ },
183
+ {
184
+ purpose: "PASSWORD",
185
+ generate: true,
186
+ recipe: {
187
+ length: 55,
188
+ characterSets: ["LETTERS", "DIGITS"]
189
+ }
190
+ }
191
+ ]
192
+ # …
193
+ }
194
+
195
+ item = client.replace_item(vault_id: vault.id, id: item.id, body: attributes)
196
+ # => #<OpConnect::Item:0x00007fae27151490 …
197
+ ```
198
+
199
+ > 👀 See the [API documentation](https://support.1password.com/connect-api-reference/#add-an-item)
200
+ > for an explanation and list of fields and object structure.
201
+
202
+ #### Change item details
203
+
204
+ Use the [JSON Patch](https://tools.ietf.org/html/rfc6902) document standard to
205
+ compile a series of operations to make more targeted changes to an item.
206
+
207
+ > 👀 See the [API documentation](https://support.1password.com/connect-api-reference/#change-item-details)
208
+ > for more information.
209
+
210
+ ```ruby
211
+ attributes = [
212
+ {op: "replace", path: "/title", value: "New Secrets Automation Item"},
213
+ {op: "replace", path: "/fields/username", value: "tinkerbell"}
214
+ ]
215
+
216
+ item = client.update_item(vault_id: vault.id, id: item.id, body: attributes)
217
+ # => #<OpConnect::Item:0x00007fae27151490 …
218
+ ```
219
+
220
+ #### Delete an item
221
+
222
+ ```ruby
223
+ client.delete_item(vault_id: vault.id, id: item.id)
224
+ # => true
225
+ ```
226
+
227
+ #### List files
228
+
229
+ ```ruby
230
+ files = client.files(vault_id: vault.id, item_id: item.id)
231
+ # => [#<OpConnect::Item::File:0x00007fae27151490 …
232
+ ```
233
+
234
+ #### Get file details
235
+
236
+ ```ruby
237
+ file = client.file(vault_id: vault.id, item_id: item.id, id: "6r65pjq33banznomn7q22sj44e")
238
+ # => #<OpConnect::Item::File:0x00007fae27151490 …
239
+ ```
240
+
241
+ #### Get file content
242
+
243
+ ```ruby
244
+ content = client.file(vault_id: vault.id, item_id: item.id, id: file.id)
245
+ # => "The future belongs to the curious.\n"
246
+ ```
247
+
248
+ #### List API activity
249
+
250
+ Retrieve a list of API requests made to the server.
251
+
252
+ ```ruby
253
+ client.activity
254
+ # => [#<OpConnect::APIRequest:0x00007fae27151490 …
255
+ ```
256
+
257
+ #### Check server for a heartbeat
258
+
259
+ Ping the server to check if it's active or not.
260
+
261
+ ```ruby
262
+ client.heartbeat
263
+ # => true
264
+ ```
265
+
266
+ #### Get server health info
267
+
268
+ Query the state of the server and its service dependencies.
269
+
270
+ ```ruby
271
+ client.health
272
+ # => #<OpConnect::ServerHealth:0x00007fae27151490 …
273
+ ```
274
+
275
+ #### Get server metrics
276
+
277
+ This returns Prometheus metrics collected by the server.
278
+
279
+ ```ruby
280
+ client.metrics
281
+ # => "# HELP go_gc_duration_seconds A summary of the pause duration of …
282
+ ```
283
+
284
+ ## Development
285
+
286
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
287
+
288
+ 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).
289
+
290
+ ### Running a local 1Password Connect API server
291
+
292
+ This project includes a docker-compose.yml file that will download and run an
293
+ API and Sync server for you to test with locally. You will need to:
294
+
295
+ - [ ] Install Docker, Docker for Mac, or Docker for Windows.
296
+ - [ ] Place your 1password-credentials.json file in the root of this project.
297
+
298
+ > 👀 See [Get started with a 1Password Secrets Automation workflow][secrets_automation_workflow]
299
+ > for more information.
300
+
301
+ ### Resources
302
+
303
+ Some links that are definitely worth checking out:
304
+
305
+ - [1Password Secrets Automation](https://1password.com/secrets/)
306
+ - [Get started with a 1Password Secrets Automation workflow][secrets_automation_workflow]
307
+ - [1Password Connect API reference][api_docs]
308
+
309
+ ## Contributing
310
+
311
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/partydrone/connect-sdk-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/partydrone/connect/blob/main/CODE_OF_CONDUCT.md).
312
+
313
+ ## License
314
+
315
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
316
+
317
+ ## Code of Conduct
318
+
319
+ Everyone interacting in the Connect project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/partydrone/connect/blob/main/CODE_OF_CONDUCT.md).
320
+
321
+ [api_docs]: https://support.1password.com/connect-api-reference '1Password Connect API reference'
322
+ [secrets_automation_workflow]: https://support.1password.com/secrets-automation/ 'Get started with a 1Password Secrets Automation workflow'
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "op_connect"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ client ||= OpConnect.client
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here