Class: Files::PublicKey
- Inherits:
-
Object
- Object
- Files::PublicKey
- Defined in:
- lib/files.com/models/public_key.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: user_id - integer - User ID.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - integer - Public Key ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - integer - User ID.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: title (required) - string - Internal reference for key.
Instance Method Summary collapse
-
#created_at ⇒ Object
date-time - Public key created at date/time.
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#fingerprint ⇒ Object
string - Public key fingerprint.
- #fingerprint=(value) ⇒ Object
-
#id ⇒ Object
int64 - Public key ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ PublicKey
constructor
A new instance of PublicKey.
-
#public_key ⇒ Object
string - Actual contents of SSH key.
- #public_key=(value) ⇒ Object
- #save ⇒ Object
-
#title ⇒ Object
string - Public key title.
- #title=(value) ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: title (required) - string - Internal reference for key.
-
#user_id ⇒ Object
int64 - User ID.
- #user_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ PublicKey
Returns a new instance of PublicKey.
7 8 9 10 |
# File 'lib/files.com/models/public_key.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/public_key.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/public_key.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
113 114 115 |
# File 'lib/files.com/models/public_key.rb', line 113 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - integer - User ID. Provide a value of `0` to operate the current session's user.
title (required) - string - Internal reference for key.
public_key (required) - string - Actual contents of SSH key.
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/files.com/models/public_key.rb', line 137 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: title must be an String") if params.dig(:title) and !params.dig(:title).is_a?(String) raise InvalidParameterError.new("Bad parameter: public_key must be an String") if params.dig(:public_key) and !params.dig(:public_key).is_a?(String) raise MissingParameterError.new("Parameter missing: title") unless params.dig(:title) raise MissingParameterError.new("Parameter missing: public_key") unless params.dig(:public_key) response, = Api.send_request("/public_keys", :post, params, ) PublicKey.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
162 163 164 165 166 167 168 169 170 |
# File 'lib/files.com/models/public_key.rb', line 162 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/public_keys/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
172 173 174 |
# File 'lib/files.com/models/public_key.rb', line 172 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - integer - Public Key ID.
119 120 121 122 123 124 125 126 127 |
# File 'lib/files.com/models/public_key.rb', line 119 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/public_keys/#{params[:id]}", :get, params, ) PublicKey.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
129 130 131 |
# File 'lib/files.com/models/public_key.rb', line 129 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - integer - User ID. Provide a value of `0` to operate the current session's user.
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
104 105 106 107 108 109 110 111 |
# File 'lib/files.com/models/public_key.rb', line 104 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) response, = Api.send_request("/public_keys", :get, params, ) end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
title (required) - string - Internal reference for key.
150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/files.com/models/public_key.rb', line 150 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: title must be an String") if params.dig(:title) and !params.dig(:title).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) raise MissingParameterError.new("Parameter missing: title") unless params.dig(:title) response, = Api.send_request("/public_keys/#{params[:id]}", :patch, params, ) PublicKey.new(response.data, ) end |
Instance Method Details
#created_at ⇒ Object
date-time - Public key created at date/time
31 32 33 |
# File 'lib/files.com/models/public_key.rb', line 31 def created_at @attributes[:created_at] end |
#delete(params = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/files.com/models/public_key.rb', line 76 def delete(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/public_keys/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
86 87 88 |
# File 'lib/files.com/models/public_key.rb', line 86 def destroy(params = {}) delete(params) end |
#fingerprint ⇒ Object
string - Public key fingerprint
36 37 38 |
# File 'lib/files.com/models/public_key.rb', line 36 def fingerprint @attributes[:fingerprint] end |
#fingerprint=(value) ⇒ Object
40 41 42 |
# File 'lib/files.com/models/public_key.rb', line 40 def fingerprint=(value) @attributes[:fingerprint] = value end |
#id ⇒ Object
int64 - Public key ID
13 14 15 |
# File 'lib/files.com/models/public_key.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/public_key.rb', line 17 def id=(value) @attributes[:id] = value end |
#public_key ⇒ Object
string - Actual contents of SSH key.
54 55 56 |
# File 'lib/files.com/models/public_key.rb', line 54 def public_key @attributes[:public_key] end |
#public_key=(value) ⇒ Object
58 59 60 |
# File 'lib/files.com/models/public_key.rb', line 58 def public_key=(value) @attributes[:public_key] = value end |
#save ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/files.com/models/public_key.rb', line 90 def save if @attributes[:id] update(@attributes) else new_obj = PublicKey.create(@attributes, @options) @attributes = new_obj.attributes end end |
#title ⇒ Object
string - Public key title
22 23 24 |
# File 'lib/files.com/models/public_key.rb', line 22 def title @attributes[:title] end |
#title=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/public_key.rb', line 26 def title=(value) @attributes[:title] = value end |
#update(params = {}) ⇒ Object
Parameters:
title (required) - string - Internal reference for key.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/files.com/models/public_key.rb', line 64 def update(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: title must be an String") if params.dig(:title) and !params.dig(:title).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) raise MissingParameterError.new("Parameter missing: title") unless params.dig(:title) Api.send_request("/public_keys/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - User ID. Provide a value of ‘0` to operate the current session’s user.
45 46 47 |
# File 'lib/files.com/models/public_key.rb', line 45 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/public_key.rb', line 49 def user_id=(value) @attributes[:user_id] = value end |