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 - int64 - User ID.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - Public Key ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - 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 (MD5).
- #fingerprint=(value) ⇒ Object
-
#fingerprint_sha256 ⇒ Object
string - Public key fingerprint (SHA256).
- #fingerprint_sha256=(value) ⇒ Object
-
#generate_algorithm ⇒ Object
string - Type of key to generate.
- #generate_algorithm=(value) ⇒ Object
-
#generate_keypair ⇒ Object
boolean - If true, generate a new SSH key pair.
- #generate_keypair=(value) ⇒ Object
-
#generate_length ⇒ Object
int64 - Length of key to generate.
- #generate_length=(value) ⇒ Object
-
#generate_private_key_password ⇒ Object
string - Password for the private key.
- #generate_private_key_password=(value) ⇒ Object
-
#generated_private_key ⇒ Object
string - Only returned when generating keys.
- #generated_private_key=(value) ⇒ Object
-
#generated_public_key ⇒ Object
string - Only returned when generating keys.
- #generated_public_key=(value) ⇒ Object
-
#id ⇒ Object
int64 - Public key ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ PublicKey
constructor
A new instance of PublicKey.
-
#last_login_at ⇒ Object
date-time - Key’s most recent login time via SFTP.
- #last_login_at=(value) ⇒ Object
-
#public_key ⇒ Object
string - Actual contents of SSH key.
- #public_key=(value) ⇒ Object
- #save ⇒ Object
-
#status ⇒ Object
string - Only returned when generating keys.
- #status=(value) ⇒ 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 this public key is associated with.
- #user_id=(value) ⇒ Object
-
#username ⇒ Object
string - Username of the user this public key is associated with.
- #username=(value) ⇒ Object
-
#workspace_id ⇒ Object
int64 - Workspace ID (0 for default workspace).
- #workspace_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
227 228 229 |
# File 'lib/files.com/models/public_key.rb', line 227 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
title (required) - string - Internal reference for key.
public_key - string - Actual contents of SSH key.
generate_keypair - boolean - If true, generate a new SSH key pair. Can not be used with `public_key`
generate_private_key_password - string - Password for the private key. Used for the generation of the key. Will be ignored if `generate_keypair` is false.
generate_algorithm - string - Type of key to generate. One of rsa, dsa, ecdsa, ed25519. Used for the generation of the key. Will be ignored if `generate_keypair` is false.
generate_length - int64 - Length of key to generate. If algorithm is ecdsa, this is the signature size. Used for the generation of the key. Will be ignored if `generate_keypair` is false.
255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/files.com/models/public_key.rb', line 255 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: title must be an String") if params[:title] and !params[:title].is_a?(String) raise InvalidParameterError.new("Bad parameter: public_key must be an String") if params[:public_key] and !params[:public_key].is_a?(String) raise InvalidParameterError.new("Bad parameter: generate_private_key_password must be an String") if params[:generate_private_key_password] and !params[:generate_private_key_password].is_a?(String) raise InvalidParameterError.new("Bad parameter: generate_algorithm must be an String") if params[:generate_algorithm] and !params[:generate_algorithm].is_a?(String) raise InvalidParameterError.new("Bad parameter: generate_length must be an Integer") if params[:generate_length] and !params[:generate_length].is_a?(Integer) raise MissingParameterError.new("Parameter missing: title") unless params[:title] response, = Api.send_request("/public_keys", :post, params, ) PublicKey.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
282 283 284 285 286 287 288 289 290 |
# File 'lib/files.com/models/public_key.rb', line 282 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/public_keys/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
292 293 294 295 |
# File 'lib/files.com/models/public_key.rb', line 292 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Public Key ID.
233 234 235 236 237 238 239 240 241 |
# File 'lib/files.com/models/public_key.rb', line 233 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/public_keys/#{params[:id]}", :get, params, ) PublicKey.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
243 244 245 |
# File 'lib/files.com/models/public_key.rb', line 243 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `workspace_id`, `user_id`, `title` or `created_at`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `created_at` and `workspace_id`.
filter_gt - object - If set, return records where the specified field is greater than the supplied value. Valid fields are `created_at`.
filter_gteq - object - If set, return records where the specified field is greater than or equal the supplied value. Valid fields are `created_at`.
filter_lt - object - If set, return records where the specified field is less than the supplied value. Valid fields are `created_at`.
filter_lteq - object - If set, return records where the specified field is less than or equal the supplied value. Valid fields are `created_at`.
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/files.com/models/public_key.rb', line 211 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params[:filter_gt] and !params[:filter_gt].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params[:filter_gteq] and !params[:filter_gteq].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params[:filter_lt] and !params[:filter_lt].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params[:filter_lteq] and !params[:filter_lteq].is_a?(Hash) List.new(PublicKey, params) do Api.send_request("/public_keys", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
title (required) - string - Internal reference for key.
270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/files.com/models/public_key.rb', line 270 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: title must be an String") if params[:title] and !params[:title].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: title") unless params[: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
40 41 42 |
# File 'lib/files.com/models/public_key.rb', line 40 def created_at @attributes[:created_at] end |
#delete(params = {}) ⇒ Object
175 176 177 178 179 180 181 182 183 |
# File 'lib/files.com/models/public_key.rb', line 175 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[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/public_keys/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
185 186 187 188 |
# File 'lib/files.com/models/public_key.rb', line 185 def destroy(params = {}) delete(params) nil end |
#fingerprint ⇒ Object
string - Public key fingerprint (MD5)
45 46 47 |
# File 'lib/files.com/models/public_key.rb', line 45 def fingerprint @attributes[:fingerprint] end |
#fingerprint=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/public_key.rb', line 49 def fingerprint=(value) @attributes[:fingerprint] = value end |
#fingerprint_sha256 ⇒ Object
string - Public key fingerprint (SHA256)
54 55 56 |
# File 'lib/files.com/models/public_key.rb', line 54 def fingerprint_sha256 @attributes[:fingerprint_sha256] end |
#fingerprint_sha256=(value) ⇒ Object
58 59 60 |
# File 'lib/files.com/models/public_key.rb', line 58 def fingerprint_sha256=(value) @attributes[:fingerprint_sha256] = value end |
#generate_algorithm ⇒ Object
string - Type of key to generate. One of rsa, dsa, ecdsa, ed25519. Used for the generation of the key. Will be ignored if ‘generate_keypair` is false.
144 145 146 |
# File 'lib/files.com/models/public_key.rb', line 144 def generate_algorithm @attributes[:generate_algorithm] end |
#generate_algorithm=(value) ⇒ Object
148 149 150 |
# File 'lib/files.com/models/public_key.rb', line 148 def generate_algorithm=(value) @attributes[:generate_algorithm] = value end |
#generate_keypair ⇒ Object
boolean - If true, generate a new SSH key pair. Can not be used with ‘public_key`
126 127 128 |
# File 'lib/files.com/models/public_key.rb', line 126 def generate_keypair @attributes[:generate_keypair] end |
#generate_keypair=(value) ⇒ Object
130 131 132 |
# File 'lib/files.com/models/public_key.rb', line 130 def generate_keypair=(value) @attributes[:generate_keypair] = value end |
#generate_length ⇒ Object
int64 - Length of key to generate. If algorithm is ecdsa, this is the signature size. Used for the generation of the key. Will be ignored if ‘generate_keypair` is false.
153 154 155 |
# File 'lib/files.com/models/public_key.rb', line 153 def generate_length @attributes[:generate_length] end |
#generate_length=(value) ⇒ Object
157 158 159 |
# File 'lib/files.com/models/public_key.rb', line 157 def generate_length=(value) @attributes[:generate_length] = value end |
#generate_private_key_password ⇒ Object
string - Password for the private key. Used for the generation of the key. Will be ignored if ‘generate_keypair` is false.
135 136 137 |
# File 'lib/files.com/models/public_key.rb', line 135 def generate_private_key_password @attributes[:generate_private_key_password] end |
#generate_private_key_password=(value) ⇒ Object
139 140 141 |
# File 'lib/files.com/models/public_key.rb', line 139 def generate_private_key_password=(value) @attributes[:generate_private_key_password] = value end |
#generated_private_key ⇒ Object
string - Only returned when generating keys. Private key generated for the user.
81 82 83 |
# File 'lib/files.com/models/public_key.rb', line 81 def generated_private_key @attributes[:generated_private_key] end |
#generated_private_key=(value) ⇒ Object
85 86 87 |
# File 'lib/files.com/models/public_key.rb', line 85 def generated_private_key=(value) @attributes[:generated_private_key] = value end |
#generated_public_key ⇒ Object
string - Only returned when generating keys. Public key generated for the user.
90 91 92 |
# File 'lib/files.com/models/public_key.rb', line 90 def generated_public_key @attributes[:generated_public_key] end |
#generated_public_key=(value) ⇒ Object
94 95 96 |
# File 'lib/files.com/models/public_key.rb', line 94 def generated_public_key=(value) @attributes[:generated_public_key] = 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 |
#last_login_at ⇒ Object
date-time - Key’s most recent login time via SFTP
72 73 74 |
# File 'lib/files.com/models/public_key.rb', line 72 def last_login_at @attributes[:last_login_at] end |
#last_login_at=(value) ⇒ Object
76 77 78 |
# File 'lib/files.com/models/public_key.rb', line 76 def last_login_at=(value) @attributes[:last_login_at] = value end |
#public_key ⇒ Object
string - Actual contents of SSH key.
117 118 119 |
# File 'lib/files.com/models/public_key.rb', line 117 def public_key @attributes[:public_key] end |
#public_key=(value) ⇒ Object
121 122 123 |
# File 'lib/files.com/models/public_key.rb', line 121 def public_key=(value) @attributes[:public_key] = value end |
#save ⇒ Object
190 191 192 193 194 195 196 197 198 199 |
# File 'lib/files.com/models/public_key.rb', line 190 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = PublicKey.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#status ⇒ Object
string - Only returned when generating keys. Can be invalid, not_generated, generating, complete
63 64 65 |
# File 'lib/files.com/models/public_key.rb', line 63 def status @attributes[:status] end |
#status=(value) ⇒ Object
67 68 69 |
# File 'lib/files.com/models/public_key.rb', line 67 def status=(value) @attributes[:status] = value end |
#title ⇒ Object
string - Public key title
31 32 33 |
# File 'lib/files.com/models/public_key.rb', line 31 def title @attributes[:title] end |
#title=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/public_key.rb', line 35 def title=(value) @attributes[:title] = value end |
#update(params = {}) ⇒ Object
Parameters:
title (required) - string - Internal reference for key.
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/files.com/models/public_key.rb', line 163 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[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: title must be an String") if params[:title] and !params[:title].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: title") unless params[:title] Api.send_request("/public_keys/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - User ID this public key is associated with
108 109 110 |
# File 'lib/files.com/models/public_key.rb', line 108 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
112 113 114 |
# File 'lib/files.com/models/public_key.rb', line 112 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - Username of the user this public key is associated with
99 100 101 |
# File 'lib/files.com/models/public_key.rb', line 99 def username @attributes[:username] end |
#username=(value) ⇒ Object
103 104 105 |
# File 'lib/files.com/models/public_key.rb', line 103 def username=(value) @attributes[:username] = value end |
#workspace_id ⇒ Object
int64 - Workspace ID (0 for default workspace).
22 23 24 |
# File 'lib/files.com/models/public_key.rb', line 22 def workspace_id @attributes[:workspace_id] end |
#workspace_id=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/public_key.rb', line 26 def workspace_id=(value) @attributes[:workspace_id] = value end |