Class: Files::UserLifecycleRule

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ UserLifecycleRule

Returns a new instance of UserLifecycleRule.



7
8
9
10
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 7

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/user_lifecycle_rule.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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



212
213
214
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 212

def self.all(params = {}, options = {})
  list(params, options)
end

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

Parameters:

action - string - Action to take on inactive users (disable or delete)
apply_to_all_workspaces - boolean - If true, a default-workspace rule also applies to users in all workspaces.
authentication_method - string - User authentication method for which the rule will apply.
group_ids - array(int64) - Array of Group IDs to which the rule applies. If empty or not set, the rule applies to all users.
inactivity_days - int64 - Number of days of inactivity before the rule applies
include_site_admins - boolean - If true, the rule will apply to site admins.
include_folder_admins - boolean - If true, the rule will apply to folder admins.
name - string - User Lifecycle Rule name
partner_tag - string - If provided, only users belonging to Partners with this tag at the Partner level will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
user_state - string - State of the users to apply the rule to (inactive or disabled)
user_tag - string - If provided, only users with this tag will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
workspace_id - int64 - Workspace ID. `0` means the default workspace.


245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 245

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params[:action] and !params[:action].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: authentication_method must be an String") if params[:authentication_method] and !params[:authentication_method].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: group_ids must be an Array") if params[:group_ids] and !params[:group_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: inactivity_days must be an Integer") if params[:inactivity_days] and !params[:inactivity_days].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: partner_tag must be an String") if params[:partner_tag] and !params[:partner_tag].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_state must be an String") if params[:user_state] and !params[:user_state].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_tag must be an String") if params[:user_tag] and !params[:user_tag].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)

  response, options = Api.send_request("/user_lifecycle_rules", :post, params, options)
  UserLifecycleRule.new(response.data, options)
end

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



292
293
294
295
296
297
298
299
300
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 292

def self.delete(id, params = {}, options = {})
  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("/user_lifecycle_rules/#{params[:id]}", :delete, params, options)
  nil
end

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



302
303
304
305
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 302

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

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - User Lifecycle Rule ID.


218
219
220
221
222
223
224
225
226
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 218

def self.find(id, params = {}, options = {})
  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, options = Api.send_request("/user_lifecycle_rules/#{params[:id]}", :get, params, options)
  UserLifecycleRule.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



228
229
230
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 228

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

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

Parameters:

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 `site_id` and `workspace_id`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `workspace_id`.


201
202
203
204
205
206
207
208
209
210
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 201

def self.list(params = {}, options = {})
  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)

  List.new(UserLifecycleRule, params) do
    Api.send_request("/user_lifecycle_rules", :get, params, options)
  end
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

action - string - Action to take on inactive users (disable or delete)
apply_to_all_workspaces - boolean - If true, a default-workspace rule also applies to users in all workspaces.
authentication_method - string - User authentication method for which the rule will apply.
group_ids - array(int64) - Array of Group IDs to which the rule applies. If empty or not set, the rule applies to all users.
inactivity_days - int64 - Number of days of inactivity before the rule applies
include_site_admins - boolean - If true, the rule will apply to site admins.
include_folder_admins - boolean - If true, the rule will apply to folder admins.
name - string - User Lifecycle Rule name
partner_tag - string - If provided, only users belonging to Partners with this tag at the Partner level will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
user_state - string - State of the users to apply the rule to (inactive or disabled)
user_tag - string - If provided, only users with this tag will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
workspace_id - int64 - Workspace ID. `0` means the default workspace.


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 273

def self.update(id, params = {}, options = {})
  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: action must be an String") if params[:action] and !params[:action].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: authentication_method must be an String") if params[:authentication_method] and !params[:authentication_method].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: group_ids must be an Array") if params[:group_ids] and !params[:group_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: inactivity_days must be an Integer") if params[:inactivity_days] and !params[:inactivity_days].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: partner_tag must be an String") if params[:partner_tag] and !params[:partner_tag].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_state must be an String") if params[:user_state] and !params[:user_state].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_tag must be an String") if params[:user_tag] and !params[:user_tag].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 MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/user_lifecycle_rules/#{params[:id]}", :patch, params, options)
  UserLifecycleRule.new(response.data, options)
end

Instance Method Details

#actionObject

string - Action to take on inactive users (disable or delete)



40
41
42
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 40

def action
  @attributes[:action]
end

#action=(value) ⇒ Object



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

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

#apply_to_all_workspacesObject

boolean - If true, a default-workspace rule also applies to users in all workspaces.



