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
-
#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 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
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
138 139 140 |
# File 'lib/files.com/models/public_key.rb', line 138 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 (required) - string - Actual contents of SSH key.
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/files.com/models/public_key.rb', line 162 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 MissingParameterError.new("Parameter missing: title") unless params[:title] raise MissingParameterError.new("Parameter missing: public_key") unless params[:public_key] response, = Api.send_request("/public_keys", :post, params, ) PublicKey.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/files.com/models/public_key.rb', line 187 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
197 198 199 200 |
# File 'lib/files.com/models/public_key.rb', line 197 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Public Key ID.
144 145 146 147 148 149 150 151 152 |
# File 'lib/files.com/models/public_key.rb', line 144 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
154 155 156 |
# File 'lib/files.com/models/public_key.rb', line 154 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).
action - string
page - int64
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/files.com/models/public_key.rb', line 126 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: action must be an String") if params[:action] and !params[:action].is_a?(String) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params[:page] and !params[:page].is_a?(Integer) 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.
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/files.com/models/public_key.rb', line 175 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
31 32 33 |
# File 'lib/files.com/models/public_key.rb', line 31 def created_at @attributes[:created_at] end |
#delete(params = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/files.com/models/public_key.rb', line 94 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
104 105 106 107 |
# File 'lib/files.com/models/public_key.rb', line 104 def destroy(params = {}) delete(params) nil end |
#fingerprint ⇒ Object
string - Public key fingerprint (MD5)
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 |
#fingerprint_sha256 ⇒ Object
string - Public key fingerprint (SHA256)
45 46 47 |
# File 'lib/files.com/models/public_key.rb', line 45 def fingerprint_sha256 @attributes[:fingerprint_sha256] end |
#fingerprint_sha256=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/public_key.rb', line 49 def fingerprint_sha256=(value) @attributes[:fingerprint_sha256] = 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.
72 73 74 |
# File 'lib/files.com/models/public_key.rb', line 72 def public_key @attributes[:public_key] end |
#public_key=(value) ⇒ Object
76 77 78 |
# File 'lib/files.com/models/public_key.rb', line 76 def public_key=(value) @attributes[:public_key] = value end |
#save ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/files.com/models/public_key.rb', line 109 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = PublicKey.create(@attributes, @options) end @attributes = new_obj.attributes true 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.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/files.com/models/public_key.rb', line 82 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
63 64 65 |
# File 'lib/files.com/models/public_key.rb', line 63 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
67 68 69 |
# File 'lib/files.com/models/public_key.rb', line 67 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - Username of the user this public key is associated with
54 55 56 |
# File 'lib/files.com/models/public_key.rb', line 54 def username @attributes[:username] end |
#username=(value) ⇒ Object
58 59 60 |
# File 'lib/files.com/models/public_key.rb', line 58 def username=(value) @attributes[:username] = value end |