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



189
190
191
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 189

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)
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.


220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 220

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)

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

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



263
264
265
266
267
268
269
270
271
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 263

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



273
274
275
276
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 273

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.


195
196
197
198
199
200
201
202
203
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 195

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



205
206
207
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 205

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`.


179
180
181
182
183
184
185
186
187
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 179

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)

  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)
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.


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

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 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

#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



149
150
151
152
153
154
155
156
157
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 149

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



159
160
161
162
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 159

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



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

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



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

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.



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

def partner_tag
  @attributes[:partner_tag]
end

#partner_tag=(value) ⇒ Object



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

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

#saveObject



164
165
166
167
168
169
170
171
172
173
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 164

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



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

def site_id
  @attributes[:site_id]
end

#site_id=(value) ⇒ Object



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

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

#update(params = {}) ⇒ Object

Parameters:

action - string - Action to take on inactive users (disable or delete)
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.


131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/files.com/models/user_lifecycle_rule.rb', line 131

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 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)



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

def user_state
  @attributes[:user_state]
end

#user_state=(value) ⇒ Object



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

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.



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

def user_tag
  @attributes[:user_tag]
end

#user_tag=(value) ⇒ Object



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

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