76
77
78
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 76

def apply_to_all_workspaces
  @attributes[:apply_to_all_workspaces]
end

#apply_to_all_workspaces=(value) ⇒ Object



80
81
82
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 80

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

#authentication_methodObject

string - User authentication method for which the rule will apply.



22
23
24
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 22

def authentication_method
  @attributes[:authentication_method]
end

#authentication_method=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 26

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

#delete(params = {}) ⇒ Object



170
171
172
173
174
175
176
177
178
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 170

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("/user_lifecycle_rules/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



180
181
182
183
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 180

def destroy(params = {})
  delete(params)
  nil
end

#group_idsObject

array(int64) - Array of Group IDs to which the rule applies. If empty or not set, the rule applies to all users.



31
32
33
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 31

def group_ids
  @attributes[:group_ids]
end

#group_ids=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 35

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

#idObject

int64 - User Lifecycle Rule ID



13
14
15
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 17

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

#inactivity_daysObject

int64 - Number of days of inactivity before the rule applies



49
50
51
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 49

def inactivity_days
  @attributes[:inactivity_days]
end

#inactivity_days=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 53

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

#include_folder_adminsObject

boolean - If true, the rule will apply to folder admins.



58
59
60
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 58

def include_folder_admins
  @attributes[:include_folder_admins]
end

#include_folder_admins=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 62

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

#include_site_adminsObject

boolean - If true, the rule will apply to site admins.



67
68
69
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 67

def include_site_admins
  @attributes[:include_site_admins]
end

#include_site_admins=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 71

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

#nameObject

string - User Lifecycle Rule name



85
86
87
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 85

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



89
90
91
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 89

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

#partner_tagObject

string - If provided, only users belonging to Partners with this tag at the Partner level will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.



94
95
96
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 94

def partner_tag
  @attributes[:partner_tag]
end

#partner_tag=(value) ⇒ Object



98
99
100
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 98

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

#saveObject



185
186
187
188
189
190
191
192
193
194
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 185

def save
  if @attributes[:id]
    new_obj = update(@attributes)
  else
    new_obj = UserLifecycleRule.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#site_idObject

int64 - Site ID



103
104
105
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 103

def site_id
  @attributes[:site_id]
end

#site_id=(value) ⇒ Object



107
108
109
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 107

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

#update(params = {}) ⇒ Object

Parameters:

action - string - Action to take on inactive users (disable or delete)
apply_to_all_workspaces - boolean - If true, a default-workspace rule also applies to users in all workspaces.
authentication_method - string - User authentication method for which the rule will apply.
group_ids - array(int64) - Array of Group IDs to which the rule applies. If empty or not set, the rule applies to all users.
inactivity_days - int64 - Number of days of inactivity before the rule applies
include_site_admins - boolean - If true, the rule will apply to site admins.
include_folder_admins - boolean - If true, the rule will apply to folder admins.
name - string - User Lifecycle Rule name
partner_tag - string - If provided, only users belonging to Partners with this tag at the Partner level will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
user_state - string - State of the users to apply the rule to (inactive or disabled)
user_tag - string - If provided, only users with this tag will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
workspace_id - int64 - Workspace ID. `0` means the default workspace.


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 151

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: action must be an String") if params[:action] and !params[:action].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: authentication_method must be an String") if params[:authentication_method] and !params[:authentication_method].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: group_ids must be an Array") if params[:group_ids] and !params[:group_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: inactivity_days must be an Integer") if params[:inactivity_days] and !params[:inactivity_days].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: partner_tag must be an String") if params[:partner_tag] and !params[:partner_tag].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_state must be an String") if params[:user_state] and !params[:user_state].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_tag must be an String") if params[:user_tag] and !params[:user_tag].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 MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/user_lifecycle_rules/#{@attributes[:id]}", :patch, params, @options)
end

#user_stateObject

string - State of the users to apply the rule to (inactive or disabled)



121
122
123
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 121

def user_state
  @attributes[:user_state]
end

#user_state=(value) ⇒ Object



125
126
127
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 125

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

#user_tagObject

string - If provided, only users with this tag will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.



130
131
132
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 130

def user_tag
  @attributes[:user_tag]
end

#user_tag=(value) ⇒ Object



134
135
136
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 134

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

#workspace_idObject

int64 - Workspace ID. ‘0` means the default workspace.



112
113
114
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 112

def workspace_id
  @attributes[:workspace_id]
end

#workspace_id=(value) ⇒ Object



116
117
118
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 116

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