Class: Certmeister::DynamoDB::Store
- Inherits:
-
Object
- Object
- Certmeister::DynamoDB::Store
- Defined in:
- lib/certmeister/dynamodb/store.rb
Instance Method Summary collapse
- #fetch(cn) ⇒ Object
- #health_check ⇒ Object
-
#initialize(table_name, options = {}, provision = {}) ⇒ Store
constructor
A new instance of Store.
- #remove(cn) ⇒ Object
- #store(cn, pem) ⇒ Object
Constructor Details
#initialize(table_name, options = {}, provision = {}) ⇒ Store
Returns a new instance of Store.
10 11 12 13 14 15 16 17 |
# File 'lib/certmeister/dynamodb/store.rb', line 10 def initialize(table_name, = {}, provision = {}) @table_name = table_name @db = Aws::DynamoDB::Client.new() if !provision.empty? do_provisioning(provision) end @healthy = true end |
Instance Method Details
#fetch(cn) ⇒ Object
23 24 25 26 27 |
# File 'lib/certmeister/dynamodb/store.rb', line 23 def fetch(cn) if item = @db.get_item(table_name: @table_name, key: {cn: cn}).item item["pem"] end end |
#health_check ⇒ Object
34 35 36 |
# File 'lib/certmeister/dynamodb/store.rb', line 34 def health_check @healthy end |
#remove(cn) ⇒ Object
29 30 31 32 |
# File 'lib/certmeister/dynamodb/store.rb', line 29 def remove(cn) deleted = @db.delete_item(table_name: @table_name, key: {cn: cn}, return_values: "ALL_OLD").attributes !!deleted end |
#store(cn, pem) ⇒ Object
19 20 21 |
# File 'lib/certmeister/dynamodb/store.rb', line 19 def store(cn, pem) @db.put_item(table_name: @table_name, item: {cn: cn, pem: pem}) end |