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
-
#allowed_2fa_method_sms ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_sms=(value) ⇒ Object
-
#allowed_2fa_method_totp ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_totp=(value) ⇒ Object
-
#allowed_2fa_method_u2f ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_u2f=(value) ⇒ Object
-
#allowed_2fa_method_yubi ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_yubi=(value) ⇒ Object
- #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
-
#login_token ⇒ Object
string - Login token.
- #login_token=(value) ⇒ Object
-
#login_token_domain ⇒ Object
string - Domain to use with ‘login_token`.
- #login_token_domain=(value) ⇒ Object
-
#max_dir_listing_size ⇒ Object
int64 - Maximum number of files to retrieve per folder for a directory listing.
- #max_dir_listing_size=(value) ⇒ Object
-
#multiple_regions ⇒ Object
boolean - Can access multiple regions?.
- #multiple_regions=(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
-
#root_path ⇒ Object
string - Initial root path to start the user’s session in.
- #root_path=(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
-
#site_id ⇒ Object
int64 - Site ID.
- #site_id=(value) ⇒ Object
-
#ssl_required ⇒ Object
boolean - Is SSL required for this user? (If so, ensure all your communications with this user use SSL.).
- #ssl_required=(value) ⇒ Object
-
#tls_disabled ⇒ Object
boolean - Are insecure TLS versions allowed for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure TLS versions for this user.).
- #tls_disabled=(value) ⇒ Object
-
#two_factor_setup_needed ⇒ Object
boolean - If true, this user needs to add a Two Factor Authentication method before performing any further actions.
- #two_factor_setup_needed=(value) ⇒ Object
-
#use_provided_modified_at ⇒ Object
boolean - Allow the user to provide file/folder modified at dates? If false, the server will always use the current date/time.
- #use_provided_modified_at=(value) ⇒ Object
-
#username ⇒ Object
string - Username to sign in as.
- #username=(value) ⇒ Object
-
#windows_mode_ftp ⇒ Object
boolean - Does this user want to use Windows line-ending emulation? (CR vs CRLF).
- #windows_mode_ftp=(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
237 238 239 240 241 242 243 244 245 |
# File 'lib/files.com/models/session.rb', line 237 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
247 248 249 250 |
# File 'lib/files.com/models/session.rb', line 247 def self.delete(params = {}, = {}) response, = Api.send_request("/sessions", :delete, params, ) response.data end |
.destroy(params = {}, options = {}) ⇒ Object
252 253 254 |
# File 'lib/files.com/models/session.rb', line 252 def self.destroy(params = {}, = {}) delete(params, ) end |
Instance Method Details
#allowed_2fa_method_sms ⇒ Object
boolean - Sent only if 2FA setup is needed. Is SMS two factor authentication allowed?
134 135 136 |
# File 'lib/files.com/models/session.rb', line 134 def allowed_2fa_method_sms @attributes[:allowed_2fa_method_sms] end |
#allowed_2fa_method_sms=(value) ⇒ Object
138 139 140 |
# File 'lib/files.com/models/session.rb', line 138 def allowed_2fa_method_sms=(value) @attributes[:allowed_2fa_method_sms] = value end |
#allowed_2fa_method_totp ⇒ Object
boolean - Sent only if 2FA setup is needed. Is TOTP two factor authentication allowed?
143 144 145 |
# File 'lib/files.com/models/session.rb', line 143 def allowed_2fa_method_totp @attributes[:allowed_2fa_method_totp] end |
#allowed_2fa_method_totp=(value) ⇒ Object
147 148 149 |
# File 'lib/files.com/models/session.rb', line 147 def allowed_2fa_method_totp=(value) @attributes[:allowed_2fa_method_totp] = value end |
#allowed_2fa_method_u2f ⇒ Object
boolean - Sent only if 2FA setup is needed. Is U2F two factor authentication allowed?
152 153 154 |
# File 'lib/files.com/models/session.rb', line 152 def allowed_2fa_method_u2f @attributes[:allowed_2fa_method_u2f] end |
#allowed_2fa_method_u2f=(value) ⇒ Object
156 157 158 |
# File 'lib/files.com/models/session.rb', line 156 def allowed_2fa_method_u2f=(value) @attributes[:allowed_2fa_method_u2f] = value end |
#allowed_2fa_method_yubi ⇒ Object
boolean - Sent only if 2FA setup is needed. Is Yubikey two factor authentication allowed?
161 162 163 |
# File 'lib/files.com/models/session.rb', line 161 def allowed_2fa_method_yubi @attributes[:allowed_2fa_method_yubi] end |
#allowed_2fa_method_yubi=(value) ⇒ Object
165 166 167 |
# File 'lib/files.com/models/session.rb', line 165 def allowed_2fa_method_yubi=(value) @attributes[:allowed_2fa_method_yubi] = value end |
#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 |
#login_token ⇒ Object
string - Login token. If set, this token will allow your user to log in via browser at the domain in ‘login_token_domain`.
35 36 37 |
# File 'lib/files.com/models/session.rb', line 35 def login_token @attributes[:login_token] end |
#login_token=(value) ⇒ Object
39 40 41 |
# File 'lib/files.com/models/session.rb', line 39 def login_token=(value) @attributes[:login_token] = value end |
#login_token_domain ⇒ Object
string - Domain to use with ‘login_token`.
44 45 46 |
# File 'lib/files.com/models/session.rb', line 44 def login_token_domain @attributes[:login_token_domain] end |
#login_token_domain=(value) ⇒ Object
48 49 50 |
# File 'lib/files.com/models/session.rb', line 48 def login_token_domain=(value) @attributes[:login_token_domain] = value end |
#max_dir_listing_size ⇒ Object
int64 - Maximum number of files to retrieve per folder for a directory listing. This is based on the user’s plan.
53 54 55 |
# File 'lib/files.com/models/session.rb', line 53 def max_dir_listing_size @attributes[:max_dir_listing_size] end |
#max_dir_listing_size=(value) ⇒ Object
57 58 59 |
# File 'lib/files.com/models/session.rb', line 57 def max_dir_listing_size=(value) @attributes[:max_dir_listing_size] = value end |
#multiple_regions ⇒ Object
boolean - Can access multiple regions?
62 63 64 |
# File 'lib/files.com/models/session.rb', line 62 def multiple_regions @attributes[:multiple_regions] end |
#multiple_regions=(value) ⇒ Object
66 67 68 |
# File 'lib/files.com/models/session.rb', line 66 def multiple_regions=(value) @attributes[:multiple_regions] = value end |
#otp ⇒ Object
string - If this user has a 2FA device, provide its OTP or code here.
206 207 208 |
# File 'lib/files.com/models/session.rb', line 206 def otp @attributes[:otp] end |
#otp=(value) ⇒ Object
210 211 212 |
# File 'lib/files.com/models/session.rb', line 210 def otp=(value) @attributes[:otp] = value end |
#partial_session_id ⇒ Object
string - Identifier for a partially-completed login
215 216 217 |
# File 'lib/files.com/models/session.rb', line 215 def partial_session_id @attributes[:partial_session_id] end |
#partial_session_id=(value) ⇒ Object
219 220 221 |
# File 'lib/files.com/models/session.rb', line 219 def partial_session_id=(value) @attributes[:partial_session_id] = value end |
#password ⇒ Object
string - Password for sign in
197 198 199 |
# File 'lib/files.com/models/session.rb', line 197 def password @attributes[:password] end |
#password=(value) ⇒ Object
201 202 203 |
# File 'lib/files.com/models/session.rb', line 201 def password=(value) @attributes[:password] = value end |
#read_only ⇒ Object
boolean - Is this session read only?
71 72 73 |
# File 'lib/files.com/models/session.rb', line 71 def read_only @attributes[:read_only] end |
#read_only=(value) ⇒ Object
75 76 77 |
# File 'lib/files.com/models/session.rb', line 75 def read_only=(value) @attributes[:read_only] = value end |
#root_path ⇒ Object
string - Initial root path to start the user’s session in.
80 81 82 |
# File 'lib/files.com/models/session.rb', line 80 def root_path @attributes[:root_path] end |
#root_path=(value) ⇒ Object
84 85 86 |
# File 'lib/files.com/models/session.rb', line 84 def root_path=(value) @attributes[:root_path] = value end |
#save ⇒ Object
223 224 225 226 227 228 229 230 |
# File 'lib/files.com/models/session.rb', line 223 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.)
89 90 91 |
# File 'lib/files.com/models/session.rb', line 89 def sftp_insecure_ciphers @attributes[:sftp_insecure_ciphers] end |
#sftp_insecure_ciphers=(value) ⇒ Object
93 94 95 |
# File 'lib/files.com/models/session.rb', line 93 def sftp_insecure_ciphers=(value) @attributes[:sftp_insecure_ciphers] = value end |
#site_id ⇒ Object
int64 - Site ID
98 99 100 |
# File 'lib/files.com/models/session.rb', line 98 def site_id @attributes[:site_id] end |
#site_id=(value) ⇒ Object
102 103 104 |
# File 'lib/files.com/models/session.rb', line 102 def site_id=(value) @attributes[:site_id] = value end |
#ssl_required ⇒ Object
boolean - Is SSL required for this user? (If so, ensure all your communications with this user use SSL.)
107 108 109 |
# File 'lib/files.com/models/session.rb', line 107 def ssl_required @attributes[:ssl_required] end |
#ssl_required=(value) ⇒ Object
111 112 113 |
# File 'lib/files.com/models/session.rb', line 111 def ssl_required=(value) @attributes[:ssl_required] = value end |
#tls_disabled ⇒ Object
boolean - Are insecure TLS versions allowed for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure TLS versions for this user.)
116 117 118 |
# File 'lib/files.com/models/session.rb', line 116 def tls_disabled @attributes[:tls_disabled] end |
#tls_disabled=(value) ⇒ Object
120 121 122 |
# File 'lib/files.com/models/session.rb', line 120 def tls_disabled=(value) @attributes[:tls_disabled] = value end |
#two_factor_setup_needed ⇒ Object
boolean - If true, this user needs to add a Two Factor Authentication method before performing any further actions.
125 126 127 |
# File 'lib/files.com/models/session.rb', line 125 def two_factor_setup_needed @attributes[:two_factor_setup_needed] end |
#two_factor_setup_needed=(value) ⇒ Object
129 130 131 |
# File 'lib/files.com/models/session.rb', line 129 def two_factor_setup_needed=(value) @attributes[:two_factor_setup_needed] = value end |
#use_provided_modified_at ⇒ Object
boolean - Allow the user to provide file/folder modified at dates? If false, the server will always use the current date/time.
170 171 172 |
# File 'lib/files.com/models/session.rb', line 170 def use_provided_modified_at @attributes[:use_provided_modified_at] end |
#use_provided_modified_at=(value) ⇒ Object
174 175 176 |
# File 'lib/files.com/models/session.rb', line 174 def use_provided_modified_at=(value) @attributes[:use_provided_modified_at] = value end |
#username ⇒ Object
string - Username to sign in as
188 189 190 |
# File 'lib/files.com/models/session.rb', line 188 def username @attributes[:username] end |
#username=(value) ⇒ Object
192 193 194 |
# File 'lib/files.com/models/session.rb', line 192 def username=(value) @attributes[:username] = value end |
#windows_mode_ftp ⇒ Object
boolean - Does this user want to use Windows line-ending emulation? (CR vs CRLF)
179 180 181 |
# File 'lib/files.com/models/session.rb', line 179 def windows_mode_ftp @attributes[:windows_mode_ftp] end |
#windows_mode_ftp=(value) ⇒ Object
183 184 185 |
# File 'lib/files.com/models/session.rb', line 183 def windows_mode_ftp=(value) @attributes[:windows_mode_ftp] = value end |