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: name (required) - string - Your GPG key name.
Instance Method Summary collapse
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#expires_at ⇒ Object
date-time - Your GPG key expiration date.
- #expires_at=(value) ⇒ Object
-
#id ⇒ Object
int64 - Your GPG key ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ GpgKey
constructor
A new instance of GpgKey.
-
#name ⇒ Object
string - Your GPG key name.
- #name=(value) ⇒ Object
-
#private_key ⇒ Object
string - Your GPG private key.
- #private_key=(value) ⇒ Object
-
#private_key_password ⇒ Object
string - Your GPG private key password.
- #private_key_password=(value) ⇒ Object
-
#public_key ⇒ Object
string - Your GPG public key.
- #public_key=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: name (required) - string - Your GPG key name.
-
#user_id ⇒ Object
int64 - GPG owner’s user id.
- #user_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
132 133 134 |
# File 'lib/files.com/models/gpg_key.rb', line 132 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.
name (required) - string - Your GPG key name.
public_key - string - Your GPG public key
private_key - string - Your GPG private key.
private_key_password - string - Your GPG private key password. Only required for password protected keys.
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/files.com/models/gpg_key.rb', line 158 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: name must be an String") if params[:name] and !params[:name].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: 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 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
190 191 192 193 194 195 196 197 198 |
# File 'lib/files.com/models/gpg_key.rb', line 190 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("/gpg_keys/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
200 201 202 |
# File 'lib/files.com/models/gpg_key.rb', line 200 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Gpg Key ID.
138 139 140 141 142 143 144 145 146 |
# File 'lib/files.com/models/gpg_key.rb', line 138 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
148 149 150 |
# File 'lib/files.com/models/gpg_key.rb', line 148 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).
122 123 124 125 126 127 128 129 130 |
# File 'lib/files.com/models/gpg_key.rb', line 122 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(GpgKey, params) do Api.send_request("/gpg_keys", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
name (required) - string - Your GPG key name.
public_key - string - Your GPG public key
private_key - string - Your GPG private key.
private_key_password - string - Your GPG private key password. Only required for password protected keys.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/files.com/models/gpg_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: name must be an String") if params[:name] and !params[:name].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: 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 MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: name") unless params[:name] response, = Api.send_request("/gpg_keys/#{params[:id]}", :patch, params, ) GpgKey.new(response.data, ) end |
Instance Method Details
#delete(params = {}) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/files.com/models/gpg_key.rb', line 95 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
105 106 107 |
# File 'lib/files.com/models/gpg_key.rb', line 105 def destroy(params = {}) delete(params) end |
#expires_at ⇒ Object
date-time - Your GPG key expiration date.
22 23 24 |
# File 'lib/files.com/models/gpg_key.rb', line 22 def expires_at @attributes[:expires_at] end |
#expires_at=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/gpg_key.rb', line 26 def expires_at=(value) @attributes[:expires_at] = value end |
#id ⇒ Object
int64 - Your 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 - Your GPG key name.
31 32 33 |
# File 'lib/files.com/models/gpg_key.rb', line 31 def name @attributes[:name] end |
#name=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/gpg_key.rb', line 35 def name=(value) @attributes[:name] = value end |
#private_key ⇒ Object
string - Your GPG private key.
58 59 60 |
# File 'lib/files.com/models/gpg_key.rb', line 58 def private_key @attributes[:private_key] end |
#private_key=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/gpg_key.rb', line 62 def private_key=(value) @attributes[:private_key] = value end |
#private_key_password ⇒ Object
string - Your GPG private key password. Only required for password protected keys.
67 68 69 |
# File 'lib/files.com/models/gpg_key.rb', line 67 def private_key_password @attributes[:private_key_password] end |
#private_key_password=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/gpg_key.rb', line 71 def private_key_password=(value) @attributes[:private_key_password] = value end |
#public_key ⇒ Object
string - Your GPG public key
49 50 51 |
# File 'lib/files.com/models/gpg_key.rb', line 49 def public_key @attributes[:public_key] end |
#public_key=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/gpg_key.rb', line 53 def public_key=(value) @attributes[:public_key] = value end |
#save ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/files.com/models/gpg_key.rb', line 109 def save if @attributes[:id] update(@attributes) else new_obj = GpgKey.create(@attributes, @options) @attributes = new_obj.attributes end end |
#update(params = {}) ⇒ Object
Parameters:
name (required) - string - Your GPG key name.
public_key - string - Your GPG public key
private_key - string - Your GPG private key.
private_key_password - string - Your GPG private key password. Only required for password protected keys.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/files.com/models/gpg_key.rb', line 80 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: name must be an String") if params[:name] and !params[:name].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: 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 MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: name") unless params[:name] Api.send_request("/gpg_keys/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - GPG owner’s user id
40 41 42 |
# File 'lib/files.com/models/gpg_key.rb', line 40 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/gpg_key.rb', line 44 def user_id=(value) @attributes[:user_id] = value end |