Class: Files::GpgKey
- Inherits:
-
Object
- Object
- Files::GpgKey
- Defined in:
- lib/files.com/models/gpg_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 - Gpg Key ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: partner_id - int64 - Partner ID who owns this GPG Key, if applicable.
Instance Method Summary collapse
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#expires_at ⇒ Object
date-time - GPG key expiration date.
- #expires_at=(value) ⇒ Object
-
#generate_email ⇒ Object
string - Email address of the key owner.
- #generate_email=(value) ⇒ Object
-
#generate_expires_at ⇒ Object
string - Expiration date of the key.
- #generate_expires_at=(value) ⇒ Object
-
#generate_full_name ⇒ Object
string - Full name of the key owner.
- #generate_full_name=(value) ⇒ Object
-
#generate_keypair ⇒ Object
boolean - If true, generate a new GPG key pair.
- #generate_keypair=(value) ⇒ Object
-
#generated_private_key ⇒ Object
string - GPG private key.
- #generated_private_key=(value) ⇒ Object
-
#generated_public_key ⇒ Object
string - GPG public key.
- #generated_public_key=(value) ⇒ Object
-
#id ⇒ Object
int64 - GPG key ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ GpgKey
constructor
A new instance of GpgKey.
-
#name ⇒ Object
string - GPG key name.
- #name=(value) ⇒ Object
-
#partner_id ⇒ Object
int64 - Partner ID who owns this GPG Key, if applicable.
- #partner_id=(value) ⇒ Object
-
#partner_name ⇒ Object
string - Name of the Partner who owns this GPG Key, if applicable.
- #partner_name=(value) ⇒ Object
-
#private_key ⇒ Object
string - The GPG private key.
- #private_key=(value) ⇒ Object
-
#private_key_md5 ⇒ Object
string - MD5 hash of the GPG private key.
- #private_key_md5=(value) ⇒ Object
-
#private_key_password ⇒ Object
string - The GPG private key password.
- #private_key_password=(value) ⇒ Object
-
#private_key_password_md5 ⇒ Object
string - GPG private key password.
- #private_key_password_md5=(value) ⇒ Object
-
#public_key ⇒ Object
string - The GPG public key.
- #public_key=(value) ⇒ Object
-
#public_key_md5 ⇒ Object
string - MD5 hash of the GPG public key.
- #public_key_md5=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: partner_id - int64 - Partner ID who owns this GPG Key, if applicable.
-
#user_id ⇒ Object
int64 - User ID who owns this GPG Key, if applicable.
- #user_id=(value) ⇒ Object
-
#workspace_id ⇒ Object
int64 - Workspace ID (0 for default workspace).
- #workspace_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ GpgKey
Returns a new instance of GpgKey.
7 8 9 10 |
# File 'lib/files.com/models/gpg_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/gpg_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/gpg_key.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
256 257 258 |
# File 'lib/files.com/models/gpg_key.rb', line 256 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.
partner_id - int64 - Partner ID who owns this GPG Key, if applicable.
public_key - string - The GPG public key
private_key - string - The GPG private key
private_key_password - string - The GPG private key password
name (required) - string - GPG key name.
workspace_id - int64 - Workspace ID (0 for default workspace).
generate_expires_at - string - Expiration date of the key. Used for the generation of the key. Will be ignored if `generate_keypair` is false.
generate_keypair - boolean - If true, generate a new GPG key pair. Can not be used with `public_key`/`private_key`
generate_full_name - string - Full name of the key owner. Used for the generation of the key. Will be ignored if `generate_keypair` is false.
generate_email - string - Email address of the key owner. Used for the generation of the key. Will be ignored if `generate_keypair` is false.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/files.com/models/gpg_key.rb', line 288 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: partner_id must be an Integer") if params[:partner_id] and !params[:partner_id].is_a?(Integer) 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: private_key must be an String") if params[:private_key] and !params[:private_key].is_a?(String) raise InvalidParameterError.new("Bad parameter: private_key_password must be an String") if params[:private_key_password] and !params[:private_key_password].is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: workspace_id must be an Integer") if params[:workspace_id] and !params[:workspace_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: generate_expires_at must be an String") if params[:generate_expires_at] and !params[:generate_expires_at].is_a?(String) raise InvalidParameterError.new("Bad parameter: generate_full_name must be an String") if params[:generate_full_name] and !params[:generate_full_name].is_a?(String) raise InvalidParameterError.new("Bad parameter: generate_email must be an String") if params[:generate_email] and !params[:generate_email].is_a?(String) raise MissingParameterError.new("Parameter missing: name") unless params[:name] response, = Api.send_request("/gpg_keys", :post, params, ) GpgKey.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
326 327 328 329 330 331 332 333 334 |
# File 'lib/files.com/models/gpg_key.rb', line 326 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("/gpg_keys/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
336 337 338 339 |
# File 'lib/files.com/models/gpg_key.rb', line 336 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Gpg Key ID.
262 263 264 265 266 267 268 269 270 |
# File 'lib/files.com/models/gpg_key.rb', line 262 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("/gpg_keys/#{params[:id]}", :get, params, ) GpgKey.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
272 273 274 |
# File 'lib/files.com/models/gpg_key.rb', line 272 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`, `name` or `expires_at`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `workspace_id`, `partner_id` or `expires_at`. Valid field combinations are `[ workspace_id, expires_at ]`.
filter_gt - object - If set, return records where the specified field is greater than the supplied value. Valid fields are `expires_at`.
filter_gteq - object - If set, return records where the specified field is greater than or equal the supplied value. Valid fields are `expires_at`.
filter_lt - object - If set, return records where the specified field is less than the supplied value. Valid fields are `expires_at`.
filter_lteq - object - If set, return records where the specified field is less than or equal the supplied value. Valid fields are `expires_at`.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/files.com/models/gpg_key.rb', line 240 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(GpgKey, params) do Api.send_request("/gpg_keys", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
partner_id - int64 - Partner ID who owns this GPG Key, if applicable.
public_key - string - The GPG public key
private_key - string - The GPG private key
private_key_password - string - The GPG private key password
name - string - GPG key name.
311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/files.com/models/gpg_key.rb', line 311 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: partner_id must be an Integer") if params[:partner_id] and !params[:partner_id].is_a?(Integer) 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: private_key must be an String") if params[:private_key] and !params[:private_key].is_a?(String) raise InvalidParameterError.new("Bad parameter: private_key_password must be an String") if params[:private_key_password] and !params[:private_key_password].is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/gpg_keys/#{params[:id]}", :patch, params, ) GpgKey.new(response.data, ) end |
Instance Method Details
#delete(params = {}) ⇒ Object
204 205 206 207 208 209 210 211 212 |
# File 'lib/files.com/models/gpg_key.rb', line 204 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("/gpg_keys/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
214 215 216 217 |
# File 'lib/files.com/models/gpg_key.rb', line 214 def destroy(params = {}) delete(params) nil end |
#expires_at ⇒ Object
date-time - GPG key expiration date.
31 32 33 |
# File 'lib/files.com/models/gpg_key.rb', line 31 def expires_at @attributes[:expires_at] end |
#expires_at=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/gpg_key.rb', line 35 def expires_at=(value) @attributes[:expires_at] = value end |
#generate_email ⇒ Object
string - Email address of the key owner. Used for the generation of the key. Will be ignored if ‘generate_keypair` is false.
175 176 177 |
# File 'lib/files.com/models/gpg_key.rb', line 175 def generate_email @attributes[:generate_email] end |
#generate_email=(value) ⇒ Object
179 180 181 |
# File 'lib/files.com/models/gpg_key.rb', line 179 def generate_email=(value) @attributes[:generate_email] = value end |
#generate_expires_at ⇒ Object
string - Expiration date of the key. Used for the generation of the key. Will be ignored if ‘generate_keypair` is false.
148 149 150 |
# File 'lib/files.com/models/gpg_key.rb', line 148 def generate_expires_at @attributes[:generate_expires_at] end |
#generate_expires_at=(value) ⇒ Object
152 153 154 |
# File 'lib/files.com/models/gpg_key.rb', line 152 def generate_expires_at=(value) @attributes[:generate_expires_at] = value end |
#generate_full_name ⇒ Object
string - Full name of the key owner. Used for the generation of the key. Will be ignored if ‘generate_keypair` is false.
166 167 168 |
# File 'lib/files.com/models/gpg_key.rb', line 166 def generate_full_name @attributes[:generate_full_name] end |
#generate_full_name=(value) ⇒ Object
170 171 172 |
# File 'lib/files.com/models/gpg_key.rb', line 170 def generate_full_name=(value) @attributes[:generate_full_name] = value end |
#generate_keypair ⇒ Object
boolean - If true, generate a new GPG key pair. Can not be used with ‘public_key`/`private_key`
157 158 159 |
# File 'lib/files.com/models/gpg_key.rb', line 157 def generate_keypair @attributes[:generate_keypair] end |
#generate_keypair=(value) ⇒ Object
161 162 163 |
# File 'lib/files.com/models/gpg_key.rb', line 161 def generate_keypair=(value) @attributes[:generate_keypair] = value end |
#generated_private_key ⇒ Object
string - GPG private key.
103 104 105 |
# File 'lib/files.com/models/gpg_key.rb', line 103 def generated_private_key @attributes[:generated_private_key] end |
#generated_private_key=(value) ⇒ Object
107 108 109 |
# File 'lib/files.com/models/gpg_key.rb', line 107 def generated_private_key=(value) @attributes[:generated_private_key] = value end |
#generated_public_key ⇒ Object
string - GPG public key
94 95 96 |
# File 'lib/files.com/models/gpg_key.rb', line 94 def generated_public_key @attributes[:generated_public_key] end |
#generated_public_key=(value) ⇒ Object
98 99 100 |
# File 'lib/files.com/models/gpg_key.rb', line 98 def generated_public_key=(value) @attributes[:generated_public_key] = value end |
#id ⇒ Object
int64 - GPG key ID.
13 14 15 |
# File 'lib/files.com/models/gpg_key.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/gpg_key.rb', line 17 def id=(value) @attributes[:id] = value end |
#name ⇒ Object
string - GPG key name.
40 41 42 |
# File 'lib/files.com/models/gpg_key.rb', line 40 def name @attributes[:name] end |
#name=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/gpg_key.rb', line 44 def name=(value) @attributes[:name] = value end |
#partner_id ⇒ Object
int64 - Partner ID who owns this GPG Key, if applicable.
49 50 51 |
# File 'lib/files.com/models/gpg_key.rb', line 49 def partner_id @attributes[:partner_id] end |
#partner_id=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/gpg_key.rb', line 53 def partner_id=(value) @attributes[:partner_id] = value end |
#partner_name ⇒ Object
string - Name of the Partner who owns this GPG Key, if applicable.
58 59 60 |
# File 'lib/files.com/models/gpg_key.rb', line 58 def partner_name @attributes[:partner_name] end |
#partner_name=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/gpg_key.rb', line 62 def partner_name=(value) @attributes[:partner_name] = value end |
#private_key ⇒ Object
string - The GPG private key
130 131 132 |
# File 'lib/files.com/models/gpg_key.rb', line 130 def private_key @attributes[:private_key] end |
#private_key=(value) ⇒ Object
134 135 136 |
# File 'lib/files.com/models/gpg_key.rb', line 134 def private_key=(value) @attributes[:private_key] = value end |
#private_key_md5 ⇒ Object
string - MD5 hash of the GPG private key.
85 86 87 |
# File 'lib/files.com/models/gpg_key.rb', line 85 def private_key_md5 @attributes[:private_key_md5] end |
#private_key_md5=(value) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/gpg_key.rb', line 89 def private_key_md5=(value) @attributes[:private_key_md5] = value end |
#private_key_password ⇒ Object
string - The GPG private key password
139 140 141 |
# File 'lib/files.com/models/gpg_key.rb', line 139 def private_key_password @attributes[:private_key_password] end |
#private_key_password=(value) ⇒ Object
143 144 145 |
# File 'lib/files.com/models/gpg_key.rb', line 143 def private_key_password=(value) @attributes[:private_key_password] = value end |
#private_key_password_md5 ⇒ Object
string - GPG private key password. Only required for password protected keys.
112 113 114 |
# File 'lib/files.com/models/gpg_key.rb', line 112 def private_key_password_md5 @attributes[:private_key_password_md5] end |
#private_key_password_md5=(value) ⇒ Object
116 117 118 |
# File 'lib/files.com/models/gpg_key.rb', line 116 def private_key_password_md5=(value) @attributes[:private_key_password_md5] = value end |
#public_key ⇒ Object
string - The GPG public key
121 122 123 |
# File 'lib/files.com/models/gpg_key.rb', line 121 def public_key @attributes[:public_key] end |
#public_key=(value) ⇒ Object
125 126 127 |
# File 'lib/files.com/models/gpg_key.rb', line 125 def public_key=(value) @attributes[:public_key] = value end |
#public_key_md5 ⇒ Object
string - MD5 hash of the GPG public key
76 77 78 |
# File 'lib/files.com/models/gpg_key.rb', line 76 def public_key_md5 @attributes[:public_key_md5] end |
#public_key_md5=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/gpg_key.rb', line 80 def public_key_md5=(value) @attributes[:public_key_md5] = value end |
#save ⇒ Object
219 220 221 222 223 224 225 226 227 228 |
# File 'lib/files.com/models/gpg_key.rb', line 219 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = GpgKey.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#update(params = {}) ⇒ Object
Parameters:
partner_id - int64 - Partner ID who owns this GPG Key, if applicable.
public_key - string - The GPG public key
private_key - string - The GPG private key
private_key_password - string - The GPG private key password
name - string - GPG key name.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/files.com/models/gpg_key.rb', line 189 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: partner_id must be an Integer") if params[:partner_id] and !params[:partner_id].is_a?(Integer) 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: private_key must be an String") if params[:private_key] and !params[:private_key].is_a?(String) raise InvalidParameterError.new("Bad parameter: private_key_password must be an String") if params[:private_key_password] and !params[:private_key_password].is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/gpg_keys/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - User ID who owns this GPG Key, if applicable.
67 68 69 |
# File 'lib/files.com/models/gpg_key.rb', line 67 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/gpg_key.rb', line 71 def user_id=(value) @attributes[:user_id] = value end |
#workspace_id ⇒ Object
int64 - Workspace ID (0 for default workspace).
22 23 24 |
# File 'lib/files.com/models/gpg_key.rb', line 22 def workspace_id @attributes[:workspace_id] end |
#workspace_id=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/gpg_key.rb', line 26 def workspace_id=(value) @attributes[:workspace_id] = value end |