Class: Files::Permission
- Inherits:
-
Object
- Object
- Files::Permission
- Defined in:
- lib/files.com/models/permission.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
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: group_id - int64 - Group ID path - string - Folder path permission - string - Permission type.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
Instance Method Summary collapse
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#group_id ⇒ Object
int64 - Group ID.
- #group_id=(value) ⇒ Object
-
#group_name ⇒ Object
string - Group name if applicable.
- #group_name=(value) ⇒ Object
-
#id ⇒ Object
int64 - Permission ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Permission
constructor
A new instance of Permission.
-
#path ⇒ Object
string - Folder path.
- #path=(value) ⇒ Object
-
#permission ⇒ Object
string - Permission type.
- #permission=(value) ⇒ Object
-
#recursive ⇒ Object
boolean - Does this permission apply to subfolders?.
- #recursive=(value) ⇒ Object
- #save ⇒ Object
-
#user_id ⇒ Object
int64 - User ID.
- #user_id=(value) ⇒ Object
-
#username ⇒ Object
string - User’s username.
- #username=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Permission
Returns a new instance of Permission.
7 8 9 10 |
# File 'lib/files.com/models/permission.rb', line 7 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/permission.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/permission.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
139 140 141 |
# File 'lib/files.com/models/permission.rb', line 139 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
group_id - int64 - Group ID
path - string - Folder path
permission - string - Permission type. Can be `admin`, `full`, `readonly`, `writeonly`, `list`, or `history`
recursive - boolean - Apply to subfolders recursively?
user_id - int64 - User ID. Provide `username` or `user_id`
username - string - User username. Provide `username` or `user_id`
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/files.com/models/permission.rb', line 150 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: permission must be an String") if params[:permission] and !params[:permission].is_a?(String) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: username must be an String") if params[:username] and !params[:username].is_a?(String) response, = Api.send_request("/permissions", :post, params, ) Permission.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
161 162 163 164 165 166 167 168 169 |
# File 'lib/files.com/models/permission.rb', line 161 def self.delete(id, params = {}, = {}) 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("/permissions/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
171 172 173 174 |
# File 'lib/files.com/models/permission.rb', line 171 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil 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).
action - string
page - int64
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[group_id]=desc`). Valid fields are `group_id`, `path`, `user_id` or `permission`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `path`, `group_id` or `user_id`. Valid field combinations are `[ group_id, path ]`, `[ user_id, path ]` or `[ user_id, group_id, path ]`.
filter_prefix - object - If set, return records where the specified field is prefixed by the supplied value. Valid fields are `path`.
path - string - Permission path. If provided, will scope all permissions(including upward) to this path.
include_groups - boolean - If searching by user or group, also include user's permissions that are inherited from its groups?
group_id - string
user_id - string
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/files.com/models/permission.rb', line 122 def self.list(params = {}, = {}) 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: action must be an String") if params[:action] and !params[:action].is_a?(String) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params[:page] and !params[: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) raise InvalidParameterError.new("Bad parameter: filter_prefix must be an Hash") if params[:filter_prefix] and !params[:filter_prefix].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: group_id must be an String") if params[:group_id] and !params[:group_id].is_a?(String) raise InvalidParameterError.new("Bad parameter: user_id must be an String") if params[:user_id] and !params[:user_id].is_a?(String) List.new(Permission, params) do Api.send_request("/permissions", :get, params, ) end end |
Instance Method Details
#delete(params = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/files.com/models/permission.rb', line 84 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("/permissions/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
94 95 96 97 |
# File 'lib/files.com/models/permission.rb', line 94 def destroy(params = {}) delete(params) nil end |
#group_id ⇒ Object
int64 - Group ID
49 50 51 |
# File 'lib/files.com/models/permission.rb', line 49 def group_id @attributes[:group_id] end |
#group_id=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/permission.rb', line 53 def group_id=(value) @attributes[:group_id] = value end |
#group_name ⇒ Object
string - Group name if applicable
58 59 60 |
# File 'lib/files.com/models/permission.rb', line 58 def group_name @attributes[:group_name] end |
#group_name=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/permission.rb', line 62 def group_name=(value) @attributes[:group_name] = value end |
#id ⇒ Object
int64 - Permission ID
13 14 15 |
# File 'lib/files.com/models/permission.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/permission.rb', line 17 def id=(value) @attributes[:id] = value end |
#path ⇒ Object
string - Folder path. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
22 23 24 |
# File 'lib/files.com/models/permission.rb', line 22 def path @attributes[:path] end |
#path=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/permission.rb', line 26 def path=(value) @attributes[:path] = value end |
#permission ⇒ Object
string - Permission type
67 68 69 |
# File 'lib/files.com/models/permission.rb', line 67 def @attributes[:permission] end |
#permission=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/permission.rb', line 71 def (value) @attributes[:permission] = value end |
#recursive ⇒ Object
boolean - Does this permission apply to subfolders?
76 77 78 |
# File 'lib/files.com/models/permission.rb', line 76 def recursive @attributes[:recursive] end |
#recursive=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/permission.rb', line 80 def recursive=(value) @attributes[:recursive] = value end |
#save ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/files.com/models/permission.rb', line 99 def save if @attributes[:id] raise NotImplementedError.new("The Permission object doesn't support updates.") else new_obj = Permission.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#user_id ⇒ Object
int64 - User ID
31 32 33 |
# File 'lib/files.com/models/permission.rb', line 31 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/permission.rb', line 35 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - User’s username
40 41 42 |
# File 'lib/files.com/models/permission.rb', line 40 def username @attributes[:username] end |
#username=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/permission.rb', line 44 def username=(value) @attributes[:username] = value end |