ridley 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gitignore +17 -0
  2. data/.travis.yml +5 -0
  3. data/Gemfile +3 -0
  4. data/Guardfile +20 -0
  5. data/LICENSE +201 -0
  6. data/README.md +273 -0
  7. data/Thorfile +48 -0
  8. data/lib/ridley.rb +48 -0
  9. data/lib/ridley/connection.rb +131 -0
  10. data/lib/ridley/context.rb +25 -0
  11. data/lib/ridley/dsl.rb +58 -0
  12. data/lib/ridley/errors.rb +82 -0
  13. data/lib/ridley/log.rb +10 -0
  14. data/lib/ridley/middleware.rb +19 -0
  15. data/lib/ridley/middleware/chef_auth.rb +45 -0
  16. data/lib/ridley/middleware/chef_response.rb +28 -0
  17. data/lib/ridley/middleware/parse_json.rb +107 -0
  18. data/lib/ridley/resource.rb +305 -0
  19. data/lib/ridley/resources/client.rb +75 -0
  20. data/lib/ridley/resources/cookbook.rb +27 -0
  21. data/lib/ridley/resources/data_bag.rb +75 -0
  22. data/lib/ridley/resources/data_bag_item.rb +186 -0
  23. data/lib/ridley/resources/environment.rb +45 -0
  24. data/lib/ridley/resources/node.rb +34 -0
  25. data/lib/ridley/resources/role.rb +33 -0
  26. data/lib/ridley/version.rb +3 -0
  27. data/ridley.gemspec +39 -0
  28. data/spec/acceptance/client_resource_spec.rb +135 -0
  29. data/spec/acceptance/cookbook_resource_spec.rb +46 -0
  30. data/spec/acceptance/data_bag_item_resource_spec.rb +171 -0
  31. data/spec/acceptance/data_bag_resource_spec.rb +51 -0
  32. data/spec/acceptance/environment_resource_spec.rb +171 -0
  33. data/spec/acceptance/node_resource_spec.rb +218 -0
  34. data/spec/acceptance/role_resource_spec.rb +200 -0
  35. data/spec/fixtures/reset.pem +27 -0
  36. data/spec/spec_helper.rb +25 -0
  37. data/spec/support/each_matcher.rb +12 -0
  38. data/spec/support/shared_examples/ridley_resource.rb +237 -0
  39. data/spec/support/spec_helpers.rb +11 -0
  40. data/spec/unit/ridley/connection_spec.rb +167 -0
  41. data/spec/unit/ridley/errors_spec.rb +34 -0
  42. data/spec/unit/ridley/middleware/chef_auth_spec.rb +14 -0
  43. data/spec/unit/ridley/middleware/chef_response_spec.rb +213 -0
  44. data/spec/unit/ridley/middleware/parse_json_spec.rb +74 -0
  45. data/spec/unit/ridley/resource_spec.rb +214 -0
  46. data/spec/unit/ridley/resources/client_spec.rb +47 -0
  47. data/spec/unit/ridley/resources/cookbook_spec.rb +5 -0
  48. data/spec/unit/ridley/resources/data_bag_item_spec.rb +42 -0
  49. data/spec/unit/ridley/resources/data_bag_spec.rb +15 -0
  50. data/spec/unit/ridley/resources/environment_spec.rb +73 -0
  51. data/spec/unit/ridley/resources/node_spec.rb +5 -0
  52. data/spec/unit/ridley/resources/role_spec.rb +5 -0
  53. data/spec/unit/ridley_spec.rb +32 -0
  54. metadata +451 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ script: "bundle exec thor spec:unit"
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.2
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,20 @@
1
+ guard 'spork' do
2
+ watch('Gemfile')
3
+ watch('spec/spec_helper.rb') { :rspec }
4
+ watch(%r{^spec/support/.+\.rb$}) { :rspec }
5
+ end
6
+
7
+ guard 'yard', stdout: '/dev/null', stderr: '/dev/null' do
8
+ watch(%r{app/.+\.rb})
9
+ watch(%r{lib/.+\.rb})
10
+ watch(%r{ext/.+\.c})
11
+ end
12
+
13
+ guard 'rspec', version: 2, cli: "--color --drb --format Fuubar", all_on_start: false, all_after_pass: false, notification: false do
14
+ watch(%r{^spec/unit/.+_spec\.rb$})
15
+ watch(%r{^spec/acceptance/.+_spec\.rb$})
16
+
17
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
18
+ watch('spec/spec_helper.rb') { "spec" }
19
+ watch(%r{^spec/support/.+\.rb$}) { "spec" }
20
+ end
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2012, Jamie Winsor
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,273 @@
1
+ # Ridley
2
+ [![Build Status](https://secure.travis-ci.org/reset/ridley.png?branch=master)](http://travis-ci.org/reset/ridley)
3
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/reset/ridley)
4
+
5
+ A reliable Chef API client with a clean syntax
6
+
7
+ ## Installation
8
+
9
+ $ gem install ridley
10
+
11
+ ## Known Issues
12
+
13
+ * Search has not been implemented
14
+ * Sandboxes has not been implemented
15
+ * Full support for Cookbooks is not included
16
+ * Acceptance test suite needs to be refactored
17
+
18
+ ## Usage
19
+
20
+ Require Ridley into your application
21
+
22
+ require 'ridley'
23
+
24
+ ## Creating a new connection
25
+
26
+ conn = Ridley::Connection.new(
27
+ server_url: "https://api.opscode.com",
28
+ client_name: "reset",
29
+ client_key: "/Users/reset/.chef/reset.pem",
30
+ organization: "ridley"
31
+ )
32
+
33
+ Creating a new connection requires you to specify at minimum:
34
+
35
+ * server_url
36
+ * client_name
37
+ * client_key
38
+
39
+ An optional organization option can be specified if you are working with Hosted or Private Chef (OHC/OPC). For a full list of available options see the [yard documentation](http://rubydoc.info/gems/ridley).
40
+
41
+ __NOTE: You do not want to specify an `organization` if you are connecting to an Open Source Chef server.__
42
+
43
+ Connections can also be instantiated by a helper function: `Ridley.connection`
44
+
45
+ Ridley.connection(
46
+ server_url: "https://api.opscode.com",
47
+ client_name: "reset",
48
+ client_key: "/Users/reset/.chef/reset.pem",
49
+ organization: "ridley"
50
+ )
51
+
52
+ Using a connection object you can interact with collections of resources on a Chef server. Resources are:
53
+
54
+ * Nodes
55
+ * Roles
56
+ * Environments
57
+ * Clients
58
+ * Cookbooks
59
+ * Data Bags
60
+
61
+ Here is a simple example of instantiating a new connection and listing all of the roles on a Chef server.
62
+
63
+ conn = Ridley.connection(...)
64
+ conn.role.all => []
65
+
66
+ For more information scroll down to the Manipulating Chef Resources section of this README.
67
+
68
+ ### Synchronous execution
69
+
70
+ An alternative syntax is provided if you want to perform multiple requests, in order, on a connection.
71
+
72
+ conn = Ridley.connection(...)
73
+
74
+ conn.sync do
75
+ role.all
76
+ role.find("reset")
77
+ role.create(name: "ridley-test")
78
+ role.delete("reset")
79
+ end
80
+
81
+ The `sync` function on the connection object takes a block with no arguments and allows you to access the DSL within the block. You can address any one of the resources within the sync block:
82
+
83
+ conn.sync do
84
+ environment.all
85
+ node.all
86
+ ...
87
+ end
88
+
89
+ A helper function exists to allow you to express yourself in a one-liner: `Ridley.sync`
90
+
91
+ Ridley.sync(server_url: "https://api.opscode.com", ...) do
92
+ role.all => []
93
+ end
94
+
95
+ ### Asynchronous execution
96
+
97
+ __COMING SOON__
98
+
99
+ ## Manipulating Chef Resources
100
+
101
+ All resource can be listed, created, retrieved, updated, or destroyed. Some resources have additional functionality described in [their documentation](http://rubydoc.info/gems/ridley).
102
+
103
+ ### Listing all resources
104
+
105
+ You use a connection to interact with the resources on the remote Chef server it is pointing to. For example, if you wanted to get a list of all of the roles on your Chef server:
106
+
107
+ conn = Ridley.connection(...)
108
+ conn.role.all => []
109
+
110
+ Calling `role.all` on the connection object will return an array of Ridley::Role objects. All of the resources can be listed, not just Roles:
111
+
112
+ conn = Ridley.connection(...)
113
+ conn.node.all => [<#Ridley::Node>]
114
+ conn.role.all => [<#Ridley::Role>]
115
+ conn.environment.all => [<#Ridley::Environment>]
116
+ conn.client.all => [<#Ridley::Client>]
117
+ conn.cookbook.all => [<#Ridley::Cookbook>]
118
+ conn.data_bag.all => [<#Ridley::DataBag>]
119
+
120
+ ### Creating a resource
121
+
122
+ A new resource can be created in a few ways
123
+
124
+ _Create by instantiate and save_
125
+
126
+ conn = Ridley.connection(...)
127
+ obj = conn.role.new
128
+
129
+ obj.name = "reset"
130
+ obj.save => <#Ridley::Role: @name="reset">
131
+
132
+ _Create by the `create` function with attribute hash_
133
+
134
+ conn = Ridley.connection(...)
135
+ conn.role.create(name: "reset") => <#Ridley::Role: @name="reset">
136
+
137
+ _Create by the `create` function with a resource object_
138
+
139
+ conn = Ridley.connection(...)
140
+ obj = conn.role.new
141
+
142
+ obj.name = "reset"
143
+ conn.role.create(obj) => <#Ridley::Role: @name="reset">
144
+
145
+ Each of these methods is identical, it is up to you on how you'd like to create new resources.
146
+
147
+ ### Retrieving a resource
148
+
149
+ There are two functions for retrieving a resource. `find` and `find!`. If you are familiar with ActiveRecord; these are the functions used to pull records out of the database.
150
+
151
+ Both `find` and `find!` will return a resource but if the resource is not found on the Chef server `find!` will raise an exception while `find` will return `nil`.
152
+
153
+ If you were following allong in the previous section we created a role named `reset`. We'll assume that role has been created in this next example.
154
+
155
+ conn = Ridley.connection(...)
156
+
157
+ conn.role.find("reset") => <#Ridley::Role: @name="reset">
158
+ conn.role.find!("reset") => <#Ridley::Role: @name="reset">
159
+
160
+ Now if we attempt to find a role that does not exist on the Chef server
161
+
162
+ conn = Ridley.connection(...)
163
+
164
+ conn.role.find("not_there") => nil
165
+ conn.role.find!("not_there") =>
166
+ Ridley::Errors::HTTPNotFound: errors: 'Cannot load role reset'
167
+ from /Users/reset/code/ridley/lib/ridley/middleware/chef_response.rb:11:in `on_complete'
168
+ from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/response.rb:9:in `block in call'
169
+ from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/response.rb:63:in `on_complete'
170
+ from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/response.rb:8:in `call'
171
+ from /Users/reset/code/ridley/lib/ridley/middleware/chef_auth.rb:31:in `call'
172
+ from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/connection.rb:226:in `run_request'
173
+ from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in `get'
174
+ from /Users/reset/code/ridley/lib/ridley/resource.rb:115:in `find!'
175
+ from /Users/reset/code/ridley/lib/ridley/context.rb:22:in `method_missing'
176
+ from (irb):6
177
+ from /Users/reset/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
178
+
179
+ ### Updating a resource
180
+
181
+ Like creating a resource, updating a resource can also be expressed a few different ways
182
+
183
+ _Update by the `update` function with an id and attribute hash_
184
+
185
+ conn = Ridley.connection(...)
186
+ conn.role.update("reset", description: "testing updates!") => <#Ridley::Role: @name="reset", @description="testing updates!">
187
+
188
+ _Update by the `update` function with a resource object_
189
+
190
+ conn = Ridley.connection(...)
191
+ obj = conn.role.find("reset")
192
+ obj.description = "resource object!"
193
+
194
+ conn.role.update(obj) => <#Ridley::Role: @name="reset", @description="resource object!">
195
+
196
+ _Update by saving a resource object_
197
+
198
+ conn = Ridley.connection(...)
199
+ obj = conn.role.find("reset")
200
+
201
+ obj.description = "saving an object!"
202
+ obj.save => <#Ridley::Role: @name="reset", @description="saving an object!">
203
+
204
+ ### Deleting a resource
205
+
206
+ Like creating or updating a resource, there are a few ways deleting a resource can be expressed
207
+
208
+ _Delete by the `delete` function with an id_
209
+
210
+ conn = Ridley.connection(...)
211
+ conn.role.delete("reset") => <#Ridley::Role: @name="reset">
212
+
213
+ _Delete by the `delete` function with a resource object_
214
+
215
+ conn = Ridley.connection(...)
216
+ obj = conn.role.find("reset")
217
+
218
+ conn.role.delete(obj) => <#Ridley::Role: @name="reset">
219
+
220
+ _Delete by the `destroy` function on a resource object_
221
+
222
+ conn = Ridley.connection(...)
223
+ obj = conn.role.find("reset")
224
+
225
+ obj.destroy => true
226
+
227
+ ### Regenerating a client's private key
228
+
229
+ _Regenerate function on a context with an id_
230
+
231
+ conn = Ridley.connection(...)
232
+ conn.client.regenerate_key("jwinsor") => <#Ridley::Client: @name="jwinsor", @private_key="HIDDEN">
233
+
234
+ _Regenerate function on an instantiated resource object_
235
+
236
+ conn = Ridley.connection(...)
237
+ obj = conn.client.find("jwinsor")
238
+
239
+ obj.regenerate_key => <#Ridley::Client: @name="jwinsor", @private_key="HIDDEN">
240
+
241
+ ## Manipulating Data Bags and Data Bag Items
242
+
243
+ A data bag is managed exactly the same as any other Chef resource
244
+
245
+ conn = Ridley.connection(...)
246
+ conn.data_bag.create("ridley-test")
247
+
248
+ You can create, delete, update, or retrieve a data bag exactly how you would expect if you read through the
249
+ Manipulating Chef Resources portion of this document.
250
+
251
+ Unlike a role, node, client, or environment, a data bag is a container for other resources. These other resources are Data Bag Items. Data Bag Items behave slightly different than other resources. Data Bag Items can have an abritrary attribute hash filled with any key values that you would like. The one exception is that every Data Bag Item __requires__ an 'id' key and value. This identifier is the name of the Data Bag Item.
252
+
253
+ ### Creating a Data Bag Item
254
+
255
+ conn = Ridley.connection(...)
256
+ data_bag = conn.data_bag.create("ridley-test")
257
+
258
+ data_bag.item.create(id: "appconfig", host: "reset.local", user: "jwinsor") =>
259
+ <#Ridley::DataBagItem: @id="appconfig", @host="reset.local", @user="jwinsor">
260
+
261
+ ### Saving a Data Bag Item
262
+
263
+ conn = Ridley.connection(...)
264
+ data_bag = conn.data_bag.create("ridley-test")
265
+
266
+ dbi = data_bag.item.new
267
+ dbi[:id] = "appconfig"
268
+ dbi[:host] = "reset.local"
269
+ dbi.save => true
270
+
271
+ # Authors and Contributors
272
+
273
+ * Jamie Winsor (<jamie@vialstudios.com>)