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.
- #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 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
122 123 124 |
# File 'lib/files.com/models/public_key.rb', line 122 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.
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/files.com/models/public_key.rb', line 146 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
171 172 173 174 175 176 177 178 179 |
# File 'lib/files.com/models/public_key.rb', line 171 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] response, = Api.send_request("/public_keys/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
181 182 183 |
# File 'lib/files.com/models/public_key.rb', line 181 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Public Key ID.
128 129 130 131 132 133 134 135 136 |
# File 'lib/files.com/models/public_key.rb', line 128 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
138 139 140 |
# File 'lib/files.com/models/public_key.rb', line 138 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).
112 113 114 115 116 117 118 119 120 |
# File 'lib/files.com/models/public_key.rb', line 112 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) 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.
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/files.com/models/public_key.rb', line 159 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
85 86 87 88 89 90 91 92 93 |
# File 'lib/files.com/models/public_key.rb', line 85 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
95 96 97 |
# File 'lib/files.com/models/public_key.rb', line 95 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.
63 64 65 |
# File 'lib/files.com/models/public_key.rb', line 63 def public_key @attributes[:public_key] end |
#public_key=(value) ⇒ Object
67 68 69 |
# File 'lib/files.com/models/public_key.rb', line 67 def public_key=(value) @attributes[:public_key] = value end |
#save ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/files.com/models/public_key.rb', line 99 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.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/files.com/models/public_key.rb', line 73 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
54 55 56 |
# File 'lib/files.com/models/public_key.rb', line 54 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
58 59 60 |
# File 'lib/files.com/models/public_key.rb', line 58 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - Username of the user this public key is associated with
45 46 47 |
# File 'lib/files.com/models/public_key.rb', line 45 def username @attributes[:username] end |
#username=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/public_key.rb', line 49 def username=(value) @attributes[:username] = value end |