Class: Files::Session
- Inherits:
-
Object
- Object
- Files::Session
- Defined in:
- lib/files.com/models/session.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
-
.create(params = {}, options = {}) ⇒ Object
Parameters: username - string - Username to sign in as password - string - Password for sign in otp - string - If this user has a 2FA device, provide its OTP or code here.
- .delete(params = {}, options = {}) ⇒ Object
- .destroy(params = {}, options = {}) ⇒ Object
Instance Method Summary collapse
- #destroy(params = {}, options = {}) ⇒ Object
-
#id ⇒ Object
string - Session ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Session
constructor
A new instance of Session.
-
#language ⇒ Object
string - Session language.
- #language=(value) ⇒ Object
-
#otp ⇒ Object
string - If this user has a 2FA device, provide its OTP or code here.
- #otp=(value) ⇒ Object
-
#partial_session_id ⇒ Object
string - Identifier for a partially-completed login.
- #partial_session_id=(value) ⇒ Object
-
#password ⇒ Object
string - Password for sign in.
- #password=(value) ⇒ Object
-
#read_only ⇒ Object
boolean - Is this session read only?.
- #read_only=(value) ⇒ Object
- #save ⇒ Object
-
#sftp_insecure_ciphers ⇒ Object
boolean - Are insecure SFTP ciphers allowed for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure SSH ciphers for this user.).
- #sftp_insecure_ciphers=(value) ⇒ Object
-
#username ⇒ Object
string - Username to sign in as.
- #username=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Session
Returns a new instance of Session.
11 12 13 14 |
# File 'lib/files.com/models/session.rb', line 11 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/session.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/session.rb', line 5 def @options end |
Class Method Details
.create(params = {}, options = {}) ⇒ Object
Parameters:
username - string - Username to sign in as
password - string - Password for sign in
otp - string - If this user has a 2FA device, provide its OTP or code here.
partial_session_id - string - Identifier for a partially-completed login
102 103 104 105 106 107 108 109 110 |
# File 'lib/files.com/models/session.rb', line 102 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String) raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String) raise InvalidParameterError.new("Bad parameter: otp must be an String") if params.dig(:otp) and !params.dig(:otp).is_a?(String) raise InvalidParameterError.new("Bad parameter: partial_session_id must be an String") if params.dig(:partial_session_id) and !params.dig(:partial_session_id).is_a?(String) response, = Api.send_request("/sessions", :post, params, ) Session.new(response.data, ) end |
.delete(params = {}, options = {}) ⇒ Object
112 113 114 115 |
# File 'lib/files.com/models/session.rb', line 112 def self.delete(params = {}, = {}) response, = Api.send_request("/sessions", :delete, params, ) response.data end |
.destroy(params = {}, options = {}) ⇒ Object
117 118 119 |
# File 'lib/files.com/models/session.rb', line 117 def self.destroy(params = {}, = {}) delete(params, ) end |
Instance Method Details
#destroy(params = {}, options = {}) ⇒ Object
7 8 9 |
# File 'lib/files.com/models/session.rb', line 7 def destroy(params = {}, = {}) Session.destroy(params, .merge(session: self, session_id: nil)) end |
#id ⇒ Object
string - Session ID
17 18 19 |
# File 'lib/files.com/models/session.rb', line 17 def id @attributes[:id] end |
#id=(value) ⇒ Object
21 22 23 |
# File 'lib/files.com/models/session.rb', line 21 def id=(value) @attributes[:id] = value end |
#language ⇒ Object
string - Session language
26 27 28 |
# File 'lib/files.com/models/session.rb', line 26 def language @attributes[:language] end |
#language=(value) ⇒ Object
30 31 32 |
# File 'lib/files.com/models/session.rb', line 30 def language=(value) @attributes[:language] = value end |
#otp ⇒ Object
string - If this user has a 2FA device, provide its OTP or code here.
71 72 73 |
# File 'lib/files.com/models/session.rb', line 71 def otp @attributes[:otp] end |
#otp=(value) ⇒ Object
75 76 77 |
# File 'lib/files.com/models/session.rb', line 75 def otp=(value) @attributes[:otp] = value end |
#partial_session_id ⇒ Object
string - Identifier for a partially-completed login
80 81 82 |
# File 'lib/files.com/models/session.rb', line 80 def partial_session_id @attributes[:partial_session_id] end |
#partial_session_id=(value) ⇒ Object
84 85 86 |
# File 'lib/files.com/models/session.rb', line 84 def partial_session_id=(value) @attributes[:partial_session_id] = value end |
#password ⇒ Object
string - Password for sign in
62 63 64 |
# File 'lib/files.com/models/session.rb', line 62 def password @attributes[:password] end |
#password=(value) ⇒ Object
66 67 68 |
# File 'lib/files.com/models/session.rb', line 66 def password=(value) @attributes[:password] = value end |
#read_only ⇒ Object
boolean - Is this session read only?
35 36 37 |
# File 'lib/files.com/models/session.rb', line 35 def read_only @attributes[:read_only] end |
#read_only=(value) ⇒ Object
39 40 41 |
# File 'lib/files.com/models/session.rb', line 39 def read_only=(value) @attributes[:read_only] = value end |
#save ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/files.com/models/session.rb', line 88 def save if @attributes[:id] raise NotImplementedError.new("The Session object doesn't support updates.") else new_obj = Session.create(@attributes, @options) @attributes = new_obj.attributes end end |
#sftp_insecure_ciphers ⇒ Object
boolean - Are insecure SFTP ciphers allowed for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure SSH ciphers for this user.)
44 45 46 |
# File 'lib/files.com/models/session.rb', line 44 def sftp_insecure_ciphers @attributes[:sftp_insecure_ciphers] end |
#sftp_insecure_ciphers=(value) ⇒ Object
48 49 50 |
# File 'lib/files.com/models/session.rb', line 48 def sftp_insecure_ciphers=(value) @attributes[:sftp_insecure_ciphers] = value end |
#username ⇒ Object
string - Username to sign in as
53 54 55 |
# File 'lib/files.com/models/session.rb', line 53 def username @attributes[:username] end |
#username=(value) ⇒ Object
57 58 59 |
# File 'lib/files.com/models/session.rb', line 57 def username=(value) @attributes[:username] = value end |