Class: Files::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/session.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/session.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/session.rb', line 5

def options
  @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 = {}, options = {})
  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, options = Api.send_request("/sessions", :post, params, options)
  Session.new(response.data, options)
end

.delete(params = {}, options = {}) ⇒ Object



247
248
249
250
# File 'lib/files.com/models/session.rb', line 247

def self.delete(params = {}, options = {})
  response, _options = Api.send_request("/sessions", :delete, params, options)
  response.data
end

.destroy(params = {}, options = {}) ⇒ Object



252
253
254
# File 'lib/files.com/models/session.rb', line 252

def self.destroy(params = {}, options = {})
  delete(params, options)
end

Instance Method Details

#allowed_2fa_method_smsObject

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_totpObject

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_u2fObject

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_yubiObject

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 = {}, options = {})
  Session.destroy(params, options.merge(session: self, session_id: nil))
end

#idObject

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

#languageObject

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_tokenObject

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 
  @attributes[:login_token]
end

#login_token=(value) ⇒ Object



39
40
41
# File 'lib/files.com/models/session.rb', line 39

def (value)
  @attributes[:login_token] = value
end

#login_token_domainObject

string - Domain to use with ‘login_token`.



44
45
46
# File 'lib/files.com/models/session.rb', line 44

def 
  @attributes[:login_token_domain]
end

#login_token_domain=(value) ⇒ Object



48
49
50
# File 'lib/files.com/models/session.rb', line 48

def (value)
  @attributes[:login_token_domain] = value
end

#max_dir_listing_sizeObject

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_regionsObject

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

#otpObject

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_idObject

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

#passwordObject

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_onlyObject

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_pathObject

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

#saveObject



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_ciphersObject

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_idObject

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_requiredObject

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_disabledObject

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_neededObject

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_atObject

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

#usernameObject

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_ftpObject

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