Class: Passwordstate::Resources::Password
Instance Attribute Summary
#client
Class Method Summary
collapse
Instance Method Summary
collapse
#api_path, api_path, #attributes, available?, delete, #get, get, index_field, #initialize, #inspect, nil_as_string, passwordstate_to_ruby_field, passwordstateify_hash, post, #post, #put, put, ruby_to_passwordstate_field, #stored?
Class Method Details
.all(client, query = {}) ⇒ Object
81
82
83
|
# File 'lib/passwordstate/resources/password.rb', line 81
def self.all(client, query = {})
super client, { query_all: true }.merge(query)
end
|
.generate(client, options = {}) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/passwordstate/resources/password.rb', line 89
def self.generate(client, options = {})
results = client.request(:get, 'generatepassword', query: options).map { |r| r['Password'] }
return results.first if results.count == 1
results
end
|
.search(client, query = {}) ⇒ Object
85
86
87
|
# File 'lib/passwordstate/resources/password.rb', line 85
def self.search(client, query = {})
super client, { _api_path: 'searchpasswords' }.merge(query)
end
|
Instance Method Details
#add_dependency(data = {}) ⇒ Object
75
76
77
78
79
|
# File 'lib/passwordstate/resources/password.rb', line 75
def add_dependency(data = {})
raise 'Password dependency creation only available for stored passwords' unless stored?
client.request :post, 'dependencies', body: self.class.passwordstatify_hash(data.merge(password_id: password_id))
end
|
#check_in ⇒ Object
54
55
56
|
# File 'lib/passwordstate/resources/password.rb', line 54
def check_in
client.request :get, "passwords/#{password_id}", query: passwordstatify_hash(check_in: nil)
end
|
#delete(recycle = false, query = {}) ⇒ Object
71
72
73
|
# File 'lib/passwordstate/resources/password.rb', line 71
def delete(recycle = false, query = {})
super query.merge(move_to_recycle_bin: recycle)
end
|
#history ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/passwordstate/resources/password.rb', line 58
def history
raise 'Password history only available on stored passwords' unless stored?
Passwordstate::ResourceList.new client, PasswordHistory,
all_path: "passwordhistory/#{password_id}",
only: :all
end
|
#permissions ⇒ Object
66
67
68
69
|
# File 'lib/passwordstate/resources/password.rb', line 66
def permissions
client.require_version('>= 8.4.8449')
PasswordPermission.new(_client: client, password_id: password_id)
end
|